first try: multiple file format loading
This commit is contained in:
parent
a4b4f33c48
commit
4224cc3066
2 changed files with 98 additions and 50 deletions
136
sahli.js
136
sahli.js
|
|
@ -34,58 +34,104 @@ var Sahli = function() {
|
|||
this.nonfsheight = document.height - 40;
|
||||
|
||||
this.loadpic = function(picdata, inserthere) {
|
||||
var infob = $('div.infobox');
|
||||
var jumptable = {
|
||||
'plain':this.loadplain(),
|
||||
'xbin':this.loadxbin(),
|
||||
'ice':this.loadice(),
|
||||
'avatar':this.loadavatar(),
|
||||
'pcboard':this.loadpcboard(),
|
||||
'ansi':this.loadansi(),
|
||||
'idf':this.loadidf(),
|
||||
'bin':this.loadbin(),
|
||||
'adf':this.loadadf(),
|
||||
'tundra':this.loadtundra()
|
||||
}
|
||||
jumptable[picdata.filetype](picdata,inserthere);
|
||||
}
|
||||
|
||||
this.loadplain = function(picdata, inserthere) {
|
||||
ref = this;
|
||||
var pdiv = $('<div>');
|
||||
var canv = document.createElement('canvas');
|
||||
var req = new XMLHttpRequest();
|
||||
var fname = sahli.location + '/' + picdata.file;
|
||||
var fname = sahli.location + '/' + picdata.file;
|
||||
var ptxt = $('<pre></pre>');
|
||||
var color = this.calccolor(picdata.color);
|
||||
var bgcolor = this.calccolor(picdata.bg);
|
||||
|
||||
pdiv.addClass('scrolly');
|
||||
ref = this;
|
||||
if (picdata.amiga && this.asciiasgfx) {
|
||||
var ptxt = $('<pre></pre>');
|
||||
var color = this.calccolor(picdata.color);
|
||||
var bgcolor = this.calccolor(picdata.bg);
|
||||
ptxt.addClass(picdata.font.toLowerCase());
|
||||
ptxt.css({
|
||||
'color': color,
|
||||
'background-color': bgcolor,
|
||||
'margin': 'auto'
|
||||
});
|
||||
ptxt.width(picdata.width * 8);
|
||||
pdiv.width('100%');
|
||||
pdiv.append(ptxt);
|
||||
// x-user-defined
|
||||
req.overrideMimeType('text/plain; charset=ISO-8859-1');
|
||||
req.onreadystatechange = function() {
|
||||
if (req.readyState === req.DONE) {
|
||||
if (req.status === 200 || req.status === 0) {
|
||||
ptxt.text(this.responseText);
|
||||
inserthere.after(pdiv);
|
||||
} else {
|
||||
sahli.loaderror(inserthere,fname,req.statusText,req.status)
|
||||
// I really should make a real error handler.
|
||||
}
|
||||
ptxt.addClass(picdata.font.toLowerCase());
|
||||
ptxt.css({
|
||||
'color': color,
|
||||
'background-color': bgcolor,
|
||||
'margin': 'auto'
|
||||
});
|
||||
ptxt.width(picdata.width * 8);
|
||||
pdiv.width('100%');
|
||||
pdiv.append(ptxt);
|
||||
// x-user-defined
|
||||
// this is going to be interesting when dealing with ansi files in UTF-8 and SHIFT-JIS etc
|
||||
req.overrideMimeType('text/plain; charset=ISO-8859-1');
|
||||
req.onreadystatechange = function() {
|
||||
if (req.readyState === req.DONE) {
|
||||
if (req.status === 200 || req.status === 0) {
|
||||
ptxt.text(this.responseText);
|
||||
inserthere.after(pdiv);
|
||||
} else {
|
||||
sahli.loaderror(inserthere,fname,req.statusText,req.status)
|
||||
}
|
||||
};
|
||||
req.open('GET', fname , true);
|
||||
req.send(null);
|
||||
|
||||
} else {
|
||||
this.image = new ImageTextModeANSI();
|
||||
this.SAUCE = new ImageTextModeSAUCE();
|
||||
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);
|
||||
}
|
||||
};
|
||||
req.open('GET', fname , true);
|
||||
req.send(null);
|
||||
|
||||
this.loadansi = function(picdata,inserthere) {
|
||||
this.image = new ImageTextModeANSI();
|
||||
this.SAUCE = new ImageTextModeSAUCE();
|
||||
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);
|
||||
}
|
||||
|
||||
this.loadxbin = function(picdata,inserthere){
|
||||
alert('xbin');
|
||||
}
|
||||
|
||||
this.loadbin = function(picdata,inserthere){
|
||||
alert('bin');
|
||||
}
|
||||
this.loadice = function(picdata,inserthere){
|
||||
alert('ice');
|
||||
}
|
||||
this.loadidf = function(picdata,inserthere){
|
||||
alert('idf');
|
||||
}
|
||||
this.loadadf = function(picdata,inserthere){
|
||||
alert('adf');
|
||||
}
|
||||
this.loadavatar = function(picdata,inserthere){
|
||||
alert('avatar');
|
||||
}
|
||||
this.loadtundra = function(picdata,inserthere){
|
||||
alert('tundra');
|
||||
}
|
||||
this.loadpcboard = function(picdata,inserthere){
|
||||
alert('pcboard');
|
||||
}
|
||||
this.loadxbin = function(picdata,inserthere){
|
||||
alert('xbin');
|
||||
}
|
||||
|
||||
|
||||
this.fillinfo = function(picdata) {
|
||||
var infob = $('div.infobox');
|
||||
infob.find('h1').text(picdata.name);
|
||||
infob.find('h2').text(picdata.author);
|
||||
infob.find('h3#text').text(picdata.line1);
|
||||
|
|
@ -104,7 +150,7 @@ var Sahli = function() {
|
|||
tmptxt = $("<h1>").text("error! "+ errorText + " code " + errorCode +
|
||||
" file " + fname);
|
||||
}
|
||||
inserthere.after(tmptxt);
|
||||
inserthere.after(tmptxt);
|
||||
}
|
||||
|
||||
this.calccolor = function(colorset) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
A Sahli file is JSON, so all JSON formatting and rule processing applies.
|
||||
|
||||
Version A:
|
||||
There were 2 primary sections within the file: The slide section and the
|
||||
There were 2 primary sections within the file: The slide section and the
|
||||
filedata section.
|
||||
Version B:
|
||||
3 primary sections, slide / filedata and now location.
|
||||
|
|
@ -14,8 +14,9 @@ Version B:
|
|||
=== slides ===
|
||||
|
||||
This, if implemented (which it isn't) would allow you to generate slides-
|
||||
such as if you weren't using partymeister for slides.
|
||||
such as if you weren't using partymeister for slides.
|
||||
|
||||
EXAMPLE:
|
||||
"slides": {
|
||||
"background": "screen.png",
|
||||
"template": "template.html",
|
||||
|
|
@ -36,7 +37,7 @@ Version B:
|
|||
This _is_ implemented and holds the data for each ansi or ascii "slide" in
|
||||
the "slideshow" (if using a 'slideshow' paradigm.)
|
||||
|
||||
|
||||
EXAMPLE:
|
||||
"filedata": [{
|
||||
"file": "spaceflight.asc",
|
||||
"name": "Spaceflight",
|
||||
|
|
@ -67,7 +68,8 @@ Version B:
|
|||
filetype: * NEW IN VERSION B*
|
||||
The type of file - i.e. use the parsing method for file type X.
|
||||
Possible legal types:
|
||||
"plain" - for standard ascii and ansi (i.e. the default.)
|
||||
"plain" - for 'standard' ascii (Amiga or pc.) ISO-8859-1
|
||||
"ansi" - 'normal' ansi, can have or not have SAUCE data.
|
||||
"xbin" - saved as xbin
|
||||
"ice" - saved in the ICE format
|
||||
"adf" - saved as ADF (NOT amiga disk file, some ansi format that is not
|
||||
|
|
@ -76,7 +78,7 @@ Version B:
|
|||
"avatar" - avatar format
|
||||
"bin" - bin format. Not "any binary" format, but the ansi 'bin' format.
|
||||
* no I don't know the difference, but someone does and they wrote the
|
||||
original code for it.
|
||||
original code for it.
|
||||
"idf" - idf format.
|
||||
"pcboard" - pcboard ansi format.
|
||||
"tundra" - tundra format. (from tundradraw, I assume.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue