Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
49 lines (46 loc) · 1.54 KB
/
Copy pathscript.js
File metadata and controls
49 lines (46 loc) · 1.54 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
//makes it possible to edit the list of possible matches
$(document).ready(function() {
var words = document.querySelectorAll('.word');
for (var i = 0; i < words.length; i++) {
words[i].addEventListener('click', function(event) {
var childNodes = this.parentElement.childNodes;
var name = '';
var hiddenInput= '';
for (var j = 0; j < childNodes.length; j++) {
if (childNodes[j] != this && childNodes[j].className == "word" ){
name += childNodes[j].innerText+" ";
}
else if (childNodes[j].nodeName == "INPUT"){
hiddenInput = childNodes[j];
}
}
name = name.trim();
hiddenInput.value = name ;
if (name == ''){
this.parentElement.remove();
}
else{
// remove duplicates
var nameInputs = document.querySelectorAll('.hiddenNames');
for (var j = 0; j < nameInputs.length; j++) {
if(nameInputs[j] != hiddenInput && nameInputs[j].value == name ){
nameInputs[j].parentElement.remove();
}
}
this.remove();
}
});
}
var removeButtons = document.querySelectorAll('.remove');
for (var i = 0; i < removeButtons.length; i++) {
removeButtons[i].addEventListener('click', function(event) {
this.parentElement.remove();
});
}
$('textarea.retracted').focus(function () {
$(this).animate({ height: "200px" }, 500);
});
$('textarea.retracted').focusout(function () {
$(this).animate({ height: "40px" }, 500);
});
});