User:1ccsDontMatter/Code

From Shmups Wiki -- The Digital Library of Shooting Games
Jump to navigation Jump to search

Hall of records variablizer

Put this in a javascript console while on the hall of records edit screen to turn any numbers greater than 4 digits that are somewhere in a table into variables in ascending letter order

var gText = $("textarea")[0].value;
var gAlphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var scoreIndex;

var newText = gText.replace(/(\|})|(\|+|!+) (?![a-z])([0-9,]+) ?(?=\||!)/gi, replacer);
$("textarea")[0].value = newText;

function replacer(match, p1, p2, p3, offset, string, groups) {
 if(p1) {
   scoreIndex = 0;
   return "|}"
 }
 else {
   if(p3.length < 5)
     return p2 + p3;
   return p2 + " " + p3 + "
";
 }
}

function getNextLetter() {
 var ret = gAlphabet[scoreIndex];
 scoreIndex++;
 return ret;
}