function cGeneric() { this.Base64 = { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = this._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = this._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }; String.prototype.ltrim = function (clist) { // Wurde eine Zeichenkette mit den zu entfernenden // Zeichen übergeben? if (clist) // In diesem Fall sollen nicht Whitespaces, sondern // alle Zeichen aus dieser Liste gelöscht werden, // die am Anfang des Strings stehen. return this.replace (new RegExp ('^[' + clist + ']+'), ''); // Führende Whitespaces aus dem String entfernen // und das resultierende String zurückgeben. return this.replace (/^\s+/, ''); } String.prototype.rtrim = function (clist) { // Zeichenkette mit den zu entfernenden Zeichen angegeben? if (clist) // Zeichen aus der Liste, die am Ende des String stehen // löschen. return this.replace (new RegExp ('[' + clist + ']+$'), ''); // Whitespaces am Ende des Strings ertfernen und dann das Ergebnis // dieser Operation zurückgeben. return this.replace (/\s+$/, ''); } String.prototype.trim = function (clist) { // Wird der Parameter clist angegeben, so werden statt der Whitespaces // die in dieser Variablen angegebenen Zeichen "getrimmt". if (clist) // Führende und abschließende Zeichen aus der Liste entfernen. return this.ltrim (clist).rtrim (clist); // Whitespaces vom Anfang und am Ende entfernen return this.ltrim ().rtrim (); }; function trim (zeichenkette) { // Erst führende, dann Abschließende Whitespaces entfernen // und das Ergebnis dieser Operationen zurückliefern return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, ''); } /** * Load dynamic CSS File * * @par string filename CSS Filename */ this.loadCSS = function(filename) { var fileref=document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", filename); if (typeof fileref!="undefined" ) { document.getElementsByTagName("head")[0].appendChild(fileref); } }; /** * Load dynamic JS File * * @par string filename JS Filename */ this.loadJS = function(filename) { var fileref=document.createElement('script'); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", filename); if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref); };$.fn.clearForm = function() { return this.each(function() { var type = this.type, tag = this.tagName.toLowerCase(); if (tag == 'form') return $(':input',this).clearForm(); if (type == 'text' || type == 'password' || tag == 'textarea') this.value = ''; else if (type == 'checkbox' || type == 'radio') this.checked = false; else if (tag == 'select') this.selectedIndex = -1; }); };/* * LaTeX Editor - JavaScript to launch the CodeCogs Equation Editor * Copyright (C) 2009 William Bateman, 2008 Waipot Ngamsaad * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ // The following code was originally developed by Waipot Ngamsaad (Website: http://www.waipot.ngamsaad.name) // It has been updated and adapted by Will Bateman for www.CodeCogs.com function combine(a,b){ var ary=[]; for (var zxc0=0;zxc0 "); html=html.replace(/(^\\|[^\\]\\)\[(.*?[^\\])\\\]/g,"
\"$2\"
"); html=html.replace(/\\\$/g,"\$"); html=html.replace(/\\\\(\[|\])/g,"$1"); eqn[i].innerHTML = html; } } if (window.addEventListener) window.addEventListener("load", renderlatex, false); else if (window.attachEvent) window.attachEvent("onload", renderlatex); this.ajax = { /** * Posts and Loads an URL Content to a DIV * * @par string link Request URL * @par string form Form ID * @par string div DIV ID */ post : function(link, form, div) { $.post(link, $("#" + form).serialize(), function(data) { $('#' + div).html(data); }); }, /** * Loads an URL Content to a DIV * * @par string link Request URL * @par string div DIV ID */ load : function(link, div, height, callback) { if(!height) height = "135px"; marginTop = "59px"; if(height == "0") { marginTop = "0px"; height = "45px"; } $("#" + div).html( '
' ); $.ajax({ url: link, success: function(data) { $('#' + div).hide(); $('#' + div).html(data); $('#' + div).fadeIn(1000); if(callback) callback.call(); } }); } }; this.deleteElement = function(title, element, url) { if (confirm(title)) { $.get(url); $(element).fadeOut('slow', function() { $(element).remove(); }); } }; this.box = { changeTab : function(element) { element.parent().children().each( function (index) { $(this).removeClass("active"); } ); element.addClass("active"); element.blur(); element.hideFocus = false; // internet explorer element.css("outline", "none"); // mozilla return false; } }; this.ajaxPost = function(title, formName, success) { // attach a submit handler to the form $(formName).submit(function(event) { // stop form from submitting normally event.preventDefault(); // get some values from elements on the page: var $form = $( this ), url = $form.attr( 'action' ); // Send the data using post and put the results in a div $.post( url, $(this).serializeArray() , function( data ) { var resultData = eval('(' + data + ')'); if(resultData['error']) { $(formName + ' .message').html(''); $(formName + " .message").append("

" + title + ":

"); $(formName + " .message").append("
    "); $.each(resultData['error'], function(i, value) { $(formName + " .message").append("
  • " + value + "
  • "); }); $(formName + " .message").append("
"); $(formName + " .message").show(500); } if(resultData['result'] == "OK") { if(success) success.call(); } } ); }); }; } var generic = new cGeneric();