doodah/web/doodah.js
// Initislise skin with content configuration file

Initislise skin with content configuration file
Initislise skin with content configuration file
initialise( skin_config ) {
        console.log("  Loading skin config");
        for (var section in skin_config ){
            console.log( "  SECTION: "+section);
            if( typeof skin_config[section]!=="object" ) continue;
            var section_name = section.toLowerCase();
            section_name = section_name.replace("\\","/");
            console.log( "  "+section_name  );
            switch( section_name ){
            case 'doodah':
            case 'rainmeter':
                this.config.update = ExtractNumber( skin_config[section], 'update', 1000 );
                if( this.config.update<500 ) this.config.update = 500;
                this.config.updatedivider = ExtractNumber( skin_config[section], 'updatedivider', 1 );
                this.config.dynamicwindowsize = ExtractNumber( skin_config[section], 'dynamicwindowsize', 0 );
                this.config.skinwidth = ExtractNumber( skin_config[section], 'skinwidth', 100 );
                this.config.skinheight = ExtractNumber( skin_config[section], 'skinheight', 30 );
                this.config.background= ExtractText( skin_config[section], 'background', "" );
                this.config.backgroundmode = ExtractNumber( skin_config[section], 'backgroundmode', 1 );
                this.config.solidcolor = ExtractColor( skin_config[section], 'solidcolor', undefined );
                this.config.solidcolor2 = ExtractColor( skin_config[section], 'solidcolor2', undefined );
                this.config.gradientangle = ExtractNumber( skin_config[section], 'gradientangle', 90 );
                if( skin_config[section]['stylesheet'] ) {
                    console.log( "LOADING STYLESHEET: "+skin_config[section]['stylesheet'] );
                    var head = document.getElementsByTagName('head')[0];  
                    var link = document.createElement('link'); 
                    link.rel = 'stylesheet';  
                    link.type = 'text/css'; 
                    link.href = this.name+"/"+skin_config[section]['stylesheet'];  
                    head.appendChild(link);
                } else {
                    console.log("NO STYLESHEET");
                }
                break;
            case 'metadata':
                this.Meta = skin_config[section];
                break;
            case 'variables':
                break;
            default:
                if( skin_config[section].meter ) {
                    console.log("Meter '"+section+"' ("+section_name+"): "+skin_config[section].meter);
                    var meter = CreateMeter( section_name, skin_config[section], this );
                    if(meter) {
                        this.meters[section_name] = meter;
                        break;
                    }
                    console.log( "ERROR CREATING METER" );
                    break;
                }
                if( skin_config[section].measure ) {
                    console.log("Measure '"+section+"': "+skin_config[section].measure);
                    var measuretype = skin_config[section].measure.toLowerCase();
                    switch( measuretype ){
                    case 'calc':
                        console.log("Creating calc measure");
                        break;
                    default:
                        console.log("# Unknown measure type "+measuretype);
                    }
                }
            }
            this.has_loaded = true;     
        }
        this.xpos = this.config.windowx;
        this.ypos = this.config.windowy;
        this.width = this.config.skinwidth;
        this.height = this.config.skinheight;
        this.dom.style.left = this.xpos+"px";
		this.dom.style.top = this.ypos+"px";
        this.dom.style.height = this.height+"px";
		this.dom.style.width = this.width+"px";
        if( this.config.dynamicwindowsize==0 ) {
            this.dom.classList.add("dynamicwindowsize0");
        }
        this.Update(0);
    }
initialise ( skin_config ) { console . log ( "  Loading skin config" ) ; for ( var section in skin_config ) { console . log ( "  SECTION: " + section ) ; if ( typeof skin_config [ section ] !== "object" ) continue ; var section_name = section . toLowerCase ( ) ; section_name = section_name . replace ( "\\" , "/" ) ; console . log ( "  " + section_name ) ; switch ( section_name ) { case 'doodah' : case 'rainmeter' : this . config . update = ExtractNumber ( skin_config [ section ] , 'update' , 1000 ) ; if ( this . config . update < 500 ) this . config . update = 500 ; this . config . updatedivider = ExtractNumber ( skin_config [ section ] , 'updatedivider' , 1 ) ; this . config . dynamicwindowsize = ExtractNumber ( skin_config [ section ] , 'dynamicwindowsize' , 0 ) ; this . config . skinwidth = ExtractNumber ( skin_config [ section ] , 'skinwidth' , 100 ) ; this . config . skinheight = ExtractNumber ( skin_config [ section ] , 'skinheight' , 30 ) ; this . config . background = ExtractText ( skin_config [ section ] , 'background' , "" ) ; this . config . backgroundmode = ExtractNumber ( skin_config [ section ] , 'backgroundmode' , 1 ) ; this . config . solidcolor = ExtractColor ( skin_config [ section ] , 'solidcolor' , undefined ) ; this . config . solidcolor2 = ExtractColor ( skin_config [ section ] , 'solidcolor2' , undefined ) ; this . config . gradientangle = ExtractNumber ( skin_config [ section ] , 'gradientangle' , 90 ) ; if ( skin_config [ section ] [ 'stylesheet' ] ) { console . log ( "LOADING STYLESHEET: " + skin_config [ section ] [ 'stylesheet' ] ) ; var head = document . getElementsByTagName ( 'head' ) [ 0 ] ; var link = document . createElement ( 'link' ) ; link . rel = 'stylesheet' ; link . type = 'text/css' ; link . href = this . name + "/" + skin_config [ section ] [ 'stylesheet' ] ; head . appendChild ( link ) ; } else { console . log ( "NO STYLESHEET" ) ; } break ; case 'metadata' : this . Meta = skin_config [ section ] ; break ; case 'variables' : break ; default : if ( skin_config [ section ] . meter ) { console . log ( "Meter '" + section + "' (" + section_name + "): " + skin_config [ section ] . meter ) ; var meter = CreateMeter ( section_name , skin_config [ section ] , this ) ; if ( meter ) { this . meters [ section_name ] = meter ; break ; } console . log ( "ERROR CREATING METER" ) ; break ; } if ( skin_config [ section ] . measure ) { console . log ( "Measure '" + section + "': " + skin_config [ section ] . measure ) ; var measuretype = skin_config [ section ] . measure . toLowerCase ( ) ; switch ( measuretype ) { case 'calc' : console . log ( "Creating calc measure" ) ; break ; default : console . log ( "# Unknown measure type " + measuretype ) ; } } } this . has_loaded = true ; } this . xpos = this . config . windowx ; this . ypos = this . config . windowy ; this . width = this . config . skinwidth ; this . height = this . config . skinheight ; this . dom . style . left = this . xpos + "px" ; this . dom . style . top = this . ypos + "px" ; this . dom . style . height = this . height + "px" ; this . dom . style . width = this . width + "px" ; if ( this . config . dynamicwindowsize == 0 ) { this . dom . classList . add ( "dynamicwindowsize0" ) ; } this . Update ( 0 ) ; }
Initislise skin with content configuration file
Initislise skin with content configuration file
//console.log(skin_config);
 // Ignore anything that is not in a section:
 // Convert to lowercase and replace backslashes!
 // Extract Skin configuration
 //
 //
 //https://www.w3schools.com/css/css3_gradients.asp
 // Does skin have it's own stylesheet?
 // Add LINK into header
 //this.Variables = skin_config[section];
 // Is section a METER?{
 //AllMeters[name+"."+section_name]=meter;
 // Is section a MEASURE?
 //var measure_name = section.toLowerCase();
 // Add a new Measure to the list
 //var measure = new Measure_Calc( this, section_name, definition );
 //this.measures[section_name] = measure;
 //AllMeasures[name+"."+section_name]=measure;
 // Meters, Measures or Variables etc...
 // Mark skin as Loaded
 // Update the skin
 //console.log( "Calling update");
 //this.Update();
 //console.log( "Update finished");
 //console.log( "sections finished");
 // Set the skin values
 // Update DOM to match object
 // Set fixed size/width skins to truncate overay content
