-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete-path.js
36 lines (33 loc) · 951 Bytes
/
delete-path.js
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
/*global document, window, alert, console, require, google, $, confirm*/
/*jslint nomen: true */
// Sends path details to delete-path
function deletePath(node) {
"use strict";
$.ajax({
type: "POST",
data: {
_id: node.id
},
url: "delete-path"
});
}
//Confirms deletion
function confirmDeletion(node, removeButton) {
"use strict";
if (confirm("Warning. This will delete the path forever.")) {
deletePath(node);
node.removeChild(removeButton);
node.remove();
}
}
// Creates delete button on loaded paths page for each path
function createDeleteButton(node) {
"use strict";
var removeButton = document.createElement('button');
removeButton.appendChild(document.createTextNode("delete"));
node.appendChild(removeButton);
removeButton.onclick = function (e) {
confirmDeletion(node, removeButton);
e.stopPropagation();
};
}