forked from mitchgre/gregsList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocations.js
103 lines (78 loc) · 1.9 KB
/
locations.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
function insertLocation()
{
var object = this;
var locationText = $("#LocationToAdd")[0].value;
$.ajax
(
{
url: "butler.php",
type: "post",
dataType: "text",
data:
{
user: object.user.name,
pass: object.user.password,
func: "insertLocation",
location: locationText
},
success: function(resp)
{
console.log(resp);
//
// clear text fields
$("#LocationToAdd")[0].value = '';
if (JSON.parse(resp) === true)
{
console.log("input worked");
// displayTable(object,[]);
getStuff(object.locations);
// object.refresh();
}
else
{
console.log("input failed");
}
} // end success function
} // end ajax data
) // end ajax function call
} // end insertLocation function
function editLocation()
{
}
function fillLocations(object,input)
{
console.log("fill industries");
console.log(object);
//console.log("input keys");
// console.log(input);
//console.log(JSON.parse(Object.keys(input)));
// erase object's contents and refill them from input
object.contents = [];
var contents = object.contents;
for (var i = 0; i < input.ids.length; i++)
{
var id = input.ids[i];
var name = input.names[i];
var p = new loc(id,name);
// console.log("p");
// console.log(p);
contents.push(p);
}
displayTable(object);
displayLocationsPortlet(object);
}
function displayLocationsPortlet(object)
{
$("#locationsPortlet").empty();
var main = $("#locationsPortlet")[0];
var table = createAppendedChildToParent('table',main);
table.className += "io";
for (var i = 0; i < object.contents.length; i++)
{
var tr = createAppendedChildToParent('tr',table);
var td = createAppendedChildToParent('td',tr);
var value = object.contents[i].name;
var content = document.createTextNode(value);
td.appendChild(content);
}
}