diff options
author | jiteshjha | 2016-06-30 15:46:15 +0530 |
---|---|---|
committer | jiteshjha | 2016-06-30 15:46:15 +0530 |
commit | 981429df495c0b30b4a0a3cfc4cdaf3d096b834b (patch) | |
tree | 1849e4104dbc39f2963bac43a3ce69a9358c04db /dependencies.js | |
parent | a45361eb58f86535805185d16b91ae05339e7771 (diff) | |
download | xcos-on-web-981429df495c0b30b4a0a3cfc4cdaf3d096b834b.tar.gz xcos-on-web-981429df495c0b30b4a0a3cfc4cdaf3d096b834b.tar.bz2 xcos-on-web-981429df495c0b30b4a0a3cfc4cdaf3d096b834b.zip |
Preloading-images-blocks-palettes-ds_files
Diffstat (limited to 'dependencies.js')
-rw-r--r-- | dependencies.js | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/dependencies.js b/dependencies.js index 17c2184..c7ba39a 100644 --- a/dependencies.js +++ b/dependencies.js @@ -1,23 +1,26 @@ -var dir = ["data_structures_correct"]; -var fileextension = "."; +$.getScript('math.js'); -var script = document.createElement("script"); - script.src = "math.js"; - document.head.appendChild(script); -$.each(dir, function(index, value) { - $.ajax({ // http://stackoverflow.com/a/18480589 - url: value, - success: function(data) { - $(data).find("a:contains(" + fileextension + ")").each(function() { - var filename = this.href.replace(window.location.host, ""); - filename = filename.replace("https://", value); - filename = filename.replace("http://", value); - var script = document.createElement("script"); - script.src = filename; - document.head.appendChild(script); - }); - } - }); +$.ajax({ + type: "POST", + + // Invoke getFilename.php + url: "getFilename.php", + + // Receive the resultant filenames from the php script in JSON format + dataType: "json", + + // add url for the required folder + data:{ url: "/data_structures_correct/"}, + success: function (data) { + + /* + * data will have the required filenames in the mentioned folder + * For each url, add the script to the body div element with getScript function + */ + for (var i = 0, length = data.length; i < length; ++i) { + $.getScript(data[i]); + } + } }); function AfficheBlock() { |