diff --git a/list.sahli b/list.sahli index c0ec7bc..15dec3a 100644 --- a/list.sahli +++ b/list.sahli @@ -1,5 +1,5 @@ { - "location": "subdir", + "location": "testshow", "slides": { "background": "screen.png", "template": "template.html", diff --git a/sahli.js b/sahli.js index 1d61bdc..cd446c0 100644 --- a/sahli.js +++ b/sahli.js @@ -38,6 +38,7 @@ var Sahli = function() { var pdiv = $('
'); var canv = document.createElement('canvas'); var req = new XMLHttpRequest(); + var fname = sahli.location + '/' + picdata.file; pdiv.addClass('scrolly'); ref = this; if (picdata.amiga && this.asciiasgfx) { @@ -61,23 +62,29 @@ var Sahli = function() { ptxt.text(this.responseText); inserthere.after(pdiv); } else { + sahli.loaderror(inserthere,fname,req.statusText,req.status) // I really should make a real error handler. - alert(req); } } }; - req.open('GET', picdata.file, true); + req.open('GET', fname , true); req.send(null); } else { this.image = new ImageTextModeANSI(); this.SAUCE = new ImageTextModeSAUCE(); - this.image.parseUrl(picdata.file); + var picload = this.image.parseUrl(fname); this.image.renderCanvas(canv); pdiv.append(canv); inserthere.after(pdiv); this.origwidth = canv.width; this.origheight = canv.height; + if (picload < 1) { + // this is incorrect but currently parseUrl does not return errors. + // fix, then deal with. + sahli.loaderror(inserthere,fname,'Not found',404); + } + } infob.find('h1').text(picdata.name); infob.find('h2').text(picdata.author); @@ -89,6 +96,17 @@ var Sahli = function() { infob.find('span#fontname').text(picdata.font); }; + this.loaderror = function(inserthere,fname,errorText,errorCode) { + var temptxt = ""; + if (errorCode === 404) { + tmptxt = $("

").text("Unable to find file " + fname); + } else { + tmptxt = $("

").text("error! "+ errorText + " code " + errorCode + + " file " + fname); + } + inserthere.after(tmptxt); + } + this.calccolor = function(colorset) { return 'rgba(' + colorset.toString() + ')'; }; @@ -202,6 +220,7 @@ var Sahli = function() { $.getJSON(url, function(json) { ref.filedata = json.filedata; ref.slides = json.slides; + ref.location = json.location; ref.buildcompo(); }); }; diff --git a/todo.txt b/todo.txt index 4a2d286..0ccc431 100644 --- a/todo.txt +++ b/todo.txt @@ -11,6 +11,8 @@ x 2014-04-05 (A) Split coffeescript into files, use cake. (A) remove their lines like SAUCE, return ANSI object for render @OTHER (B) load other-info into 'info' (done at prep) @OTHER +(A) Error handler for file not found + (B) THUMBNAILS - for returning to partymeister (A) Create Editor - Standalone @EDITOR