         resolve()
       document.body.appendChild j3Tag
 
+  @loadDebuggerControl:(url)->
+    new Promise (resolve,reject)=>
+      xhr = new XMLHttpRequest()
+      xhr.open "GET",url,true
+      xhr.responseType = "text"
+      xhr.onload = () =>
+        document.querySelector ".debugControl"
+          .innerHTML = xhr.responseText
+        resolve()
+      xhr.onerror = (err) =>
+        reject();
+      xhr.send(null);
+
+  @loadStyle:(url)->
+    styleTag = document.createElement 'link'
+    styleTag.setAttribute 'rel','stylesheet'
+    styleTag.setAttribute 'type','text/css'
+    styleTag.setAttribute 'href',url
+    document.head.appendChild styleTag
+
   @loadjsScript:(url)->
     new Promise (resolve,reject)=>
       jsTag = document.createElement 'script'

class JThreePreviewController
  @loadedScriptCount = 0;

  @initJThree:(config,codeKey)->
   JThreePreviewController.loadj3Script config,codeKey
    .then ()=>
     JThreePreviewController.checkFinalize config,codeKey
     promise = Promise.resolve()
     config.codes[codeKey].js.forEach (v,i)=>
       url = v
       if !/https?\:\/\//.exec(v)
         url = config.codes[codeKey].root + v
       promise = promise
        .then ()=>
          JThreePreviewController.loadjsScript url
        .then ()=>
          JThreePreviewController.checkFinalize config,codeKey
      promise

  @loadj3Script:(config,codeKey)->
    new Promise (resolve,reject)=>

        resolve()
      document.body.appendChild jsTag

  @loadCompleted:(config,codeKey)->
      window.j3.lateStart();

module.exports = JThreePreviewController;
