color hashing of groups

master
Fabien Benetou 14 years ago committed by utopiah
parent 954b8d97ed
commit 6e1d484b40
  1. 24
      pub/code/reverted_pim_links.user.js

@ -12,8 +12,6 @@
* todo * todo
* generate the data store on demand * generate the data store on demand
* check link_extractor/revertingpimlinks.sh * check link_extractor/revertingpimlinks.sh
* change background-color based on a hash of the group
* within bound of readable values
* *
* add links to the database * add links to the database
* note that date is optional but the source is not * note that date is optional but the source is not
@ -35,6 +33,18 @@ for SCANNETWORK in $(ls ~/irclogs/); do echo -n -e "$SCANNETWORK\t" && grep http
* *
*/ */
String.prototype.ColorHash = function(){
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
hash = Math.round(Math.sqrt(Math.abs(hash))); // How to convert to 16bit integer?
return hash;
// suppose to send back a correct HTML color value
}
// configuration // configuration
var script_name = "rPIMlinks"; var script_name = "rPIMlinks";
@ -63,8 +73,14 @@ if (PIMpages != "fail")
var myDiv = document.createElement('div'); var myDiv = document.createElement('div');
myDiv.id = "GM_PIM_Window"; myDiv.id = "GM_PIM_Window";
while (page = pages.shift()){ while (page = pages.shift()){
grouppage = page.split(".");
group = grouppage[0];
page = grouppage[1];
myDiv.innerHTML += "<p class=\"GM_PIM_link\">" myDiv.innerHTML += "<p class=\"GM_PIM_link\">"
+"<a href=\""+PIM_URL+page+"\">"+page+"</a>" +"<a href=\""+PIM_URL+group+"/"+page+"\">"
+"<font color=\""+group.ColorHash()+"\">"+group+"</font>/"
+"<font color=\"white\">"+page+"</font>/"
+"</a>"
+"<sup><a href=\""+PIM_URL+page+"?action=edit\">[e]</a></sup>" +"<sup><a href=\""+PIM_URL+page+"?action=edit\">[e]</a></sup>"
+"</p>"; +"</p>";
} }
@ -111,8 +127,6 @@ function unregisterShortcuts() {
registerShortcuts(); registerShortcuts();
$x('//input | //textarea | //select').forEach(registerListener);
function registerListener(node) { function registerListener(node) {
node.addEventListener("mouseover", function() { node.addEventListener("mouseover", function() {
unregisterShortcuts(); unregisterShortcuts();

Loading…
Cancel
Save