Team:Tongji China/tags/v0.2/js/meetup.js

$(document).ready(function () {

   function readyLoaded() {
       let a = document.getElementById("pre_loader");
       a.style.opacity = 1;
       function modOpacity() {
           a.style.opacity -= 0.02;
           if (a.style.opacity > 0) {
               setTimeout(modOpacity, 10);
           } else {
               a.parentElement.removeChild(a);
           }
       }
       setTimeout(modOpacity, 10);
   }
   $.ajax({
       url: "https://2019.igem.org/wiki/index.php?title=Team:Tongji_China/tags/v0.2/json/meetup.json&action=raw&ctype=text/css",
       dataType: "json",
       success: function (msg) {
           document.getElementById("page_header").innerHTML = msg.header;
           document.getElementById("page_container").innerHTML = msg.content;
           document.getElementById("banner").style = "padding:0";
           // load style
           document.querySelectorAll("link").forEach(function (each) {
               if (each.href.indexOf("load.php") > 1) {
                   let parent = each.parentElement
                   parent.removeChild(each)
                   let newLink = document.createElement("link")
                   newLink.rel = "stylesheet"
                   newLink.onload = function () { readyLoaded() }
                   newLink.href = "https://2019.igem.org/wiki/index.php?title=Team:Tongji_China/resource/css/overwrite.css&action=raw&ctype=text/css";
                   parent.append(newLink)
               }
           });
       }
   })

});