<commit_before><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=1280">
  <title>Explore Computer Vision</title>
  <link rel="stylesheet" type="text/css" href="css/style.css">

  <script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
  <script type="text/javascript" src="js/wmain.js"></script>
  <script type="text/javascript" src="js/ace.js"></script>
  <script type="text/javascript" src="js/mode-javascript.js"></script>
  <script type="text/javascript" src="js/theme-monokai.js"></script>
  <script type="text/javascript" src="js/ext-language_tools.js"></script>
  <script type="text/javascript" src="js/worker-javascript.js"></script>
  <script type="text/javascript">
    function resize() {
        var cell = $("#stretchy");
        cell.css("height", "100%");
        var px = cell.height();
        cell.height(px);

        $("#log").height($("#logContainer").height());
      }

      $(document).ready(function() {
        //initialise the video
        initialiseVideo("source", "sink", function() {
          //load the code once the video is initialised
          <?php 
            $name = "saved-code/default.json";
            if (isset($_REQUEST['id']))
              $name = "saved-code/".$_REQUEST['id'].".json";
            echo "var file = \"".$name."\";";
          ?>
          $.getJSON(file, function(data) {
            $("#title").val(data.name);
            editor.setValue(data.code, -1);
            run(data.code);
          })
          .fail(function() {
            alert("fail");
            $.getJSON("saved-code/default.json", function(data) {
              $("#title").val(data.name);
              editor.setValue(data.code, -1);
              run(data.code);
            });
          });
        });

        //setup the ui controls
        var editor = ace.edit("editor");
        editor.setTheme("ace/theme/monokai");
        editor.getSession().setMode("ace/mode/javascript");
        editor.$blockScrolling = Infinity;
        editor.setShowPrintMargin(false);
        // editor.setOptions({
        //   enableBasicAutocompletion: true,
        //   enableSnippets: true,
        //   enableLiveAutocompletion: true
        // });

        //disable backspace navigation  
        $(document).on('keydown',function(e){
          var $target = $(e.target||e.srcElement);
          if(e.keyCode == 8 && !$target.is('input,[contenteditable="true"],textarea'))
          {
            e.preventDefault();
          }
        })

        $('#runbtn').click(function() {<commit_msg>add demo mode<commit_after><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=1280">
  <title>Explore Computer Vision</title>
  <link rel="stylesheet" type="text/css" href="css/style.css">

  <script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
  <script type="text/javascript" src="js/wmain.js"></script>
  <script type="text/javascript" src="js/ace.js"></script>
  <script type="text/javascript" src="js/mode-javascript.js"></script>
  <script type="text/javascript" src="js/theme-monokai.js"></script>
  <script type="text/javascript" src="js/ext-language_tools.js"></script>
  <script type="text/javascript" src="js/worker-javascript.js"></script>
  <script type="text/javascript">
    function resize() {
        var cell = $("#stretchy");
        cell.css("height", "100%");
        var px = cell.height();
        cell.height(px);

        $("#log").height($("#logContainer").height());
      }

      $(document).ready(function() {
        //initialise the video
        initialiseVideo("source", "sink", function() {
          //load the code once the video is initialised
          <?php 
            $demos = [];
            $files = scandir("saved-code");
            foreach ($files as $file) {
              if (strlen($file) > 10) {
                $demos[] = $file;
              }
            }

            $name = "saved-code/default.json";
            if (isset($_REQUEST['id'])) {
              if (strcasecmp($_REQUEST['id'], "demo")==0) {
                $name = "saved-code/".$demos[0];
                echo "var demofiles = ".json_encode($demos).";\n";
              } else {
                echo "var demofiles;";
                $name = "saved-code/".$_REQUEST['id'].".json";
              }
            }
            echo "var file = \"".$name."\";\n";
          ?>
          $.getJSON(file, function(data) {
            $("#title").val(data.name);
            editor.setValue(data.code, -1);
            run(data.code);
          })
          .fail(function() {
            $.getJSON("saved-code/default.json", function(data) {
              $("#title").val(data.name);
              editor.setValue(data.code, -1);
              run(data.code);
            });
          });

          if (demofiles) {
            var count = 0;
            setInterval(function() {
              count++;
              if (count>demofiles.length)
                count = 0;
              console.log(demofiles[count]);
              $.getJSON("saved-code/" + demofiles[count], function(data) {
                $("#title").val(data.name);
                editor.setValue(data.code, -1);
                run(data.code);
              });
            }, 5000);
          }
        });

        //setup the ui controls
        var editor = ace.edit("editor");
        editor.setTheme("ace/theme/monokai");
        editor.getSession().setMode("ace/mode/javascript");
        editor.$blockScrolling = Infinity;
        editor.setShowPrintMargin(false);
        // editor.setOptions({
        //   enableBasicAutocompletion: true,
        //   enableSnippets: true,
        //   enableLiveAutocompletion: true
        // });

        //disable backspace navigation  
        $(document).on('keydown',function(e){
          var $target = $(e.target||e.srcElement);
          if(e.keyCode == 8 && !$target.is('input,[contenteditable="true"],textarea'))
          {
            e.preventDefault();
          }
        })

        $('#runbtn').click(function() {
{'fraction_non_alphanumeric': 0.18251508726145815, 'fraction_numerical': 0.006361115641820258, 'mean_word_length': 1.98539435248296, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7672318', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1786, 'n_words': 292}