javascriptdashcode

How can I add my library to be loaded Dashcode parts


Dashcode loads a bunch of library listed in an array within part.js

(function() {
    var scripts = dashcodePartSupport['core'];

    scripts = scripts.concat(dashcodePartSupport['scripts']);

    for(var index in scripts) {
        var path = scripts[index];
        var scriptTag = '<script apple-no-regeneration="yes" type="text/javascript" src="' + path + '"></script>';

        document.write( scriptTag );
    }    
})();

I tried to edit that file to append my own lib, but the file is not editable. So how can I do ?


Solution

  • function loadCode(code) {
        var i, j = code.length, element;
    
        for(i=0;i<j;++i) {
            element = document.createElement('script');
            element.src = code[i];
    
            document.getElementsByTagName('head')[0].appendChild(element);
        }
    }
    

    You can use this function this way:

    loadCode(['code1.js', 'code2.js', ...]);