Browser turned into image-viewer/ebook-reader

In earlier days of the internet, Iqbal Cyber Library was among the first sites that hosted Urdu ebooks. The books, however, were not available in the form of Unicode or searchable text in simple words. The individual book pages were hosted in the form of images, probably created using Inpage Urdu editor. The site allowed downloading of these books with httptrack, a tool to copy complete website on computer hard disk for offline reading. I preferred saving all the ebook pages in one folder with extension pnnnn.gif, nnnn being the 4-digit page number. Then I  programmed little javascript code to view all pages in that folder, navigating with left and right arrow keys.

<html>
<head>
	<title> HTML Ebook </title>
	
	<style type="text/css">
    div{
		transform: rotate(0deg);
		-ms-transform: rotate(0deg); /* IE 9 */
		-webkit-transform: rotate(0deg); /* Safari and Chrome */
	}
	</style>

		
	var imgN=1;
	function padDigits(number, digits) {
		return Array(Math.max(digits - String(number).length + 1, 0)).join(0) + number;
	}

	function nextImg(){
		imgN++; 
		document.getElementById('pageNum').innerHTML='Page: '+ "p"+ padDigits(imgN, 4);
		document.images[0].src= "p"+padDigits(imgN, 4)+".gif";
		//document.images[0].style.msTransform='rotate('+((0=++0%4)*90)+'deg)';
		document.images[0].css("-webkit-transform", "rotate(40deg)");
	}

	function prevImg(){
		imgN--; 
		document.getElementById('pageNum').innerHTML='Page: '+ "p"+ padDigits(imgN, 4);
		document.images[0].src= "p"+padDigits(imgN, 4)+".gif";
		//document.images[0].style.msTransform='rotate('+((0=++0%4)*90)+'deg)';
	}

	document.onkeydown = checkKey;

	function checkKey(e) {
		e = e || window.event;
		if (e.keyCode == '37') {
			// left arrow
			document.body.scrollTop = document.documentElement.scrollTop = 0; //Scroll up page
			nextImg();
		}
		else if (e.keyCode == '39') {
			// right arrow
			document.body.scrollTop = document.documentElement.scrollTop = 0; //Scroll up page
			prevImg();
		}
		//left key code = 37
		//up key code = 38
		//right key code = 39
		//down key code= 40
	}
</head>

<body bgcolor="#FFFFFF" dir=rtl>

	<INPUT TYPE="button" VALUE="< Previous Page" ONCLICK="prevImg()">
	<INPUT TYPE="button" VALUE="Next Page>" ONCLICK="nextImg()">
	<!--<INPUT TYPE="text" VALUE="" ONCLICK="goToImage(text)">-->
 </body>
 </html>
Advertisements

Comments Invited

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s