Error handler + subdirectory support.
This commit is contained in:
parent
251ae57269
commit
980c855d7a
3 changed files with 25 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"location": "subdir",
|
||||
"location": "testshow",
|
||||
"slides": {
|
||||
"background": "screen.png",
|
||||
"template": "template.html",
|
||||
|
|
|
|||
25
sahli.js
25
sahli.js
|
|
@ -38,6 +38,7 @@ var Sahli = function() {
|
|||
var pdiv = $('<div>');
|
||||
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 = $("<h1>").text("Unable to find file " + fname);
|
||||
} else {
|
||||
tmptxt = $("<h1>").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();
|
||||
});
|
||||
};
|
||||
|
|
|
|||
2
todo.txt
2
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue