forked from mitchgre/gregsList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.js
81 lines (67 loc) · 1.43 KB
/
utilities.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
/*
This file will contain utility functions that are not specialized for this project.
*/
// create a child DOM element of type childType ct and append to parent p
// return the created child
function createAppendedChildToParent( ct ,parent)
{
var c = document.createElement(ct);
parent.appendChild(c);
return c;
}
/*
Remove all of element e's children from DOM
*/
function emptyElement(e)
{
if (typeof e != 'undefined')
if (e.firstChild)
while (e.firstChild)
e.removeChild(e.firstChild);
}
/*
A function to render an input type to a container div (element).
*/
function addInput(parent, inputType, inputClass, inputValue, inputId)
{
var input = createAppendedChildToParent('input',parent);
input.type = inputType;
if (inputClass)
input.type = inputClass;
if (inputValue)
input.value = inputValue;
if (inputId)
input.id = inputId;
return input;
}
function isInArray(value, array) {
return array.indexOf(value) > -1;
}
function removeElement(id)
{
var element = document.getElementById(id);
element.parentNode.removeChild(element);
}
function month()
{
this.names =
[
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
}
function getMonthName(date)
{
var m = new month();
return m.names[date.getMonth()];
}