/*
The BSD 2-Clause
Copyright (c) 2012-2013, Janne Hyytiä
All rights reserved.
*/
function Needles() {
var
rootO = this;
rootO.ele = document.getElementById("usingNeedles");
rootO.URL = {};
rootO.filters = {
"pictures": defPictures,
"crawlers": defCrawlers,
"HTML": defHTMLs
};
this.toggle = function (e) {
e.target.classList.toggle("active");
if(rootO.filters[e.target.id]) {
rootO.createURL(e.target.id);
}
};
this.createURL = function (toggleThis) {
var
i = 0,
filterWithDelimiters;
if(rootO.URL[toggleThis]) {
delete rootO.URL[toggleThis];
} else {
rootO.URL[toggleThis] = {};
rootO.URL[toggleThis] = rootO.filters[toggleThis];
}
rootO.ele.value = "";
for(filter in rootO.URL) {
filterWithDelimiters = rootO.filters[filter].join(",");
rootO.ele.value += filterWithDelimiters+",";
}
console.log(rootO.ele.value.length);
rootO.ele.value = rootO.ele.value.substring(0, rootO.ele.value.length -1);
console.log(rootO.ele.value);
};
for(key in this.filters) {
document.getElementById(key).addEventListener("click", rootO.toggle);
}
};
|