Sha256: 2483bc91a554cc97d22d59427aee43db3d26530375750ec9d3b6a53a917f7840

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

// -*- c++ -*-
// 
// Copyright (C) 2003-2005 Kouichirou Eto
//     All rights reserved.
//     This is free software with ABSOLUTELY NO WARRANTY.
// 
// You can redistribute it and/or modify it under the terms of 
// the GNU General Public License version 2.
// 

// ============================== xmlhttp
function createXmlHttp() {
  var x;
  try {
    x = new ActiveXObject("Msxml2.XMLHTTP");
    return x;
  } catch (e) {
    try {
      x = new ActiveXObject("Microsoft.XMLHTTP");
      return x;
    } catch (E) {
      try {
	if (typeof XMLHttpRequest != 'undefined') {
	  x = new XMLHttpRequest();
	  return x;
	}
      } catch (E) {
	return false;
      }
    }
  }
  return false;
}

// ============================== monitor
function Monitor(pagename) {
  this.pagename = pagename;
  this.xmlhttp = null;

  this.toString = function() {
    return "Monitor("+this.pagename+")";
  }

  this.getting_p = function() {
    if (! this.xmlhttp) return;
    var s = this.xmlhttp.readyState;
    return (s != 4);
  }

  this.get = function() {
    //g_debug.p("start get "+this.pagename);
    var div = getById("body");
    if (!div) return;

    var url = this.pagename+".monitor";
    var xmlhttp = createXmlHttp();
    this.xmlhttp = xmlhttp;
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4) {
	if (xmlhttp.status == 200) {
	  div.innerHTML = xmlhttp.responseText;
	//g_debug.p("set html");
	  g_monitor_env.start();
	}
      }
    }
    xmlhttp.send(null);
  }
}

// ==================== monitor env
function MonitorEnv() {
  this.monitors = [];

  this.add = function(pagename) {
    var mon = new Monitor(pagename);
    this.monitors.push(mon);
  }

  this.start = function() {
    for (var i=0; i < this.monitors.length; i++) {
      var mon = this.monitors[i];
      if (!mon.getting_p()) {
	mon.get();
      }
    }
  }
}

var g_monitor_env;
if (typeof g_monitor_env == 'undefined') {
  g_monitor_env = new MonitorEnv();
}

// end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qwik2md-2.0.1 vendor/qwik/share/theme/js/monitor.js
qwik2md-2.0.0 vendor/qwik/share/theme/js/monitor.js
qwik2md-1.0.2 vendor/qwik/share/theme/js/monitor.js