Commit 791e2896 authored by Imran Hussain's avatar Imran Hussain

Add a function to delete a usercolour from the colous db

parent 8cbeb6aa
......@@ -67,7 +67,7 @@ function processUnixtime(unixtime) {
// function to replace every instance of a word in a string
function replace(targetWord, newWord, text) {
if (debugmode == 1) {
if (debugmode >= 2) {
mw.print("DEBUG: replacing " + targetWord + " with " + newWord);
}
......@@ -75,7 +75,7 @@ function replace(targetWord, newWord, text) {
var subTexts = text.split(" ");
var newSubTexts = [];
if (debugmode == 1) {
if (debugmode >= 2) {
mw.print("DEBUG: text before replace: " + subTexts);
}
subTexts.forEach(function(element) {
......@@ -84,7 +84,7 @@ function replace(targetWord, newWord, text) {
// "gi" just says match every (g) and ignore case (i)
newSubTexts.push(element.replace(new RegExp("(^|\b)"+targetWord,"gi"),newWord));
});
if (debugmode == 1) {
if (debugmode >= 2) {
mw.print("DEBUG: text after replace: " + newSubTexts);
}
text = newSubTexts.join(" ");
......@@ -147,7 +147,15 @@ function recolour() {
}
//mw.command.recolour = recolour;
register("recolour",recolour,"Recolour a user. If you enter just a uysername, random colour is chosen if you enter a username followed by a space and then a colour that colour is used.");
register("recolour",recolour,"Recolour a user. If you enter just a username, random colour is chosen if you enter a username followed by a space and then a colour that colour is used.");
//simple function to delete a user from the colours 'db'
function deleteColour() {
var userinput = mw.input();
delete usercolours[userinput];
mw.store["usercolours"] = JSON.stringify(usercolours); //update the mw.store object
}
register("deletecolour",deleteColour,"Delete a coloured username.");
// simple fuction to show all the colours assigned to users
function showcolours() {
......
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