-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcascade_widget.js
executable file
·58 lines (48 loc) · 1.95 KB
/
cascade_widget.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @param type - 0 means an ID. 1 means a class
*/
function createElementView(type, widgetID) {
if (type == 0) {
type = "ID";
} else if (type == 1) {
type = "Class";
}
// Assimilaçao de elemento
var element_view = document.getElementById(widgetID);
// Criaçao do container do widget
var divContainerWidget = document.createElement("div");
divContainerWidget.setAttribute("ID", widgetID + "_gen_" + this.IDClassList.length);
// Text element to be between fields
// Checks if is the first widget or not
// If does, it's not necessary to perform the following action
if (document.querySelectorAll("#" + widgetID + " > div").length != 0) {
var divNodeInfo = document.createElement('div');
divNodeInfo.setAttribute("class", "extract_field_info");
var nodeInfo = document.createTextNode("and after");
divNodeInfo.appendChild(nodeInfo);
divContainerWidget.appendChild(divNodeInfo);
}
// Criaçao dos outros elementos constituintes do widget
var nodeinfo = document.createTextNode(type);
var inputText = document.createElement("input");
var inputRemove = document.createElement("input");
inputText.setAttribute("type", "text");
inputRemove.setAttribute("type","button");
inputRemove.setAttribute("value","X");
inputRemove.setAttribute("onClick", "document.getElementById('" + widgetID + "_gen_" + this.IDClassList.length + "').outerHTML = ''");
divContainerWidget.appendChild(nodeinfo);
divContainerWidget.appendChild(inputText);
divContainerWidget.appendChild(inputRemove);
element_view.appendChild(divContainerWidget);
this.IDClassList.push(divContainerWidget);
}
/**
* Array to hold all ID elements holders
*/
createElementView.prototype.IDClassList = [];
/**
* Function to create element
*/
function createOBJ(type, WidgetID) {
window[WidgetID] = new createElementView(type, WidgetID);
}