-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
57 lines (53 loc) · 1.32 KB
/
Copy pathserver.js
File metadata and controls
57 lines (53 loc) · 1.32 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
/**
* Created by Pathik on 3/3/2017.
*/
var server = server || {};
(function ($) {
var url = window.location.origin;
server.ajax0 = function (path, name, data, callback) {
$.ajax({
type: "post",
url: url,
headers: {
"_worker": "_v8"
},
data: JSON.stringify({
path: path,
data: data,
name: name
}),
contentType: "text/plain",
success: function (data) {
if (callback) {
callback(data);
}
}
});
};
server.ajax = function (args) {
$.ajax({
type: "post",
url: url,
headers: {
"_worker": "_v8"
},
data: JSON.stringify({
path: args.path,
data: args.data,
name: args.name
}),
contentType: "text/plain",
success: function (data) {
if (args.done) {
args.done(data);
}
}
});
};
})(jQuery);
(function ($) {
var ws = new WebSocket("ws://" + window.location.host + "/error");
ws.onmessage = function (e) {
console.warn(e.data);
};
})(jQuery);