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": {
|
"slides": {
|
||||||
"background": "screen.png",
|
"background": "screen.png",
|
||||||
"template": "template.html",
|
"template": "template.html",
|
||||||
|
|
|
||||||
25
sahli.js
25
sahli.js
|
|
@ -38,6 +38,7 @@ var Sahli = function() {
|
||||||
var pdiv = $('<div>');
|
var pdiv = $('<div>');
|
||||||
var canv = document.createElement('canvas');
|
var canv = document.createElement('canvas');
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
|
var fname = sahli.location + '/' + picdata.file;
|
||||||
pdiv.addClass('scrolly');
|
pdiv.addClass('scrolly');
|
||||||
ref = this;
|
ref = this;
|
||||||
if (picdata.amiga && this.asciiasgfx) {
|
if (picdata.amiga && this.asciiasgfx) {
|
||||||
|
|
@ -61,23 +62,29 @@ var Sahli = function() {
|
||||||
ptxt.text(this.responseText);
|
ptxt.text(this.responseText);
|
||||||
inserthere.after(pdiv);
|
inserthere.after(pdiv);
|
||||||
} else {
|
} else {
|
||||||
|
sahli.loaderror(inserthere,fname,req.statusText,req.status)
|
||||||
// I really should make a real error handler.
|
// I really should make a real error handler.
|
||||||
alert(req);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
req.open('GET', picdata.file, true);
|
req.open('GET', fname , true);
|
||||||
req.send(null);
|
req.send(null);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.image = new ImageTextModeANSI();
|
this.image = new ImageTextModeANSI();
|
||||||
this.SAUCE = new ImageTextModeSAUCE();
|
this.SAUCE = new ImageTextModeSAUCE();
|
||||||
this.image.parseUrl(picdata.file);
|
var picload = this.image.parseUrl(fname);
|
||||||
this.image.renderCanvas(canv);
|
this.image.renderCanvas(canv);
|
||||||
pdiv.append(canv);
|
pdiv.append(canv);
|
||||||
inserthere.after(pdiv);
|
inserthere.after(pdiv);
|
||||||
this.origwidth = canv.width;
|
this.origwidth = canv.width;
|
||||||
this.origheight = canv.height;
|
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('h1').text(picdata.name);
|
||||||
infob.find('h2').text(picdata.author);
|
infob.find('h2').text(picdata.author);
|
||||||
|
|
@ -89,6 +96,17 @@ var Sahli = function() {
|
||||||
infob.find('span#fontname').text(picdata.font);
|
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) {
|
this.calccolor = function(colorset) {
|
||||||
return 'rgba(' + colorset.toString() + ')';
|
return 'rgba(' + colorset.toString() + ')';
|
||||||
};
|
};
|
||||||
|
|
@ -202,6 +220,7 @@ var Sahli = function() {
|
||||||
$.getJSON(url, function(json) {
|
$.getJSON(url, function(json) {
|
||||||
ref.filedata = json.filedata;
|
ref.filedata = json.filedata;
|
||||||
ref.slides = json.slides;
|
ref.slides = json.slides;
|
||||||
|
ref.location = json.location;
|
||||||
ref.buildcompo();
|
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
|
(A) remove their lines like SAUCE, return ANSI object for render @OTHER
|
||||||
(B) load other-info into 'info' (done at prep) @OTHER
|
(B) load other-info into 'info' (done at prep) @OTHER
|
||||||
|
|
||||||
|
(A) Error handler for file not found
|
||||||
|
|
||||||
(B) THUMBNAILS - for returning to partymeister
|
(B) THUMBNAILS - for returning to partymeister
|
||||||
|
|
||||||
(A) Create Editor - Standalone @EDITOR
|
(A) Create Editor - Standalone @EDITOR
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue