Merge pull request #3 from lastebil/overhaul

all noted todo items complete except editor parts, ready for remote test by others
This commit is contained in:
Per Persson 2015-03-25 20:54:59 +02:00
commit 82489faae9
9 changed files with 1311 additions and 141 deletions

View file

@ -28,3 +28,15 @@ x 2015-02-22 Fix Amiga mode rendering via sixteencolors lib @16colors
x 2015-02-22 check below items for neccesity
x 2015-02-22 load to array/picture, render from picture @16colors
x 2015-02-22 speed up rendering more? @16colors
x 2015-03-25 BIN @OTHER
x 2015-03-25 IDF @OTHER
x 2015-03-25 Tundra @OTHER
x 2015-03-25 PCBOARD @OTHER
x 2015-03-25 Avatar @OTHER
x 2015-03-25 2015-02-22 ADF @OTHER
x 2015-03-25 XBIN @OTHER
x 2015-03-25 remove the SAUCE lines at bottom, return ANSI object for render @SAUCE
x 2015-03-25 help on top of panel mode (always top)
x 2015-03-25 info page
x 2015-03-25 center panel mode vertically
x 2015-03-25 center ascii if smaller than 1 page (ansi too?)

View file

@ -40,8 +40,10 @@
<li><span class="key">C</span> "panel" view toggle</li>
<li><span class="key">Up</span><span class="key">Down</span><span class="key">Pageup</span><span class="key">Pagedown</span> Move about by line/page</li>
<li><span class="key">Home</span><span class="key">End</span> Move to top/bottom (no zoom reset)</li>
<li><span class="key">I</span> SAUCE or Partymeister info</li>
<li><span class="key">V</span> Center Small Ascii Vertically</li>
<li><span class="key">H</span> This help (: <span class="key">Esc</span> Cancel fullscreen</li>
<li class='nodot'><b>Tab also works for "info" but browsers hate it, so use 'U'</b></li>
<li class='nodot'><b>Tab also works for "info" but browsers hate it, so use 'I'</b></li>
</ul>
</div>
</div>

File diff suppressed because one or more lines are too long

View file

@ -1,202 +1,499 @@
{
"location": "testshow",
"slides": {
"background": "",
"template": "",
"css": ""
},
"filedata": [
{
"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": [
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."
},
{
"file": "Glitch_8bit_ANSi_Compo_Entry_by_Luciano_Ayres.ans",
"name": "Glitch 8-bit",
"amiga": false,
"filetype": "ansi",
"width": "80",
"author": "Luciano Ayres",
"font": "Propaz",
"color": [
255,
255,
255,
255
],
"bg": [
0,
0,
0,
255
],
"line1": "NVscene 2015",
"line2": "Blocktronics",
"text": "f*n brilliant"
},
{
"file": "h7-supergroupies.ans",
"name": "SuperGroupies",
"amiga": false,
"filetype": "ansi",
"width": "80",
"author": "H7",
"font": "Propaz",
"color": [
154,
254,
46,
255
],
"bg": [
11,
11,
59,
255
],
"line1": "H7",
"line2": "Ansi",
"text": "Test file #1"
},
{
"file": "Blocktronics-WTF4_Megajoint.ans",
"name": "WTF4",
"amiga": false,
"filetype": "ansi",
"width": "80",
"author": "Blocktronics",
"font": "Propaz",
"color": [
0,
46,
247,
255
],
"bg": [
160,
160,
224,
255
],
"line1": "",
"line2": "",
"text": ""
},
{
"file": "51_DRGN.XB",
"name": "Dragon",
"amiga": false,
"filetype": "xbin",
"width": "80",
"author": "Someone",
"font": "Propaz",
"color": [
255,
128,
0,
255
],
"bg": [
46,
254,
247,
255
],
"line1": "Test #2",
"line2": "Test #2",
"text": ""
},
{
"file": "ARTX-LGO.ADF",
"name": "ADF test",
"amiga": false,
"filetype": "adf",
"width": "80",
"author": "",
"font": "Propaz",
"color": [
255,
255,
255,
255
],
"bg": [
0,
0,
0,
255
],
"line1": "",
"line2": "",
"text": ""
},
{
"file": "MD-XMAS.IDF",
"name": "IDF test",
"amiga": false,
"filetype": "idf",
"width": "80",
"author": "",
"font": "Propaz",
"color": [
255,
255,
255,
255
],
"bg": [
0,
0,
0,
255
],
"line1": "",
"line2": "",
"text": ""
},
{
"file": "US-SADIS.BIN",
"name": "BIN test",
"amiga": false,
"filetype": "bin",
"width": "160",
"author": "",
"font": "Propaz",
"color": [
255,
255,
255,
255
],
"bg": [
0,
0,
0,
255
],
"line1": "",
"line2": "",
"text": ""
},
{
"file": "zv_iniq.tnd",
"name": "Tundra test",
"amiga": false,
"filetype": "tundra",
"width": "80",
"author": "",
"font": "Propaz",
"color": [
255,
255,
255,
255
],
"bg": [
0,
0,
0,
255
],
"line1": "",
"line2": "",
"text": ""
}
]
}

View file

@ -64,36 +64,20 @@ class @Sahli
pdiv.prepend buf.clone()
pdiv.append ptxt
pdiv.append buf
# this is going to be interesting when dealing with ansi files in UTF-8
# or SHIFT-JIS etc - is it needed now?
# this is still needed for some Amiga stuff done on Amiga.
# probably should allow other overrides for UTF-8 and so on.
req.overrideMimeType 'text/plain; charset=ISO-8859-1'
req.onreadystatechange = ->
if req.readyState == req.DONE
if req.status == 200 or req.status == 0
ptxt.text @responseText
inserthere.after pdiv
$('body').scrollTop(0)
$('body').scrollTop 0
else
@loaderror inserthere, fname, req.statusText, req.status
req.open 'GET', fname, true
req.send null
@loadansi = (picdata, inserthere) ->
fname = @location + '/' + picdata.file
pdiv = $('<div>')
pdiv.addClass 'scrolly'
AnsiLove.render fname, ((canv, SAUCE) ->
pdiv.append canv
inserthere.after pdiv
@origwidth = canv.width
@origheight = canv.height
@SAUCE = SAUCE
),
'font': '80x25'
'bits': '8'
'columns': 160
'thumbnail': 0
@loadhugeansi = (picdata, inserthere) ->
fname = @location + '/' + picdata.file
pdiv = $('<div>')
@ -108,6 +92,7 @@ class @Sahli
calcheight = calcheight + canv.height
canvwidth = canv.width
inserthere.after pdiv
$('body').scrollTop 0
@SAUCE = SAUCE
@origwidth = canvwidth
@origheight = calcheight
@ -115,7 +100,7 @@ class @Sahli
), 30, 'bits': '8'
@loadavatar = (picdata, inserthere) ->
alert 'avatar', picdata, inserthere
console.log 'avatar', picdata, inserthere
@requestsahlifile = (url) ->
@loadkeys()
@ -129,9 +114,19 @@ class @Sahli
@filedata = json.filedata
@slides = json.slides
@location = json.location
alert "SAHLI READY TO GO\n#{@filedata.length} Entries"
@loadinfopanel = (index) ->
data = @filedata[index]
$('.infobox h1').text data.name
$('.infobox h2').text data.author
$('h3.infobox')[0].textContent = data.line1
$('h3.infobox')[1].textContent = data.line2
$('p.bigtext').text data.text
$('.infobox span')[0].textContent = data.filename
$('.infobox span')[1].textContent = data.width
$('.infobox span')[2].textContent = data.font
@nextpic = =>
viewbox = $('div#sahliviewer')
viewbox.children().remove()
@ -149,8 +144,7 @@ class @Sahli
$('#panel').hide()
$('#outbox').show()
$('body').stop()
$('body').scrollTop(0)
@loadinfopanel i
@togglefullscreen = ->
docElm = document.documentElement
@ -210,6 +204,13 @@ class @Sahli
@scroll_direction = - @scroll_direction
@setscroll()
# chromium wasn't working with up/down/pageup/pagedown, firefox was. This makes
# both work the same way.
@moveline = (direction) ->
curpos = $('body').scrollTop()
$('body').scrollTop(curpos + (16*direction))
@changescrolldirection = (direction) ->
@scroll_direction = direction
$('body').stop()
@ -218,7 +219,7 @@ class @Sahli
# - save width upon draw
# - toggle zoom out to full width / normal
# - with a number, change width by that much
# if scrolling, where are we in the doc? zoom to THAT area.
# if scrolling, where are we in the doc? zoom to THAT area. - not implemented
@zoom = (amt) ->
zoomee = $('div.scrolly')
if amt?
@ -226,72 +227,71 @@ class @Sahli
newwidth = @origwidth
else
newwidth = zoomee.width() + amt
console.log "#{zoomee.width()} #{newwidth}"
zoomee.width newwidth
$('canvas').width newwidth
else
if zoomee.width() != @origwidth
zoomee.width @origwidthg
zoomee.width @origwidth
$('canvas').width '100%'
else
zoomee.width '100%'
$('canvas').width '100%'
# calculate # strips - how many times does window height go into full height
# and then move the canvases into it. - done
# outbox toggled last to avoid losing width. (prolly need to fix.)
# create a panel of 'strips' so as to show a very long vertical piece on one
# big 'plate'
@panelmode = ->
$('#panel').toggle()
canvs = $('canvas')
if $('.scrolly').width() == @origwidth
$('.scrolly').width '100%'
$('.scrolly').width @origwidth
if $('#panel').css('display') != 'none'
$('#panel').empty()
ww = window.innerWidth
wh = window.innerHeight
numpanels = canvs.length
fullpicheight = 0
fullpicheight = (fullpicheight + i.height) for i in canvs
screenratio = ww/wh
stripe_width = ww/Math.ceil(fullpicheight/ww)
num_strips = Math.sqrt (ww/stripe_width)*(fullpicheight/wh)
panelratio = canvs[0].height/canvs[0].width
numcols = Math.floor num_strips-1
x = Math.sqrt numpanels/screenratio
numcols = Math.round(screenratio*x)
picdpercol = Math.round(numpanels/numcols)
scaling_factor = num_strips * (wh / fullpicheight)
newwidth = ww/numcols
# newheight = canvs[0].height * scaling_factor
# $(canvs[0]).height newheight
newwidth = scaling_factor * canvs.height()
canvs.width newwidth
newheight = $(canvs[0]).height()
colwidth = ww/numcols
newheight = canvs.height()
panelsperslot = Math.floor wh/newheight
panelslotheight = panelsperslot * newheight
outer = $('<div>')
outer.append @createpanel(i,colwidth - 6) for i in [1..numcols]
console.log numcols
outer.addClass 'nosb'
$('#panel').append outer
$('#outbox').toggle()
level = 0
drawcol = 1
ct = 0
outer.append @createpanel(1,newwidth - 6)
for pic in canvs
$("#column#{drawcol}").append pic
level = level + newheight
if level+(newheight/2) > wh
level += 1
ct += 1
if level == panelsperslot
level = 0
drawcol = drawcol + 1
if ct < numpanels
outer.append @createpanel(drawcol,newwidth - 6)
else
$('.scrolly').width @origwidth
$('#outbox').show()
$('.scrolly').append pic for pic in canvs
canvs.width @origwidth
$('body').scrollTop 0
@createpanel = (i,amt) ->
dcol = $("<div id='column#{i}'>#{i}</div>")
dcol.addClass 'panelcolumn'
dcol = $("<div id='column#{i}' class='panelcolumn'>#{i}</div>")
dcol.width amt
@loadkeys = ->
@ -322,7 +322,11 @@ class @Sahli
when @keycode 'x'
@changescrolldirection 1
when @keycode 'c'
@panelmode()
@panelmode(1)
when @keycode 'i'
$('div.infobox').toggle()
when @keycode 'v'
$('h6').height( (window.innerHeight - $('.scrolly').height()) / 2 )
when @keycode '1'
@changespeed 1
when @keycode '2'
@ -336,6 +340,14 @@ class @Sahli
@scroll_speed = 4
when @keycode '5'
@changespeed 5
when 40 # down
@moveline 1
when 38 # up
@moveline -1
when 34 # pagedown
@moveline 40
when 33 # pageup
@moveline -40
when @keycode 'h'
$('.help').css {'left':'33%'}
$('.help').toggle 'fast'

View file

@ -1,3 +1,7 @@
/*
Sahli css
*/
body {
background-color: black;
margin: 0;
@ -28,17 +32,8 @@ body {
}
h6 {
position: fixed;
top: 1ex;
left: 1ex;
border: 1px green ridge;
padding: .125em 1em;
color: black;
background-color: green;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
display: none;
color: transparent;
background-color: transparent;
}
.help {
@ -79,7 +74,7 @@ h1.help {
padding: .15ex;
}
ul.keylist li.nodot {
ul.keylist nodot {
list-style: none;
padding-left: 2em;
}
@ -96,12 +91,12 @@ ul.keylist li.nodot {
div.infobox {
font-family: mosoul,topaz1200,microknight, Consolas, monospace;
position: absolute;
position: fixed;
top: 1ex;
left: 1ex;
-webkit-border-radius: 42px;
-moz-border-radius: 42px;
border-radius: 42px;
-webkit-border-radius: 1ex;
-moz-border-radius: 1ex;
border-radius: 1ex;
padding: 2ex;
margin: 3em;
background-color: aliceblue;
@ -127,40 +122,43 @@ p.infobox {
margin: .25ex;
}
.ty50 {
transform: translateY(-50%);
}
.bigtext {
background-color: lightsteelblue;
border: 1px outset steelblue;
margin: .25ex;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
padding: .5ex;
-webkit-border-radius: 0.5em;
-moz-border-radius: 0.5em;
border-radius: 0.5em;
width: 30ex;
}
#panel {
width: 100%;
background: #0a0a0f;
height: 100%;
border: 0;
font-family: microknight;
position: absolute;
position: fixed;
left: 0;
top: 0;
top: 50%;
padding: 0;
margin: 0;
text-align: center;
}
.panelcolumn {
height: 100%;
color: #00f080;
color: transparent;
width: 2em;
background: #082020;
display: inline-table;
}
.nosb {
overflow: hidden;
transform: translateY(-50%);
}
@font-face {

117
sahli.js
View file

@ -87,25 +87,6 @@ l__________/__________|___|______l__________j_____j
return req.send(null);
};
Sahli.loadansi = function(picdata, inserthere) {
var fname, pdiv;
fname = this.location + '/' + picdata.file;
pdiv = $('<div>');
pdiv.addClass('scrolly');
return AnsiLove.render(fname, (function(canv, SAUCE) {
pdiv.append(canv);
inserthere.after(pdiv);
this.origwidth = canv.width;
this.origheight = canv.height;
return this.SAUCE = SAUCE;
}), {
'font': '80x25',
'bits': '8',
'columns': 160,
'thumbnail': 0
});
};
Sahli.loadhugeansi = function(picdata, inserthere) {
var calcheight, canvwidth, fname, pdiv;
fname = this.location + '/' + picdata.file;
@ -123,6 +104,7 @@ l__________/__________|___|______l__________j_____j
return canvwidth = canv.width;
});
inserthere.after(pdiv);
$('body').scrollTop(0);
_this.SAUCE = SAUCE;
_this.origwidth = canvwidth;
_this.origheight = calcheight;
@ -134,7 +116,7 @@ l__________/__________|___|______l__________j_____j
};
Sahli.loadavatar = function(picdata, inserthere) {
return alert('avatar', picdata, inserthere);
return console.log('avatar', picdata, inserthere);
};
Sahli.requestsahlifile = function(url) {
@ -155,6 +137,19 @@ l__________/__________|___|______l__________j_____j
})(this));
};
Sahli.loadinfopanel = function(index) {
var data;
data = this.filedata[index];
$('.infobox h1').text(data.name);
$('.infobox h2').text(data.author);
$('h3.infobox')[0].textContent = data.line1;
$('h3.infobox')[1].textContent = data.line2;
$('p.bigtext').text(data.text);
$('.infobox span')[0].textContent = data.filename;
$('.infobox span')[1].textContent = data.width;
return $('.infobox span')[2].textContent = data.font;
};
Sahli.nextpic = function() {
var filedata, i, viewbox;
viewbox = $('div#sahliviewer');
@ -174,7 +169,7 @@ l__________/__________|___|______l__________j_____j
$('#panel').hide();
$('#outbox').show();
$('body').stop();
return $('body').scrollTop(0);
return Sahli.loadinfopanel(i);
};
Sahli.togglefullscreen = function() {
@ -251,6 +246,12 @@ l__________/__________|___|______l__________j_____j
return this.setscroll();
};
Sahli.moveline = function(direction) {
var curpos;
curpos = $('body').scrollTop();
return $('body').scrollTop(curpos + (16 * direction));
};
Sahli.changescrolldirection = function(direction) {
this.scroll_direction = direction;
$('body').stop();
@ -266,12 +267,11 @@ l__________/__________|___|______l__________j_____j
} else {
newwidth = zoomee.width() + amt;
}
console.log((zoomee.width()) + " " + newwidth);
zoomee.width(newwidth);
return $('canvas').width(newwidth);
} else {
if (zoomee.width() !== this.origwidth) {
zoomee.width(this.origwidthg);
zoomee.width(this.origwidth);
return $('canvas').width('100%');
} else {
zoomee.width('100%');
@ -281,55 +281,57 @@ l__________/__________|___|______l__________j_____j
};
Sahli.panelmode = function() {
var canvs, colwidth, drawcol, fullpicheight, i, level, newheight, newwidth, num_strips, numcols, numpanels, outer, pic, scaling_factor, stripe_width, wh, ww, _i, _j, _k, _l, _len, _len1, _len2, _results;
var canvs, ct, drawcol, level, newheight, newwidth, numcols, numpanels, outer, panelratio, panelslotheight, panelsperslot, pic, picdpercol, screenratio, wh, ww, x, _i, _j, _len, _len1, _results;
$('#panel').toggle();
canvs = $('canvas');
if ($('.scrolly').width() === this.origwidth) {
$('.scrolly').width('100%');
$('.scrolly').width(this.origwidth);
if ($('#panel').css('display') !== 'none') {
$('#panel').empty();
ww = window.innerWidth;
wh = window.innerHeight;
numpanels = canvs.length;
fullpicheight = 0;
for (_i = 0, _len = canvs.length; _i < _len; _i++) {
i = canvs[_i];
fullpicheight = fullpicheight + i.height;
}
stripe_width = ww / Math.ceil(fullpicheight / ww);
num_strips = Math.sqrt((ww / stripe_width) * (fullpicheight / wh));
numcols = Math.floor(num_strips - 1);
scaling_factor = num_strips * (wh / fullpicheight);
newwidth = scaling_factor * canvs.height();
screenratio = ww / wh;
panelratio = canvs[0].height / canvs[0].width;
x = Math.sqrt(numpanels / screenratio);
numcols = Math.round(screenratio * x);
picdpercol = Math.round(numpanels / numcols);
newwidth = ww / numcols;
canvs.width(newwidth);
newheight = $(canvs[0]).height();
colwidth = ww / numcols;
newheight = canvs.height();
panelsperslot = Math.floor(wh / newheight);
panelslotheight = panelsperslot * newheight;
outer = $('<div>');
for (i = _j = 1; 1 <= numcols ? _j <= numcols : _j >= numcols; i = 1 <= numcols ? ++_j : --_j) {
outer.append(this.createpanel(i, colwidth - 6));
}
console.log(numcols);
outer.addClass('nosb');
$('#panel').append(outer);
$('#outbox').toggle();
level = 0;
drawcol = 1;
ct = 0;
outer.append(this.createpanel(1, newwidth - 6));
_results = [];
for (_k = 0, _len1 = canvs.length; _k < _len1; _k++) {
pic = canvs[_k];
for (_i = 0, _len = canvs.length; _i < _len; _i++) {
pic = canvs[_i];
$("#column" + drawcol).append(pic);
level = level + newheight;
if (level + (newheight / 2) > wh) {
level += 1;
ct += 1;
if (level === panelsperslot) {
level = 0;
_results.push(drawcol = drawcol + 1);
drawcol = drawcol + 1;
if (ct < numpanels) {
_results.push(outer.append(this.createpanel(drawcol, newwidth - 6)));
} else {
_results.push(void 0);
}
} else {
_results.push(void 0);
}
}
return _results;
} else {
$('.scrolly').width(this.origwidth);
$('#outbox').show();
for (_l = 0, _len2 = canvs.length; _l < _len2; _l++) {
pic = canvs[_l];
for (_j = 0, _len1 = canvs.length; _j < _len1; _j++) {
pic = canvs[_j];
$('.scrolly').append(pic);
}
canvs.width(this.origwidth);
@ -339,8 +341,7 @@ l__________/__________|___|______l__________j_____j
Sahli.createpanel = function(i, amt) {
var dcol;
dcol = $("<div id='column" + i + "'>" + i + "</div>");
dcol.addClass('panelcolumn');
dcol = $("<div id='column" + i + "' class='panelcolumn'>" + i + "</div>");
return dcol.width(amt);
};
@ -373,7 +374,11 @@ l__________/__________|___|______l__________j_____j
case _this.keycode('x'):
return _this.changescrolldirection(1);
case _this.keycode('c'):
return _this.panelmode();
return _this.panelmode(1);
case _this.keycode('i'):
return $('div.infobox').toggle();
case _this.keycode('v'):
return $('h6').height((window.innerHeight - $('.scrolly').height()) / 2);
case _this.keycode('1'):
return _this.changespeed(1);
case _this.keycode('2'):
@ -387,6 +392,14 @@ l__________/__________|___|______l__________j_____j
return _this.scroll_speed = 4;
case _this.keycode('5'):
return _this.changespeed(5);
case 40:
return _this.moveline(1);
case 38:
return _this.moveline(-1);
case 34:
return _this.moveline(40);
case 33:
return _this.moveline(-40);
case _this.keycode('h'):
$('.help').css({
'left': '33%'

File diff suppressed because one or more lines are too long

View file

@ -1,14 +1,9 @@
(B) 2015-02-22 ADF @OTHER
(B) @EDITOR add more Amiga fonts.
(B) @EDITOR redo filenames to load from list of files in directory (specfied in 'location')
(A) remove the SAUCE lines at bottom, return ANSI object for render @SAUCE
(A) XBIN @OTHER
(C) Amiga ANSI @OTHER
(B) Avatar @OTHER
(B) BIN @OTHER
(B) IDF @OTHER
(B) PCBOARD @OTHER
(D) THUMBNAILS - for returning to partymeister @PARTYMEISTER
(B) Tundra @OTHER
(D) implement package import from partymeister @PARTYMEISTER
(D) hook for progress @progress @PARTYMEISTER
(C) SAHLI ansi & ascii for load page
(C) redo load page (not popup, info)
(B) Preload