v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "User:HebaruSan/monobook.js"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m (typo)
m (one last attempt, may give up after this)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
addOnLoadHook(
 +
function() {
 +
  alert("The onloadhook function works.");
 +
}
 +
);
 +
 +
var animDelay = 750;
 
var animTimer = 0;
 
var animTimer = 0;
 
var animations = new Array();
 
var animations = new Array();
 
var current = new Array();
 
var current = new Array();
 +
 +
alert("Loading custom script.");
  
 
function initAnim(name,count) {
 
function initAnim(name,count) {
 
  /* Attempt re-entrancy. */
 
  /* Attempt re-entrancy. */
 
  if (!animTimer) {
 
  if (!animTimer) {
   setTimeout("doAnim();", 250);
+
   setTimeout("doAnim();", animDelay);
 
   animTimer = 1;
 
   animTimer = 1;
 
  }
 
  }
Line 15: Line 24:
 
/* Change each animated cell to its next character */
 
/* Change each animated cell to its next character */
 
function doAnim() {
 
function doAnim() {
 +
alert("doAnim was called.");
 
  var a;
 
  var a;
 
  for (a in animations) {
 
  for (a in animations) {
Line 20: Line 30:
 
   var prev_elt = document.getElementById(prev_id);
 
   var prev_elt = document.getElementById(prev_id);
 
   prev_elt.style.display = "none";
 
   prev_elt.style.display = "none";
   if (current[a] < animations[a]) {
+
   if (++current[a] >= animations[a]) {
  ++current[a];
 
  } else {
 
 
   current[a] = 0;
 
   current[a] = 0;
 
   }
 
   }
Line 28: Line 36:
 
   var next_elt = document.getElementById(next_id);
 
   var next_elt = document.getElementById(next_id);
 
   next_elt.style.display = "";
 
   next_elt.style.display = "";
  }
+
  ]
  setTimeout("doAnim();", 250);
+
  setTimeout("doAnim();", animDelay);
 +
}
 +
 
 +
initAnim("test",2);
 +
 
 +
if (window.addEventListener) {
 +
  window.addEventListener("load", "initAnim('test',2);", false);
 +
} else if (window.attachEvent) {
 +
  window.attachEvent("onload", "initAnim('test',2);");
 
}
 
}

Latest revision as of 20:06, 25 October 2009

addOnLoadHook(
 function() {
  alert("The onloadhook function works.");
 }
);

var animDelay = 750;
var animTimer = 0;
var animations = new Array();
var current = new Array();

alert("Loading custom script.");

function initAnim(name,count) {
 /* Attempt re-entrancy. */
 if (!animTimer) {
  setTimeout("doAnim();", animDelay);
  animTimer = 1;
 }
 animations[name] = count;
 current[name] = 0;
}

/* Change each animated cell to its next character */
function doAnim() {
 alert("doAnim was called.");
 var a;
 for (a in animations) {
  var prev_id = a + "_" + current[a];
  var prev_elt = document.getElementById(prev_id);
  prev_elt.style.display = "none";
  if (++current[a] >= animations[a]) {
   current[a] = 0;
  }
  var next_id = a + "_" + current[a];
  var next_elt = document.getElementById(next_id);
  next_elt.style.display = "";
 ]
 setTimeout("doAnim();", animDelay);
}

initAnim("test",2);

if (window.addEventListener) {
  window.addEventListener("load", "initAnim('test',2);", false);
} else if (window.attachEvent) {
  window.attachEvent("onload", "initAnim('test',2);");
}