JSFiddle - React, Tailwind, and code Playground

by ph34r

JavaScript

/**
 * Define a framework for plugins
 */
var framework = function () {};

framework.prototype.start = function (arrayOfPluginObject) {
    console.log("started");

    for (var i = 0; i < arrayOfPluginObject.length; i++) {

        var currentPlugin = arrayOfPluginObject[i];
        //var pluginClassName = window[currentPlugin.pluginName];console.log(pluginClassName);
        //var instantiation = framework.prototype.bind.apply(pluginClassName, arguments);

        //var test = new (window["plugin1"]().prototype.bind.apply("plugin1", ["a", "b"]));
        //console.log(test);


        //instantiation.getID();
    }

};

/**
 * Define a plugin for the framework
 */
var plugin1 = function (arg1, arg2) {

    this.uniqueID = Math.floor((Math.random() * 100) + 1);
    alert("plugin1 instantiated");

    console.log("plugin1 args" + arg1 + "" + arg2);

};

plugin1.prototype.getID = function () {
    alert(this.uniqueID);
}

/**
 * Define an array of plugin objects
 */
var plugins = [{
    pluginName: "plugin1",
    args: ["hi", "sir"]
}];

/**
 * Now test it all out
 */

var test = new framework();

console.log(this['plugin1']);
//test.start(plugins);