doodah/web/doodah.js
// Request a skin file from the server

Request a skin file from the server
Request a skin file from the server
request_skin( skin, skin_file, skin_name, config ) {
        var server = new XMLHttpRequest();
        server.skin = skin;
        server.skin_config = config;
        server.skin_name = skin_name;
        server.skin_parent = this;
        server.open( "GET", skin_file+"/$", true);
        server.onreadystatechange = function() {
            if (server.readyState != 4) return;
            console.log( ".   Server Status: "+server.status );
            switch( server.status ){
            case 0:
                console.log( "Resource cannot be initialised." );
                break;
            case 200:
                try{
                    var response = JSON.parse(server.responseText);
                    console.log( "INITIALISE SKIN: '"+response.name+"', "+response.status );
                    if( response.status!=="ok" ) {
                        console.log( "$ FAILED TO LOAD SKIN: "+response.name );
                        console.log( "$ ERROR: "+response.status );
                    } else {
                        console.log( "  Loaded Successfully" );
                        skin_name = server.skin_name;
                        var ini = parseINIString( response.ini );
                        server.skin.initialise( ini );
                    }
                } catch(e) {
                    console.log( "Failed to parse JSON response: "+e );
                    console.trace();
                }
                break;
            case 404:{
                ini={
                    'doodah':{
                        'skinwidth':150,
                        'skinheight':40
                    },
                    'error':{
                        'meter':'string',
                        'text':"Skin '"+skin_name+"' missing"
                    }
                };
                server.skin.initialise( ini );
                server.skin.dom.classList.add( "error" );
            }
            default:
            }
        }
        server.send();
    }
request_skin ( skin , skin_file , skin_name , config ) { var server = new XMLHttpRequest ( ) ; server . skin = skin ; server . skin_config = config ; server . skin_name = skin_name ; server . skin_parent = this ; server . open ( "GET" , skin_file + "/$" , true ) ; server . onreadystatechange = function ( ) { if ( server . readyState != 4 ) return ; console . log ( ".   Server Status: " + server . status ) ; switch ( server . status ) { case 0 : console . log ( "Resource cannot be initialised." ) ; break ; case 200 : try { var response = JSON . parse ( server . responseText ) ; console . log ( "INITIALISE SKIN: '" + response . name + "', " + response . status ) ; if ( response . status !== "ok" ) { console . log ( "$ FAILED TO LOAD SKIN: " + response . name ) ; console . log ( "$ ERROR: " + response . status ) ; } else { console . log ( "  Loaded Successfully" ) ; skin_name = server . skin_name ; var ini = parseINIString ( response . ini ) ; server . skin . initialise ( ini ) ; } } catch ( e ) { console . log ( "Failed to parse JSON response: " + e ) ; console . trace ( ) ; } break ; case 404 : { ini = { 'doodah' : { 'skinwidth' : 150 , 'skinheight' : 40 } , 'error' : { 'meter' : 'string' , 'text' : "Skin '" + skin_name + "' missing" } } ; server . skin . initialise ( ini ) ; server . skin . dom . classList . add ( "error" ) ; } default : } } server . send ( ) ; }
Request a skin file from the server
Request a skin file from the server
// Create a request
 // Save some variables that we will need later:
 //
 //server.open( "GET", "$Skin="+skin_file, true);
 // Wait for Ready State 4:
 //console.log( "Connection Successful", 1 );
 //console.log(xhttp.responseText);
 //console.log( "Data length:"+response.length );
 //console.log( response );
 //console.log( server.skin_name);
 //layout = 
 //console.log( "CREATING SKIN "+skin_name );
 //var skin = new Skin( server.skin_parent, skin_name, ini, server.skin_config );
 //console.log( "  Skin created");
 // 
 //if(skin) {
 // Save sking in list
 // Skins[skin_name] = skin;
 //} else {
 //    console.log( "$ Invalid skin");
 //}
 /*
                        //console.log( "INI:" );
                        //console.log( response.ini );
                        // Get existing Skin
                        var skin_name = this.skin_name; response.name;
                        //skin_name = skin_name.toLowerCase();
                        //skin_name = skin_name.replace("\\","/");
                        console.log( "IS:: "+response.name+","+this.skin_name);
                        console.log( "CREATING SKIN "+skin_name );
                        var ini = parseINIString( response.ini );
                        var skin = new Skin( skin_name, ini, this.layout );
                        if(skin) {
                            Skins[skin_name] = skin
                            console.log("$ Skin valid");
                            
                            //console.log( "DATA FILE" );
                            //console.log( response.ini );
                            //console.log( "INI FILE" );
                            //console.log( ini );
                            //skin.load_config( ini );
                            showcard( skin );
                            // Add layout configuration into skin
                            if(layout_config.windowx) skin.config.windowx=layout_config.windowx;
                            if(layout_config.windowy) skin.config.windowy=layout_config.windowy;
                        } else {
                            console.log("$ Invalid skin");
                        }
                        */ // We have requested a missing skin
 // (Be warned: Skins are case sensitive)
 // So, now we must create a TEXT error message in it's place
 //console.log( "Status:"+xhttp.status+" ("+xhttp.statusText+")" );
 //console.log( HTMLProtect(xhttp.responseText) );
