User:RandomStringOfCharacters/Scripts/DefconBar.js

addOnloadHook(defcon_init); function defcon_init(){ var link_div = document.createElement('div'); link_div.className = 'body'; var div =

addOnloadHook(defcon_init);

function defcon_init(){

  var link_div = document.createElement('div');
  link_div.className = 'body';
  var div = document.createElement('div');
  div.setAttribute('id', 'p-defcon');
  div.className = 'portal';
  var heading = document.createElement('h5');
  heading.appendChild(document.createTextNode('Defcon'));
  div.appendChild(heading);
  div.appendChild(link_div);
 
  // enable link
  var p = document.createElement('p');
  p.style.fontSize = 'x-small';
  p.style.margin = '0px';
  var a = document.createElement('a');
  a.appendChild(document.createTextNode('Check Defcon'));
  a.onclick = defcon_make_req;
  p.appendChild(a);
  link_div.appendChild(p);
 
  // now replace the div
  var old_div = document.getElementById('p-defcon');
  var side_col = document.getElementById('panel');
  if (old_div != null) {
    side_col.replaceChild(div, old_div);
  } else {
    var node = document.getElementById('p-interaction');
    side_col.insertBefore(div, node);


}}

function defcon_make_req(){

  try {
    npp_http = new XMLHttpRequest();
 
  } catch (e) {
    try {
      npp_http = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        npp_http = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        return false;
      }
    }
  }
 
  npp_http.onreadystatechange = function() {
    if(npp_http.readyState == 4) defcon_ajax_response();
  }

  npp_http.open("GET", "http://en.wikipedia.org/wiki/Wikipedia:Defcon", true);
  npp_http.send(null);


}

function defcon_ajax_response() {


  var div = document.createElement('div');
  div.setAttribute('id', 'p-defcon');
  div.className = 'portal expanded';
  var heading = document.createElement('h5');
  heading.appendChild(document.createTextNode('Defcon'));
  div.appendChild(heading);

  var link_div = document.createElement('div');
  link_div.className = 'body';
  link_div.style.display = "block";

var level = 'lol';

//re = /\|info =(.*)\|align/ ;



if (npp_http.responseText.indexOf('Dc_one') == -1){}else{
level = 'Level 1';
}
if (npp_http.responseText.indexOf('Dc_two') == -1){}else{
level = 'Level 2';
}
if (npp_http.responseText.indexOf('Dc_three') == -1){}else{
level = 'Level 3';
}
if (npp_http.responseText.indexOf('Dc_four') == -1){}else{
level = 'Level 4';
}
if (npp_http.responseText.indexOf('Dc_five') == -1){}else{
level = 'Level 5';
}

var mymatch = /\|info =(.*)\|align/.exec(npp_http.responseText);

//level = level + mymatch.length;

  var p = document.createElement('p');
  p.style.fontSize = 'x-small';
  p.style.margin = '0px';
  p.style.display = 'block';

p.appendChild(document.createTextNode(level));

link_div.appendChild(p);

div.appendChild(link_div);

  var old_div = document.getElementById('p-defcon');
  var side_col = document.getElementById('panel');
  if (old_div != null) {
    side_col.replaceChild(div, old_div);
  } else {
    var node = document.getElementById('p-interaction');
    side_col.insertBefore(div, node);
  }


 }

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.