mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Disabling minify creates now one big js file, instead of loading js files dynamicly. This solves problems we had with random loading of the js files
This commit is contained in:
parent
3ccdcec7e8
commit
1c8f70fae9
1 changed files with 24 additions and 14 deletions
|
@ -228,24 +228,34 @@ exports.padJS = function(req, res)
|
|||
res.sendfile(pathStr, { maxAge: server.maxAge });
|
||||
})
|
||||
}
|
||||
//minifying is disabled, so load the files with jquery
|
||||
//minifying is disabled, so put the files together in one file
|
||||
else
|
||||
{
|
||||
res.write("function loadjsfile(filename){\n"+
|
||||
"var fileref=document.createElement('script');\n"+
|
||||
"fileref.setAttribute('type','text/javascript');\n"+
|
||||
"var path = 'static/js/' + filename;\n"+
|
||||
"fileref.setAttribute('src', path);\n" +
|
||||
"document.getElementsByTagName('head')[0].appendChild(fileref);\n" +
|
||||
"}\n");
|
||||
var fileValues = {};
|
||||
|
||||
for(var i in jsFiles)
|
||||
//read all js files
|
||||
async.forEach(jsFiles, function (item, callback)
|
||||
{
|
||||
console.log(jsFiles[i]);
|
||||
res.write("loadjsfile('"+ jsFiles[i] + "');\n");
|
||||
}
|
||||
fs.readFile("../static/js/" + item, "utf-8", function(err, data)
|
||||
{
|
||||
fileValues[item] = data;
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
//send all files together
|
||||
function(err)
|
||||
{
|
||||
if(err) throw err;
|
||||
|
||||
res.end();
|
||||
for(var i=0;i<jsFiles.length;i++)
|
||||
{
|
||||
var fileName = jsFiles[i];
|
||||
res.write("\n\n\n/*** File: static/js/" + fileName + " ***/\n\n\n");
|
||||
res.write(fileValues[fileName]);
|
||||
}
|
||||
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue