From b155f806bca8ac269a32109f6ad981f9a7e48c34 Mon Sep 17 00:00:00 2001 From: winkidney Date: Wed, 20 Mar 2019 18:19:12 +0800 Subject: [PATCH] Refactor: Reformat helpers.js --- pinry/static/js/helpers.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pinry/static/js/helpers.js b/pinry/static/js/helpers.js index f22ad4c..0841f3f 100644 --- a/pinry/static/js/helpers.js +++ b/pinry/static/js/helpers.js @@ -34,8 +34,9 @@ function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); } + $.ajaxSetup({ - beforeSend: function(xhr, settings) { + beforeSend: function (xhr, settings) { if (!csrfSafeMethod(settings.type) && !this.crossDomain) { xhr.setRequestHeader("X-CSRFToken", getCSRFToken()); } @@ -61,7 +62,7 @@ function getPinData(pinId) { function deletePinData(pinId) { - var apiUrl = API_BASE + 'pins/' +pinId + '/?format=json'; + var apiUrl = API_BASE + 'pins/' + pinId + '/?format=json'; return $.ajax(apiUrl, { type: 'DELETE' }); @@ -78,5 +79,5 @@ function postPinData(data) { function getUrlParameter(name) { - return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; + return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null; }