@@ -17,35 +17,7 @@ var ie = (function(){
1717 document . body . scrollTop = document . documentElement . scrollTop = 0 ;
1818 }
1919
20- function csrfSafeMethod ( method ) {
21- // these HTTP methods do not require CSRF protection
22- return ( / ^ ( G E T | H E A D | O P T I O N S | T R A C E ) $ / . test ( method ) ) ;
23- }
24-
25- function getCSRF ( ) {
26- //eventually you'll have to login
27- var cookieValue = null ;
28- if ( document . cookie && document . cookie != '' ) {
29- var cookies = document . cookie . split ( ';' ) ;
30- for ( var i = 0 ; i < cookies . length ; i ++ ) {
31- var cookie = jQuery . trim ( cookies [ i ] ) ;
32- var name = "csrftoken" ;
33- if ( cookie . substring ( 0 , name . length + 1 ) == ( name + '=' ) ) {
34- cookieValue = decodeURIComponent ( cookie . substring ( name . length + 1 ) ) ;
35- break ;
36- }
37- }
38- }
39- return cookieValue ;
40- }
41-
42- function setCSRF ( xhr , settings , csrf ) {
43- if ( ! csrfSafeMethod ( settings . type ) && ! this . crossDomain ) {
44- xhr . setRequestHeader ( "X-CSRFToken" , csrf ) ;
45- }
46- }
47-
48- function save ( data , csrf , bfelog , callback ) {
20+ function save ( data , bfelog , callback ) {
4921 var $messagediv = $ ( '<div>' , { id : "bfeditor-messagediv" , class :"col-md-10 main" } ) ;
5022
5123 var url = config . url + "/verso/api/bfs/upsertWithWhere?where=%7B%22name%22%3A%20%22" + data . name + "%22%7D" ;
@@ -54,7 +26,6 @@ var ie = (function(){
5426 url : url ,
5527 type : "POST" ,
5628 data :JSON . stringify ( data ) ,
57- csrf : csrf ,
5829 dataType : "json" ,
5930 contentType : "application/json; charset=utf-8"
6031 } ) . done ( function ( data ) {
@@ -212,18 +183,13 @@ var ie = (function(){
212183 }
213184
214185
215- function deleteId ( id , csrf , bfelog ) {
186+ function deleteId ( id , bfelog ) {
216187 var url = config . url + "/verso/api/bfs/" + id ;
217188
218- //$.ajaxSetup({
219- // beforeSend: function(xhr, settings){getCSRF(xhr, settings, csrf);}
220- //});
221-
222189 $ . ajax ( {
223190 type : "DELETE" ,
224191 url : url ,
225192 dataType : "json" ,
226- csrf : csrf ,
227193 success : function ( data ) {
228194 bfelog . addMsg ( new Error ( ) , "INFO" , "Deleted " + id ) ;
229195 } ,
@@ -464,25 +430,9 @@ var ie = (function(){
464430 "deleteId" : {
465431 "callback" : deleteId
466432 } ,
467- "getCSRF" :{
468- "callback" : getCSRF
469- } ,
470- /* "load": [
471- {
472- "templateID": ["profile:bf:Work:Monograph", "profile:bf:Instance:Monograph", "profile:bf:Annotation:AdminMeta"],
473- "defaulturi": "http://id.loc.gov/resources/bibs/5226",
474- "_remark": "Source must be JSONLD expanded, so only jsonp and json are possible requestTypes",
475- "source": {
476- "location": "http://id.loc.gov/resources/bibs/5226.bibframe_raw.jsonp",
477- "requestType": "jsonp",
478- "data": "UNUSED, BUT REMEMBER IT"
479- }
480- }
481- ],*/
482433 "return" : {
483434 "format" : "jsonld-expanded" ,
484435 "callback" : myCB
485436 }
486437 }
487- var bfeditor = bfe . fulleditor ( config , "bfeditor" ) ;
488438
0 commit comments