message this user

Name

getscript

Global

function getscript(url,cb) {
 var script = document.createElement('script');
 script.setAttribute('src',url);
 script.setAttribute('type','text/javascript');
 script.setAttribute('charset','utf-8');
 script.addEventListener('load',e=>{
  cb(null,e);
 });
 document.head.appendChild(script);
}

function getscripts(urls,cb) {
 var waitcount=urls.length;
 urls.forEach(u=>{
  getscript(u,()=>{
   if(--waitcount===0) {
    cb();
   }
  })
 })
}

function getcss(url,cb) {
 var link = document.createElement('link');
 link.setAttribute('rel','stylesheet');
 link.setAttribute('type','text/css');
 link.setAttribute('href',url);
 if(cb) {
  link.addEventListener('load',e=>{
   cb(null,e);
  });
 }
 document.head.appendChild(link);
}

function add_style(cssRules,cb) {
 var styleElement = document.createElement('style');
 styleElement.appendChild(document.createTextNode(cssRules));
 document.head.appendChild(styleElement);
 if(cb) {
  styleElement.addEventListener('load',cb);
 }
}

Init

startChat('chat-server');

Build

chat