diff --git a/js/global.js b/js/global.js index 4f36db6..cec5429 100644 --- a/js/global.js +++ b/js/global.js @@ -1,4 +1,4 @@ let prev = document.getElementById('edit-preview'); -if (prev != null && prev != undefined) { +if (prev != NULL && prev != undefined) { prev.classList.add('button'); } diff --git a/js/job_form.js b/js/job_form.js index a01c75c..313464e 100644 --- a/js/job_form.js +++ b/js/job_form.js @@ -25,13 +25,14 @@ function onContentTypeChange(obj) { } function onDateChage(obj) { if (obj.value) { - if (obj.value == null || obj.value == '') return; + if (obj.value == NULL || obj.value == '') { return; + } let date = new Date(obj.value); let dayOfWeek = date.getDay(); let isWeekend = (dayOfWeek === 6) || (dayOfWeek === 0); - if (isWeekend == true) { - obj.value = null; + if (isWeekend == TRUE) { + obj.value = NULL; alert("You cann't choose weekend "); } } -} \ No newline at end of file +} diff --git a/js/wordsonline-job.js b/js/wordsonline-job.js index 6b91ddc..166710a 100644 --- a/js/wordsonline-job.js +++ b/js/wordsonline-job.js @@ -8,12 +8,12 @@ function CheckHasFile(isRefresh = false) { document.getElementById("wol-loader").style.display = "block"; var url = root + "check-has-file"; var request = new XMLHttpRequest() - request.open('POST', url, true) + request.open('POST', url, TRUE) request.onload = function () { // // Begin accessing JSON data here var data = JSON.parse(this.response); - if (data.status == "success" && data.changed == true) { - if (isRefresh == true) { + if (data.status == "success" && data.changed == TRUE) { + if (isRefresh == TRUE) { sessionStorage.setItem('wol-reload', '1'); Refresh(); } @@ -28,7 +28,7 @@ function checkQuoted() { let page = document.getElementsByName("job_page"); let name = document.getElementsByName("job_data"); var params = getAllUrlParams(window.location.href); - var url = root + "check-quoted" + "?top=" + page[0].value; + var url = root + "check-quoted?top=" + page[0].value; if (params) { if (params.skip) { url = url + "&skip =" + params.skip; @@ -39,16 +39,16 @@ function checkQuoted() { } let data = name[0].value; - if (data != null && data != '') { + if (data != NULL && data != '') { url = url + '&key=' + data; } document.getElementById("wol-loader").style.display = "block"; var request = new XMLHttpRequest() - request.open('POST', url, true) + request.open('POST', url, TRUE) request.onload = function () { // // Begin accessing JSON data here var data = JSON.parse(this.response); - if (data.status == "success" && data.changed == true) { + if (data.status == "success" && data.changed == TRUE) { Refresh(); } @@ -60,10 +60,10 @@ setTimeout(() => { CheckHasFile(); }, 5); function OnRefreshPage() { - CheckHasFile(true); + CheckHasFile(TRUE); var params = getAllUrlParams(window.location.href); let name = document.getElementsByName("job_data"); - let oldSearch = null; + let oldSearch = NULL; if (params) { if (params.key) { oldSearch = params.key; @@ -72,7 +72,7 @@ function OnRefreshPage() { } let data = name[0].value; if (data == '') { - data = null; + data = NULL; } if (oldSearch != data) { Refresh(); @@ -89,7 +89,7 @@ function reimport(job_id) { document.getElementById("wol-loader").style.display = "block"; var url = root + "reimport?job_id=" + job_id; var request = new XMLHttpRequest() - request.open('POST', url, true) + request.open('POST', url, TRUE) request.onload = function () { // // Begin accessing JSON data here var data = JSON.parse(this.response) @@ -114,7 +114,7 @@ function getQuote() { var url = root + "get-quote?job_id=" + job_id; var request = new XMLHttpRequest() - request.open('POST', url, true) + request.open('POST', url, TRUE) request.onload = function () { // Begin accessing JSON data here var data = JSON.parse(this.response) @@ -161,7 +161,7 @@ function searchJob() { let page = document.getElementsByName("job_page"); if (val) { let data = val[0].value; - if (data != null && data != '') { + if (data != NULL && data != '') { url = url + '?key=' + data; if (page) { url = url + "&top=" + page[0].value; @@ -177,7 +177,6 @@ function searchJob() { } } - location.href = url; } function goPage(num) { @@ -243,18 +242,20 @@ function getAllUrlParams(url) { // set parameter name and value (use 'true' if empty) var paramName = a[0]; - var paramValue = typeof (a[1]) === 'undefined' ? true : a[1]; + var paramValue = typeof (a[1]) === 'undefined' ? TRUE : a[1]; // (optional) keep case consistent paramName = paramName.toLowerCase(); - if (typeof paramValue === 'string') paramValue = paramValue.toLowerCase(); + if (typeof paramValue === 'string') { paramValue = paramValue.toLowerCase(); + } // if the paramName ends with square brackets, e.g. colors[] or colors[2] if (paramName.match(/\[(\d+)?\]$/)) { // create key if it doesn't exist var key = paramName.replace(/\[(\d+)?\]/, ''); - if (!obj[key]) obj[key] = []; + if (!obj[key]) { obj[key] = []; + } // if it's an indexed array e.g. colors[2] if (paramName.match(/\[\d+\]$/)) { @@ -308,7 +309,7 @@ function Refresh() { } let data = name[0].value; - if (data != null && data != '') { + if (data != NULL && data != '') { url = url + '&key=' + data; } @@ -320,12 +321,13 @@ function Refresh() { } function onDateChage(obj, timezone) { if (obj.value) { - if (obj.value == null || obj.value == '') return; + if (obj.value == NULL || obj.value == '') { return; + } let date = new Date(obj.value); let dayOfWeek = date.getDay(); let isWeekend = (dayOfWeek === 6) || (dayOfWeek === 0); - if (isWeekend == true) { - obj.value = null; + if (isWeekend == TRUE) { + obj.value = NULL; alert("You cann't choose weekend"); } } @@ -334,4 +336,4 @@ Array.from(document.querySelectorAll('.use-ajax')).forEach(e => e.addEventListen var url = e.currentTarget.getAttribute("href"); Drupal.ajax({ url: url }).execute(); e.preventDefault(); -})) \ No newline at end of file +})) diff --git a/js/wordsonline.js b/js/wordsonline.js index 4814d60..c3eeb64 100644 --- a/js/wordsonline.js +++ b/js/wordsonline.js @@ -1,4 +1,3 @@ - var root = window.location.origin + window.location.pathname.replace('wordsonline/jobs', 'wordsonline/').replace('wordsonline/wol-order', 'wordsonline/') function downloadxlf() { diff --git a/src/WordsOnlineTranslatorUi.php b/src/WordsOnlineTranslatorUi.php index a372fb9..4838d8b 100644 --- a/src/WordsOnlineTranslatorUi.php +++ b/src/WordsOnlineTranslatorUi.php @@ -284,10 +284,10 @@ class WordsOnlineTranslatorUi extends TranslatorPluginUiBase { '#required' => TRUE, '#default_value' => $this->defaultServiceLevel, '#options' => [ - "Basic" => "Basic", - "Standard" => "Standard", - "Enterprise" => "Enterprise", - "Premium" => "Premium", + "Basic" => $this->t("Basic"), + "Standard" => $this->t("Standard"), + "Enterprise" => $this->t("Enterprise"), + "Premium" => $this->t("Premium"), ], '#prefix' => '
', '#suffix' => '
',