forked from IMQS/onboard-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
143 lines (113 loc) · 3.83 KB
/
app.ts
File metadata and controls
143 lines (113 loc) · 3.83 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
const myTable = new Table();
window.onload = function () {
addButtons();
myTable.initialTableBuild();
}
$(window).on('resize', function () {
myTable.buildTable();
}
);
function buttonPropertySet() {
let previous = <HTMLInputElement>document.getElementById("previous");
let previous5 = <HTMLInputElement>document.getElementById("previous5");
let previous10 = <HTMLInputElement>document.getElementById("previous10");
let next = <HTMLInputElement>document.getElementById("next");
let next5 = <HTMLInputElement>document.getElementById("next5");
let next10 = <HTMLInputElement>document.getElementById("next10");
let jumpToButton = <HTMLInputElement>document.getElementById("jumpToButton");
let from = myTable.from;
let totalRecords = myTable.totalRecords;
// disable previous buttons when out of range
if (from === 0) {
previous.disabled = true;
previous5.disabled = true;
previous10.disabled = true;
}
else {
previous.disabled = false;
previous5.disabled = false;
previous10.disabled = false;
}
// disable next buttons when out of range
if (from + myTable.getNumberOfRows() === (totalRecords - 1)) {
next.disabled = true;
next5.disabled = true;
next10.disabled = true;
}
else {
next.disabled = false;
next5.disabled = false;
next10.disabled = false;
}
jumpToButton.disabled = false;
}
// previous button function that takes a multiplier indicating the amount of pages to page at a time
function previousButton(multiplier: number) {
myTable.from = myTable.from - ((myTable.getNumberOfRows() + 1) * multiplier);
myTable.buildTable();
}
// next button function that takes a multiplier indicating the amount of pages to page at a time
function nextButton(multiplier: number) {
myTable.from = myTable.from + ((myTable.getNumberOfRows() + 1) * multiplier);
myTable.buildTable();
}
function jumpToButton() {
let inputElement = <HTMLInputElement>document.getElementById("jumpToValue");
let from: number;
if (inputElement.value === "")
from = 0;
else
from = parseInt(inputElement.value);
myTable.from = from;
myTable.buildTable();
}
function addButtons() {
let button: HTMLButtonElement;
let buttonDiv = <HTMLElement>document.getElementById("buttondiv");
button = document.createElement("button");
button.innerHTML = "<<< 10";
button.id = "previous10";
button.setAttribute("disabled", "true");
button.onclick = () => { previousButton(10) };
buttonDiv.appendChild(button);
button = document.createElement("button");
button.innerHTML = "<< 5";
button.id = "previous5";
button.setAttribute("disabled", "true");
button.onclick = () => { previousButton(5) };
buttonDiv.appendChild(button);
button = document.createElement("button");
button.innerHTML = "<";
button.id = "previous";
button.setAttribute("disabled", "true");
button.onclick = () => { previousButton(1) };
buttonDiv.appendChild(button);
button = document.createElement("button");
button.innerHTML = ">";
button.id = "next";
button.setAttribute("disabled", "true");
button.onclick = () => { nextButton(1) };
buttonDiv.appendChild(button);
button = document.createElement("button");
button.innerHTML = "5 >> ";
button.id = "next5";
button.setAttribute("disabled", "true");
button.onclick = () => { nextButton(5) };
buttonDiv.appendChild(button);
button = document.createElement("button");
button.innerHTML = "10 >>>";
button.id = "next10";
button.setAttribute("disabled", "true");
button.onclick = () => { nextButton(10) };
buttonDiv.appendChild(button);
button = document.createElement("button");
button.innerHTML = "Jump To:";
button.id = "jumpToButton";
button.setAttribute("disabled", "true");
button.onclick = () => { jumpToButton() };
buttonDiv.appendChild(button);
let input = document.createElement("INPUT");
input.id = "jumpToValue";
input.setAttribute("type", "number");
buttonDiv.appendChild(input);
}