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.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;
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);
pdiv.addClass('scrolly');
ptxt.addClass(picdata.font.toLowerCase());
ptxt.css({
'color': color,
@ -55,6 +70,7 @@ var Sahli = function() {
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) {
@ -63,14 +79,13 @@ var Sahli = function() {
inserthere.after(pdiv);
} else {
sahli.loaderror(inserthere,fname,req.statusText,req.status)
// I really should make a real error handler.
}
}
};
req.open('GET', fname , true);
req.send(null);
} else {
this.loadansi = function(picdata,inserthere) {
this.image = new ImageTextModeANSI();
this.SAUCE = new ImageTextModeSAUCE();
var picload = this.image.parseUrl(fname);
@ -85,7 +100,38 @@ var Sahli = function() {
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);

View file

@ -16,6 +16,7 @@ Version B:
This, if implemented (which it isn't) would allow you to generate 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