JSFiddle - React, Tailwind, and code Playground

by grammakov

JavaScript

var $all = $('*');

//plugin information

var plugins = {

    'plugin1' : {
            'class': 'blue',
            'path': 'http://blue'
        },
    
    'plugin2' : {
        'class': 'orange',
        'path': 'http://orange'
        },

    'plugin3' : {
        'class': 'green',
        'path': 'http://green'
        }
};

pluginsToActivate = [];

    //iterate through every element on page and check if it has a corresponding                 class

for (var i in plugins) if (plugins.hasOwnProperty(i)) {
    if ( $all.hasClass(plugins[i].class) ) {
        console.log('we have ' + plugins[i].class);
    } else { console.info('we do not have ' + plugins[i].class) }
}



//ok we now have an array with classes

//alert(scriptsToActivate);

if ($all.hasClass('blue')) { 
 $('div.blue').addClass('blue-active');
}

if ($all.hasClass('orange')) { 
 $('div.orange').addClass('orange-active');
}

if ($all.hasClass('green')) { 
    $('div.green').addClass('green-active');
}