Commit 2365e767 authored by Pierre M's avatar Pierre M
Browse files

avoid anonymous functions when possible


Signed-off-by: Pierre M's avatarPierre Mazière <pierre.maziere@gmx.com>
parent 3f5d46aa
......@@ -67,6 +67,16 @@
GM_addStyle("#plonkList+button{margin-top:10px}")
GM_addStyle("#plonkForm h2{text-align:center}");
function togglePlonk(user,type){
let i;
switch(type){
case 'article': i=0; break;
case 'comment': i=1; break;
}
plonkList[user][i] = !plonkList[user][i];
GM_setValue("plonkList",JSON.stringify(plonkList));
}
function closePlonkList(){
document.getElementsByClassName("overlaywin").item(0).remove();
document.getElementsByClassName("overlaybg").item(0).remove();
......@@ -126,10 +136,7 @@
if( user !== alias ){
button.appendChild(document.createTextNode("' alias '"+alias+"'"));
}
button.addEventListener("click",function(e){
plonk(user,alias);
e.preventDefault();
},true);
button.addEventListener("click",plonk.bind(null,user,alias),true);
let p = document.createElement("p");
let container = document.createElement("div");
......@@ -202,10 +209,7 @@
checkbox = document.createElement("input");
checkbox.setAttribute("type","checkbox");
checkbox.setAttribute("name","articles_"+u);
checkbox.addEventListener("change",function(){
plonkList[u][0]=!plonkList[u][0];
GM_setValue("plonkList",JSON.stringify(plonkList));
});
checkbox.addEventListener("change",togglePlonk.bind(null,u,'article'));
if(plonkList[u][0]){
checkbox.setAttribute("checked","checked");
}
......@@ -216,10 +220,7 @@
checkbox = document.createElement("input");
checkbox.setAttribute("type","checkbox");
checkbox.setAttribute("name","comments_"+u);
checkbox.addEventListener("change",function(){
plonkList[u][1]=!plonkList[u][1];
GM_setValue("plonkList",JSON.stringify(plonkList));
});
checkbox.addEventListener("change",togglePlonk.bind(null,u,'comment'));
if(plonkList[u][1]){
checkbox.setAttribute("checked","checked");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment