diff --git a/js/lang.js b/js/lang.js index 177c1df..deedacc 100644 --- a/js/lang.js +++ b/js/lang.js @@ -17,14 +17,14 @@ $(document).ready(function () { function addLangLangs(langID, langName, langIDList) { if (langIDList != null) { - for (var i = 0; i < langIDList.length; i++) { + langIDList.forEach(function (item) { $.ajax({ url: "lang.php", type: "PUT", - data: {langID: langID, associatedLang: langIDList[i]}, + data: {langID: langID, associatedLang: item}, error: displayError }); - } + }); } successAlert("Successfully Added language: " + langName, "lang"); @@ -46,15 +46,15 @@ function loadLangs() { function addLangs(langList) { var mainList = $("#mainList"); - for (var i = 0; i < langList.length; i++) { - $("
").attr({ "id": "lang-" + langList[i].langID }).appendTo(mainList); + langList.forEach(function (item) { + $("
").attr({ "id": "lang-" + item.langID }).appendTo(mainList); $.ajax({ - url: "lang.php?langID=" + langList[i].langID, + url: "lang.php?langID=" + item.langID, type: "GET", success: function (result) { addLang(result) }, error: function (result) { displayError(result) } }); - } + }); } function addLang(lang) { diff --git a/js/main.js b/js/main.js index e887f4a..389df91 100644 --- a/js/main.js +++ b/js/main.js @@ -7,7 +7,9 @@ $(document).ready(function () { $("#addLangTab").tab("show"); $(".addField").val(""); buildLangSelect(); - }).on("shown.bs.modal", function (e) { $("#txtLangName").focus(); }); + }).on("shown.bs.modal", function (e) { + $("#txtLangName").focus(); + }); $("#btnAddItem").click(addNewItem); $(".clearLangSelect").click(function () { $(".langSelect").val([]); }); @@ -26,14 +28,14 @@ function buildLangSelect() { function addSelectLangs(langList) { var selectors = $(".langSelect"); selectors.empty(); - for (let cur of langList) { + langList.forEach(function (cur) { $("