-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
192 lines (154 loc) · 4.86 KB
/
index.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
dragula([
document.getElementById('1'),
document.getElementById('2'),
document.getElementById('3'),
document.getElementById('4'),
document.getElementById('5')
])
.on('drag', function(el) {
// add 'is-moving' class to element being dragged
el.classList.add('is-moving');
})
.on('dragend', function(el) {
// remove 'is-moving' class from element after dragging has stopped
el.classList.remove('is-moving');
// add the 'is-moved' class for 600ms then remove it
window.setTimeout(function() {
el.classList.add('is-moved');
window.setTimeout(function() {
el.classList.remove('is-moved');
}, 600);
}, 100);
});
var createOptions = (function() {
var dragOptions = document.querySelectorAll('.drag-options');
// these strings are used for the checkbox labels
var options = ['Research', 'Strategy', 'Inspiration', 'Execution'];
// create the checkbox and labels here, just to keep the html clean. append the <label> to '.drag-options'
function create() {
for (var i = 0; i < dragOptions.length; i++) {
options.forEach(function(item) {
var checkbox = document.createElement('input');
var label = document.createElement('label');
var span = document.createElement('span');
checkbox.setAttribute('type', 'checkbox');
span.innerHTML = item;
label.appendChild(span);
label.insertBefore(checkbox, label.firstChild);
label.classList.add('drag-options-label');
dragOptions[i].appendChild(label);
});
}
}
return {
create: create
}
}());
var showOptions = (function () {
// the 3 dot icon
var more = document.querySelectorAll('.drag-header-more');
function show() {
// show 'drag-options' div when the more icon is clicked
var target = this.getAttribute('data-target');
var options = document.getElementById(target);
options.classList.toggle('active');
}
function init() {
for (i = 0; i < more.length; i++) {
more[i].addEventListener('click', show, false);
}
}
return {
init: init
}
}());
createOptions.create();
showOptions.init();
/* Start customize */
function msgbarText(isLengthError, columnId, msgText){
msgText.push(columnId);
}
function checkingResultCol1(){
var msgText = [];
var line1Values = $($('.drag-inner-list')[0]).find('.drag-item');
var result = [
['Mobile App Programmer', 'Analyst Programmer'],
['Business Analyst', 'Project Manager'],
['Data Scientist', 'Data Warehousing'],
['Network Infrastructure', 'Data Center Operator']
];
var columnHeadings = [
"Development",
"Business & Admin",
"Big Data Analysis",
"Operation"
]
var resultLine0 = ['DREAMWEAVER', 'Sublime Text'];
var checkingResult = [true, true, true, true];
for(var i = 0; i <result.length; i++){
//Start looping result set
var columnItems = $($('.drag-inner-list')[i]).find('.drag-item');
var cnt = 0;
var columnItemTextArr = [];
$(columnItems).each(function(){
columnItemTextArr.push($(this).text())
});
for(var k = 0; k < columnItems.length; k++){
//Start checking column by column
var currentColumnId = i ;
var currentItem = $(columnItems[k]);
var currentItemText = $(currentItem).text();
console.log("k: " + k + ", currentItemText: " + currentItemText);
console.log(columnItemTextArr);
//Checking 1, if length not correct already false.
if(result[i].length != columnItems.length){
msgbarText(true, currentColumnId, msgText);
console.log("Column" + (i+1) + " has something wrong(length), would you please try again :) ");
checkingResult[i] = false;
break;
};
//Checking 2: even column length correct, the text inside still will fail!
if(result[i].indexOf(currentItemText)>-1){
cnt++;
}else{
console.log("currentItemText:" + currentItemText);
console.log("result[i].indexOf(currentItemText): " + result[i].indexOf(currentItemText));
msgbarText(false, currentColumnId, msgText);
console.log("Column" + (i+1) + " has something wrong(item), would you please try again :) ");
checkingResult[i] = false;
break;
}
if(cnt==columnItemTextArr.length){
checkingResult[i] = true;
console.log("Result Column " + i + " is correct!");
}
}
}
var finalResult = true;
for(var i = 0; i <checkingResult.length; i++){
if(!checkingResult[i]){
finalResult = false;
console.log("Final is false");
}
}
if(finalResult){
$('#status-bar').text("You made it! Congratulations!");
$('#msg-bar').text("You made it! Congratulations!")
// alert("Really success!");
}else{
$('#status-bar').text("Oops!");
var colWordings = "";
for(var i = 0; i < msgText.length; i++){
if(i>0){
colWordings += " and ";
}
var idx = msgText[i];
colWordings += "\"" + columnHeadings[idx] + "\"";
}
$('#msg-bar').text("There are wrong choices in column " + colWordings.toString() + " , try again!");
// alert("Checking not success le~!");
}
}
function reset(){
location.reload();
}