Skip to content

Commit

Permalink
Use eval instead of $.script
Browse files Browse the repository at this point in the history
Fixes #4067

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
  • Loading branch information
LukasReschke committed Mar 26, 2017
1 parent ec6853a commit 08acb2b
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,31 @@ var OCP = {},
* @param ready event handler to be called when the script is loaded
*/
addScript:function(app,script,ready){
var deferred, path=OC.filePath(app,'js',script+'.js');
if(!OC.addScript.loaded[path]){
if(ready){
deferred=$.getScript(path,ready);
}else{
deferred=$.getScript(path);
var scriptContent, path=OC.filePath(app,'js',script+'.js');
if(!OC.addScript.loaded[path]) {
if(ready) {
scriptContent = jQuery.ajax({
url: path,
cache: true,
success: function (content) {
eval(content);
eval(ready);
},
async: false
});
} else {
scriptContent = jQuery.ajax({
url: path,
cache: true,
success: function (content) {
eval(content);
},
async: false
});
}
OC.addScript.loaded[path]=deferred;
}else{
if(ready){
OC.addScript.loaded[path] = scriptContent;
} else {
if (ready) {
ready();
}
}
Expand Down

0 comments on commit 08acb2b

Please sign in to comment.