mirror of
https://github.com/pinry/pinry.git
synced 2025-11-18 02:40:40 +01:00
Refactor: Reformat helpers.js
This commit is contained in:
committed by
Isaac Bythewood
parent
b44bc9f12a
commit
b155f806bc
@@ -34,8 +34,9 @@ function csrfSafeMethod(method) {
|
|||||||
// these HTTP methods do not require CSRF protection
|
// these HTTP methods do not require CSRF protection
|
||||||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
beforeSend: function(xhr, settings) {
|
beforeSend: function (xhr, settings) {
|
||||||
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
||||||
xhr.setRequestHeader("X-CSRFToken", getCSRFToken());
|
xhr.setRequestHeader("X-CSRFToken", getCSRFToken());
|
||||||
}
|
}
|
||||||
@@ -61,7 +62,7 @@ function getPinData(pinId) {
|
|||||||
|
|
||||||
|
|
||||||
function deletePinData(pinId) {
|
function deletePinData(pinId) {
|
||||||
var apiUrl = API_BASE + 'pins/' +pinId + '/?format=json';
|
var apiUrl = API_BASE + 'pins/' + pinId + '/?format=json';
|
||||||
return $.ajax(apiUrl, {
|
return $.ajax(apiUrl, {
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
});
|
});
|
||||||
@@ -78,5 +79,5 @@ function postPinData(data) {
|
|||||||
|
|
||||||
|
|
||||||
function getUrlParameter(name) {
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user