diff --git a/index.html b/index.html index e070433..233d273 100644 --- a/index.html +++ b/index.html @@ -47,6 +47,7 @@
  • B Jump to Bottom
  • 12345 Alter scrollspeed (fast -> slow)
  • Z Zoom full width
  • +
  • Q Best fit for images
  • ER Zoom in steps larger/smaller
  • C "panel" view toggle
  • UpDownPageupPagedown Move about by line/page
  • diff --git a/list.sahli b/list.sahli index e394280..5e6ceb5 100644 --- a/list.sahli +++ b/list.sahli @@ -14,6 +14,56 @@ "filedata": [ + { + "file": "AD - Green Beam.scaled.png", + "name": "Green Beam", + "amiga": false, + "filetype": "image", + "width": "1600", + "author": "AD", + "font": "Propaz", + "color": [ + 0, + 0, + 0, + 255 + ], + "bg": [ + 255, + 255, + 255, + 255 + ], + "line1": "", + "line2": "", + "text": "" + }, + + { + "file": "om-boss.png", + "name": "Green Beam", + "amiga": false, + "filetype": "image", + "width": "640", + "author": "AD", + "font": "Propaz", + "color": [ + 0, + 0, + 0, + 255 + ], + "bg": [ + 255, + 255, + 255, + 255 + ], + "line1": "", + "line2": "", + "text": "" + }, + { "file": "spaceflight.asc", diff --git a/sahli.coffee b/sahli.coffee index 9b2bb39..f1f313b 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -39,6 +39,8 @@ class @Sahli @loadhugeansi picdata, inserthere when 'tundra' @loadhugeansi picdata, inserthere + when 'image' + @loadpicture picdata, inserthere else @loadplain picdata, inserthere @@ -78,6 +80,29 @@ class @Sahli req.open 'GET', fname, true req.send null + @loadpicture = (picdata, inserthere) -> + fname = @location + '/' + picdata.file + pdiv = $('
    ') + pdiv.addClass 'scrolly' + pdiv.width picdata.width + pdiv.css 'display', 'inline-block' + pimg = $('') + pimg.addClass 'fullwidth' + pdiv.append pimg + inserthere.after pdiv + $('h6').hide() + $('body').scrollTop 0 + @origwidth = picdata.width + + @bestfit = => + if $('div.scrolly').hasClass('bestfit') + $('div.scrolly').removeClass 'bestfit' + $('div.scrolly').width @origwidth + else + $('h6').hide() + $('div.scrolly').addClass 'bestfit' + $('div.scrolly').width(""); + @loadhugeansi = (picdata, inserthere) -> fname = @location + '/' + picdata.file pdiv = $('
    ') @@ -97,7 +122,7 @@ class @Sahli @origwidth = canvwidth @origheight = calcheight pdiv.width canvwidth - ), 30, 'bits': '8' + ), 30, {'bits': '8', "font": picdata.font} @loadavatar = (picdata, inserthere) -> console.log 'avatar', picdata, inserthere @@ -137,6 +162,7 @@ class @Sahli filedata = @filedata filedata[i].pic = $('
    ' + filedata[i].file + '
    ') viewbox.append filedata[i].pic + $('h6').show() @loadpic filedata[i], filedata[i].pic @currentpic += 1 if @currentpic > filedata.length - 1 @@ -237,7 +263,7 @@ class @Sahli zoomee.width newwidth $('canvas').width newwidth else - if zoomee.width() != @origwidth + if parseInt( zoomee.width(), 10 ) != parseInt( @origwidth, 10) zoomee.width @origwidth $('canvas').width '100%' else @@ -342,6 +368,8 @@ class @Sahli @zoom 100 when @keycode 'r' @zoom -100 + when @keycode 'q' + @bestfit() when @keycode 'w' @changescrolldirection -1 when @keycode 'x' @@ -351,6 +379,7 @@ class @Sahli when @keycode 'i' $('div.infobox').toggle() when @keycode 'v' + $('h6').show() $('h6').height( (window.innerHeight - $('.scrolly').height()) / 2 ) when @keycode '1' @changespeed 1 diff --git a/sahli.css b/sahli.css index b0a213a..2429eae 100644 --- a/sahli.css +++ b/sahli.css @@ -52,6 +52,18 @@ h6 { width: 33%; } +.fullwidth { + width: 100%; +} + +.bestfit { + padding: 0; + display: block; + margin: 0 auto; + max-width: 100%; + max-height: 100%; +} + .keylist { border: inset lightgrey; background-color: white; diff --git a/sahli.js b/sahli.js index a80b989..7872b6d 100644 --- a/sahli.js +++ b/sahli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.11.0 +// Generated by CoffeeScript 1.9.3 /* .___________________________________, ___ @@ -40,6 +40,8 @@ l__________/__________|___|______l__________j_____j return this.loadhugeansi(picdata, inserthere); case 'tundra': return this.loadhugeansi(picdata, inserthere); + case 'image': + return this.loadpicture(picdata, inserthere); default: return this.loadplain(picdata, inserthere); } @@ -87,6 +89,33 @@ l__________/__________|___|______l__________j_____j return req.send(null); }; + Sahli.loadpicture = function(picdata, inserthere) { + var fname, pdiv, pimg; + fname = this.location + '/' + picdata.file; + pdiv = $('
    '); + pdiv.addClass('scrolly'); + pdiv.width(picdata.width); + pdiv.css('display', 'inline-block'); + pimg = $(''); + pimg.addClass('fullwidth'); + pdiv.append(pimg); + inserthere.after(pdiv); + $('h6').hide(); + $('body').scrollTop(0); + return this.origwidth = picdata.width; + }; + + Sahli.bestfit = function() { + if ($('div.scrolly').hasClass('bestfit')) { + $('div.scrolly').removeClass('bestfit'); + return $('div.scrolly').width(Sahli.origwidth); + } else { + $('h6').hide(); + $('div.scrolly').addClass('bestfit'); + return $('div.scrolly').width(""); + } + }; + Sahli.loadhugeansi = function(picdata, inserthere) { var calcheight, canvwidth, fname, pdiv; fname = this.location + '/' + picdata.file; @@ -111,7 +140,8 @@ l__________/__________|___|______l__________j_____j return pdiv.width(canvwidth); }; })(this)), 30, { - 'bits': '8' + 'bits': '8', + "font": picdata.font }); }; @@ -161,6 +191,7 @@ l__________/__________|___|______l__________j_____j filedata = Sahli.filedata; filedata[i].pic = $('
    ' + filedata[i].file + '
    '); viewbox.append(filedata[i].pic); + $('h6').show(); Sahli.loadpic(filedata[i], filedata[i].pic); Sahli.currentpic += 1; if (Sahli.currentpic > filedata.length - 1) { @@ -280,7 +311,7 @@ l__________/__________|___|______l__________j_____j zoomee.width(newwidth); return $('canvas').width(newwidth); } else { - if (zoomee.width() !== this.origwidth) { + if (parseInt(zoomee.width(), 10) !== parseInt(this.origwidth, 10)) { zoomee.width(this.origwidth); return $('canvas').width('100%'); } else { @@ -404,6 +435,8 @@ l__________/__________|___|______l__________j_____j return _this.zoom(100); case _this.keycode('r'): return _this.zoom(-100); + case _this.keycode('q'): + return _this.bestfit(); case _this.keycode('w'): return _this.changescrolldirection(-1); case _this.keycode('x'): @@ -413,6 +446,7 @@ l__________/__________|___|______l__________j_____j case _this.keycode('i'): return $('div.infobox').toggle(); case _this.keycode('v'): + $('h6').show(); return $('h6').height((window.innerHeight - $('.scrolly').height()) / 2); case _this.keycode('1'): return _this.changespeed(1); diff --git a/testshow/AD - Green Beam.scaled.png b/testshow/AD - Green Beam.scaled.png new file mode 100644 index 0000000..fbecb25 Binary files /dev/null and b/testshow/AD - Green Beam.scaled.png differ diff --git a/testshow/om-boss.png b/testshow/om-boss.png new file mode 100644 index 0000000..e3abd45 Binary files /dev/null and b/testshow/om-boss.png differ