User:Hesperian/works.js

From Wikisource
Jump to navigation Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

var specialFormats = (function() {
	var chapterof = function(page) {
		// the actual page numbers (not DjVu page numbers) on which each chapter starts - set offset in work
		var chapterpages = [161,183,197,221];
	
		var chapter=0;
		for (var num in chapterpages) {
			if (chapterpages[num]>page)
				return chapter;
			else
				chapter++;
		}
		return chapter;
	};
	
	var pagenum = (function() {
		var m = /\.djvu\/([0-9]+)&action=edit/g.exec(location.href);
		if (m===null) return null;
		return parseInt(m[1], 10);
	})();
	
	// convenience function for converting to roman numerals
	var roman = function(number) {
		var values = {m:1000, cm:900, d:500, cd:400, c:100, xc:90, l:50, xl:40, x:10, ix:9, v:5, iv:4, i:1};
		var romanexpr = '';
		var value;
	
		for (value in values) {
			while (number >= values[value] ) {
				romanexpr = romanexpr + value;
				number = number - values[value];
			}
		}
		return romanexpr;
	};
	
	return [
		// add as many as you like...
		// format is ["url to match", "even numbered /pages", "odd numbered /pages", "footer if no ref", "footer if ref"]
	
		[
			"Page:The Sense of the Past",
			"{{center|{{larger block|THE SENSE OF THE PAST}}}}",
			"{{center|{{larger block|THE SENSE OF THE PAST}}}}",
			"{{center|"+(pagenum-14)+"}}",
			"{{center|"+(pagenum-14)+"}}"
		]
	];
	// format is ["url to match", "even numbered /pages", "odd numbered /pages", "footer if no ref", "footer if ref"]
})();