first try: multiple file format loading

This commit is contained in:
Iam Naughton Phier 2014-08-05 17:02:29 +03:00
parent a4b4f33c48
commit 4224cc3066
2 changed files with 98 additions and 50 deletions

View file

@ -34,17 +34,32 @@ var Sahli = function() {
this.nonfsheight = document.height - 40; this.nonfsheight = document.height - 40;
this.loadpic = function(picdata, inserthere) { 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 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; var fname = sahli.location + '/' + picdata.file;
pdiv.addClass('scrolly');
ref = this;
if (picdata.amiga && this.asciiasgfx) {
var ptxt = $('<pre></pre>'); var ptxt = $('<pre></pre>');
var color = this.calccolor(picdata.color); var color = this.calccolor(picdata.color);
var bgcolor = this.calccolor(picdata.bg); var bgcolor = this.calccolor(picdata.bg);
pdiv.addClass('scrolly');
ptxt.addClass(picdata.font.toLowerCase()); ptxt.addClass(picdata.font.toLowerCase());
ptxt.css({ ptxt.css({
'color': color, 'color': color,
@ -55,6 +70,7 @@ var Sahli = function() {
pdiv.width('100%'); pdiv.width('100%');
pdiv.append(ptxt); pdiv.append(ptxt);
// x-user-defined // 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.overrideMimeType('text/plain; charset=ISO-8859-1');
req.onreadystatechange = function() { req.onreadystatechange = function() {
if (req.readyState === req.DONE) { if (req.readyState === req.DONE) {
@ -63,14 +79,13 @@ var Sahli = function() {
inserthere.after(pdiv); inserthere.after(pdiv);
} else { } else {
sahli.loaderror(inserthere,fname,req.statusText,req.status) sahli.loaderror(inserthere,fname,req.statusText,req.status)
// I really should make a real error handler.
} }
} }
}; };
req.open('GET', fname , true); req.open('GET', fname , true);
req.send(null); req.send(null);
} else { this.loadansi = function(picdata,inserthere) {
this.image = new ImageTextModeANSI(); this.image = new ImageTextModeANSI();
this.SAUCE = new ImageTextModeSAUCE(); this.SAUCE = new ImageTextModeSAUCE();
var picload = this.image.parseUrl(fname); var picload = this.image.parseUrl(fname);
@ -85,7 +100,38 @@ var Sahli = function() {
sahli.loaderror(inserthere,fname,'Not found',404); 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('h1').text(picdata.name);
infob.find('h2').text(picdata.author); infob.find('h2').text(picdata.author);
infob.find('h3#text').text(picdata.line1); infob.find('h3#text').text(picdata.line1);

View file

@ -16,6 +16,7 @@ Version B:
This, if implemented (which it isn't) would allow you to generate 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": { "slides": {
"background": "screen.png", "background": "screen.png",
"template": "template.html", "template": "template.html",
@ -36,7 +37,7 @@ Version B:
This _is_ implemented and holds the data for each ansi or ascii "slide" in This _is_ implemented and holds the data for each ansi or ascii "slide" in
the "slideshow" (if using a 'slideshow' paradigm.) the "slideshow" (if using a 'slideshow' paradigm.)
EXAMPLE:
"filedata": [{ "filedata": [{
"file": "spaceflight.asc", "file": "spaceflight.asc",
"name": "Spaceflight", "name": "Spaceflight",
@ -67,7 +68,8 @@ Version B:
filetype: * NEW IN VERSION B* filetype: * NEW IN VERSION B*
The type of file - i.e. use the parsing method for file type X. The type of file - i.e. use the parsing method for file type X.
Possible legal types: 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 "xbin" - saved as xbin
"ice" - saved in the ICE format "ice" - saved in the ICE format
"adf" - saved as ADF (NOT amiga disk file, some ansi format that is not "adf" - saved as ADF (NOT amiga disk file, some ansi format that is not