From 5e05d0fbb871bc350b187a8ad65f73829dc04d8d Mon Sep 17 00:00:00 2001 From: m0qui Date: Mon, 26 Mar 2018 21:54:03 +0200 Subject: [PATCH] Added feature to increase/decrease font size in Amiga/plain mode --- index.html | 1 + list.sahli | 52 +++------------------------------------------------- sahli.coffee | 15 ++++++++++++--- sahli.js | 17 ++++++++++++++--- 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/index.html b/index.html index 233d273..63b9fa1 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@
  • Z Zoom full width
  • Q Best fit for images
  • ER Zoom in steps larger/smaller
  • +
  • 89 Incease/decrease font size by 2 (Amiga/plain mode)
  • C "panel" view toggle
  • UpDownPageupPagedown Move about by line/page
  • HomeEnd Move to top/bottom (no zoom reset)
  • diff --git a/list.sahli b/list.sahli index 5e6ceb5..0a19dfc 100644 --- a/list.sahli +++ b/list.sahli @@ -67,97 +67,51 @@ { "file": "spaceflight.asc", - "name": "Spaceflight", - "amiga": true, - "filetype": "plain", - "width": "80", - "author": "Urs", - "font": "pot-noodle", - "color": [ - 255, - 128, - 0, - 255 - ], - "bg": [ - 0, - 0, - 0, - 255 - ], - "line1": "Orange on Dark Grey", - "line2": "Test for plain files", - "text": "" - }, - { - "file": "az0!-revi510n.txt", - "name": "Revision", - "amiga": true, - "filetype": "plain", - "width": "80", - "author": "Azzarro/Madwizards", - - "font": "Propaz", - - "color": [ - + "font": "mosoul", + "color": [ 0, - 240, - 0, - 255 - ], - "bg": [ - 255, - 0, - 0, - 255 - ], - "line1": "Azzaro Returns", - "line2": "Revision ansi/ascii compo 2013", - - "text": "Color test as well as Microknight test." - + "text": "Color test as well as mOsOul test." }, { "file": "dS!-JUFV.txt", diff --git a/sahli.coffee b/sahli.coffee index 0aa9357..043bc09 100644 --- a/sahli.coffee +++ b/sahli.coffee @@ -52,6 +52,7 @@ class @Sahli buf = $('') buf.css {'margin':'0 auto'} ptxt = $('
    ')
    +    ptxt.addClass 'plaintext'
         color = @calccolor(picdata.color)
         bgcolor = @calccolor(picdata.bg)
         pdiv.addClass 'scrolly'
    @@ -61,9 +62,9 @@ class @Sahli
           'background-color': bgcolor
           'margin': 'auto'
           'display': 'inline-block'
    -    ptxt.width picdata.width * 8
    -    @origwidth = ptxt.width
    -    pdiv.width ptxt.width
    +    #ptxt.width picdata.width * 8
    +    #@origwidth = ptxt.width
    +    #pdiv.width ptxt.width
         pdiv.prepend buf.clone()
         pdiv.append ptxt
         pdiv.append buf
    @@ -81,6 +82,10 @@ class @Sahli
         req.open 'GET', fname, true
         req.send null
     
    +  @increaseFont = (node, increaseBy=5) ->
    +    current_size = parseInt($(node).css("font-size"));
    +    $(node).css("font-size", current_size + increaseBy);
    +
       @loadpicture = (picdata, inserthere) ->
         fname = @location + '/' + picdata.file
         pdiv = $('
    ') @@ -407,6 +412,10 @@ class @Sahli @scroll_speed = 4 when @keycode '5' @changespeed 5 + when @keycode '8' + @increaseFont($('pre'), -2) + when @keycode '9' + @increaseFont($('pre'), 2) when 40 # down @moveline 1 when 38 # up diff --git a/sahli.js b/sahli.js index 30a3e25..45def1d 100644 --- a/sahli.js +++ b/sahli.js @@ -59,6 +59,7 @@ l__________/__________|___|______l__________j_____j 'margin': '0 auto' }); ptxt = $('
    ');
    +      ptxt.addClass('plaintext');
           color = this.calccolor(picdata.color);
           bgcolor = this.calccolor(picdata.bg);
           pdiv.addClass('scrolly');
    @@ -69,9 +70,6 @@ l__________/__________|___|______l__________j_____j
             'margin': 'auto',
             'display': 'inline-block'
           });
    -      ptxt.width(picdata.width * 8);
    -      this.origwidth = ptxt.width;
    -      pdiv.width(ptxt.width);
           pdiv.prepend(buf.clone());
           pdiv.append(ptxt);
           pdiv.append(buf);
    @@ -91,6 +89,15 @@ l__________/__________|___|______l__________j_____j
           return req.send(null);
         };
     
    +    Sahli.increaseFont = function(node, increaseBy) {
    +      var current_size;
    +      if (increaseBy == null) {
    +        increaseBy = 5;
    +      }
    +      current_size = parseInt($(node).css("font-size"));
    +      return $(node).css("font-size", current_size + increaseBy);
    +    };
    +
         Sahli.loadpicture = function(picdata, inserthere) {
           var fname, pdiv, pimg;
           fname = this.location + '/' + picdata.file;
    @@ -476,6 +483,10 @@ l__________/__________|___|______l__________j_____j
                   return _this.scroll_speed = 4;
                 case _this.keycode('5'):
                   return _this.changespeed(5);
    +            case _this.keycode('8'):
    +              return _this.increaseFont($('pre'), -2);
    +            case _this.keycode('9'):
    +              return _this.increaseFont($('pre'), 2);
                 case 40:
                   return _this.moveline(1);
                 case 38: