-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathserver.js
More file actions
90 lines (74 loc) · 2.54 KB
/
server.js
File metadata and controls
90 lines (74 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var batcheditServer = (function () {
var cookie = '{7b4e584c-bf85-4f7b-953b-15e327df08ff}';
var session = null;
var transaction = null;
function initialize() {
session = jQuery('input[name=session]').val();
}
function sendRequest(request, data, onSuccess, onError) {
if (transaction != null) {
return false;
}
data.append('call', 'batchedit');
data.append('session', jQuery('input[name=session]').val());
data.append('command', request);
transaction = request;
function errorHandler(status, message) {
console.log(status + ': ' + message);
if (typeof onError != 'undefined') {
onError(status, message);
}
}
jQuery.ajax({
cache : false,
data : data,
processData: false,
contentType: false,
global : false,
type : 'POST',
timeout : 1000,
url : DOKU_BASE + 'lib/exe/ajax.php',
success : function (data) {
if (typeof data != 'object') {
errorHandler('invalid_data', 'Invalid data type');
return;
}
if (data.hasOwnProperty('error')) {
errorHandler(data['error'], data['message']);
return;
}
if (typeof onSuccess != 'undefined') {
onSuccess(data);
}
},
error : function (xhr, status, message) {
errorHandler(transaction + '_failed', message);
},
dataFilter : function (data) {
var match = data.match(new RegExp(cookie + '(.+?)' + cookie));
if ((match == null) || (match.length != 2)) {
return '{"error":"invalid_data","message":"Malformed response"}';
}
return match[1];
},
complete : function () {
transaction = null;
}
});
return true;
}
function checkProgress(onSuccess, onError) {
return sendRequest('progress', new FormData(), onSuccess, onError);
}
function cancelOperation(onSuccess, onError) {
return sendRequest('cancel', new FormData(), onSuccess, onError);
}
return {
initialize : initialize,
checkProgress : checkProgress,
cancelOperation : cancelOperation
}
})();
jQuery(function () {
batcheditServer.initialize();
});