<commit_before>var lively4Url =  'http://localhost:8081/';
loadTemplate('lively-toolbox');

function loadTemplate (templateIdentifier) {
  loadJQuery();
  loadSystem();
  setTimeout(function () {
    loadBabel();
    loadLively4();
    loadPart(templateIdentifier);
    mountPart(templateIdentifier);
  }, 1000)
}

function loadJQuery () {
  var jQueryNode = document.createElement('script');
  jQueryNode.setAttribute('type', 'text/javascript');
  jQueryNode.setAttribute('src', 'https://code.jquery.com/jquery-2.1.4.js');
  document.head.appendChild(jQueryNode);
}

function loadSystem () {
  var systemScriptNode = document.createElement('script');
  systemScriptNode.setAttribute('type', 'text/javascript');
  systemScriptNode.setAttribute('src', lively4Url + 'src/external/system.src.js');
  document.head.appendChild(systemScriptNode);
}

function loadBabel () {
  var babelLoaderNode = document.createElement('script');
  babelLoaderNode.setAttribute('type', 'text/javascript');
  babelLoaderNode.innerHTML = '' + '\n' +
    "System.paths['babel'] = '" + lively4Url + "src/external/babel-browser.js'" + '\n' +
    "System.config({" + '\n' +
      "transpiler: 'babel'," + '\n' +
      "babelOptions: { }," + '\n' +
      "map: {" + '\n' +
          "babel: '" + lively4Url + "src/external/babel-browser.js'" + '\n' +
      "}" + '\n' +
    "});"
  document.head.appendChild(babelLoaderNode);
  System.config({
    baseURL: lively4Url + 'draft/'
  });
}

function loadLively4 () {
  System.import(lively4Url + "src/client/load.js").then(function(){
    System.import("commandline.js")
    System.import(lively4Url + "src/client/debug-serviceworker.js")
  }).catch(function(err) { alert("load Lively4 failed")});
}

function loadPart (partIdentifierString) {
  $.get(lively4Url + 'templates/' + partIdentifierString + '.html', function(data) {
    data = data.replace('var baseUrl = "../src/client/morphic/";', 'var baseUrl = "' + lively4Url + 'src/client/morphic/";')
    data = data.replace('../src/client/css/morphic.css',  lively4Url + 'src/client/css/morphic.css');
    var parserNode = document.createElement('div');
    parserNode.innerHTML = data;
    var templateNode = parserNode.children[0];
    var scriptNode = parserNode.children[1];
    var scriptString = scriptNode.innerHTML;
    document.head.appendChild(templateNode);
    scriptString = scriptString.replace('document.currentScript.ownerDocument', 'document');
    scriptString = scriptString.replace("System.import('../", "System.import('" + lively4Url);
    eval(scriptString);
  });
}

function mountPart(partIdentifierString) {
  var aToolbox = document.createElement(partIdentifierString);
  document.body.insertBefore(aToolbox, document.body.firstChild);
  aToolbox.style.setProperty('position', 'fixed');
}<commit_msg>includes object editor and ace in export. lively toolbox is now compatible with http pages<commit_after>var lively4Url =  'http://localhost:8081/';
loadTemplates('lively-toolbox', 'lively-window', 'lively-object-editor', 'lively-treeview', 'lively-editor', 'juicy-ace-editor');

function loadTemplates () {
  var identifiers = Array.from(arguments);
  loadJQuery();
  loadSystem();
  setTimeout(function () {
    loadBabel();
    loadLively4();
    loadAce();
    identifiers.forEach(function(templateIdentifier) {
      loadPart(templateIdentifier);
    })
    mountPart(identifiers[0]);
  }, 1000)
}

function loadAce() {
  var aceNode = document.createElement('script');
  aceNode.setAttribute('type', 'text/javascript');
  aceNode.setAttribute('src', lively4Url + 'src/external/ace.js');
  document.head.appendChild(aceNode);
}

function loadJQuery () {
  var jQueryNode = document.createElement('script');
  jQueryNode.setAttribute('type', 'text/javascript');
  jQueryNode.setAttribute('src', 'https://code.jquery.com/jquery-2.1.4.js');
  document.head.appendChild(jQueryNode);
}

function loadSystem () {
  var systemScriptNode = document.createElement('script');
  systemScriptNode.setAttribute('type', 'text/javascript');
  systemScriptNode.setAttribute('src', lively4Url + 'src/external/system.src.js');
  document.head.appendChild(systemScriptNode);
}

function loadBabel () {
  var babelLoaderNode = document.createElement('script');
  babelLoaderNode.setAttribute('type', 'text/javascript');
  babelLoaderNode.innerHTML = '' + '\n' +
    "System.paths['babel'] = '" + lively4Url + "src/external/babel-browser.js'" + '\n' +
    "System.config({" + '\n' +
      "transpiler: 'babel'," + '\n' +
      "babelOptions: { }," + '\n' +
      "map: {" + '\n' +
          "babel: '" + lively4Url + "src/external/babel-browser.js'" + '\n' +
      "}" + '\n' +
    "});"
  document.head.appendChild(babelLoaderNode);
  System.config({
    baseURL: lively4Url + 'draft/'
  });
}

function loadLively4 () {
  System.import(lively4Url + "src/client/load.js").then(function(){
    System.import("commandline.js")
    System.import(lively4Url + "src/client/debug-serviceworker.js")
  }).catch(function(err) { alert("load Lively4 failed")});
  System.import(lively4Url + "src/client/script-manager.js").then(function(module) {
      window.scriptManager = module;
      log("scriptManager loaded");
  });
  System.import(lively4Url + "src/client/persistence.js").then(function(module) {
      window.persistence = module;
      log("persistence loaded");
  });
}

function loadPart (partIdentifierString) {
  $.get(lively4Url + 'templates/' + partIdentifierString + '.html', function(data) {
    data = data.replace('var baseUrl = "../src/client/morphic/";', 'var baseUrl = "' + lively4Url + 'src/client/morphic/";')
    data = data.replace('../src/client/css/morphic.css',  lively4Url + 'src/client/css/morphic.css');
    var parserNode = document.createElement('div');
    parserNode.innerHTML = data;
    document.head.appendChild(parserNode.getElementsByTagName('template')[0]);
    Array.from(parserNode.getElementsByTagName('script')).forEach(function(scriptNode) {
      if (scriptNode.getAttribute('src')) {
        document.head.appendChild(scriptNode);
      } else {
        var scriptString = scriptNode.innerHTML;
        scriptString = scriptString.replace(/document.currentScript.ownerDocument/g, 'document');
        scriptString = scriptString.replace(/\(document._currentScript \|\| document.currentScript\).ownerDocument/g, 'document');
        scriptString = scriptString.replace(/System.import\('..\//g, "System.import('" + lively4Url);
        scriptString = scriptString.replace(/System.import\("..\//g, 'System.import("' + lively4Url);
        eval(scriptString);
      }
    })
  });
}

function mountPart(partIdentifierString) {
  var aToolbox = document.createElement(partIdentifierString);
  document.body.insertBefore(aToolbox, document.body.firstChild);
  aToolbox.style.setProperty('position', 'fixed');
}
{'fraction_non_alphanumeric': 0.1720351390922401, 'fraction_numerical': 0.00849194729136164, 'mean_word_length': 4.3872239747634065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1962565', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2091, 'n_words': 315}