diff options
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() { |