Commit e3bfc5f8 authored by Pierre M's avatar Pierre M
Browse files

use user registration names for the plonk list


Signed-off-by: Pierre M's avatarPierre Mazière <pierre.maziere@gmx.com>
parent 75a314a0
......@@ -33,7 +33,7 @@
location.reload();
}
function buildForm(form,user){
function buildForm(form,user,alias){
let p = document.createElement("p");
let select = document.createElement("select");
if(plonkList.length){
......@@ -72,8 +72,8 @@
let addButton = document.createElement("button");
addButton.setAttribute("id","plonkAdd");
addButton.appendChild(document.createTextNode("Plonker '"+user+"'"));
addButton.addEventListener("click",function(){plonk(plonkList,user);},true);
addButton.appendChild(document.createTextNode("Plonker '"+user+"' alias '"+alias+"'"));
addButton.addEventListener("click",function(){plonk(user,alias);},true);
if(plonkList.indexOf(user) !== -1){
addButton.setAttribute("disabled","disabled");
}
......@@ -81,7 +81,7 @@
let delButton = document.createElement("button");
delButton.appendChild(document.createTextNode("Supprimer la sélection"));
delButton.addEventListener("click",function(){unplonk(plonkList,user);},true);
delButton.addEventListener("click",function(){unplonk(user,alias);},true);
if(!plonkList.length){
delButton.setAttribute("disabled","disabled");
}
......@@ -93,7 +93,7 @@
form.appendChild(cancelButton);
}
function plonk(plonkList,user){
function plonk(user,alias){
plonkList.push(user);
GM_setValue("plonkList",JSON.stringify(plonkList));
let select = document.getElementById("plonkList");
......@@ -102,7 +102,7 @@
form.remove();
form = document.createElement("form");
form.setAttribute("id","plonkForm");
buildForm(form,user);
buildForm(form,user,alias);
document.getElementsByClassName("overlaywin").item(0).appendChild(form);
}else{
let option = document.createElement("option");
......@@ -113,7 +113,7 @@
}
}
function unplonk(plonkList,user){
function unplonk(user,alias){
select = document.getElementById("plonkList");
for (let i = 0; i < select.length; i++){
if(!select[i].selected){
......@@ -127,14 +127,14 @@
form.remove();
form = document.createElement("form");
form.setAttribute("id","plonkForm");
buildForm(form,user);
buildForm(form,user,alias);
document.getElementsByClassName("overlaywin").item(0).appendChild(form);
}
GM_setValue("plonkList",JSON.stringify(plonkList));
}
function addToPlonkList(plonkList,user){
function addToPlonkList(user,alias){
let bg = document.createElement("div");
bg.className = "overlaybg";
document.body.appendChild(bg);
......@@ -142,7 +142,7 @@
win.className = "overlaywin";
let form = document.createElement("form");
form.setAttribute("id","plonkForm");
buildForm(form,user);
buildForm(form,user,alias);
win.appendChild(form);
document.body.appendChild(win);
return false;
......@@ -156,7 +156,7 @@
let a = document.createElement("a");
let txt = document.createTextNode(" Plonk");
a.appendChild(txt);
a.addEventListener("click",function(){addToPlonkList(plonkList,userLink.textContent);},true);
a.addEventListener("click",function(){addToPlonkList(userLink.href.match(userRE)[1],userLink.textContent);},true);
a.href = "#";
sup.appendChild(a);
span.appendChild(sup);
......
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