Source code for /src/view.js.txt

//======================================================================//
// Author: Mark Qian <markqian@hotmail.com>                             //
// WWW: http://www.coolshare.com                                        //
// Copyright (c) 2006, Mark Qian                                        //
//                                                                      //
// You must contact Mark Qian to get a permission of use                //
// in case you want to make any use of the codes except viewing it     //
// on Mark's site.                                                      //
//======================================================================//


function view(s) {
  var w = window.open("about:blank", "ViewWin", "left=20,top=20,width=630,height=550,toolbar=1,resizable=0");

  w.document.open();
  w.document.write("<table><tr><td><textarea style=\"width:600; height:500\">"+s+"</textarea></td></tr><tr><td align=center><input type=button value=\"OK\" onclick=\"window.close()\"></td></tr></table>");

}

function remoteView(url) {
  var viewRemote = new ViewRemote();
  viewRemote.view(url);
}

function ViewRemote() {
	  
	  this.view = function(url) {
	      this.getUrl(url, this.cb);
	  }
	  var self = this;
	  this.cb = function(status, headers, text) {
	    view(text);
	  }
  
	  this.getXmlHttp = function(){
		  var xmlhttp;
		  try {
		    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		  } catch (e) {
		    try {
		      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		    } catch (E) {
		      xmlhttp = false;
		    }
		  }
		  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		    xmlhttp = new XMLHttpRequest();
		  }
		  return xmlhttp;
	}

    ////////////////// a closure is form to preserve self /////////////////
	this.getUrl = function(url, cb) {
	  var xmlhttp = this.getXmlHttp();
	  xmlhttp.open("GET", url);
	  xmlhttp.onreadystatechange = function() {
	    if (xmlhttp.readyState == 4) {
	      self.cb(xmlhttp.status, 
	         xmlhttp.getAllResponseHeaders(), 
	         xmlhttp.responseText);
	      }
	  }
	  xmlhttp.send(null);
	}

}