-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
42 lines (35 loc) · 1.03 KB
/
main.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
37
38
39
40
41
42
const shexParser = require("./src/ShExParser.js");
const $ = require('jquery');
var id = 0;
function getID() {
return id++;
}
function shexToForm(shex) {
return shexParser.parseShExToForm(shex);
}
function postProcess() {
$( ".newButton" ).each(function(index) {
$(this).on("click", function(){
let id = $(this).prev().attr("id").replace(":", "\\:");
let copy = $(this).prev().clone();
let copyIDn = getID();
let copyID = "copy" + copyIDn;
$("#container-" + id).after(`<div id="${copyID}"></div>`);
$("#" + copyID).append(copy);
$("#" + copyID).append("<a class='button delButton'>×</a>");
$(`#${copyID} input`).attr("id", $(`#${copyID} input`).attr("id") + copyIDn);
$(`#${copyID} .delButton`).on("click", function() {
$(`#${copyID}`).remove();
})
});
$("#checkbtn").click(function() {
if(! $("#shexgform")[0].checkValidity()) {
$("#shexgform").find(':submit').click();
}
});
});
}
module.exports = {
shexToForm,
postProcess
}