Template:VersionTimeline

  • Revision slug: Template:VersionTimeline
  • Revision title: Template:VersionTimeline
  • Revision id: 29132
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

<% /* parameters: version created, version last changed, version obsoleted (optional), version deprecated (optional) */ /* specify 0 for obsoleted if it's deprecated but not yet obsolete */ /* get page language first */ var currentGecko = "11.0"; // Update this to current Gecko version var currentBlob = template.xverblob(currentGecko) - template.xverblob(1); var u = uri.parts(Page.uri); var lang = string.tolower(u.path[0]); var unitBlob = template.xverblob(1); // Variables defining positioning of items in the diagram var barTopHeight = "height:8px; top:16px;"; var underTextTop = "top:22px;"; if (string.contains(lang, "project") || string.contains(lang, "Project")) { lang = string.substr(lang, 8); } /* fall back to page.language on a user page */ else if (string.StartsWith(lang, "user:")) { lang = page.language; } var availLength = currentBlob - template.xverblob($0);
var start = 0; var end = 0; var v = 0; var st = ""; // Draw version legend
(web.html("1.0"));
// Only draw the "current version" legend if nothing collides with it if (($2 != currentGecko) && ($0 != currentGecko) && ($3 != currentGecko)) {   
(currentGecko)
} // Compute length of initial red block, if any. This will run from version 1.0 to $0 var startVer = $0; if (startVer < 1) {   startVer = 1;    // deal with cases where the start version predates 1.0 } v = template.xverblob(startVer) - unitBlob; if (v) { end = 100*(v/currentBlob); st = barTopHeight + "background:#dd0000; position:absolute; width:" + end + "%";
  if (startVer == currentGecko) {   st = "top:0px; font-size:11px; position:absolute; text-align:right; width:" + end + "%;";   } else {   st = "top:0px; font-size:11px; position:absolute; left:" + end + "%;";      }
(web.html("Introduced"));
  if (startVer == currentGecko) {     st = underTextTop + "font-size:11px; position:absolute; text-align:right; width:" + end + "%;";   } else {     st = underTextTop + "font-size:11px; position:absolute; left:" + end + "%;";   }
(web.html("Gecko " + $0));
} start = end; // Now do the green block representing "implemented"; this will go up to $3 if it exists, or $2 if that exists, // or to the end if neither does introTitle = "Introduced in Gecko " + $0 + " " + template.GeckoRelease($0); if ($3) { v = template.xverblob($3) - unitBlob; end = 100*(v/currentBlob);  st = barTopHeight + "left:" + start + "%; background:#00dd00; position:absolute; width:" + end-start + "%";
start = end; // now do the deprecated part if ($2) { v = template.xverblob($2) - unitBlob; end = 100*(v/currentBlob); } else { end = 100; st = "top:0px; font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
(web.html("Deprecated"));
st = underTextTop +"font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
(web.html("Gecko " + $3));
} st = barTopHeight + "left:" + start + "%; background:#ff8000; position:absolute; width:" + end-start + "%";   title = "Deprecated in Gecko " + $3 + " " + template.GeckoRelease($3);
start = end; } else if ($2) { v = template.xverblob($2) - unitBlob; end = 100*(v/currentBlob); st = barTopHeight + "left:" + start + "%; background:#00dd00; position:absolute; width:" + end-start + "%";
start = end; } else { end = 100; st = barTopHeight + "left:" + start + "%; background:#00dd00; position:absolute; width:" + end-start + "%";
start = end; } // obsolete section if ($2) {   title = "Obsolete in Gecko " + $2 + " " + template.geckoRelease($2);  st = barTopHeight + "left:" + start + "%; background:#000000; position:absolute; width:" + 100-start + "%";
st = "top:0px; font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
(web.html("Obsolete"));
st = underTextTop + "font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
(web.html("Gecko " + $2));
} // draw an indicator for the last-changed version if ($1) {   start = (100 * ((template.xverblob($1) - unitBlob) / currentBlob)) - 0.5;   title = "Last changed in Gecko " + $1 + " " + template.geckoRelease($0);   st = barTopHeight + "left:" + start + "%; background:#eeee00; position:absolute; width:1%; border-radius:4px; -webkit-border-radius:4px; -moz-border-radius:4px; -o-border-radius:4px;";  
}

Revision Source

<%

/* parameters: version created, version last changed, version obsoleted (optional), version deprecated (optional) */
/* specify 0 for obsoleted if it's deprecated but not yet obsolete */
/* get page language first */

var currentGecko = "11.0";  // Update this to current Gecko version
var currentBlob = template.xverblob(currentGecko) - template.xverblob(1);
var u = uri.parts(Page.uri);
var lang = string.tolower(u.path[0]);
var unitBlob = template.xverblob(1);

// Variables defining positioning of items in the diagram

var barTopHeight = "height:8px; top:16px;";
var underTextTop = "top:22px;";

if (string.contains(lang, "project") || string.contains(lang, "Project")) {
  lang = string.substr(lang, 8);
}
/* fall back to page.language on a user page */
else if (string.StartsWith(lang, "user:")) {
 lang = page.language;
}

var availLength = currentBlob - template.xverblob($0);

<div style="height:42px; position:relative; padding:2px; width:auto;">

var start = 0;
var end = 0;
var v = 0;
var st = "";

// Draw version legend

<div style="top:22px; font-size:11px; position:absolute;">(web.html("1.0"));</div>

// Only draw the "current version" legend if nothing collides with it

if (($2 != currentGecko) && ($0 != currentGecko) && ($3 != currentGecko)) {
  <div style="top:22px; font-size:11px; position:absolute; text-align:right; width:100%;">(currentGecko)</div>
}

// Compute length of initial red block, if any. This will run from version 1.0 to $0

var startVer = $0;
if (startVer < 1) {
  startVer = 1;    // deal with cases where the start version predates 1.0
}
v = template.xverblob(startVer) - unitBlob;
if (v) {
  end = 100*(v/currentBlob);
  st = barTopHeight + "background:#dd0000; position:absolute; width:" + end + "%";
  <div style=(st)></div>
  if (startVer == currentGecko) {
    st = "top:0px; font-size:11px; position:absolute; text-align:right; width:" + end + "%;";
  } else {
    st = "top:0px; font-size:11px; position:absolute; left:" + end + "%;";    
  }
  <div style=(st)>(web.html("Introduced"));</div>
  if (startVer == currentGecko) {
    st = underTextTop + "font-size:11px; position:absolute; text-align:right; width:" + end + "%;";
  } else {
    st = underTextTop + "font-size:11px; position:absolute; left:" + end + "%;";
  }
  <div style=(st)>(web.html("Gecko " + $0));</div>
}
start = end;

// Now do the green block representing "implemented"; this will go up to $3 if it exists, or $2 if that exists,
// or to the end if neither does

introTitle = "Introduced in Gecko " + $0 + " " + template.GeckoRelease($0);
if ($3) {
  v = template.xverblob($3) - unitBlob;
  end = 100*(v/currentBlob);
  st = barTopHeight + "left:" + start + "%; background:#00dd00; position:absolute; width:" + end-start + "%";
  <div style=(st) title=(introTitle)></div>
  start = end;

  // now do the deprecated part
  if ($2) {
    v = template.xverblob($2) - unitBlob;
    end = 100*(v/currentBlob);
  } else {
    end = 100;
    st = "top:0px; font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
    <div style=(st)>(web.html("Deprecated"));</div>
    st = underTextTop +"font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
    <div style=(st)>(web.html("Gecko " + $3));</div>
   }
  st = barTopHeight + "left:" + start + "%; background:#ff8000; position:absolute; width:" + end-start + "%";
  title = "Deprecated in Gecko " + $3 + " " + template.GeckoRelease($3);
  <div style=(st) title=(title)></div>
  start = end;
} else if ($2) {
  v = template.xverblob($2) - unitBlob;
  end = 100*(v/currentBlob);
  st = barTopHeight + "left:" + start + "%; background:#00dd00; position:absolute; width:" + end-start + "%";
  <div style=(st) title=(introTitle)></div>
  start = end;
} else {
  end = 100;
  st = barTopHeight + "left:" + start + "%; background:#00dd00; position:absolute; width:" + end-start + "%";
  <div style=(st) title=(introTitle)></div>
  start = end;
}

// obsolete section
 
if ($2) {
  title = "Obsolete in Gecko " + $2 + " " + template.geckoRelease($2);
  st = barTopHeight + "left:" + start + "%; background:#000000; position:absolute; width:" + 100-start + "%";
  <div style=(st) title=(title)></div>
  st = "top:0px; font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
  <div style=(st)>(web.html("Obsolete"));</div>
  st = underTextTop + "font-size:11px; position:absolute; left:0px; text-align:right; float: right; width:" + start + "%;";
  <div style=(st)>(web.html("Gecko " + $2));</div>
}

// draw an indicator for the last-changed version

if ($1) {
  start = (100 * ((template.xverblob($1) - unitBlob) / currentBlob)) - 0.5;
  title = "Last changed in Gecko " + $1 + " " + template.geckoRelease($0);
  st = barTopHeight + "left:" + start + "%; background:#eeee00; position:absolute; width:1%; border-radius:4px; -webkit-border-radius:4px; -moz-border-radius:4px; -o-border-radius:4px;";
  <div style=(st) title=(title)></div>
}
</div>
</pre>
Revert to this revision