// Generated by CoffeeScript 1.12.7
var RemotePlugin,
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

RemotePlugin = (function(superClass) {
  extend(RemotePlugin, superClass);

  function RemotePlugin() {
    return RemotePlugin.__super__.constructor.apply(this, arguments);
  }

  return RemotePlugin;

})(CUI.Element);

ez5.session_ready((function(_this) {
  return function() {
    var config, cssNode, css_loc, css_url, i, inst, js_loc, js_url, len, ref, ref1, scriptNode;
    config = ez5.session.getBaseConfig("plugin", "easydb-remote-plugin");
    config = config.system || config;
    ref1 = ((ref = config.webfrontend_remote_plugin) != null ? ref.instances : void 0) || [];
    for (i = 0, len = ref1.length; i < len; i++) {
      inst = ref1[i];
      js_url = inst.js_url;
      js_loc = CUI.parseLocation(js_url);
      if (!(js_loc != null ? js_loc.href : void 0)) {
        console.warn("Unable to parse location:", js_url, inst);
      } else {
        scriptNode = CUI.dom.element("SCRIPT", {
          src: js_loc.href,
          type: "text/javascript",
          charset: "utf-8"
        });
        console.info("RemotePlugin: Javascript:", js_loc.href);
        document.head.appendChild(scriptNode);
      }
      css_url = inst.css_url;
      css_loc = CUI.parseLocation(css_url);
      if (!(css_loc != null ? css_loc.href : void 0)) {
        console.warn("Unable to parse location:", css_url, inst);
      } else {
        cssNode = CUI.dom.element("LINK", {
          rel: "stylesheet",
          charset: "utf-8",
          href: css_loc.href
        });
        console.info("RemotePlugin: CSS:", css_loc.href);
        document.head.appendChild(cssNode);
      }
    }
  };
})(this));
