Code cosmetics
This commit is contained in:
parent
0405cec4ac
commit
a6dfcedfdb
|
@ -78,8 +78,9 @@ kthoom.saveSettings = function() {
|
||||||
|
|
||||||
kthoom.loadSettings = function() {
|
kthoom.loadSettings = function() {
|
||||||
try {
|
try {
|
||||||
if (localStorage.kthoomSettings.length < 10)
|
if (localStorage.kthoomSettings.length < 10){
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var s = JSON.parse(localStorage.kthoomSettings);
|
var s = JSON.parse(localStorage.kthoomSettings);
|
||||||
kthoom.rotateTimes = s.rotateTimes;
|
kthoom.rotateTimes = s.rotateTimes;
|
||||||
hflip = s.hflip;
|
hflip = s.hflip;
|
||||||
|
@ -111,13 +112,13 @@ var createURLFromArray = function(array, mimeType) {
|
||||||
throw "Browser support for Blobs is missing.";
|
throw "Browser support for Blobs is missing.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((typeof URL !== "function" && typeof URL != "object") ||
|
if ((typeof URL !== "function" && typeof URL !== "object") ||
|
||||||
typeof URL.createObjectURL !== "function") {
|
typeof URL.createObjectURL !== "function") {
|
||||||
throw "Browser support for Object URLs is missing";
|
throw "Browser support for Object URLs is missing";
|
||||||
}
|
}
|
||||||
|
|
||||||
return URL.createObjectURL(blob);
|
return URL.createObjectURL(blob);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
// Stores an image filename and its data: URI.
|
// Stores an image filename and its data: URI.
|
||||||
|
@ -301,7 +302,7 @@ function loadFromArrayBuffer(ab) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// display first page if we haven't yet
|
// display first page if we haven't yet
|
||||||
if (imageFiles.length == currentImage + 1) {
|
if (imageFiles.length === currentImage + 1) {
|
||||||
updatePage();
|
updatePage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -323,7 +324,7 @@ function updatePage() {
|
||||||
title.appendChild(document.createTextNode( (currentImage + 1 ) + "/" + totalImages ));
|
title.appendChild(document.createTextNode( (currentImage + 1 ) + "/" + totalImages ));
|
||||||
|
|
||||||
getElem("meter2").setAttribute("width",
|
getElem("meter2").setAttribute("width",
|
||||||
100 * (totalImages == 0 ? 0 : ((currentImage +1 ) / totalImages)) + "%");
|
100 * (totalImages === 0 ? 0 : ((currentImage + 1 ) / totalImages)) + "%");
|
||||||
if (imageFiles[currentImage]) {
|
if (imageFiles[currentImage]) {
|
||||||
setImage(imageFiles[currentImage].dataURI);
|
setImage(imageFiles[currentImage].dataURI);
|
||||||
} else {
|
} else {
|
||||||
|
@ -386,7 +387,10 @@ function setImage(url) {
|
||||||
sh = h;
|
sh = h;
|
||||||
kthoom.rotateTimes = (4 + kthoom.rotateTimes) % 4;
|
kthoom.rotateTimes = (4 + kthoom.rotateTimes) % 4;
|
||||||
x.save();
|
x.save();
|
||||||
if (kthoom.rotateTimes % 2 == 1) { sh = w; sw = h;}
|
if (kthoom.rotateTimes % 2 === 1) {
|
||||||
|
sh = w;
|
||||||
|
sw = h;
|
||||||
|
}
|
||||||
canvas.height = sh;
|
canvas.height = sh;
|
||||||
canvas.width = sw;
|
canvas.width = sw;
|
||||||
x.translate(sw / 2, sh / 2);
|
x.translate(sw / 2, sh / 2);
|
||||||
|
@ -444,13 +448,13 @@ function updateScale(clear) {
|
||||||
if (!/main/.test(getElem("titlebar").className)) {
|
if (!/main/.test(getElem("titlebar").className)) {
|
||||||
maxheight -= 25;
|
maxheight -= 25;
|
||||||
}
|
}
|
||||||
if (clear || fitMode == kthoom.Key.N) {
|
if (clear || fitMode === kthoom.Key.N) {
|
||||||
} else if (fitMode == kthoom.Key.B) {
|
} else if (fitMode === kthoom.Key.B) {
|
||||||
mainImageStyle.maxWidth = "100%";
|
mainImageStyle.maxWidth = "100%";
|
||||||
mainImageStyle.maxHeight = maxheight + "px";
|
mainImageStyle.maxHeight = maxheight + "px";
|
||||||
} else if (fitMode == kthoom.Key.H) {
|
} else if (fitMode === kthoom.Key.H) {
|
||||||
mainImageStyle.height = maxheight + "px";
|
mainImageStyle.height = maxheight + "px";
|
||||||
} else if (fitMode == kthoom.Key.W) {
|
} else if (fitMode === kthoom.Key.W) {
|
||||||
mainImageStyle.width = "100%";
|
mainImageStyle.width = "100%";
|
||||||
}
|
}
|
||||||
kthoom.saveSettings();
|
kthoom.saveSettings();
|
||||||
|
@ -459,8 +463,9 @@ function updateScale(clear) {
|
||||||
function keyHandler(evt) {
|
function keyHandler(evt) {
|
||||||
var code = evt.keyCode;
|
var code = evt.keyCode;
|
||||||
|
|
||||||
if ($("#progress").css("display") == "none")
|
if ($("#progress").css("display") === "none"){
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
canKeyNext = (($("body").css("offsetWidth") + $("body").css("scrollLeft")) / $("body").css("scrollWidth")) >= 1;
|
canKeyNext = (($("body").css("offsetWidth") + $("body").css("scrollLeft")) / $("body").css("scrollWidth")) >= 1;
|
||||||
canKeyPrev = (scrollX <= 0);
|
canKeyPrev = (scrollX <= 0);
|
||||||
|
|
||||||
|
@ -489,10 +494,10 @@ function keyHandler(evt) {
|
||||||
case kthoom.Key.F:
|
case kthoom.Key.F:
|
||||||
if (!hflip && !vflip) {
|
if (!hflip && !vflip) {
|
||||||
hflip = true;
|
hflip = true;
|
||||||
} else if(hflip == true) {
|
} else if (hflip === true) {
|
||||||
vflip = true;
|
vflip = true;
|
||||||
hflip = false;
|
hflip = false;
|
||||||
} else if(vflip == true) {
|
} else if (vflip === true) {
|
||||||
vflip = false;
|
vflip = false;
|
||||||
}
|
}
|
||||||
updatePage();
|
updatePage();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user