Difference between revisions of "MediaWiki:Love.js"

(Add version picker script by airstruck)
 
(Update version to 11.2)
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
// From https://gist.github.com/airstruck/1603d55d79c469ac9fa6
+
// Source on github: https://github.com/airstruck/love-wiki-version-picker
function versionpicker()
+
function versionpicker() {
{
+
var picker = document.createElement('select');
// Test it on https://love2d.org/wiki/love.thread.newThread
+
// TODO: dl notes: https://love2d.org/wiki/GraphicsFeature
+
// TODO: box notes: https://love2d.org/wiki/love.event.push
+
  
var picker = document.createElement('select')
+
picker.onchange = function () {
 +
applyFilter(this.options[this.selectedIndex].value);
 +
}
  
picker.onchange = function () {
+
function array (a) {
    applyFilter(this.options[this.selectedIndex].value)
+
return [].slice.apply(a || []);
}
+
}
  
function array (a) {
+
// Some helpers for localStorage, basically resort to doing nothing
    return [].slice.apply(a || [])
+
// if it isn't available.
}
+
function storeValue(name, value) {
 +
try {
 +
localStorage[name] = value;
 +
}
 +
catch (e) {
 +
}
 +
}
  
var pickerVersions = {}
+
function retrieveValue(name) {
 +
try {
 +
return localStorage[name];
 +
}
 +
catch (e) {
 +
return undefined;
 +
}
 +
}
  
function injectPickerOption (version, text) {
+
var pickerVersions = {};
    if (pickerVersions[version]) {
+
        return
+
    }
+
    pickerVersions[version] = true
+
   
+
    var option = document.createElement('option')
+
   
+
    option.value = version
+
    option.textContent = text
+
    picker.appendChild(option)
+
}
+
  
function makeWrapper () {
+
function injectPickerOption (version, text) {
    var wrapper = document.createElement('div')
+
if (pickerVersions[version]) {
   
+
return;
    wrapper.setAttribute('data-love-filterable', true)
+
}
   
+
pickerVersions[version] = true;
    return wrapper
+
}
+
  
function wrapSections () {
+
var option = document.createElement('option');
    var element = document.querySelector('h2')
+
    var wrapper
+
   
+
    while (element) {
+
        var next = element.nextSibling
+
        if (element.nodeName == 'H2') {
+
            wrapper = makeWrapper()
+
            element.parentNode.insertBefore(wrapper, element)
+
        }
+
        wrapper.appendChild(element)
+
        element = next
+
    }
+
}
+
  
function updateSectionFromNote (section, note) {
+
option.value = version;
    if (note.textContent.match(/available since/i)) {
+
option.textContent = text;
        var a = note.querySelector('a')
+
picker.appendChild(option);
        section.setAttribute('data-love-version-added', a.title)
+
}
        note.setAttribute('data-love-version-note', true)
+
    }
+
    if (note.textContent.match(/removed in/i)) {
+
        var a = note.querySelector('a')
+
        section.setAttribute('data-love-version-removed', a.title)
+
        note.setAttribute('data-love-version-note', true)
+
    }
+
}
+
  
function QueryIterator (query) {
+
function makeWrapper () {
    return function (callback) {
+
var wrapper = document.createElement('div');
        return array(document.querySelectorAll(query)).forEach(callback)
+
    }
+
}
+
  
var withSections = QueryIterator('*[data-love-filterable]')
+
wrapper.setAttribute('data-love-filterable', true);
var withAdded = QueryIterator('*[data-love-version-added]')
+
var withRemoved = QueryIterator('*[data-love-version-removed]')
+
var withNotes = QueryIterator('*[data-love-version-note]')
+
  
function hideNotes () {
+
return wrapper;
    withNotes(function (note) { note.style.display = 'none' })
+
}
}
+
  
function showNotes () {
+
function wrapSections () {
    withNotes(function (note) { note.style.display = null })
+
var element = document.querySelector('h2');
}
+
var wrapper;
  
var needsFilter = false
+
while (element) {
 +
var next = element.nextSibling;
 +
if (element.nodeName == 'H2') {
 +
wrapper = makeWrapper();
 +
element.parentNode.insertBefore(wrapper, element);
 +
}
 +
wrapper.appendChild(element);
 +
element = next;
 +
}
 +
}
  
function scanSections () {
+
function updateSectionFromNote (section, note) {
    withSections(function (section) {
+
if (note.textContent.match(/available since/i)) {
        var note = section.querySelector('table')
+
var a = note.querySelector('a');
        if (!note) {
+
section.setAttribute('data-love-version-added', a.title);
            return
+
note.setAttribute('data-love-version-note', true);
        }
+
}
        updateSectionFromNote(section, note)
+
if (note.textContent.match(/removed in/i)) {
        while (note.nextSibling && note.nextSibling.tagName == 'TABLE') {
+
var a = note.querySelector('a');
            note = note.nextSibling
+
section.setAttribute('data-love-version-removed', a.title);
            updateSectionFromNote(section, note)
+
note.setAttribute('data-love-version-note', true);
        }
+
}
        needsFilter = true
+
}
    })
+
}
+
  
function scanTables () {
+
function QueryIterator (query) {
    var added = document.querySelectorAll('.smwtable *[alt="Added since"] + *')
+
return function (callback) {
    var removed = document.querySelectorAll('.smwtable *[alt="Removed in"] + *')
+
return array(document.querySelectorAll(query)).forEach(callback);
   
+
}
    array(added).forEach(function (a) {
+
}
        var e = a.parentNode.parentNode
+
        e.setAttribute('data-love-filterable', true)
+
        e.setAttribute('data-love-version-added', a.title)
+
        needsFilter = true
+
    })
+
    array(removed).forEach(function (a) {
+
        var e = a.parentNode.parentNode
+
        e.setAttribute('data-love-filterable', true)
+
        e.setAttribute('data-love-version-removed', a.title)
+
        needsFilter = true
+
    })
+
}
+
  
// return true if 'installed' is greater than or equal to 'required'
+
var withSections = QueryIterator('*[data-love-filterable]');
// http://stackoverflow.com/a/6832670
+
var withAdded = QueryIterator('*[data-love-version-added]');
function compareVersions (installed, required) {
+
var withRemoved = QueryIterator('*[data-love-version-removed]');
    var a = installed.split('.');
+
var withAddedRemoved = QueryIterator('*[data-love-version-added][data-love-version-removed]');
    var b = required.split('.');
+
var withNotes = QueryIterator('*[data-love-version-note]');
  
    for (var i = 0; i < a.length; ++i) {
+
function hideNotes () {
        a[i] = Number(a[i]);
+
withNotes(function (note) { note.style.display = 'none' });
    }
+
}
    for (var i = 0; i < b.length; ++i) {
+
        b[i] = Number(b[i]);
+
    }
+
    if (a.length == 2) {
+
        a[2] = 0;
+
    }
+
  
    if (a[0] > b[0]) return true;
+
function showNotes () {
    if (a[0] < b[0]) return false;
+
withNotes(function (note) { note.style.display = null });
 +
}
  
    if (a[1] > b[1]) return true;
+
var needsFilter = false;
    if (a[1] < b[1]) return false;
+
  
    if (a[2] > b[2]) return true;
+
function scanSections () {
    if (a[2] < b[2]) return false;
+
withSections(function (section) {
 +
var note = section.querySelector('table');
 +
if (!note) {
 +
return;
 +
}
 +
updateSectionFromNote(section, note);
 +
while (note.nextSibling && note.nextSibling.tagName == 'TABLE') {
 +
note = note.nextSibling;
 +
updateSectionFromNote(section, note);
 +
}
 +
needsFilter = true;
 +
});
 +
}
  
    return true;
+
function scanTables () {
}
+
var added = document.querySelectorAll('.smwtable *[alt="Added since"] + *');
 +
var removed = document.querySelectorAll('.smwtable *[alt="Removed in"] + *');
  
function filterVersion (installed) {
+
array(added).forEach(function (a) {
    filterAll(hideNotes)
+
var e = a.parentNode.parentNode;
    withAdded(function (section) {
+
e.setAttribute('data-love-filterable', true);
        var required = section.getAttribute('data-love-version-added')
+
e.setAttribute('data-love-version-added', a.title);
        if (!compareVersions(installed, required)) {
+
needsFilter = true;
            section.style.display = 'none'
+
});
        }
+
array(removed).forEach(function (a) {
    })
+
var e = a.parentNode.parentNode;
    withRemoved(function (section) {
+
e.setAttribute('data-love-filterable', true);
        var removed = section.getAttribute('data-love-version-removed')
+
e.setAttribute('data-love-version-removed', a.title);
        if (compareVersions (installed, removed)) {
+
needsFilter = true;
            section.style.display = 'none'
+
});
        }
+
}
    })
+
}
+
  
function filterAll (hideOrShowNotes) {
+
// return true if 'installed' is greater than or equal to 'required'
    hideOrShowNotes()
+
// http://stackoverflow.com/a/6832670
    withSections(function (section) { section.style.display = null })
+
function compareVersions (installed, required) {
}
+
var a = installed.split('.');
 +
var b = required.split('.');
  
function filterLatest () {
+
for (var i = 0; i < a.length; ++i) {
    filterAll(hideNotes)
+
a[i] = Number(a[i]);
    withRemoved(function (section) { section.style.display = 'none' })
+
}
}
+
for (var i = 0; i < b.length; ++i) {
 +
b[i] = Number(b[i]);
 +
}
 +
if (a.length == 2) {
 +
a[2] = 0;
 +
}
 +
if (b.length == 2) {
 +
b[2] = 0;
 +
}
  
function applyFilter (value) {
+
if (a[0] > b[0]) return true;
    if (value == 'all') {
+
if (a[0] < b[0]) return false;
        filterAll(showNotes)
+
        return
+
    }
+
    if (value == 'latest') {
+
        filterLatest()
+
        return
+
    }
+
    filterVersion(value)
+
}
+
  
function injectFilterPicker () {
+
if (a[1] > b[1]) return true;
    var target = document.getElementById('ca-nstab-main').parentNode
+
if (a[1] < b[1]) return false;
   
+
    picker.style.position = 'absolute'
+
    picker.style.right = 0
+
    picker.style.height = target.parentNode.offsetHeight - 8 + 'px'
+
    picker.style.margin = '4px'
+
   
+
    target.parentNode.insertBefore(picker, target)
+
}
+
  
function injectVersionTag (number, name) {
+
if (a[2] > b[2]) return true;
    injectPickerOption(number, 'Version ' + number + ': ' + name)
+
if (a[2] < b[2]) return false;
}
+
  
function injectVersionTags () {
+
return true;
    var url = '/w/index.php?title=Version_History&action=raw';
+
}
    var xhr = new XMLHttpRequest()
+
    xhr.onload = function () {
+
        var re = /\[\[([\d.]+)\]\][^\n]*\n[^\|]*\|(.*)\n/gm
+
        var m
+
       
+
        while (m = re.exec(this.responseText)) {
+
            injectVersionTag(m[1], m[2])
+
        }
+
    }
+
    xhr.open('get', url, true)
+
    xhr.send()
+
}
+
  
function main () {
+
function filterVersion (installed) {
    wrapSections()
+
filterAll(hideNotes);
    scanSections()
+
withAdded(function (section) {
    scanTables()
+
var required = section.getAttribute('data-love-version-added');
    if (!needsFilter) {
+
if (!compareVersions(installed, required)) {
        return
+
section.style.display = 'none';
    }
+
}
    injectPickerOption('all', 'All Versions')
+
});
    injectPickerOption('latest', 'Latest Version')
+
withRemoved(function (section) {
    injectVersionTags()
+
var removed = section.getAttribute('data-love-version-removed');
    injectFilterPicker()
+
if (compareVersions (installed, removed)) {
}
+
section.style.display = 'none';
 +
}
 +
});
 +
withAddedRemoved(function (section) {
 +
var added = section.getAttribute('data-love-version-added');
 +
var removed = section.getAttribute('data-love-version-removed');
 +
if (compareVersions(added, removed) && compareVersions(installed, added)) {
 +
section.style.display = null;
 +
}
 +
});
 +
}
 +
 
 +
function filterAll (hideOrShowNotes) {
 +
hideOrShowNotes();
 +
withSections(function (section) { section.style.display = null });
 +
}
 +
 
 +
function filterLatest () {
 +
filterAll(hideNotes);
 +
withRemoved(function (section) { section.style.display = 'none' });
 +
withAddedRemoved(function (section) {
 +
var added = section.getAttribute('data-love-version-added');
 +
var removed = section.getAttribute('data-love-version-removed');
 +
if (compareVersions(added, removed)) {
 +
section.style.display = null;
 +
}
 +
});
 +
}
 +
 
 +
function applyFilter (value) {
 +
storeValue('versionpicker-version', value);
 +
if (value == 'all') {
 +
filterAll(showNotes);
 +
return;
 +
}
 +
if (value == 'latest') {
 +
filterLatest();
 +
return;
 +
}
 +
filterVersion(value);
 +
}
 +
 
 +
function injectFilterPicker () {
 +
var target = document.getElementById('ca-nstab-main').parentNode;
 +
 
 +
picker.style.position = 'absolute';
 +
picker.style.right = 0;
 +
picker.style.height = target.parentNode.offsetHeight - 8 + 'px';
 +
picker.style.margin = '4px';
 +
 
 +
target.parentNode.insertBefore(picker, target);
 +
}
 +
 
 +
function injectVersionTag (number, name) {
 +
injectPickerOption(number, 'Version ' + number + ': ' + name);
 +
}
 +
 
 +
function injectVersionTags () {
 +
var versions = [
 +
{"version": "11.2", "codename": "Mysterious Mysteries"},
 +
{"version": "11.1", "codename": "Mysterious Mysteries"},
 +
{"version": "11.0", "codename": "Mysterious Mysteries"},
 +
{"version": "0.10.2", "codename": "Super Toast"},
 +
{"version": "0.10.1", "codename": "Super Toast"},
 +
{"version": "0.10.0", "codename": "Super Toast"},
 +
{"version": "0.9.2", "codename": "Baby Inspector"},
 +
{"version": "0.9.1", "codename": "Baby Inspector"},
 +
{"version": "0.9.0", "codename": "Baby Inspector"},
 +
{"version": "0.8.0", "codename": "Rubber Piggy"},
 +
{"version": "0.7.2", "codename": "Game Slave"},
 +
{"version": "0.7.1", "codename": "Game Slave"},
 +
{"version": "0.7.0", "codename": "Game Slave"},
 +
{"version": "0.6.2", "codename": "Jiggly Juice"},
 +
{"version": "0.6.1", "codename": "Jiggly Juice"},
 +
{"version": "0.6.0", "codename": "Jiggly Juice"},
 +
{"version": "0.5.0", "codename": "Salted Nuts"},
 +
{"version": "0.4.0", "codename": "Taco Beam"},
 +
{"version": "0.3.2", "codename": "Lemony Fresh"},
 +
{"version": "0.3.1", "codename": "Space Meat"},
 +
{"version": "0.3.0", "codename": "Mutant Vermin"},
 +
{"version": "0.2.1", "codename": "Impending Doom"},
 +
{"version": "0.2.0", "codename": "Mini Moose"},
 +
{"version": "0.1.1", "codename": "Santa Power"}
 +
]
 +
 
 +
for (var i = 0; i < versions.length; i++) {
 +
injectVersionTag(versions[i].version, versions[i].codename);
 +
}
 +
}
 +
 
 +
function queryVersionTags () {
 +
var url = '/w/index.php?title=Version_History&action=raw';
 +
var xhr = new XMLHttpRequest();
 +
xhr.onload = function () {
 +
var re = /\[\[([\d.]+)\]\][^\n]*\n[^\|]*\|(.*)\n/gm;
 +
var m;
 +
 
 +
while (m = re.exec(this.responseText)) {
 +
injectVersionTag(m[1], m[2]);
 +
}
 +
}
 +
xhr.open('get', url, true);
 +
xhr.send();
 +
}
  
main()
+
function setPicker (target) {
 +
for (var i = 0; i < picker.options.length; ++i) {
 +
if (picker.options[i].value === target) {
 +
picker.selectedIndex = i;
 +
picker.onchange();
 +
break;
 +
}
 +
}
 +
}
 +
 
 +
function main () {
 +
wrapSections();
 +
scanSections();
 +
scanTables();
 +
injectPickerOption('all', 'All Versions');
 +
injectPickerOption('latest', 'Latest Version');
 +
injectVersionTags();
 +
injectFilterPicker();
 +
var target = retrieveValue('versionpicker-version');
 +
if (target !== undefined) {
 +
setPicker(target);
 +
}
 +
}
 +
 
 +
main();
 
}
 
}
 +
 +
versionpicker();

Latest revision as of 19:35, 25 November 2018

// Source on github: https://github.com/airstruck/love-wiki-version-picker
function versionpicker() {
	var picker = document.createElement('select');
 
	picker.onchange = function () {
		applyFilter(this.options[this.selectedIndex].value);
	}
 
	function array (a) {
		return [].slice.apply(a || []);
	}
 
	// Some helpers for localStorage, basically resort to doing nothing
	// if it isn't available.
	function storeValue(name, value) {
		try {
			localStorage[name] = value;
		}
		catch (e) {
		}
	}
 
	function retrieveValue(name) {
		try {
			return localStorage[name];
		}
		catch (e) {
			return undefined;
		}
	}
 
	var pickerVersions = {};
 
	function injectPickerOption (version, text) {
		if (pickerVersions[version]) {
			return;
		}
		pickerVersions[version] = true;
 
		var option = document.createElement('option');
 
		option.value = version;
		option.textContent = text;
		picker.appendChild(option);
	}
 
	function makeWrapper () {
		var wrapper = document.createElement('div');
 
		wrapper.setAttribute('data-love-filterable', true);
 
		return wrapper;
	}
 
	function wrapSections () {
		var element = document.querySelector('h2');
		var wrapper;
 
		while (element) {
			var next = element.nextSibling;
			if (element.nodeName == 'H2') {
				wrapper = makeWrapper();
				element.parentNode.insertBefore(wrapper, element);
			}
			wrapper.appendChild(element);
			element = next;
		}
	}
 
	function updateSectionFromNote (section, note) {
		if (note.textContent.match(/available since/i)) {
			var a = note.querySelector('a');
			section.setAttribute('data-love-version-added', a.title);
			note.setAttribute('data-love-version-note', true);
		}
		if (note.textContent.match(/removed in/i)) {
			var a = note.querySelector('a');
			section.setAttribute('data-love-version-removed', a.title);
			note.setAttribute('data-love-version-note', true);
		}
	}
 
	function QueryIterator (query) {
		return function (callback) {
			return array(document.querySelectorAll(query)).forEach(callback);
		}
	}
 
	var withSections = QueryIterator('*[data-love-filterable]');
	var withAdded = QueryIterator('*[data-love-version-added]');
	var withRemoved = QueryIterator('*[data-love-version-removed]');
	var withAddedRemoved = QueryIterator('*[data-love-version-added][data-love-version-removed]');
	var withNotes = QueryIterator('*[data-love-version-note]');
 
	function hideNotes () {
		withNotes(function (note) { note.style.display = 'none' });
	}
 
	function showNotes () {
		withNotes(function (note) { note.style.display = null });
	}
 
	var needsFilter = false;
 
	function scanSections () {
		withSections(function (section) {
			var note = section.querySelector('table');
			if (!note) {
				return;
			}
			updateSectionFromNote(section, note);
			while (note.nextSibling && note.nextSibling.tagName == 'TABLE') {
				note = note.nextSibling;
				updateSectionFromNote(section, note);
			}
			needsFilter = true;
		});
	}
 
	function scanTables () {
		var added = document.querySelectorAll('.smwtable *[alt="Added since"] + *');
		var removed = document.querySelectorAll('.smwtable *[alt="Removed in"] + *');
 
		array(added).forEach(function (a) {
			var e = a.parentNode.parentNode;
			e.setAttribute('data-love-filterable', true);
			e.setAttribute('data-love-version-added', a.title);
			needsFilter = true;
		});
		array(removed).forEach(function (a) {
			var e = a.parentNode.parentNode;
			e.setAttribute('data-love-filterable', true);
			e.setAttribute('data-love-version-removed', a.title);
			needsFilter = true;
		});
	}
 
	// return true if 'installed' is greater than or equal to 'required'
	// http://stackoverflow.com/a/6832670
	function compareVersions (installed, required) {
		var a = installed.split('.');
		var b = required.split('.');
 
		for (var i = 0; i < a.length; ++i) {
			a[i] = Number(a[i]);
		}
		for (var i = 0; i < b.length; ++i) {
			b[i] = Number(b[i]);
		}
		if (a.length == 2) {
			a[2] = 0;
		}
		if (b.length == 2) {
			b[2] = 0;
		}
 
		if (a[0] > b[0]) return true;
		if (a[0] < b[0]) return false;
 
		if (a[1] > b[1]) return true;
		if (a[1] < b[1]) return false;
 
		if (a[2] > b[2]) return true;
		if (a[2] < b[2]) return false;
 
		return true;
	}
 
	function filterVersion (installed) {
		filterAll(hideNotes);
		withAdded(function (section) {
			var required = section.getAttribute('data-love-version-added');
			if (!compareVersions(installed, required)) {
				section.style.display = 'none';
			}
		});
		withRemoved(function (section) {
			var removed = section.getAttribute('data-love-version-removed');
			if (compareVersions (installed, removed)) {
				section.style.display = 'none';
			}
		});
		withAddedRemoved(function (section) {
			var added = section.getAttribute('data-love-version-added');
			var removed = section.getAttribute('data-love-version-removed');
			if (compareVersions(added, removed) && compareVersions(installed, added)) {
				section.style.display = null;
			}
		});
	}
 
	function filterAll (hideOrShowNotes) {
		hideOrShowNotes();
		withSections(function (section) { section.style.display = null });
	}
 
	function filterLatest () {
		filterAll(hideNotes);
		withRemoved(function (section) { section.style.display = 'none' });
		withAddedRemoved(function (section) {
			var added = section.getAttribute('data-love-version-added');
			var removed = section.getAttribute('data-love-version-removed');
			if (compareVersions(added, removed)) {
				section.style.display = null;
			}
		});
	}
 
	function applyFilter (value) {
		storeValue('versionpicker-version', value);
		if (value == 'all') {
			filterAll(showNotes);
			return;
		}
		if (value == 'latest') {
			filterLatest();
			return;
		}
		filterVersion(value);
	}
 
	function injectFilterPicker () {
		var target = document.getElementById('ca-nstab-main').parentNode;
 
		picker.style.position = 'absolute';
		picker.style.right = 0;
		picker.style.height = target.parentNode.offsetHeight - 8 + 'px';
		picker.style.margin = '4px';
 
		target.parentNode.insertBefore(picker, target);
	}
 
	function injectVersionTag (number, name) {
		injectPickerOption(number, 'Version ' + number + ': ' + name);
	}
 
	function injectVersionTags () {
		var versions = [
			{"version": "11.2", "codename": "Mysterious Mysteries"},
			{"version": "11.1", "codename": "Mysterious Mysteries"},
			{"version": "11.0", "codename": "Mysterious Mysteries"},
			{"version": "0.10.2", "codename": "Super Toast"},
			{"version": "0.10.1", "codename": "Super Toast"},
			{"version": "0.10.0", "codename": "Super Toast"},
			{"version": "0.9.2", "codename": "Baby Inspector"},
			{"version": "0.9.1", "codename": "Baby Inspector"},
			{"version": "0.9.0", "codename": "Baby Inspector"},
			{"version": "0.8.0", "codename": "Rubber Piggy"},
			{"version": "0.7.2", "codename": "Game Slave"},
			{"version": "0.7.1", "codename": "Game Slave"},
			{"version": "0.7.0", "codename": "Game Slave"},
			{"version": "0.6.2", "codename": "Jiggly Juice"},
			{"version": "0.6.1", "codename": "Jiggly Juice"},
			{"version": "0.6.0", "codename": "Jiggly Juice"},
			{"version": "0.5.0", "codename": "Salted Nuts"},
			{"version": "0.4.0", "codename": "Taco Beam"},
			{"version": "0.3.2", "codename": "Lemony Fresh"},
			{"version": "0.3.1", "codename": "Space Meat"},
			{"version": "0.3.0", "codename": "Mutant Vermin"},
			{"version": "0.2.1", "codename": "Impending Doom"},
			{"version": "0.2.0", "codename": "Mini Moose"},
			{"version": "0.1.1", "codename": "Santa Power"}
		]
 
		for (var i = 0; i < versions.length; i++) {
			injectVersionTag(versions[i].version, versions[i].codename);
		}
	}
 
	function queryVersionTags () {
		var url = '/w/index.php?title=Version_History&action=raw';
		var xhr = new XMLHttpRequest();
		xhr.onload = function () {
			var re = /\[\[([\d.]+)\]\][^\n]*\n[^\|]*\|(.*)\n/gm;
			var m;
 
			while (m = re.exec(this.responseText)) {
				injectVersionTag(m[1], m[2]);
			}
		}
		xhr.open('get', url, true);
		xhr.send();
	}
 
	function setPicker (target) {
		for (var i = 0; i < picker.options.length; ++i) {
			if (picker.options[i].value === target) {
				picker.selectedIndex = i;
				picker.onchange();
				break;
			}
		}
	}
 
	function main () {
		wrapSections();
		scanSections();
		scanTables();
		injectPickerOption('all', 'All Versions');
		injectPickerOption('latest', 'Latest Version');
		injectVersionTags();
		injectFilterPicker();
		var target = retrieveValue('versionpicker-version');
		if (target !== undefined) {
			setPicker(target);
		}
	}
 
	main();
}
 
versionpicker();