-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.js
75 lines (60 loc) · 2.34 KB
/
backend.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
/*
Javascript routines for WebsiteBaker module Bakery
Copyright (C) 2007 - 2017, Christoph Marti
This Javascript routines are free software. You can redistribute it and/or modify it
under the terms of the GNU General Public License - version 2 or later,
as published by the Free Software Foundation: http://www.gnu.org/licenses/gpl.html.
The Javascript routines are distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
// **********************************************************************************
// Function to change the checkbox status at the same time
// for all checkboxes having the same name like the clicked one
// **********************************************************************************
function sync_checkboxes(clicked_checkbox) {
// Get all checkboxes with the same name
var checkboxes = document.getElementsByName(clicked_checkbox.name);
// Get state of clicked checkbox and define new state for all checkboxes
var new_state = false;
if (clicked_checkbox.checked == true) {
new_state = true;
}
// Loop through all checkboxes and set new state
for (var i = 0; i < checkboxes.length; ++i) {
if (checkboxes[i].type == "checkbox") {
checkboxes[i].checked = new_state;
}
}
}
// **********************************************************************************
// Function to add and remove file type inputs
// (http://codingforums.com/showthread.php?t=65390)
// **********************************************************************************
function addFile(delTxt) {
var root = document.getElementById('upload').getElementsByTagName('tr')[0].parentNode;
var oR = cE('tr');
var oC = cE('td');
var oI = cE('input');
var oS = cE('span');
cA(oI,'type','file');
cA(oI,'name','image[]');
oS.style.cursor = 'pointer';
oS.onclick = function() {
this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
}
oS.appendChild(document.createTextNode(delTxt));
oC.appendChild(oI);
oC.appendChild(oS);
oR.appendChild(oC);
root.appendChild(oR);
}
function cE(el){
this.obj = document.createElement(el);
return this.obj;
}
function cA(obj,att,val) {
obj.setAttribute(att,val);
return;
}