cleanup before testing.
This commit is contained in:
parent
893b5cf1de
commit
4f48d4d45f
1 changed files with 225 additions and 206 deletions
83
sahli.js
83
sahli.js
|
|
@ -1,7 +1,7 @@
|
||||||
// .___________________________________. ._____.
|
// .___________________________________, ___
|
||||||
// | / | | . | |_____|
|
// | / | | . \ .(___):
|
||||||
// | ____ | : | | |
|
// | _______ | : \ : |
|
||||||
//: |___/ / | | l_____| |
|
//: |___/ / | | \__| |
|
||||||
//| / | | | |
|
//| / | | | |
|
||||||
//l__________/__________|___|______l__________j_____j
|
//l__________/__________|___|______l__________j_____j
|
||||||
//
|
//
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
var Sahli = function() {
|
var Sahli = function() {
|
||||||
this.outbox = $('div#outbox');
|
this.outbox = $('div#outbox');
|
||||||
this.dbox = $('div#drawbox');
|
this.dbox = $('div#drawbox');
|
||||||
this.image;
|
this.image = 0;
|
||||||
|
|
||||||
// scroll speed of 5 looks ... "ok" on macbook pro. 4 was original.
|
// scroll speed of 5 looks ... "ok" on macbook pro. 4 was original.
|
||||||
this.scroll_speed = 5;
|
this.scroll_speed = 5;
|
||||||
|
|
@ -26,7 +26,10 @@ var Sahli = function(){
|
||||||
this.dbox.height(document.height - 24);
|
this.dbox.height(document.height - 24);
|
||||||
this.dbox.width(document.width - 2);
|
this.dbox.width(document.width - 2);
|
||||||
this.sizemult = 16; // 32 is larger than screen, and somewhat silly
|
this.sizemult = 16; // 32 is larger than screen, and somewhat silly
|
||||||
this.origheight, this.origwidth, this.filedata, this.slides;
|
this.origheight = 0;
|
||||||
|
this.origwidth = 0;
|
||||||
|
this.filedata = '';
|
||||||
|
this.slides = 0;
|
||||||
this.currentpic = 0;
|
this.currentpic = 0;
|
||||||
this.nonfsheight = document.height - 40;
|
this.nonfsheight = document.height - 40;
|
||||||
|
|
||||||
|
|
@ -42,7 +45,11 @@ var Sahli = function(){
|
||||||
var color = this.calccolor(picdata.color);
|
var color = this.calccolor(picdata.color);
|
||||||
var bgcolor = this.calccolor(picdata.bg);
|
var bgcolor = this.calccolor(picdata.bg);
|
||||||
ptxt.addClass(picdata.font.toLowerCase());
|
ptxt.addClass(picdata.font.toLowerCase());
|
||||||
ptxt.css({'color':color,'background-color':bgcolor,'margin':'auto'});
|
ptxt.css({
|
||||||
|
'color': color,
|
||||||
|
'background-color': bgcolor,
|
||||||
|
'margin': 'auto'
|
||||||
|
});
|
||||||
ptxt.width(picdata.width * 8);
|
ptxt.width(picdata.width * 8);
|
||||||
pdiv.width('100%');
|
pdiv.width('100%');
|
||||||
pdiv.append(ptxt);
|
pdiv.append(ptxt);
|
||||||
|
|
@ -56,7 +63,7 @@ var Sahli = function(){
|
||||||
} else {
|
} else {
|
||||||
// I really should make a real error handler.
|
// I really should make a real error handler.
|
||||||
alert(req);
|
alert(req);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
req.open('GET', picdata.file, true);
|
req.open('GET', picdata.file, true);
|
||||||
|
|
@ -66,11 +73,11 @@ var Sahli = function(){
|
||||||
this.image = new ImageTextModeANSI();
|
this.image = new ImageTextModeANSI();
|
||||||
this.image.parseUrl(picdata.file);
|
this.image.parseUrl(picdata.file);
|
||||||
this.image.renderCanvas(canv);
|
this.image.renderCanvas(canv);
|
||||||
pdiv.append(canv)
|
pdiv.append(canv);
|
||||||
inserthere.after(pdiv);
|
inserthere.after(pdiv);
|
||||||
this.origwidth = canv.width;
|
this.origwidth = canv.width;
|
||||||
this.origheight = canv.height;
|
this.origheight = canv.height;
|
||||||
};
|
}
|
||||||
infob.find('h1').text(picdata.name);
|
infob.find('h1').text(picdata.name);
|
||||||
infob.find('h2').text(picdata.author);
|
infob.find('h2').text(picdata.author);
|
||||||
infob.find('h3#text').text(picdata.line1);
|
infob.find('h3#text').text(picdata.line1);
|
||||||
|
|
@ -89,7 +96,10 @@ var Sahli = function(){
|
||||||
var canv = $('canvas');
|
var canv = $('canvas');
|
||||||
var w = canv.width() * amt;
|
var w = canv.width() * amt;
|
||||||
var h = canv.height() * amt;
|
var h = canv.height() * amt;
|
||||||
canv.animate({width:w,height:h},this.zoomspeed);
|
canv.animate({
|
||||||
|
width: w,
|
||||||
|
height: h
|
||||||
|
}, this.zoomspeed);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fullwidth = function() {
|
this.fullwidth = function() {
|
||||||
|
|
@ -98,7 +108,10 @@ var Sahli = function(){
|
||||||
this.originalsize(this.zoomspeed);
|
this.originalsize(this.zoomspeed);
|
||||||
} else {
|
} else {
|
||||||
var ratio = this.origwidth / this.dbox.width();
|
var ratio = this.origwidth / this.dbox.width();
|
||||||
$('canvas').animate({width:this.dbox.width(),height:this.origheight / ratio},this.zoomspeed);
|
$('canvas').animate({
|
||||||
|
width: this.dbox.width(),
|
||||||
|
height: this.origheight / ratio
|
||||||
|
}, this.zoomspeed);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -109,21 +122,27 @@ var Sahli = function(){
|
||||||
this.originalsize(this.zoomspeed);
|
this.originalsize(this.zoomspeed);
|
||||||
} else {
|
} else {
|
||||||
var ratio = this.origheight / this.dbox.height();
|
var ratio = this.origheight / this.dbox.height();
|
||||||
canv.animate({height: this.dbox.height(), width:this.origwidth / ratio},this.zoomspeed);
|
canv.animate({
|
||||||
|
height: this.dbox.height(),
|
||||||
|
width: this.origwidth / ratio
|
||||||
|
}, this.zoomspeed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.originalsize = function(zoomspeed) {
|
this.originalsize = function(zoomspeed) {
|
||||||
// why do we not have origwidth now? hmm.
|
// why do we not have origwidth now? hmm.
|
||||||
var canv = $('canvas');
|
var canv = $('canvas');
|
||||||
canv.animate({width: this.origwidth, height:this.origheight},this.zoomspeed);
|
canv.animate({
|
||||||
|
width: this.origwidth,
|
||||||
|
height: this.origheight
|
||||||
|
}, this.zoomspeed);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.toptext = function(text) {
|
this.toptext = function(text) {
|
||||||
if (this.DEBUG) {
|
if (this.DEBUG) {
|
||||||
$('h1#top').text(text);
|
$('h1#top').text(text);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setscroll = function() {
|
this.setscroll = function() {
|
||||||
|
|
@ -142,7 +161,9 @@ var Sahli = function(){
|
||||||
}
|
}
|
||||||
this.toptext(this.scroll_speed + ' | ' + steps);
|
this.toptext(this.scroll_speed + ' | ' + steps);
|
||||||
|
|
||||||
this.dbox.animate({scrollTop : scrollto}, this.scroll_speed*steps ,'linear');
|
this.dbox.animate({
|
||||||
|
scrollTop: scrollto
|
||||||
|
}, this.scroll_speed * steps, 'linear');
|
||||||
};
|
};
|
||||||
|
|
||||||
this.resizedrawbox = function(height) {
|
this.resizedrawbox = function(height) {
|
||||||
|
|
@ -212,11 +233,9 @@ var Sahli = function(){
|
||||||
var toid = window.setTimeout(sahli.resizedrawbox, 100);
|
var toid = window.setTimeout(sahli.resizedrawbox, 100);
|
||||||
if (docElm.requestFullscreen) {
|
if (docElm.requestFullscreen) {
|
||||||
docElm.requestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
|
docElm.requestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||||
}
|
} else if (docElm.mozRequestFullScreen) {
|
||||||
else if (docElm.mozRequestFullScreen) {
|
|
||||||
docElm.mozRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
docElm.mozRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||||
}
|
} else if (docElm.webkitRequestFullScreen) {
|
||||||
else if (docElm.webkitRequestFullScreen) {
|
|
||||||
docElm.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
docElm.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,11 +245,9 @@ var Sahli = function(){
|
||||||
var toid = window.setTimeout(sahli.resizedrawbox, 100, this.nonfsheight);
|
var toid = window.setTimeout(sahli.resizedrawbox, 100, this.nonfsheight);
|
||||||
if (document.exitFullscreen) {
|
if (document.exitFullscreen) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
}
|
} else if (document.mozCancelFullScreen) {
|
||||||
else if (document.mozCancelFullScreen) {
|
|
||||||
document.mozCancelFullScreen();
|
document.mozCancelFullScreen();
|
||||||
}
|
} else if (document.webkitCancelFullScreen) {
|
||||||
else if (document.webkitCancelFullScreen) {
|
|
||||||
document.webkitCancelFullScreen();
|
document.webkitCancelFullScreen();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -238,7 +255,10 @@ var Sahli = function(){
|
||||||
this.fixhelpbox = function() {
|
this.fixhelpbox = function() {
|
||||||
var h = $('.help');
|
var h = $('.help');
|
||||||
// var xy = {'top': document.height/2 - h.height()/2, 'left': document.width/2 - h.width()/2};
|
// var xy = {'top': document.height/2 - h.height()/2, 'left': document.width/2 - h.width()/2};
|
||||||
var xy = {'top': 0, 'left': document.width/2 - h.width()/2};
|
var xy = {
|
||||||
|
'top': 0,
|
||||||
|
'left': document.width / 2 - h.width() / 2
|
||||||
|
};
|
||||||
h.css(xy);
|
h.css(xy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -258,7 +278,7 @@ var Sahli = function(){
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ref.setscroll();
|
ref.setscroll();
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('keydown', function(ev) {
|
$(document).bind('keydown', function(ev) {
|
||||||
|
|
@ -282,7 +302,7 @@ var Sahli = function(){
|
||||||
ref.resize(2);
|
ref.resize(2);
|
||||||
break;
|
break;
|
||||||
case 75: // k
|
case 75: // k
|
||||||
ref.resize(.5);
|
ref.resize(0.5);
|
||||||
break;
|
break;
|
||||||
case 79: // o
|
case 79: // o
|
||||||
ref.fullwidth();
|
ref.fullwidth();
|
||||||
|
|
@ -366,9 +386,9 @@ var Sahli = function(){
|
||||||
default:
|
default:
|
||||||
if (ref.DEBUG) {
|
if (ref.DEBUG) {
|
||||||
alert(ev.which);
|
alert(ev.which);
|
||||||
};
|
}
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -383,6 +403,5 @@ var Sahli = function(){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dammit I hate how conttrol-R in textmate is "some shell shit"
|
// I switched to Sublime text + sublemacs pro.
|
||||||
// I also hate how scrolling is incredibly stupid on osX
|
// Yes, the author of Sublime Text's emacs hatred is annoying.
|
||||||
// Mind you, it's better than touching anything in Windows.
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue