added sourcefiles for web frontend
authorunknown <p1@.(none)>
Mon, 11 May 2009 18:03:40 +0000 (20:03 +0200)
committerunknown <p1@.(none)>
Mon, 11 May 2009 18:03:40 +0000 (20:03 +0200)
64 files changed:
web/css/RowEditor.css [new file with mode: 0644]
web/img/icons/accept.png [new file with mode: 0644]
web/img/icons/cross.png [new file with mode: 0644]
web/img/icons/disk.png [new file with mode: 0644]
web/img/icons/magnifier.png [new file with mode: 0644]
web/img/icons/refresh.gif [new file with mode: 0644]
web/img/icons/user_add.png [new file with mode: 0644]
web/img/row-editor-bg.gif [new file with mode: 0644]
web/img/row-editor-btns.gif [new file with mode: 0644]
web/index.php [new file with mode: 0644]
web/js/RowEditor.js [new file with mode: 0644]
web/js/codepress/codepress.css [new file with mode: 0644]
web/js/codepress/codepress.html [new file with mode: 0644]
web/js/codepress/codepress.js [new file with mode: 0644]
web/js/codepress/engines/gecko.js [new file with mode: 0644]
web/js/codepress/engines/khtml.js [new file with mode: 0644]
web/js/codepress/engines/msie.js [new file with mode: 0644]
web/js/codepress/engines/older.js [new file with mode: 0644]
web/js/codepress/engines/opera.js [new file with mode: 0644]
web/js/codepress/images/line-numbers.png [new file with mode: 0644]
web/js/codepress/index.html [new file with mode: 0644]
web/js/codepress/languages/asp.css [new file with mode: 0644]
web/js/codepress/languages/asp.js [new file with mode: 0644]
web/js/codepress/languages/autoit.css [new file with mode: 0644]
web/js/codepress/languages/autoit.js [new file with mode: 0644]
web/js/codepress/languages/csharp.css [new file with mode: 0644]
web/js/codepress/languages/csharp.js [new file with mode: 0644]
web/js/codepress/languages/css.css [new file with mode: 0644]
web/js/codepress/languages/css.js [new file with mode: 0644]
web/js/codepress/languages/generic.css [new file with mode: 0644]
web/js/codepress/languages/generic.js [new file with mode: 0644]
web/js/codepress/languages/html.css [new file with mode: 0644]
web/js/codepress/languages/html.js [new file with mode: 0644]
web/js/codepress/languages/java.css [new file with mode: 0644]
web/js/codepress/languages/java.js [new file with mode: 0644]
web/js/codepress/languages/javascript.css [new file with mode: 0644]
web/js/codepress/languages/javascript.js [new file with mode: 0644]
web/js/codepress/languages/perl.css [new file with mode: 0644]
web/js/codepress/languages/perl.js [new file with mode: 0644]
web/js/codepress/languages/php.css [new file with mode: 0644]
web/js/codepress/languages/php.js [new file with mode: 0644]
web/js/codepress/languages/ruby.css [new file with mode: 0644]
web/js/codepress/languages/ruby.js [new file with mode: 0644]
web/js/codepress/languages/sql.css [new file with mode: 0644]
web/js/codepress/languages/sql.js [new file with mode: 0644]
web/js/codepress/languages/text.css [new file with mode: 0644]
web/js/codepress/languages/text.js [new file with mode: 0644]
web/js/codepress/languages/vbscript.css [new file with mode: 0644]
web/js/codepress/languages/vbscript.js [new file with mode: 0644]
web/js/codepress/languages/xsl.css [new file with mode: 0644]
web/js/codepress/languages/xsl.js [new file with mode: 0644]
web/js/codepress/license.txt [new file with mode: 0644]
web/js/communication.js [new file with mode: 0644]
web/js/md5.js [new file with mode: 0644]
web/php/communication.php [new file with mode: 0644]
web/php/page/adminnav.pg [new file with mode: 0644]
web/php/page/createplant.pg [new file with mode: 0644]
web/php/page/debug.pg [new file with mode: 0644]
web/php/page/myplants.pg [new file with mode: 0644]
web/php/page/nav.pg [new file with mode: 0644]
web/php/page/testplant.pg [new file with mode: 0644]
web/php/phpinfo.php [new file with mode: 0644]
web/setup/script00.sql [new file with mode: 0644]
web/test.html [new file with mode: 0644]

diff --git a/web/css/RowEditor.css b/web/css/RowEditor.css
new file mode 100644 (file)
index 0000000..d8cede7
--- /dev/null
@@ -0,0 +1,38 @@
+.x-row-editor-header {
+    height:2px;
+    overflow:hidden;
+    background: transparent url(../img/row-editor-bg.gif) repeat-x 0 0;
+}
+.x-row-editor-footer {
+    height:2px;
+    overflow:hidden;
+    background: transparent url(../img/row-editor-bg.gif) repeat-x 0 -2px;
+}
+.ext-ie .x-row-editor-footer {
+           margin-top:-1px;
+       }
+
+.x-row-editor-body {
+    overflow:hidden;
+    zoom:1;
+    background: #ebf2fb;
+    padding-top:2px;
+}
+.x-row-editor .x-btns {
+    position:absolute;
+    top:28px;
+    left:20px;
+    padding-left:5px;
+    background: transparent url(../img/row-editor-btns.gif) no-repeat 0 0;
+}
+.x-row-editor .x-btns .x-plain-bwrap {
+    padding-right:5px;
+    background: transparent url(../img/row-editor-btns.gif) no-repeat right -31px;
+}
+.x-row-editor .x-btns .x-plain-body {
+    background: transparent url(../img/row-editor-btns.gif) repeat-x 0 -62px;
+    height:31px;
+}
+.x-row-editor .x-btns .x-table-layout-cell {
+    padding:3px;
+}
diff --git a/web/img/icons/accept.png b/web/img/icons/accept.png
new file mode 100644 (file)
index 0000000..89c8129
Binary files /dev/null and b/web/img/icons/accept.png differ
diff --git a/web/img/icons/cross.png b/web/img/icons/cross.png
new file mode 100644 (file)
index 0000000..1514d51
Binary files /dev/null and b/web/img/icons/cross.png differ
diff --git a/web/img/icons/disk.png b/web/img/icons/disk.png
new file mode 100644 (file)
index 0000000..99d532e
Binary files /dev/null and b/web/img/icons/disk.png differ
diff --git a/web/img/icons/magnifier.png b/web/img/icons/magnifier.png
new file mode 100644 (file)
index 0000000..cf3d97f
Binary files /dev/null and b/web/img/icons/magnifier.png differ
diff --git a/web/img/icons/refresh.gif b/web/img/icons/refresh.gif
new file mode 100644 (file)
index 0000000..110f684
Binary files /dev/null and b/web/img/icons/refresh.gif differ
diff --git a/web/img/icons/user_add.png b/web/img/icons/user_add.png
new file mode 100644 (file)
index 0000000..deae99b
Binary files /dev/null and b/web/img/icons/user_add.png differ
diff --git a/web/img/row-editor-bg.gif b/web/img/row-editor-bg.gif
new file mode 100644 (file)
index 0000000..03b3b2c
Binary files /dev/null and b/web/img/row-editor-bg.gif differ
diff --git a/web/img/row-editor-btns.gif b/web/img/row-editor-btns.gif
new file mode 100644 (file)
index 0000000..10668ed
Binary files /dev/null and b/web/img/row-editor-btns.gif differ
diff --git a/web/index.php b/web/index.php
new file mode 100644 (file)
index 0000000..d5e29c2
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+
+//require("php/communication.php");
+
+//$res = GetPlantList();
+//echo $res;
+
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html>
+       <head>
+               <title>L-Seed</title>
+
+               <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
+               <link rel="stylesheet" type="text/css" href="ext/resources/css/xtheme-slate.css" />
+               <link rel="stylesheet" type="text/css" href="css/RowEditor.css" />
+               <style type="text/css">
+                       #loading {
+                         position: absolute;
+                         left: 45%;
+                         top: 40%;
+                         margin-left: -45px;
+                         padding: 2px;
+                         z-index: 20001;
+                         height: auto;
+                         border: 1px solid #ccc;
+                       }
+
+                       #loading a {
+                         color: #225588;
+                       }
+
+                       #loading .loading-indicator {
+                         background: white;
+                         color: #444;
+                         font: bold 13px tahoma, arial, helvetica;
+                         padding: 10px;
+                         margin: 0;
+                         height: auto;
+                         width:130px;
+                       }
+
+                       #loading .loading-indicator img {
+                         margin-right:8px;
+                         float:left;
+                         vertical-align:top;
+                       }
+
+                       #loading-msg {
+                         font: normal 10px arial, tahoma, sans-serif;
+                       }
+
+               </style>
+
+               <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
+               <script type="text/javascript" src="ext/ext-all-debug.js"></script>
+               <script type="text/javascript" src="js/md5.js"></script>
+               <script type="text/javascript" src="js/communication.js"></script>
+               <script type="text/javascript" src="js/codepress/codepress.js"></script>
+               <script type="text/javascript" src="js/RowEditor.js"></script>
+               <script type="text/javascript">
+                       communication = new Lseed.Communication();
+                       editor = new Lseed.Editor();
+
+                       Ext.onReady(function() {
+                               Ext.QuickTips.init();
+
+                               new Ext.Viewport({
+                                   layout: 'border'
+                                   ,items: [{
+                                               region: 'north'
+                                               ,html: '<h1 class="x-panel-header">L-Seed Manager</h1>'
+                                               ,autoHeight: true
+                                               ,border: false
+                                               ,margins: '0 0 5 0'
+                                       },{
+                                               id: 'navTree'
+                                               ,region: 'west'
+                                               ,collapsible: true
+                                               ,title: 'Navigation'
+                                               ,xtype: 'treepanel'
+                                               ,width: 200
+                                               ,autoScroll: true
+                                               ,split: true
+                                               ,tbar: [{
+                                                       xtype: "button"
+                                                       ,text: "Logout"
+                                                       ,handler: communication.logout.createDelegate(communication)
+                                               }]
+                                               ,loader: new Ext.tree.TreeLoader()
+                                               ,root: new Ext.tree.AsyncTreeNode({
+                                                       expanded: true
+                                                       ,children: [{
+                                                               text: 'Start'
+                                                               ,leaf: true
+                                                       }]
+                                               })
+                                               ,rootVisible: false
+                                               ,listeners: {
+                                                       click: function(obj) {
+                                                               communication.showTab(obj.attributes.id);
+                                                       }
+                                               }
+                                               ,bbar: [{
+                                                       id: 'loadPageProgressbar'
+                                                       ,xtype: 'progress'
+                                               }]
+                                       },{
+                                               id: 'contentTabPanel'
+                                               ,region: 'center'
+                                               ,xtype: 'tabpanel'
+                                               ,activeTab: 0
+                                               ,items: [{
+                                                       id: 'ContentPanel_start'
+                                                       ,style: 'padding: 5px;'
+                                                       ,title: 'Start'
+                                                       ,html: 'Willkommen beim L-Seed Manager.'
+                                               }]
+                                       },{
+                                               region: 'south'
+                                               ,title: 'Statusanzeige'
+                                               ,collapsible: true
+                                               ,collapsed: true
+                                               ,html: 'Statusanzeige'
+                                               ,split: true
+                                               ,height: 100
+                                               ,minHeight: 100
+                                       }]
+                               });
+
+                               communication.Init(editor);
+                       });
+               </script>
+       </head>
+       <body style="overflow: hidden">
+
+
+               <div id="content"/>
+       </body>
+</html>
\ No newline at end of file
diff --git a/web/js/RowEditor.js b/web/js/RowEditor.js
new file mode 100644 (file)
index 0000000..ba8e72f
--- /dev/null
@@ -0,0 +1,475 @@
+/*
+ * Ext JS Library 3.0 RC1
+ * Copyright(c) 2006-2009, Ext JS, LLC.
+ * licensing@extjs.com
+ * 
+ * http://extjs.com/license
+ */
+
+/*
+ * Ext JS Library 3.0 Pre-alpha
+ * Copyright(c) 2006-2008, Ext JS, LLC.
+ * licensing@extjs.com
+ * 
+ * http://extjs.com/license
+ */
+
+Ext.ux.RowEditor = Ext.extend(Ext.Panel, {
+    floating: true,
+    shadow: false,
+    layout: 'hbox',
+    cls: 'x-small-editor',
+    buttonAlign: 'center',
+    baseCls: 'x-row-editor',
+    elements: 'header,footer,body',
+    frameWidth: 5,
+    buttonPad: 3,
+    clicksToEdit: 'auto',
+    monitorValid: true,
+    focusDelay: 250,
+    errorSummary: true,
+
+    defaults: {
+        normalWidth: true
+    },
+
+    initComponent: function(){
+        Ext.ux.RowEditor.superclass.initComponent.call(this);
+        this.addEvents('beforeedit', 'validateedit', 'afteredit');
+    },
+
+    init: function(grid){
+        this.grid = grid;
+        this.ownerCt = grid;
+        if(this.clicksToEdit == 2){
+            this.grid.on('rowdblclick', this.onRowDblClick, this);
+        }else{
+            this.grid.on('rowclick', this.onRowClick, this);
+        }
+        this.grid.on('keydown', this.onGridKey, this);
+        this.grid.on('columnresize', this.verifyLayout, this);
+        this.grid.on('columnmove', this.onColumnMove, this);
+        this.grid.on('bodyscroll', this.positionButtons, this, {buffer: 250});
+        this.grid.getColumnModel().on('hiddenchange', this.verifyLayout, this, {delay:1});
+        var view = grid.getView();
+        view.on('refresh', this.stopEditing.createDelegate(this, []));
+    },
+
+    onColumnMove: function(){
+        this.initFields();
+        this.verifyLayout();
+    },
+    
+    isDirty: function(){
+        var dirty;
+        this.items.each(function(f){
+            if(String(this.values[f.id]) != String(f.getValue())){
+                dirty = true;
+                return false;
+            }
+        }, this);
+        return dirty;
+    },
+
+    startEditing: function(rowIndex, doFocus){
+        if(this.editing && this.isDirty()){
+            this.showTooltip('You need to commit or cancel your changes');
+            return;
+        }
+        this.editing = true;
+        if(typeof rowIndex == 'object'){
+            rowIndex = this.grid.getStore().indexOf(rowIndex);
+        }
+        if(this.fireEvent('beforedit', this, rowIndex) !== false){
+            var g = this.grid, view = g.getView();
+            var row = view.getRow(rowIndex);
+            var record = g.store.getAt(rowIndex);
+            this.record = record;
+            this.rowIndex = rowIndex;
+            this.values = {};
+            if(!this.rendered){
+                this.render(view.getEditorParent());
+            }
+            var w = Ext.fly(row).getWidth();
+            this.setSize(w);
+            if(!this.initialized){
+                this.initFields();
+            }
+            var cm = g.colModel, fields = this.items.items, f, val;
+            for(var i = 0, len = cm.getColumnCount(); i < len; i++){
+                val = this.preEditValue(record, cm.getDataIndex(i));
+                f = fields[i];
+                f.setValue(val);
+                this.values[f.id] = val || '';
+            }
+            this.verifyLayout(true);
+            if(!this.isVisible()){
+                this.setPagePosition(Ext.fly(row).getXY());
+            } else{
+                this.el.setXY(Ext.fly(row).getXY(), {duration:.15});
+            }
+            if(!this.isVisible()){
+                this.show();
+                if(Ext.isIE){
+                    this.doLayout();
+                }
+            }
+            if(doFocus !== false){
+                this.doFocus.defer(this.focusDelay, this);
+            }
+        }
+    },
+
+    stopEditing : function(saveChanges){
+        this.editing = false;
+        if(!this.isVisible()){
+            return;
+        }
+        if(saveChanges === false || !this.isValid()){
+            this.hide();
+            return;
+        }
+        var changes = {}, r = this.record, hasChange = false;
+        var cm = this.grid.colModel, fields = this.items.items;
+        for(var i = 0, len = cm.getColumnCount(); i < len; i++){
+            if(!cm.isHidden(i)){
+                var dindex = cm.getDataIndex(i);
+                var oldValue = r.data[dindex];
+                var value = this.postEditValue(fields[i].getValue(), oldValue, r, dindex);
+                if(String(oldValue) !== String(value)){
+                    changes[dindex] = value;
+                    hasChange = true;
+                }
+            }
+        }
+        if(hasChange && this.fireEvent('validateedit', this, changes, r, this.rowIndex) !== false){
+            r.beginEdit();
+            for(var k in changes){
+                if(changes.hasOwnProperty(k)){
+                    r.set(k, changes[k]);
+                }
+            }
+            r.endEdit();
+            this.fireEvent('afteredit', this, changes, r, this.rowIndex)
+        }
+        this.hide();
+    },
+
+    verifyLayout: function(force){
+        if(this.el && (this.isVisible() || force === true)){
+            var row = this.grid.getView().getRow(this.rowIndex);
+            this.setSize(Ext.fly(row).getWidth());
+            var cm = this.grid.colModel, fields = this.items.items;
+            for(var i = 0, len = cm.getColumnCount(); i < len; i++){
+                if(!cm.isHidden(i)){
+                    var adjust = 0;
+                    if(i == 0){
+                        adjust += 0; // outer padding
+                    }
+                    if(i == (len - 1)){
+                        adjust += 3; // outer padding
+                    } else{
+                        adjust += 1;
+                    }
+                    fields[i].show();
+                    fields[i].setWidth(cm.getColumnWidth(i) - adjust);
+                } else{
+                    fields[i].hide();
+                }
+            }
+            this.doLayout();
+            this.positionButtons();
+        }
+    },
+
+    slideHide : function(){
+        this.hide();
+    },
+
+    initFields: function(){
+        var cm = this.grid.getColumnModel(), pm = Ext.layout.ContainerLayout.prototype.parseMargins;
+        for(var i = 0, len = cm.getColumnCount(); i < len; i++){
+            var c = cm.getColumnAt(i);
+            var ed = c.getEditor();
+            if(!ed){
+                ed = c.displayEditor || new Ext.form.DisplayField();
+            }
+            if(i == 0){
+                ed.margins = pm('0 1 2 1');
+            } else if(i == len - 1){
+                ed.margins = pm('0 0 2 1');
+            } else{
+                ed.margins = pm('0 1 2');
+            }
+            ed.setWidth(cm.getColumnWidth(i));
+            ed.column = c;
+            if(ed.ownerCt != this){
+                ed.on('focus', this.ensureVisible, this);
+                ed.on('specialkey', this.onKey, this);
+            }
+            this.insert(i, ed);
+        }
+        this.initialized = true;
+    },
+
+    onKey: function(f, e){
+        if(e.getKey() == e.ENTER){
+            this.stopEditing(true);
+            e.stopPropagation();
+        }
+    },
+
+    onGridKey: function(e){
+        if(e.getKey() == e.ENTER && !this.isVisible()){
+            var r = this.grid.getSelectionModel().getSelected();
+            if(r){
+                var index = this.grid.store.indexOf(r);
+                this.startEditing(index);
+                e.stopPropagation();
+            }
+        }
+    },
+
+    ensureVisible: function(editor){
+        if(this.isVisible()){
+             this.grid.getView().ensureVisible(this.rowIndex, this.grid.colModel.getIndexById(editor.column.id), true);
+        }
+    },
+
+    onRowClick: function(g, rowIndex, e){
+        if(this.clicksToEdit == 'auto'){
+            var li = this.lastClickIndex;
+            this.lastClickIndex = rowIndex;
+            if(li != rowIndex && !this.isVisible()){
+                return;
+            }
+        }
+        this.startEditing(rowIndex, false);
+        this.doFocus.defer(this.focusDelay, this, [e.getPoint()]);
+    },
+
+    onRowDblClick: function(g, rowIndex, e){
+        this.startEditing(rowIndex, false);
+        this.doFocus.defer(this.focusDelay, this, [e.getPoint()]);
+    },
+
+    onRender: function(){
+        Ext.ux.RowEditor.superclass.onRender.apply(this, arguments);
+        this.el.swallowEvent(['keydown', 'keyup', 'keypress']);
+        this.btns = new Ext.Panel({
+            baseCls: 'x-plain',
+            cls: 'x-btns',
+            elements:'body',
+            layout: 'table',
+            width: (this.minButtonWidth * 2) + (this.frameWidth * 2) + (this.buttonPad * 4), // width must be specified for IE
+            items: [{
+                ref: 'saveBtn',
+                itemId: 'saveBtn',
+                xtype: 'button',
+                text: this.saveText || 'Save',
+                width: this.minButtonWidth,
+                handler: this.stopEditing.createDelegate(this, [true])
+            }, {
+                xtype: 'button',
+                text: this.cancelText || 'Cancel',
+                width: this.minButtonWidth,
+                handler: this.stopEditing.createDelegate(this, [false])
+            }]
+        });
+        this.btns.render(this.bwrap);
+    },
+
+    afterRender: function(){
+        Ext.ux.RowEditor.superclass.afterRender.apply(this, arguments);
+        this.positionButtons();
+        if(this.monitorValid){
+            this.startMonitoring();
+        }
+    },
+
+    onShow: function(){
+        if(this.monitorValid){
+            this.startMonitoring();
+        }
+        Ext.ux.RowEditor.superclass.onShow.apply(this, arguments);
+    },
+
+    onHide: function(){
+        Ext.ux.RowEditor.superclass.onHide.apply(this, arguments);
+        this.stopMonitoring();
+        this.grid.getView().focusRow(this.rowIndex);
+    },
+
+    positionButtons: function(){
+        if(this.btns){
+            var h = this.el.dom.clientHeight;
+            var view = this.grid.getView();
+            var scroll = view.scroller.dom.scrollLeft;
+            var width =  view.mainBody.getWidth();
+            var bw = this.btns.getWidth();
+            this.btns.el.shift({left: (width/2)-(bw/2)+scroll, top: h - 2, stopFx: true, duration:.2});
+        }
+    },
+
+    // private
+    preEditValue : function(r, field){
+        var value = r.data[field];
+        return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlDecode(value) : value;
+    },
+
+    // private
+    postEditValue : function(value, originalValue, r, field){
+        return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlEncode(value) : value;
+    },
+
+    doFocus: function(pt){
+        if(this.isVisible()){
+            var index = 0;
+            if(pt){
+                index = this.getTargetColumnIndex(pt);
+            }
+            var cm = this.grid.getColumnModel();
+            for(var i = index||0, len = cm.getColumnCount(); i < len; i++){
+                var c = cm.getColumnAt(i);
+                if(!c.hidden && c.getEditor()){
+                    c.getEditor().focus();
+                    break;
+                }
+            }
+        }
+    },
+
+    getTargetColumnIndex: function(pt){
+        var grid = this.grid, v = grid.view;
+        var x = pt.left;
+        var cms = grid.colModel.config;
+        var i = 0, match = false;
+        for(var len = cms.length, c; c = cms[i]; i++){
+            if(!c.hidden){
+                if(Ext.fly(v.getHeaderCell(i)).getRegion().right >= x){
+                    match = i;
+                    break;
+                }
+            }
+        }
+        return match;
+    },
+
+    startMonitoring : function(){
+        if(!this.bound && this.monitorValid){
+            this.bound = true;
+            Ext.TaskMgr.start({
+                run : this.bindHandler,
+                interval : this.monitorPoll || 200,
+                scope: this
+            });
+        }
+    },
+
+    stopMonitoring : function(){
+        this.bound = false;
+        if(this.tooltip){
+            this.tooltip.hide();
+        }
+    },
+
+    isValid: function(){
+        var valid = true;
+        this.items.each(function(f){
+            if(!f.isValid(true)){
+                valid = false;
+                return false;
+            }
+        });
+        return valid;
+    },
+
+    // private
+    bindHandler : function(){
+        if(!this.bound){
+            return false; // stops binding
+        }
+        var valid = this.isValid();
+        if(!valid && this.errorSummary){
+            this.showTooltip(this.getErrorText().join(''));
+        }
+        this.btns.saveBtn.setDisabled(!valid);
+        this.fireEvent('validation', this, valid);
+    },
+    
+    showTooltip: function(msg){
+        var t = this.tooltip;
+        if(!t){
+            t = this.tooltip = new Ext.ToolTip({
+                maxWidth: 600,
+                cls: 'errorTip',
+                width: 300,
+                title: 'Errors',
+                autoHide: false,
+                anchor: 'left',
+                anchorToTarget: true,
+                mouseOffset: [40,0]
+            });
+        }
+        t.initTarget(this.items.last().getEl());
+        if(!t.rendered){
+            t.show();
+            t.hide();
+        }
+        t.body.update(msg);
+        t.doAutoWidth();
+        t.show();
+    },
+
+    getErrorText: function(){
+        var data = ['<ul>'];
+        this.items.each(function(f){
+            if(!f.isValid(true)){
+                data.push('<li>', f.activeError, '</li>');
+            }
+        });
+        data.push('</ul>');
+        return data;
+    }
+});
+Ext.preg('roweditor', Ext.ux.RowEditor);
+
+Ext.override(Ext.form.Field, {
+    markInvalid : function(msg){
+        if(!this.rendered || this.preventMark){ // not rendered
+            return;
+        }
+        msg = msg || this.invalidText;
+
+        var mt = this.getMessageHandler();
+        if(mt){
+            mt.mark(this, msg);
+        }else if(this.msgTarget){
+            this.el.addClass(this.invalidClass);
+            var t = Ext.getDom(this.msgTarget);
+            if(t){
+                t.innerHTML = msg;
+                t.style.display = this.msgDisplay;
+            }
+        }
+        this.activeError = msg;
+        this.fireEvent('invalid', this, msg);
+    }
+});
+
+Ext.override(Ext.ToolTip, {
+    doAutoWidth : function(){
+        var bw = this.body.getTextWidth();
+        if(this.title){
+            bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
+        }
+        bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + 20;
+        this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
+        
+        // IE7 repaint bug on initial show
+        if(Ext.isIE7 && !this.repainted){
+            this.el.repaint();
+            this.repainted = true;
+        }
+    }
+});
\ No newline at end of file
diff --git a/web/js/codepress/codepress.css b/web/js/codepress/codepress.css
new file mode 100644 (file)
index 0000000..3a4a00a
--- /dev/null
@@ -0,0 +1,21 @@
+body {
+       margin-top:13px;
+       _margin-top:14px;
+       background:white;
+       margin-left:32px;
+       font-family:monospace;
+       font-size:13px;
+       white-space:pre;
+       background-image:url("images/line-numbers.png");
+       background-repeat:repeat-y;
+       background-position:0 3px;
+       line-height:16px;
+       height:100%;
+}
+pre {margin:0;}
+html>body{background-position:0 2px;}
+P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;}
+b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
+
+body.hide-line-numbers {background:white;margin-left:16px;}
+body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;}
\ No newline at end of file
diff --git a/web/js/codepress/codepress.html b/web/js/codepress/codepress.html
new file mode 100644 (file)
index 0000000..d9711d6
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+       <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
+       <meta name="description" content="CodePress - source code editor window" />
+
+       <script type="text/javascript">
+       var language = 'generic';
+       var engine = 'older';
+       var ua = navigator.userAgent;
+       var ts = (new Date).getTime(); // timestamp to avoid cache
+       var lh = location.href;
+       
+       if(ua.match('MSIE')) engine = 'msie';
+       else if(ua.match('KHTML')) engine = 'khtml'; 
+       else if(ua.match('Opera')) engine = 'opera'; 
+       else if(ua.match('Gecko')) engine = 'gecko';
+
+       if(lh.match('language=')) language = lh.replace(/.*language=(.*?)(&.*)?$/,'$1');
+
+       document.write('<link type="text/css" href="codepress.css?ts='+ts+'" rel="stylesheet" />');
+       document.write('<link type="text/css" href="languages/'+language+'.css?ts='+ts+'" rel="stylesheet" id="cp-lang-style" />');
+       document.write('<scr'+'ipt type="text/javascript" src="engines/'+engine+'.js?ts='+ts+'"></scr'+'ipt>');
+       document.write('<scr'+'ipt type="text/javascript" src="languages/'+language+'.js?ts='+ts+'"></scr'+'ipt>');
+       </script>
+
+</head>
+
+<script type="text/javascript">
+if(engine == "msie" || engine == "gecko") document.write('<body><pre> </pre></body>');
+else if(engine == "opera") document.write('<body></body>');
+// else if(engine == "khtml") document.write('<body> </body>');
+</script>
+
+</html>
diff --git a/web/js/codepress/codepress.js b/web/js/codepress/codepress.js
new file mode 100644 (file)
index 0000000..b3f563a
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * 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() {
+       s = document.getElementsByTagName('script');
+       for(var i=0,n=s.length;i<n;i++) {
+               if(s[i].src.match('codepress.js')) {
+                       CodePress.path = s[i].src.replace('codepress.js','');
+               }
+       }
+       t = document.getElementsByTagName('textarea');
+       for(var 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);
diff --git a/web/js/codepress/engines/gecko.js b/web/js/codepress/engines/gecko.js
new file mode 100644 (file)
index 0000000..cd239ee
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
+ * 
+ * Copyright (C) 2007 Fernando M.A.d.S. <fermads@gmail.com>
+ *
+ * Developers:
+ *             Fernando M.A.d.S. <fermads@gmail.com>
+ *             Michael Hurni <michael.hurni@gmail.com>
+ * Contributors:       
+ *             Martin D. Kirk
+ *
+ * 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 = {
+       scrolling : false,
+       autocomplete : true,
+
+       // set initial vars and start sh
+       initialize : function() {
+               if(typeof(editor)=='undefined' && !arguments[0]) return;
+               body = document.getElementsByTagName('body')[0];
+               body.innerHTML = body.innerHTML.replace(/\n/g,"");
+               chars = '|32|46|62|8|'; // charcodes that trigger syntax highlighting
+               cc = '\u2009'; // carret char
+               editor = document.getElementsByTagName('pre')[0];
+               document.designMode = 'on';
+               document.addEventListener('keypress', this.keyHandler, true);
+               window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false);
+               completeChars = this.getCompleteChars();
+               completeEndingChars =  this.getCompleteEndingChars();
+       },
+
+       // treat key bindings
+       keyHandler : function(evt) {
+       keyCode = evt.keyCode;  
+               charCode = evt.charCode;
+               fromChar = String.fromCharCode(charCode);
+
+               if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
+                       CodePress.shortcuts(charCode?charCode:keyCode);
+               }
+               else if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1) && CodePress.autocomplete) { // auto complete
+                       if(!CodePress.completeEnding(fromChar))
+                            CodePress.complete(fromChar);
+               }
+           else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting
+                       top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100);
+               }
+               else if(keyCode==9 || evt.tabKey) {  // snippets activation (tab)
+                       CodePress.snippets(evt);
+               }
+               else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed
+                       CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML;
+               }
+               else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo
+                       (charCode==121||evt.shiftKey) ? CodePress.actions.redo() :  CodePress.actions.undo(); 
+                       evt.preventDefault();
+               }
+               else if(charCode==118 && evt.ctrlKey)  { // handle paste
+                       top.setTimeout(function(){CodePress.syntaxHighlight('generic');},100);
+               }
+               else if(charCode==99 && evt.ctrlKey)  { // handle cut
+                       //alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF'));
+               }
+
+       },
+
+       // put cursor back to its original position after every parsing
+       findString : function() {
+               if(self.find(cc))
+                       window.getSelection().getRangeAt(0).deleteContents();
+       },
+       
+       // split big files, highlighting parts of it
+       split : function(code,flag) {
+               if(flag=='scroll') {
+                       this.scrolling = true;
+                       return code;
+               }
+               else {
+                       this.scrolling = false;
+                       mid = code.indexOf(cc);
+                       if(mid-2000<0) {ini=0;end=4000;}
+                       else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;}
+                       else {ini=mid-2000;end=mid+2000;}
+                       code = code.substring(ini,end);
+                       return code;
+               }
+       },
+       
+       getEditor : function() {
+               if(!document.getElementsByTagName('pre')[0]) {
+                       body = document.getElementsByTagName('body')[0];
+                       if(!body.innerHTML) return body;
+                       if(body.innerHTML=="<br>") body.innerHTML = "<pre> </pre>";
+                       else body.innerHTML = "<pre>"+body.innerHTML+"</pre>";
+               }
+               return document.getElementsByTagName('pre')[0];
+       },
+       
+       // syntax highlighting parser
+       syntaxHighlight : function(flag) {
+               //if(document.designMode=='off') document.designMode='on'
+               if(flag != 'init') { window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));}
+               editor = CodePress.getEditor();
+               o = editor.innerHTML;
+               o = o.replace(/<br>/g,'\n');
+               o = o.replace(/<.*?>/g,'');
+               x = z = this.split(o,flag);
+               x = x.replace(/\n/g,'<br>');
+
+               if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]);
+       
+               for(i=0;i<Language.syntax.length;i++) 
+                       x = x.replace(Language.syntax[i].input,Language.syntax[i].output);
+
+               editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.split(z).join(x);
+               if(flag!='init') this.findString();
+       },
+       
+       getLastWord : function() {
+               var rangeAndCaret = CodePress.getRangeAndCaret();
+               words = rangeAndCaret[0].substring(rangeAndCaret[1]-40,rangeAndCaret[1]);
+               words = words.replace(/[\s\n\r\);\W]/g,'\n').split('\n');
+               return words[words.length-1].replace(/[\W]/gi,'').toLowerCase();
+       },
+       
+       snippets : function(evt) {
+               var snippets = Language.snippets;       
+               var trigger = this.getLastWord();
+               for (var i=0; i<snippets.length; i++) {
+                       if(snippets[i].input == trigger) {
+                               var content = snippets[i].output.replace(/</g,'&lt;');
+                               content = content.replace(/>/g,'&gt;');
+                               if(content.indexOf('$0')<0) content += cc;
+                               else content = content.replace(/\$0/,cc);
+                               content = content.replace(/\n/g,'<br>');
+                               var pattern = new RegExp(trigger+cc,'gi');
+                               evt.preventDefault(); // prevent the tab key from being added
+                               this.syntaxHighlight('snippets',pattern,content);
+                       }
+               }
+       },
+       
+       readOnly : function() {
+               document.designMode = (arguments[0]) ? 'off' : 'on';
+       },
+
+       complete : function(trigger) {
+               window.getSelection().getRangeAt(0).deleteContents();
+               var complete = Language.complete;
+               for (var i=0; i<complete.length; i++) {
+                       if(complete[i].input == trigger) {
+                               var pattern = new RegExp('\\'+trigger+cc);
+                               var content = complete[i].output.replace(/\$0/g,cc);
+                               parent.setTimeout(function () { CodePress.syntaxHighlight('complete',pattern,content)},0); // wait for char to appear on screen
+                       }
+               }
+       },
+
+       getCompleteChars : function() {
+               var cChars = '';
+               for(var i=0;i<Language.complete.length;i++)
+                       cChars += '|'+Language.complete[i].input;
+               return cChars+'|';
+       },
+       
+       getCompleteEndingChars : function() {
+               var cChars = '';
+               for(var i=0;i<Language.complete.length;i++)
+                       cChars += '|'+Language.complete[i].output.charAt(Language.complete[i].output.length-1);
+               return cChars+'|';
+       },
+       
+       completeEnding : function(trigger) {
+               var range = window.getSelection().getRangeAt(0);
+               try {
+                       range.setEnd(range.endContainer, range.endOffset+1)
+               }
+               catch(e) {
+                       return false;
+               }
+               var next_character = range.toString()
+               range.setEnd(range.endContainer, range.endOffset-1)
+               if(next_character != trigger) return false;
+               else {
+                       range.setEnd(range.endContainer, range.endOffset+1)
+                       range.deleteContents();
+                       return true;
+               }
+       },
+       
+       shortcuts : function() {
+               var cCode = arguments[0];
+               if(cCode==13) cCode = '[enter]';
+               else if(cCode==32) cCode = '[space]';
+               else cCode = '['+String.fromCharCode(charCode).toLowerCase()+']';
+               for(var i=0;i<Language.shortcuts.length;i++)
+                       if(Language.shortcuts[i].input == cCode)
+                               this.insertCode(Language.shortcuts[i].output,false);
+       },
+       
+       getRangeAndCaret : function() { 
+               var range = window.getSelection().getRangeAt(0);
+               var range2 = range.cloneRange();
+               var node = range.endContainer;                  
+               var caret = range.endOffset;
+               range2.selectNode(node);        
+               return [range2.toString(),caret];
+       },
+       
+       insertCode : function(code,replaceCursorBefore) {
+               var range = window.getSelection().getRangeAt(0);
+               var node = window.document.createTextNode(code);
+               var selct = window.getSelection();
+               var range2 = range.cloneRange();
+               // Insert text at cursor position
+               selct.removeAllRanges();
+               range.deleteContents();
+               range.insertNode(node);
+               // Move the cursor to the end of text
+               range2.selectNode(node);                
+               range2.collapse(replaceCursorBefore);
+               selct.removeAllRanges();
+               selct.addRange(range2);
+       },
+       
+       // get code from editor
+       getCode : function() {
+               if(!document.getElementsByTagName('pre')[0] || editor.innerHTML == '')
+                       editor = CodePress.getEditor();
+               var code = editor.innerHTML;
+               code = code.replace(/<br>/g,'\n');
+               code = code.replace(/\u2009/g,'');
+               code = code.replace(/<.*?>/g,'');
+               code = code.replace(/&lt;/g,'<');
+               code = code.replace(/&gt;/g,'>');
+               code = code.replace(/&amp;/gi,'&');
+               return code;
+       },
+
+       // put code inside editor
+       setCode : function() {
+               var code = arguments[0];
+               code = code.replace(/\u2009/gi,'');
+               code = code.replace(/&/gi,'&amp;');
+               code = code.replace(/</g,'&lt;');
+               code = code.replace(/>/g,'&gt;');
+               editor.innerHTML = code;
+               if (code == '')
+                       document.getElementsByTagName('body')[0].innerHTML = '';
+       },
+
+       // undo and redo methods
+       actions : {
+               pos : -1, // actual history position
+               history : [], // history vector
+               
+               undo : function() {
+                       editor = CodePress.getEditor();
+                       if(editor.innerHTML.indexOf(cc)==-1){
+                               if(editor.innerHTML != " ")
+                                       window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));
+                               this.history[this.pos] = editor.innerHTML;
+                       }
+                       this.pos --;
+                       if(typeof(this.history[this.pos])=='undefined') this.pos ++;
+                       editor.innerHTML = this.history[this.pos];
+                       if(editor.innerHTML.indexOf(cc)>-1) editor.innerHTML+=cc;
+                       CodePress.findString();
+               },
+               
+               redo : function() {
+                       // editor = CodePress.getEditor();
+                       this.pos++;
+                       if(typeof(this.history[this.pos])=='undefined') this.pos--;
+                       editor.innerHTML = this.history[this.pos];
+                       CodePress.findString();
+               },
+               
+               next : function() { // get next vector position and clean old ones
+                       if(this.pos>20) this.history[this.pos-21] = undefined;
+                       return ++this.pos;
+               }
+       }
+}
+
+Language={};
+window.addEventListener('load', function() { CodePress.initialize('new'); }, true);
\ No newline at end of file
diff --git a/web/js/codepress/engines/khtml.js b/web/js/codepress/engines/khtml.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/web/js/codepress/engines/msie.js b/web/js/codepress/engines/msie.js
new file mode 100644 (file)
index 0000000..2558c39
--- /dev/null
@@ -0,0 +1,304 @@
+/*
+ * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
+ * 
+ * Copyright (C) 2007 Fernando M.A.d.S. <fermads@gmail.com>
+ *
+ * Developers:
+ *             Fernando M.A.d.S. <fermads@gmail.com>
+ *             Michael Hurni <michael.hurni@gmail.com>
+ * Contributors:       
+ *             Martin D. Kirk
+ *
+ * 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 = {
+       scrolling : false,
+       autocomplete : true,
+       
+       // set initial vars and start sh
+       initialize : function() {
+               if(typeof(editor)=='undefined' && !arguments[0]) return;
+               chars = '|32|46|62|'; // charcodes that trigger syntax highlighting
+               cc = '\u2009'; // carret char
+               editor = document.getElementsByTagName('pre')[0];
+               editor.contentEditable = 'true';
+               document.getElementsByTagName('body')[0].onfocus = function() {editor.focus();}
+               document.attachEvent('onkeydown', this.metaHandler);
+               document.attachEvent('onkeypress', this.keyHandler);
+               window.attachEvent('onscroll', function() { if(!CodePress.scrolling) setTimeout(function(){CodePress.syntaxHighlight('scroll')},1)});
+               completeChars = this.getCompleteChars();
+               completeEndingChars =  this.getCompleteEndingChars();
+               setTimeout(function() { window.scroll(0,0) },50); // scroll IE to top
+       },
+       
+       // treat key bindings
+       keyHandler : function(evt) {
+               charCode = evt.keyCode;
+               fromChar = String.fromCharCode(charCode);
+               
+               if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1  )&& CodePress.autocomplete) { // auto complete
+                       if(!CodePress.completeEnding(fromChar))
+                            CodePress.complete(fromChar);
+               }
+           else if(chars.indexOf('|'+charCode+'|')!=-1||charCode==13) { // syntax highlighting
+                       CodePress.syntaxHighlight('generic');
+               }
+       },
+
+       metaHandler : function(evt) {
+               keyCode = evt.keyCode;
+               
+               if(keyCode==9 || evt.tabKey) { 
+                       CodePress.snippets();
+               }
+               else if((keyCode==122||keyCode==121||keyCode==90) && evt.ctrlKey) { // undo and redo
+                       (keyCode==121||evt.shiftKey) ? CodePress.actions.redo() :  CodePress.actions.undo(); 
+                       evt.returnValue = false;
+               }
+               else if(keyCode==34||keyCode==33) { // handle page up/down for IE
+                       self.scrollBy(0, (keyCode==34) ? 200 : -200); 
+                       evt.returnValue = false;
+               }
+               else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed
+                       CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML;
+               }
+               else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && keyCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
+                       CodePress.shortcuts(keyCode);
+                       evt.returnValue = false;
+               }
+               else if(keyCode==86 && evt.ctrlKey)  { // handle paste
+                       window.clipboardData.setData('Text',window.clipboardData.getData('Text').replace(/\t/g,'\u2008'));
+                       top.setTimeout(function(){CodePress.syntaxHighlight('paste');},10);
+               }
+               else if(keyCode==67 && evt.ctrlKey)  { // handle cut
+                       // window.clipboardData.setData('Text',x[0]);
+                       // code = window.clipboardData.getData('Text');
+               }
+       },
+
+       // put cursor back to its original position after every parsing
+       
+       
+       findString : function() {
+               range = self.document.body.createTextRange();
+               if(range.findText(cc)){
+                       range.select();
+                       range.text = '';
+               }
+       },
+       
+       // split big files, highlighting parts of it
+       split : function(code,flag) {
+               if(flag=='scroll') {
+                       this.scrolling = true;
+                       return code;
+               }
+               else {
+                       this.scrolling = false;
+                       mid = code.indexOf(cc);
+                       if(mid-2000<0) {ini=0;end=4000;}
+                       else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;}
+                       else {ini=mid-2000;end=mid+2000;}
+                       code = code.substring(ini,end);
+                       return code.substring(code.indexOf('<P>'),code.lastIndexOf('</P>')+4);
+               }
+       },
+       
+       // syntax highlighting parser
+       syntaxHighlight : function(flag) {
+               if(flag!='init') document.selection.createRange().text = cc;
+               o = editor.innerHTML;
+               if(flag=='paste') { // fix pasted text
+                       o = o.replace(/<BR>/g,'\r\n'); 
+                       o = o.replace(/\u2008/g,'\t');
+               }
+               o = o.replace(/<P>/g,'\n');
+               o = o.replace(/<\/P>/g,'\r');
+               o = o.replace(/<.*?>/g,'');
+               o = o.replace(/&nbsp;/g,'');                    
+               o = '<PRE><P>'+o+'</P></PRE>';
+               o = o.replace(/\n\r/g,'<P></P>');
+               o = o.replace(/\n/g,'<P>');
+               o = o.replace(/\r/g,'<\/P>');
+               o = o.replace(/<P>(<P>)+/,'<P>');
+               o = o.replace(/<\/P>(<\/P>)+/,'</P>');
+               o = o.replace(/<P><\/P>/g,'<P><BR/></P>');
+               x = z = this.split(o,flag);
+
+               if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]);
+       
+               for(i=0;i<Language.syntax.length;i++) 
+                       x = x.replace(Language.syntax[i].input,Language.syntax[i].output);
+                       
+               editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.replace(z,x);
+               if(flag!='init') this.findString();
+       },
+
+       snippets : function(evt) {
+               var snippets = Language.snippets;
+               var trigger = this.getLastWord();
+               for (var i=0; i<snippets.length; i++) {
+                       if(snippets[i].input == trigger) {
+                               var content = snippets[i].output.replace(/</g,'&lt;');
+                               content = content.replace(/>/g,'&gt;');
+                               if(content.indexOf('$0')<0) content += cc;
+                               else content = content.replace(/\$0/,cc);
+                               content = content.replace(/\n/g,'</P><P>');
+                               var pattern = new RegExp(trigger+cc,"gi");
+                               this.syntaxHighlight('snippets',pattern,content);
+                       }
+               }
+       },
+       
+       readOnly : function() {
+               editor.contentEditable = (arguments[0]) ? 'false' : 'true';
+       },
+       
+       complete : function(trigger) {
+               var complete = Language.complete;
+               for (var i=0; i<complete.length; i++) {
+                       if(complete[i].input == trigger) {
+                               var pattern = new RegExp('\\'+trigger+cc);
+                               var content = complete[i].output.replace(/\$0/g,cc);
+                               setTimeout(function () { CodePress.syntaxHighlight('complete',pattern,content)},0); // wait for char to appear on screen
+                       }
+               }
+       },
+       
+       getCompleteChars : function() {
+               var cChars = '';
+               for(var i=0;i<Language.complete.length;i++)
+                       cChars += '|'+Language.complete[i].input;
+               return cChars+'|';
+       },
+
+       getCompleteEndingChars : function() {
+               var cChars = '';
+               for(var i=0;i<Language.complete.length;i++)
+                       cChars += '|'+Language.complete[i].output.charAt(Language.complete[i].output.length-1);
+               return cChars+'|';
+       },
+
+       completeEnding : function(trigger) {
+               var range = document.selection.createRange();
+               try {
+                       range.moveEnd('character', 1)
+               }
+               catch(e) {
+                       return false;
+               }
+               var next_character = range.text
+               range.moveEnd('character', -1)
+               if(next_character != trigger )  return false;
+               else {
+                       range.moveEnd('character', 1)
+                       range.text=''
+                       return true;
+               }
+       },      
+
+       shortcuts : function() {
+               var cCode = arguments[0];
+               if(cCode==13) cCode = '[enter]';
+               else if(cCode==32) cCode = '[space]';
+               else cCode = '['+String.fromCharCode(keyCode).toLowerCase()+']';
+               for(var i=0;i<Language.shortcuts.length;i++)
+                       if(Language.shortcuts[i].input == cCode)
+                               this.insertCode(Language.shortcuts[i].output,false);
+       },
+       
+       getLastWord : function() {
+               var rangeAndCaret = CodePress.getRangeAndCaret();
+               words = rangeAndCaret[0].substring(rangeAndCaret[1]-40,rangeAndCaret[1]);
+               words = words.replace(/[\s\n\r\);\W]/g,'\n').split('\n');
+               return words[words.length-1].replace(/[\W]/gi,'').toLowerCase();
+       }, 
+
+       getRangeAndCaret : function() { 
+               var range = document.selection.createRange();
+               var caret = Math.abs(range.moveStart('character', -1000000)+1);
+               range = this.getCode();
+               range = range.replace(/\n\r/gi,'  ');
+               range = range.replace(/\n/gi,'');
+               return [range.toString(),caret];
+       },
+       
+       insertCode : function(code,replaceCursorBefore) {
+               var repdeb = '';
+               var repfin = '';
+               
+               if(replaceCursorBefore) { repfin = code; }
+               else { repdeb = code; }
+               
+               if(typeof document.selection != 'undefined') {
+                       var range = document.selection.createRange();
+                       range.text = repdeb + repfin;
+                       range = document.selection.createRange();
+                       range.move('character', -repfin.length);
+                       range.select(); 
+               }       
+       },
+
+       // get code from editor 
+       getCode : function() {
+               var code = editor.innerHTML;
+               code = code.replace(/<br>/g,'\n');
+               code = code.replace(/<\/p>/gi,'\r');
+               code = code.replace(/<p>/i,''); // IE first line fix
+               code = code.replace(/<p>/gi,'\n');
+               code = code.replace(/&nbsp;/gi,'');
+               code = code.replace(/\u2009/g,'');
+               code = code.replace(/<.*?>/g,'');
+               code = code.replace(/&lt;/g,'<');
+               code = code.replace(/&gt;/g,'>');
+               code = code.replace(/&amp;/gi,'&');
+               return code;
+       },
+
+       // put code inside editor
+       setCode : function() {
+               var code = arguments[0];
+               code = code.replace(/\u2009/gi,'');
+               code = code.replace(/&/gi,'&amp;');             
+               code = code.replace(/</g,'&lt;');
+        code = code.replace(/>/g,'&gt;');
+               editor.innerHTML = '<pre>'+code+'</pre>';
+       },
+
+       
+       // undo and redo methods
+       actions : {
+               pos : -1, // actual history position
+               history : [], // history vector
+               
+               undo : function() {
+                       if(editor.innerHTML.indexOf(cc)==-1){
+                               document.selection.createRange().text = cc;
+                               this.history[this.pos] = editor.innerHTML;
+                       }
+                       this.pos--;
+                       if(typeof(this.history[this.pos])=='undefined') this.pos++;
+                       editor.innerHTML = this.history[this.pos];
+                       CodePress.findString();
+               },
+               
+               redo : function() {
+                       this.pos++;
+                       if(typeof(this.history[this.pos])=='undefined') this.pos--;
+                       editor.innerHTML = this.history[this.pos];
+                       CodePress.findString();
+               },
+               
+               next : function() { // get next vector position and clean old ones
+                       if(this.pos>20) this.history[this.pos-21] = undefined;
+                       return ++this.pos;
+               }
+       }
+}
+
+Language={};
+window.attachEvent('onload', function() { CodePress.initialize('new');});
\ No newline at end of file
diff --git a/web/js/codepress/engines/older.js b/web/js/codepress/engines/older.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/web/js/codepress/engines/opera.js b/web/js/codepress/engines/opera.js
new file mode 100644 (file)
index 0000000..155bf09
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * CodePress - Real Time Syntax Highlighting Editor written in JavaScript - http://codepress.org/
+ * 
+ * Copyright (C) 2007 Fernando M.A.d.S. <fermads@gmail.com>
+ *
+ * Contributors :
+ *
+ *     Michael Hurni <michael.hurni@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 = {
+       scrolling : false,
+       autocomplete : true,
+
+       // set initial vars and start sh
+       initialize : function() {
+               if(typeof(editor)=='undefined' && !arguments[0]) return;
+               chars = '|32|46|62|'; // charcodes that trigger syntax highlighting
+               cc = '\u2009'; // control char
+               editor = document.getElementsByTagName('body')[0];
+               document.designMode = 'on';
+               document.addEventListener('keyup', this.keyHandler, true);
+               window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false);
+               completeChars = this.getCompleteChars();
+//             CodePress.syntaxHighlight('init');
+       },
+
+       // treat key bindings
+       keyHandler : function(evt) {
+       keyCode = evt.keyCode;  
+               charCode = evt.charCode;
+
+               if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
+                       CodePress.shortcuts(charCode?charCode:keyCode);
+               }
+               else if(completeChars.indexOf('|'+String.fromCharCode(charCode)+'|')!=-1 && CodePress.autocomplete) { // auto complete
+                       CodePress.complete(String.fromCharCode(charCode));
+               }
+           else if(chars.indexOf('|'+charCode+'|')!=-1||keyCode==13) { // syntax highlighting
+                       CodePress.syntaxHighlight('generic');
+               }
+               else if(keyCode==9 || evt.tabKey) {  // snippets activation (tab)
+                       CodePress.snippets(evt);
+               }
+               else if(keyCode==46||keyCode==8) { // save to history when delete or backspace pressed
+                       CodePress.actions.history[CodePress.actions.next()] = editor.innerHTML;
+               }
+               else if((charCode==122||charCode==121||charCode==90) && evt.ctrlKey) { // undo and redo
+                       (charCode==121||evt.shiftKey) ? CodePress.actions.redo() :  CodePress.actions.undo(); 
+                       evt.preventDefault();
+               }
+               else if(keyCode==86 && evt.ctrlKey)  { // paste
+                       // TODO: pasted text should be parsed and highlighted
+               }
+       },
+
+       // put cursor back to its original position after every parsing
+       findString : function() {
+               var sel = window.getSelection();
+               var range = window.document.createRange();
+               var span = window.document.getElementsByTagName('span')[0];
+                       
+               range.selectNode(span);
+               sel.removeAllRanges();
+               sel.addRange(range);
+               span.parentNode.removeChild(span);
+               //if(self.find(cc))
+               //window.getSelection().getRangeAt(0).deleteContents();
+       },
+       
+       // split big files, highlighting parts of it
+       split : function(code,flag) {
+               if(flag=='scroll') {
+                       this.scrolling = true;
+                       return code;
+               }
+               else {
+                       this.scrolling = false;
+                       mid = code.indexOf('<SPAN>');
+                       if(mid-2000<0) {ini=0;end=4000;}
+                       else if(mid+2000>code.length) {ini=code.length-4000;end=code.length;}
+                       else {ini=mid-2000;end=mid+2000;}
+                       code = code.substring(ini,end);
+                       return code;
+               }
+       },
+       
+       // syntax highlighting parser
+       syntaxHighlight : function(flag) {
+               //if(document.designMode=='off') document.designMode='on'
+               if(flag!='init') {
+                       var span = document.createElement('span');
+                       window.getSelection().getRangeAt(0).insertNode(span);
+               }
+
+               o = editor.innerHTML;
+//             o = o.replace(/<br>/g,'\r\n');
+//             o = o.replace(/<(b|i|s|u|a|em|tt|ins|big|cite|strong)?>/g,'');
+               //alert(o)
+               o = o.replace(/<(?!span|\/span|br).*?>/gi,'');
+//             alert(o)
+//             x = o;
+               x = z = this.split(o,flag);
+               //alert(z)
+//             x = x.replace(/\r\n/g,'<br>');
+               x = x.replace(/\t/g, '        ');
+
+
+               if(arguments[1]&&arguments[2]) x = x.replace(arguments[1],arguments[2]);
+       
+               for(i=0;i<Language.syntax.length;i++) 
+                       x = x.replace(Language.syntax[i].input,Language.syntax[i].output);
+
+               editor.innerHTML = this.actions.history[this.actions.next()] = (flag=='scroll') ? x : o.split(z).join(x); 
+
+               if(flag!='init') this.findString();
+       },
+       
+       getLastWord : function() {
+               var rangeAndCaret = CodePress.getRangeAndCaret();
+               words = rangeAndCaret[0].substring(rangeAndCaret[1]-40,rangeAndCaret[1]);
+               words = words.replace(/[\s\n\r\);\W]/g,'\n').split('\n');
+               return words[words.length-1].replace(/[\W]/gi,'').toLowerCase();
+       }, 
+       
+       snippets : function(evt) {
+               var snippets = Language.snippets;       
+               var trigger = this.getLastWord();
+               for (var i=0; i<snippets.length; i++) {
+                       if(snippets[i].input == trigger) {
+                               var content = snippets[i].output.replace(/</g,'&lt;');
+                               content = content.replace(/>/g,'&gt;');
+                               if(content.indexOf('$0')<0) content += cc;
+                               else content = content.replace(/\$0/,cc);
+                               content = content.replace(/\n/g,'<br>');
+                               var pattern = new RegExp(trigger+cc,'gi');
+                               evt.preventDefault(); // prevent the tab key from being added
+                               this.syntaxHighlight('snippets',pattern,content);
+                       }
+               }
+       },
+       
+       readOnly : function() {
+               document.designMode = (arguments[0]) ? 'off' : 'on';
+       },
+
+       complete : function(trigger) {
+               window.getSelection().getRangeAt(0).deleteContents();
+               var complete = Language.complete;
+               for (var i=0; i<complete.length; i++) {
+                       if(complete[i].input == trigger) {
+                               var pattern = new RegExp('\\'+trigger+cc);
+                               var content = complete[i].output.replace(/\$0/g,cc);
+                               parent.setTimeout(function () { CodePress.syntaxHighlight('complete',pattern,content)},0); // wait for char to appear on screen
+                       }
+               }
+       },
+
+       getCompleteChars : function() {
+               var cChars = '';
+               for(var i=0;i<Language.complete.length;i++)
+                       cChars += '|'+Language.complete[i].input;
+               return cChars+'|';
+       },
+
+       shortcuts : function() {
+               var cCode = arguments[0];
+               if(cCode==13) cCode = '[enter]';
+               else if(cCode==32) cCode = '[space]';
+               else cCode = '['+String.fromCharCode(charCode).toLowerCase()+']';
+               for(var i=0;i<Language.shortcuts.length;i++)
+                       if(Language.shortcuts[i].input == cCode)
+                               this.insertCode(Language.shortcuts[i].output,false);
+       },
+       
+       getRangeAndCaret : function() { 
+               var range = window.getSelection().getRangeAt(0);
+               var range2 = range.cloneRange();
+               var node = range.endContainer;                  
+               var caret = range.endOffset;
+               range2.selectNode(node);        
+               return [range2.toString(),caret];
+       },
+       
+       insertCode : function(code,replaceCursorBefore) {
+               var range = window.getSelection().getRangeAt(0);
+               var node = window.document.createTextNode(code);
+               var selct = window.getSelection();
+               var range2 = range.cloneRange();
+               // Insert text at cursor position
+               selct.removeAllRanges();
+               range.deleteContents();
+               range.insertNode(node);
+               // Move the cursor to the end of text
+               range2.selectNode(node);                
+               range2.collapse(replaceCursorBefore);
+               selct.removeAllRanges();
+               selct.addRange(range2);
+       },
+       
+       // get code from editor
+       getCode : function() {
+               var code = editor.innerHTML;
+               code = code.replace(/<br>/g,'\n');
+               code = code.replace(/\u2009/g,'');
+               code = code.replace(/<.*?>/g,'');
+               code = code.replace(/&lt;/g,'<');
+               code = code.replace(/&gt;/g,'>');
+               code = code.replace(/&amp;/gi,'&');
+               return code;
+       },
+
+       // put code inside editor
+       setCode : function() {
+               var code = arguments[0];
+               code = code.replace(/\u2009/gi,'');
+               code = code.replace(/&/gi,'&amp;');
+               code = code.replace(/</g,'&lt;');
+        code = code.replace(/>/g,'&gt;');
+               editor.innerHTML = code;
+       },
+
+       // undo and redo methods
+       actions : {
+               pos : -1, // actual history position
+               history : [], // history vector
+               
+               undo : function() {
+                       if(editor.innerHTML.indexOf(cc)==-1){
+                               window.getSelection().getRangeAt(0).insertNode(document.createTextNode(cc));
+                               this.history[this.pos] = editor.innerHTML;
+                       }
+                       this.pos--;
+                       if(typeof(this.history[this.pos])=='undefined') this.pos++;
+                       editor.innerHTML = this.history[this.pos];
+                       CodePress.findString();
+               },
+               
+               redo : function() {
+                       this.pos++;
+                       if(typeof(this.history[this.pos])=='undefined') this.pos--;
+                       editor.innerHTML = this.history[this.pos];
+                       CodePress.findString();
+               },
+               
+               next : function() { // get next vector position and clean old ones
+                       if(this.pos>20) this.history[this.pos-21] = undefined;
+                       return ++this.pos;
+               }
+       }
+}
+
+Language={};
+window.addEventListener('load', function() { CodePress.initialize('new'); }, true);
diff --git a/web/js/codepress/images/line-numbers.png b/web/js/codepress/images/line-numbers.png
new file mode 100644 (file)
index 0000000..ffea4e6
Binary files /dev/null and b/web/js/codepress/images/line-numbers.png differ
diff --git a/web/js/codepress/index.html b/web/js/codepress/index.html
new file mode 100644 (file)
index 0000000..60fc918
--- /dev/null
@@ -0,0 +1,443 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html>
+<head>
+       <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
+
+       <style>
+       body {color:#000;background-color:white;font:15px georgia, "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; letter-spacing:0.01em;margin:15px;}
+       p {margin:0 0 15px 0;}
+       a,a:visited {color:#7f0055;}
+       select {background:#ffffe1;}
+       button {margin-top:5px;}
+       button.actions {width:171px;font-family:arial;}
+       h1 {color:#7f0055;margin:0;padding:0;font-size:42px;font-weight:normal;}
+       h1 a {text-decoration:none;}
+       h2 {margin:0;}
+       h2 a {text-decoration:none;font-weight:normal;font-size:22px;color:black !important;}
+       h3 {font-size:20px;font-weight:normal;padding:0;margin:25px 0 5px 0;color:#7f0055;font-weight:bold;border-bottom:2px dotted #d8d8d8;}
+       h4 {font-size:18px;font-weight:normal;z-index:0;}       
+       code {color:#0080c0;font-size:13px;font-weight:bold;}
+       ol, ul {padding:5px 0 5px 25px;margin:0;}
+       ol li, ul li {margin:8px 0 8px 0;}
+       
+       #logo {text-align:center;background-color:#d6d6d6;padding:10px;-moz-border-radius:5px;border:1px solid silver;}
+       #container {width:700px;margin:20px auto;padding:25px;border:3px solid #d9d9d9;-moz-border-radius:10px;background:#f8f8f8;}
+       #languages {margin:5px 0;}
+       
+       #menu {width:100%;background:#7f0055;-moz-border-radius:4px;}
+       #menu a {font:bold 17px georgia;color:white;padding:4px;display:block;border-left:1px solid white;text-align:center;text-decoration:none;}
+       #menu a:hover {background:#b9669e;} 
+
+       .hidden-code {display:none;}
+       .copycode {border:1px dotted gray;padding:10px;background:white;font-family:monospace;color:gray}
+       </style>
+
+</head>
+
+<body>
+<div id="container">
+
+<div id="logo">
+       <h1><a href="http://codepress.org/">CodePress</a></h1>
+       <h2><a href="http://codepress.org/">Online Real Time Syntax Highlighting Editor</a></h2>
+</div>
+
+<br />
+
+<table cellpadding="0" cellspacing="0" id="menu">
+<tr>
+       <td>
+               <a href="http://www.codepress.org/index.php">Home/Download</a>
+       </td>
+       <td>
+               <a href="http://www.codepress.org/install.php">&nbsp;&nbsp;Install&nbsp;&nbsp;</a>
+       </td>
+       <td>
+               <a href="http://www.codepress.org/to-do.php">&nbsp;&nbsp;To-do&nbsp;&nbsp;</a>
+       </td>
+       <td>
+               <a href="http://www.codepress.org/about.php" id="about">&nbsp;&nbsp;About&nbsp;&nbsp;</a>
+       </td>
+</tr>
+</table>
+
+<h4>
+       CodePress is web-based source code editor with syntax highlighting written in JavaScript that colors text in real time while it's being typed in the browser.
+</h4>
+       
+<p>
+       Go to <strong><a href="http://codepress.org/">http://codepress.org/</a></strong> for updates.
+</p>
+
+<h3>Demo</h3>
+<div id="languages">
+       <em>choose example in:</em> 
+       <button onclick="cp1.edit('cp-php','php')">PHP</button> 
+       <button onclick="cp1.edit('cp-javascript','javascript')">JavaScript</button> 
+       <button onclick="cp1.edit('cp-java','java')">Java</button>
+       <button onclick="cp1.edit('cp-perl','perl')">Perl</button>
+       <button onclick="cp1.edit('cp-sql','sql')">SQL</button> 
+       <button onclick="cp1.edit('cp-html','html')">HTML</button> 
+       <button onclick="cp1.edit('cp-css','css')">CSS</button>         
+</div>
+
+<textarea id="cp1" class="codepress php" style="width:700px;height:300px;" wrap="off">
+<?php
+// Very simple implementation of server side script
+
+if(isset($_GET['file'])) {
+       $file = basename($_GET['file']);
+       $full_file = $path['server'].'/'.$path['webdocs'].'/'.$path['files']."/".$file;
+       if(file_exists($full_file)) {
+               $code = file_get_contents($full_file);
+               $code = preg_replace("/>/","&amp;gt;",$code);
+               $code = preg_replace("/</","&amp;lt;",$code);
+               $language = getLanguage($file);
+       }
+}
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+       <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
+       <link type="text/css" href="languages/codepress-<?=$language?>.css" rel="stylesheet" id="cp-lang-style" />
+       <script type="text/javascript" src="codepress.js"></script>
+       <script type="text/javascript">
+               CodePress.language = '<?=$language?>';
+       </script>
+</head>
+<body id="ffedt"><pre id="ieedt"><?=$code?></pre></body>
+</html>
+</textarea>
+
+<br /><br />
+
+<textarea id="codepress2" class="codepress javascript linenumbers-off" style="width:700px;height:200px;" wrap="off">
+//set language
+this.setLanguage = function() {
+       if(arguments[0]) {
+               language = (typeof(Content.languages[arguments[0]])!='undefined') ? arguments[0] : this.setLanguage();
+               cpLanguage.innerHTML = Content.languages[language].name;
+               if(cpBody.document.designMode=='on') cpBody.document.designMode = 'off';
+               CodePress.loadScript(cpBody.document, '../languages/'+language+'.js', function () { cpBody.CodePress.syntaxHighlight('init'); })
+               cpBody.document.getElementById('cp-lang-style').href = '../languages/'+language+'.css';
+               this.hideMenu();
+       }
+       else {
+               var extension = filename.replace(/.*\.([^\.]+)$/,'$1');
+               var aux = false;
+               for(lang in Content.languages) {
+                       extensions = ','+Content.languages[lang].extensions+',';
+                       if(extensions.match(','+extension+',')) aux = lang;
+               }
+               language = (aux) ? aux : 'generic';
+       }
+}
+</textarea>
+
+<p>
+       <button class="actions" onclick="alert(codepress2.getCode())">get code from editor</button>
+       <button class="actions" onclick="codepress2.toggleEditor()">turn on/off CodePress</button>
+       <button class="actions" onclick="codepress2.toggleLineNumbers()">show/hide line numbers</button>
+       <button class="actions" onclick="codepress2.toggleAutoComplete()">turn on/off auto-complete</button>
+       <button class="actions" onclick="codepress2.toggleReadOnly()">turn on/off read only</button>
+</p>
+
+
+
+<h3>Installation</h3>
+<ol>
+       <li>
+               <p>
+                       <a href="http://codepress.org/">Download</a> and uncompress CodePress under a directory inside your webserver.<br>
+                       Example:<strong> http://yourserver/codepress/</strong><br />
+                       Since CodePress is pure JavaScript and HTML, you can also test it without a webserver.
+               </p>
+       </li>
+       <li>
+               <p>
+                       Insert CodePress script somewhere in your page inside the <code>&lt;head&gt;</code> or above the <code>&lt;/body&gt;</code> tag.
+               </p>
+       
+               <p class="copycode">
+                       &lt;script src="/codepress/codepress.js" type="text/javascript"&gt;&lt;/script&gt;
+               </p>
+       </li>
+       
+       <li>
+               <p>
+                       Add the <code>&lt;textarea&gt;</code> tag to the place on your page you want CodePress to appear. CodePress will inherit the width and height of your textarea.
+                       When the page loads, it will automatically replace your textarea with a CodePress window.
+               </p>
+               <p class="copycode">
+                       &lt;textarea id="myCpWindow" class="codepress javascript linenumbers-off"&gt;<br />
+                       &nbsp;&nbsp;&nbsp;// your code here<br />
+                       &lt;/textarea&gt;
+               </p>
+               <ul>
+                       <li>
+                               The <code>javascript</code> portion of the class="" means that the language being edited is JavaScript.
+                       </li>
+                       <li>
+                               The <code>codepress</code> portion of the class="" is mandatory and indicates a textarea to be replaced for a CodePress window.
+                       </li>
+                       <li>
+                               Other class options are <code>linenumbers-off</code>, <code>autocomplete-off</code> and <code>readonly-on</code>.
+                       </li>                   
+                       <li>
+                               Careful not to use the same id for two different CodePress windows (<code>&lt;textarea id="<strong>xx</strong>"...&gt;</code>)
+                       </li>
+               </ul>
+
+       </li>
+</ol>
+
+<h3>You also can...</h3>
+<ol>
+       <li>
+               Open/edit code from a different textarea.<br />
+               Example: <code>textarea_id.edit('other_textarea_id','language')</code><br>
+       </li>
+       <li>
+               Get code from CodePress window.<br />
+               Example: <code>textarea_id.getCode()</code><br>
+       </li>
+       <li>
+               Turn on/off CodePress editor and return to the regular textarea.<br />
+               Example: <code>textarea_id.toggleEditor()</code><br>
+       </li>
+       <li>
+               Turn on/off line numbers.<br />
+               Example: <code>textarea_id.toggleLineNumbers()</code><br>
+       </li>
+       <li>
+               Turn on/off read only.<br />
+               Example: <code>textarea_id.toggleReadOnly()</code><br>
+       </li>
+       <li>
+               Turn on/off auto-complete.<br />
+               Example: <code>textarea_id.toggleAutoComplete()</code><br>
+       </li>
+       
+</ol>
+
+<!-- p>
+       You may want to use [id].getCode() to get the content code from CodePress window and save it to your server since CodePress only edit files and do not save them.
+</p>
+<p>
+       You may also want to open files from server. You'll have to write a server side script and replace the JavaScript call on codepress.js from codepress.html to codepress.php (if your server side language is PHP, of course).
+</p -->
+
+<h3>License</h3>
+<p>
+       CodePress is distributed under the <a href="http://www.opensource.org/licenses/lgpl-license.php">LGPL</a>. If your software is <a href="http://www.gnu.org/philosophy/license-list.html#GPLCompatibleLicenses">compatible</a> with this licence or it is under <a href="http://creativecommons.org/">Creative Commons</a>, you can use it as you want. Just keep the credits somewhere around.
+</p>
+
+
+</div><!--/container-->
+
+
+
+<!-- hidden codes for loading -->
+<textarea id="cp-php" class="hidden-code">
+<?php
+// Very simple implementation of server side script
+
+if(isset($_GET['file'])) {
+       $file = basename($_GET['file']);
+       $full_file = $path['server'].'/'.$path['webdocs'].'/'.$path['files']."/".$file;
+       if(file_exists($full_file)) {
+               $code = file_get_contents($full_file);
+               $code = preg_replace("/>/","&amp;gt;",$code);
+               $code = preg_replace("/</","&amp;lt;",$code);
+               $language = getLanguage($file);
+       }
+}
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+       <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
+       <link type="text/css" href="languages/codepress-<?=$language?>.css" rel="stylesheet" id="cp-lang-style" />
+       <script type="text/javascript" src="codepress.js"></script>
+       <script type="text/javascript">
+               CodePress.language = '<?=$language?>';
+       </script>
+</head>
+<body id="ffedt"><pre id="ieedt"><?=$code?></pre></body>
+</html>
+</textarea>
+
+<textarea id="cp-javascript" class="hidden-code">
+CodePress = function(obj) {
+       var self = document.createElement('iframe');
+       self.textarea = obj;
+       self.textarea.disabled = true;
+       self.style.height = self.textarea.clientHeight +'px';
+       self.style.width = self.textarea.clientWidth +'px';
+       
+       self.initialize = function() {
+               self.editor = self.contentWindow.CodePress;
+               self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0];
+               self.editor.setCode(self.textarea.value);
+               self.editor.syntaxHighlight('init');
+       }
+       
+       self.edit = function(id,language) {
+               self.language = (language) ? language : self.textarea.className.replace(/ ?codepress ?/,'');
+               self.src = cpPath+'modules/codepress.html?engine='+self.getEngine()+'&language='+self.language;
+               if(self.attachEvent) self.attachEvent('onload',self.initialize);
+               else self.addEventListener('load',self.initialize,false);
+       }
+}
+</textarea>
+
+<textarea id="cp-autoit" class="hidden-code">
+#include
+IsNumber(15)
+@Macro
+;comment
+$var = "string"
+</textarea>
+
+<textarea id="cp-java" class="hidden-code">
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * Project ECCO - File manager class
+ * @author Fernando M.A.d.S.
+ */
+public class FileManager extends HttpServlet {
+
+       private static final long serialVersionUID = 1L;
+       private static String login = "feanndor"; // session var should come here
+       private static String usersPath = System.getProperty("user.dir")+File.separator+"htdocs"+File.separator+"ecco"+File.separator+"users"+File.separator;
+       private static File dir = new File(usersPath+login+File.separator);
+       static boolean existDirectories = false;
+       static int isDirectory = 0;
+
+       public FileFilter filterFiles(File dir) {
+               return (new FileFilter() {
+                       public boolean accept(File pathname) {
+                               return !(pathname.isDirectory());
+                       }
+               });
+       }
+}
+</textarea>
+
+<textarea id="cp-perl" class="hidden-code">
+#!/usr/bin/perl      
+# The first line of the script envokes Perl 
+
+# Scalar variables
+$var1 = "Hello World";   
+$var2 = 14.6;
+
+# Array variables
+@arr1 = ("zero","one","two","three","four");
+
+# Hash variable, or associative array
+%hash1 = ("one","Monday","two", "Tuesday","three", "Wednesday","four","Thursday");
+
+# Some simple printing
+print $var1; 
+
+# Subroutine
+sub test() {
+       print "ok";
+}
+</textarea>
+
+<textarea id="cp-sql" class="hidden-code">
+--
+-- simple select example
+-- 
+SELECT * FROM books
+       WHERE price > 100.00 and price < 150.00
+       ORDER BY title
+
+SELECT books.title, count(*) AS Authors
+       FROM books
+       JOIN book_authors 
+               ON books.book_number = book_authors.book_number
+       GROUP BY books.title
+
+-- insert, update and delete examples
+       
+INSERT INTO my_table (field1, field2, field3) VALUES ('test', 'N', NULL);
+
+BEGIN WORK;
+       UPDATE inventory SET quantity = quantity - 3 WHERE item = 'pants';
+COMMIT;
+</textarea>
+
+<textarea id="cp-html" class="hidden-code">
+<html>
+<head>
+       <title>CodePress - Online Real Time Syntax Highlighting Editor</title>
+
+       <style type="text/css">
+       @import url(styles.css);        
+       </style>
+       <script type="text/javascript">
+       function getCode() {
+               alert(textWithoutHighlighting);
+       }
+       </script>
+</head>
+<body>
+<div id="logo">
+       <h1><a href="http://codepress.org/">CodePress</a></h1>
+       <h2>Online Real Time Syntax Highlighting Editor</h2>
+       <img src="testimage.gif" />
+</div>
+<div id="languages">
+       <em>choose language:</em> 
+       <button onclick="edit('codepress.php',this)" id="default">PHP</button> 
+       <button onclick="edit('FileManager.java',this)">Java</button> 
+</div>
+</body>
+</html>
+</textarea>
+
+<textarea id="cp-css" class="hidden-code">
+/* CSS comment */
+
+body {
+       color:#000;
+       background-color:white;
+       font:15px Georgia, "Lucida Grande", Arial, sans-serif; 
+       letter-spacing:0.01em;
+       margin:15px;
+}
+
+p { 
+       margin:0 0 15px 0; 
+}
+
+a,a:visited {
+       color:#7f0055;
+}
+
+select {
+       background:#ffffe1;
+}
+
+h1 {
+       color:#7f0055;
+       margin:0;
+       padding:0;
+       font-size:42px;
+}
+</textarea>
+
+
+<script src="codepress.js" type="text/javascript"></script>
+</body>
+</html>
diff --git a/web/js/codepress/languages/asp.css b/web/js/codepress/languages/asp.css
new file mode 100644 (file)
index 0000000..9a4c505
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * CodePress color styles for ASP-VB syntax highlighting
+ * By Martin D. Kirk
+ */
+/* tags */
+
+b {
+       color:#000080;
+} 
+/* comments */
+big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {
+       color:gray;
+       font-weight:normal;
+}
+/* ASP comments */
+strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{
+       color:gray;
+       font-weight:normal;
+}
+ /* attributes */ 
+s, s b, span s u, span s cite, strong span s {
+       color:#5656fa ;
+       font-weight:normal;
+}
+ /* strings */ 
+strong s,strong s b, strong s u, strong s cite {
+       color:#009900;
+       font-weight:normal;
+}
+strong ins{
+       color:#000000;
+       font-weight:bold;
+}
+ /* Syntax */
+strong a, strong a u {
+       color:#0000FF;
+       font-weight:;
+}
+ /* Native Keywords */
+strong u {
+       color:#990099;
+       font-weight:bold;
+}
+/* Numbers */
+strong var{
+       color:#FF0000;
+}
+/* ASP Language */
+span{
+       color:#990000;
+       font-weight:bold;
+}
+strong i,strong a i, strong u i {
+       color:#009999;
+}
+/* style */
+em {
+       color:#800080;
+       font-style:normal;
+}
+ /* script */ 
+ins {
+       color:#800000;
+       font-weight:bold;
+}
+
+/* <?php and ?> */
+cite, s cite {
+       color:red;
+       font-weight:bold;
+}
\ No newline at end of file
diff --git a/web/js/codepress/languages/asp.js b/web/js/codepress/languages/asp.js
new file mode 100644 (file)
index 0000000..21e78dd
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * CodePress regular expressions for ASP-vbscript syntax highlighting
+ */
+
+// ASP VBScript
+Language.syntax = [
+// all tags
+       { input : /(&lt;[^!%|!%@]*?&gt;)/g, output : '<b>$1</b>' }, 
+// style tags  
+       { input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' }, 
+// script tags 
+       { input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g, output : '<ins>$1</ins><ins>$2</ins><ins>$3</ins>' }, 
+// strings "" and attributes
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, 
+// ASP Comment
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<dfn>\'$1$2</dfn>'}, 
+// <%.*
+       { input : /(&lt;%)/g, output : '<strong>$1' }, 
+// .*%>        
+       { input : /(%&gt;)/g, output : '$1</strong>' }, 
+// <%@...%>    
+       { input : /(&lt;%@)(.+?)(%&gt;)/gi, output : '$1<span>$2</span>$3' }, 
+//Numbers      
+       { input : /\b([\d]+)\b/g, output : '<var>$1</var>' }, 
+// Reserved Words 1 (Blue)
+       { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '<a>$1</a>' }, 
+       { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '<a>$1</a>' }, 
+       { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '<a>$1</a>' }, 
+// Reserved Words 2 (Purple)   
+       { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '<u>$1</u>' },
+       { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '<u>$1</u>' }, 
+// Reserved Words 3 (Turquis)
+       { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '<i>$1</i>' },
+// html comments
+       { input : /(&lt;!--.*?--&gt.)/g, output : '<big>$1</big>' } 
+]
+
+Language.Functions = [ 
+       // Output at index 0, must be the desired tagname surrounding a $1
+       // Name is the index from the regex that marks the functionname
+       {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '<ins>$1</ins>', name : '$3'}
+]
+
+Language.snippets = [
+//Conditional
+       { input : 'if', output : 'If $0 Then\n\t\nEnd If' },
+       { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' },
+       { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'},
+//Response
+       { input : 'rw', output : 'Response.Write( $0 )' },
+       { input : 'resc', output : 'Response.Cookies( $0 )' },
+       { input : 'resb', output : 'Response.Buffer'},
+       { input : 'resflu', output : 'Response.Flush()'},
+       { input : 'resend', output : 'Response.End'},
+//Request
+       { input : 'reqc', output : 'Request.Cookies( $0 )' },
+       { input : 'rq', output : 'Request.Querystring("$0")' },
+       { input : 'rf', output : 'Request.Form("$0")' },
+//FSO
+       { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' },
+       { input : 'setfo', output : 'Set fo = fso.getFolder($0)' },
+       { input : 'setfi', output : 'Set fi = fso.getFile($0)' },
+       { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'},
+       { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'},
+//Server
+       { input : 'mapp', output : 'Server.Mappath($0)' },
+//Loops
+       { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' },
+       { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' },
+       { input : 'do', output : 'Do While($0)\n\t\nLoop' },
+       { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' },
+//ADO
+       { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' },
+       { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' },
+       { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' },
+//Http Request
+       { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' },
+       { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'},
+//Functions
+       { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'},
+       { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'}
+
+]
+
+Language.complete = [
+       //{ input : '\'', output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = [
+       { input : '[space]', output : '&nbsp;' },
+       { input : '[enter]', output : '<br />' } ,
+       { input : '[j]', output : 'testing' },
+       { input : '[7]', output : '&amp;' }
+]
\ No newline at end of file
diff --git a/web/js/codepress/languages/autoit.css b/web/js/codepress/languages/autoit.css
new file mode 100644 (file)
index 0000000..eb2b43b
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * CodePress color styles for AutoIt syntax highlighting
+ */
+
+u {font-style:normal;color:#000090;font-weight:bold;font-family:Monospace;}
+var {color:#AA0000;font-weight:bold;font-style:normal;}
+em {color:#FF33FF;}
+ins {color:#AC00A9;}
+i {color:#F000FF;}
+b {color:#FF0000;}
+a {color:#0080FF;font-weight:bold;}
+s, s u, s b {color:#9999CC;font-weight:normal;}
+cite, cite *{color:#009933;font-weight:normal;}
\ No newline at end of file
diff --git a/web/js/codepress/languages/autoit.js b/web/js/codepress/languages/autoit.js
new file mode 100644 (file)
index 0000000..6f5c19d
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * CodePress regular expressions for AutoIt syntax highlighting
+ * @author: James Brooks, Michael HURNI
+ */ 
+// AutoIt 
+Language.syntax = [  
+    { input : /({|}|\(|\))/g, output : '<b>$1</b>' }, // Brackets
+       { input : /(\*|\+|-)/g, output : '<b>$1</b>' }, // Operator
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : "<s>\"$1$2</s>" }, // strings double 
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single  
+       { input : /\b([\d]+)\b/g, output : '<ins>$1</ins>' }, // Numbers 
+       { input : /#(.*?)(<br>|<\/P>)/g, output : '<i>#$1</i>$2' }, // Directives and Includes 
+       { input : /(\$[\w\.]*)/g, output : '<var>$1</var>' }, // vars
+       { input : /(_[\w\.]*)/g, output : '<a>$1</a>' }, // underscored word
+       { input : /(\@[\w\.]*)/g, output : '<em>$1</em>' }, // Macros
+       { input : /\b(Abs|ACos|AdlibDisable|AdlibEnable|Asc|AscW|ASin|Assign|ATan|AutoItSetOption|AutoItWinGetTitle|AutoItWinSetTitle|Beep|Binary|BinaryLen|BinaryMid|BinaryToString|BitAND|BitNOT|BitOR|BitSHIFT|BitXOR|BlockInput|Break|Call|CDTray|Ceiling|Chr|ChrW|ClipGet|ClipPut|ConsoleRead|ConsoleWrite|ConsoleWriteError|ControlClick|ControlCommand|ControlDisable|ControlEnable|ControlFocus|ControlGetFocus|ControlGetHandle|ControlGetPos|ControlGetText|ControlHide|ControlListView|ControlMove|ControlSend|ControlSetText|ControlShow|Cos|Dec|DirCopy|DirCreate|DirGetSize|DirMove|DirRemove|DllCall|DllCall|DllClose|DllOpen|DllStructCreate|DllStructGetData|DllStructGetPtr|DllStructGetSize|DllStructSetData|DriveGetDrive|DriveGetFileSystem|DriveGetLabel|DriveGetSerial|DriveGetType|DriveMapAdd|DriveMapDel|DriveMapGet|DriveSetLabel|DriveSpaceFree|DriveSpaceTotal|DriveStatus|EnvGet|EnvSet|EnvUpdate|Eval|Execute|Exp|FileChangeDir|FileClose|FileCopy|FileCreateNTFS|FileCreateShortcut|FileDelete|FileExists|FileFindFirstFile|FileFindNextFile|FileGetAttrib|FileGetLongName|FileGetShortcut|FileGetShortName|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileOpen|FileOpenDialog|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileSaveDialog|FileSelectFolder|FileSetAttrib|FileSetTime|FileWrite|FileWriteLine|Floor|FtpSetProxy|GuiCreate|GuiCtrlCreateAvi|GuiCtrlCreateButton|GuiCtrlCreateCheckbox|GuiCtrlCreateCombo|GuiCtrlCreateContextMenu|GuiCtrlCreateDate|GuiCtrlCreateDummy|GuiCtrlCreateEdit|GuiCtrlCreateGraphic|GuiCtrlCreateGroup|GuiCtrlCreateIcon|GuiCtrlCreateInput|GuiCtrlCreateLabel|GuiCtrlCreateList|GuiCtrlCreateListView|GuiCtrlCreateListViewItem|GuiCtrlCreateMenu|GuiCtrlCreateMenuItem|GuiCtrlCreateMonthCal|GuiCtrlCreateObj|GuiCtrlCreatePic|GuiCtrlCreateProgress|GuiCtrlCreateRadio|GuiCtrlCreateSlider|GuiCtrlCreateTab|GuiCtrlCreateTabItem|GuiCtrlCreateUpdown|GuiCtrlDelete|GuiCtrlGetHandle|GuiCtrlGetState|GuiCtrlRead|GuiCtrlRecvMsg|GuiCtrlSentMsg|GuiCtrlSendToDummy|GuiCtrlSetBkColor|GuiCtrlSetColor|GuiCtrlSetCursor|GuiCtrlSetData|GuiCtrlSetFont|GuiCtrlSetGraphic|GuiCtrlSetImage|GuiCtrlSetLimit|GuiCtrlSetOnEvent|GuiCtrlSetPos|GuiCtrlResizing|GuiCtrlSetState|GuiCtrlSetTip|GuiDelete|GuiGetCursorInfo|GuiGetMsg|GuiGetStyle|GuiRegisterMsg|GuiSetBkColor|GuiSetCoord|GuiSetCursor|GuiSetFont|GuiSetHelp|GuiSetIcon|GuiSetOnEvent|GuiSetStat|GuiSetStyle|GuiStartGroup|GuiSwitch|Hex|HotKeySet|HttpSetProxy|HWnd|InetGet|InetGetSize|IniDelete|IniRead|IniReadSection|IniReadSectionNames|IniRenameSection|IniWrite|IniWriteSection|InputBox|Int|IsAdmin|IsArray|IsBinary|IsBool|IsDeclared|IsDllStruct|IsFloat|IsHWnd|IsInt|IsKeyword|IsNumber|IsObj|IsString|Log|MemGetStats|Mod|MouseClick|MouseClickDrag|MouseDown|MouseGetCursor|MouseGetPos|MouseMove|MouseUp|MouseWheel|MsgBox|Number|ObjCreate|ObjEvent|ObjGet|ObjName|Ping|PixelCheckSum|PixelGetColor|PixelSearch|ProcessClose|ProcessExists|ProcessList|ProcessSetPriority|ProcessWait|ProcessWaitClose|ProgressOff|ProcessOn|ProgressSet|Random|RegDelete|RegEnumKey|RegEnumVal|RegRead|RegWrite|Round|Run|RunAsSet|RunWait|Send|SetError|SetExtended|ShellExecute|ShellExecuteWait|Shutdown|Sin|Sleep|SoundPlay|SoundSetWaveVolume|SplashImageOn|SplashOff|SplashTextOn|Sqrt|SRandom|StatusbarGetText|StderrRead|StdinWrite|StdoutRead|String|StringAddCR|StringCompare|StringFormat|StringInStr|StringIsAlNum|StringIsAlpha|StringIsASCII|StringIsDigit|StringIsFloat|StringIsInt|StringIsLower|StringIsSpace|StringIsUpper|StringIsXDigit|StringLeft|StringLen|StringLower|StringMid|StringRegExp|StringRegExpReplace|StringReplace|StringRight|StringSplit|StringStripCR|StringStripWS|StringToBinary|StringTrimLeft|StringTrimRight|StringUpper|Tan|TCPAccept|TCPCloseSocket|TCPConnect|TCPListen|TCPNameToIP|TCPrecv|TCPSend|TCPShutdown|TCPStartup|TimerDiff|TimerInit|ToolTip|TrayCreateItem|TrayCreateMenu|TrayGetMenu|TrayGetMsg|TrayItemDelete|TrayItemGetHandle|TrayItemGetState|TrayItemGetText|TrayItemSetOnEvent|TrayItemSetState|TrayItemSetText|TraySetClick|TraySetIcon|TraySetOnEvent|TraySetPauseIcon|TraySetState|TraySetToolTip|TrayTip|UBound|UDPBind|UDPCloseSocket|UDPOpen|UDPRecv|UDPSend|WinActivate|WinActive|WinClose|WinExists|WinFlash|WinGetCaretPos|WinGetClassList|WinGetClientSize|WinGetHandle|WinGetPos|WinGetProcess|WinGetState|WinGetText|WinGetTitle|WinKill|WinList|WinMenuSelectItem|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinSetOnTop|WinSetState|WinSetTitle|WinSetTrans|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/g, output : '<u>$1</u>' } ,// reserved words
+       { input : /\B;(.*?)(<br>|<\/P>)/g, output : '<cite>;$1</cite>$2' }, // comments 
+       { input : /#CS(.*?)#CE/g, output : '<cite>#CS$1#CE</cite>' } // Block Comments
+] 
+Language.snippets = [] 
+Language.complete = [ 
+{ input : '\'',output : '\'$0\'' }, 
+{ input : '"', output : '"$0"' }, 
+{ input : '(', output : '\($0\)' }, 
+{ input : '[', output : '\[$0\]' }, 
+{ input : '{', output : '{\n\t$0\n}' } 
+] 
+Language.shortcuts = [] 
diff --git a/web/js/codepress/languages/csharp.css b/web/js/codepress/languages/csharp.css
new file mode 100644 (file)
index 0000000..8464c5d
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * CodePress color styles for Java syntax highlighting
+ * By Edwin de Jonge
+ */
+
+b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */
+a {color:#2A0088;font-weight:bold;font-style:normal;} /* types */
+i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */
+s, s b {color:#2A00FF;font-weight:normal;} /* strings */
\ No newline at end of file
diff --git a/web/js/codepress/languages/csharp.js b/web/js/codepress/languages/csharp.js
new file mode 100644 (file)
index 0000000..0a61fd5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * CodePress regular expressions for C# syntax highlighting
+ * By Edwin de Jonge
+ */
+Language.syntax = [ // C#
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
+       { input : /\'(.?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single quote 
+       { input : /\b(abstract|as|base|break|case|catch|checked|continue|default|delegate|do|else|event|explicit|extern|false|finally|fixed|for|foreach|get|goto|if|implicit|in|interface|internal|is|lock|namespace|new|null|object|operator|out|override|params|partial|private|protected|public|readonly|ref|return|set|sealed|sizeof|static|stackalloc|switch|this|throw|true|try|typeof|unchecked|unsafe|using|value|virtual|while)\b/g, output : '<b>$1</b>' }, // reserved words
+       { input : /\b(bool|byte|char|class|double|float|int|interface|long|string|struct|void)\b/g, output : '<a>$1</a>' }, // types
+       { input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3' }, // comments //  
+       { input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' } // comments /* */
+];
+
+Language.snippets = [];
+
+Language.complete = [ // Auto complete only for 1 character
+       {input : '\'',output : '\'$0\'' },
+       {input : '"', output : '"$0"' },
+       {input : '(', output : '\($0\)' },
+       {input : '[', output : '\[$0\]' },
+       {input : '{', output : '{\n\t$0\n}' }           
+];
+
+Language.shortcuts = [];
\ No newline at end of file
diff --git a/web/js/codepress/languages/css.css b/web/js/codepress/languages/css.css
new file mode 100644 (file)
index 0000000..49ba584
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * CodePress color styles for CSS syntax highlighting
+ */
+
+b, b a, b u {color:#000080;} /* tags, ids, classes */
+i, i b, i s, i a, i u {color:gray;} /* comments */
+s, s b {color:#a0a0dd;} /* parameters */
+a {color:#0000ff;} /* keys */
+u {color:red;} /* values */
+
diff --git a/web/js/codepress/languages/css.js b/web/js/codepress/languages/css.js
new file mode 100644 (file)
index 0000000..c29059b
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * CodePress regular expressions for CSS syntax highlighting
+ */
+
+// CSS
+Language.syntax = [
+       { input : /(.*?){(.*?)}/g,output : '<b>$1</b>{<u>$2</u>}' }, // tags, ids, classes, values
+       { input : /([\w-]*?):([^\/])/g,output : '<a>$1</a>:$2' }, // keys
+       { input : /\((.*?)\)/g,output : '(<s>$1</s>)' }, // parameters
+       { input : /\/\*(.*?)\*\//g,output : '<i>/*$1*/</i>'} // comments
+]
+
+Language.snippets = []
+
+Language.complete = [
+       { input : '\'',output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/generic.css b/web/js/codepress/languages/generic.css
new file mode 100644 (file)
index 0000000..712942f
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * CodePress color styles for generic syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+u {color:darkblue;font-weight:bold;} /* special words */
+i, i b, i s, i u, i em {color:green;font-weight:normal;} /* comments */
+s, s b, s em {color:#2A00FF;font-weight:normal;} /* strings */
+em {font-weight:bold;} /* special chars */
\ No newline at end of file
diff --git a/web/js/codepress/languages/generic.js b/web/js/codepress/languages/generic.js
new file mode 100644 (file)
index 0000000..4c866de
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * CodePress regular expressions for generic syntax highlighting
+ */
+// generic languages
+Language.syntax = [
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single quote
+       { input : /\b(abstract|continue|for|new|switch|default|goto|boolean|do|if|private|this|break|double|protected|throw|byte|else|import|public|throws|case|return|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|const|float|while|function|label)\b/g, output : '<b>$1</b>' }, // reserved words
+       { input : /([\(\){}])/g, output : '<em>$1</em>' }, // special chars;
+       { input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3' }, // comments //
+       { input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' } // comments /* */
+]
+
+Language.snippets = []
+
+Language.complete = [
+       { input : '\'', output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/html.css b/web/js/codepress/languages/html.css
new file mode 100644 (file)
index 0000000..14882e5
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * CodePress color styles for HTML syntax highlighting
+ */
+
+b {color:#000080;} /* tags */
+ins, ins b, ins s, ins em {color:gray;} /* comments */
+s, s b {color:#7777e4;} /* attribute values */
+a {color:green;} /* links */
+u {color:#E67300;} /* forms */
+big {color:#db0000;} /* images */
+em, em b {color:#800080;} /* style */
+strong {color:#800000;} /* script */
+tt i {color:darkblue;font-weight:bold;} /* script reserved words */
diff --git a/web/js/codepress/languages/html.js b/web/js/codepress/languages/html.js
new file mode 100644 (file)
index 0000000..4ead0b0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * CodePress regular expressions for HTML syntax highlighting
+ */
+
+// HTML
+Language.syntax = [
+       { input : /(&lt;[^!]*?&gt;)/g, output : '<b>$1</b>'     }, // all tags
+       { input : /(&lt;a .*?&gt;|&lt;\/a&gt;)/g, output : '<a>$1</a>' }, // links
+       { input : /(&lt;img .*?&gt;)/g, output : '<big>$1</big>' }, // images
+       { input : /(&lt;\/?(button|textarea|form|input|select|option|label).*?&gt;)/g, output : '<u>$1</u>' }, // forms
+       { input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' }, // style tags
+       { input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g, output : '<strong>$1</strong><tt>$2</tt><strong>$3</strong>' }, // script tags
+       { input : /=(".*?")/g, output : '=<s>$1</s>' }, // atributes double quote
+       { input : /=('.*?')/g, output : '=<s>$1</s>' }, // atributes single quote
+       { input : /(&lt;!--.*?--&gt.)/g, output : '<ins>$1</ins>' }, // comments 
+       { input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '<i>$1</i>' } // script reserved words 
+]
+
+Language.snippets = [
+       { input : 'aref', output : '<a href="$0"></a>' },
+       { input : 'h1', output : '<h1>$0</h1>' },
+       { input : 'h2', output : '<h2>$0</h2>' },
+       { input : 'h3', output : '<h3>$0</h3>' },
+       { input : 'h4', output : '<h4>$0</h4>' },
+       { input : 'h5', output : '<h5>$0</h5>' },
+       { input : 'h6', output : '<h6>$0</h6>' },
+       { input : 'html', output : '<html>\n\t$0\n</html>' },
+       { input : 'head', output : '<head>\n\t<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n\t<title>$0</title>\n\t\n</head>' },
+       { input : 'img', output : '<img src="$0" alt="" />' },
+       { input : 'input', output : '<input name="$0" id="" type="" value="" />' },
+       { input : 'label', output : '<label for="$0"></label>' },
+       { input : 'legend', output : '<legend>\n\t$0\n</legend>' },
+       { input : 'link', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },              
+       { input : 'base', output : '<base href="$0" />' }, 
+       { input : 'body', output : '<body>\n\t$0\n</body>' }, 
+       { input : 'css', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
+       { input : 'div', output : '<div>\n\t$0\n</div>' },
+       { input : 'divid', output : '<div id="$0">\n\t\n</div>' },
+       { input : 'dl', output : '<dl>\n\t<dt>\n\t\t$0\n\t</dt>\n\t<dd></dd>\n</dl>' },
+       { input : 'fieldset', output : '<fieldset>\n\t$0\n</fieldset>' },
+       { input : 'form', output : '<form action="$0" method="" name="">\n\t\n</form>' },
+       { input : 'meta', output : '<meta name="$0" content="" />' },
+       { input : 'p', output : '<p>$0</p>' },
+       { input : 'script', output : '<script type="text/javascript" language="javascript" charset="utf-8">\n\t$0\t\n</script>' },
+       { input : 'scriptsrc', output : '<script src="$0" type="text/javascript" language="javascript" charset="utf-8"></script>' },
+       { input : 'span', output : '<span>$0</span>' },
+       { input : 'table', output : '<table border="$0" cellspacing="" cellpadding="">\n\t<tr><th></th></tr>\n\t<tr><td></td></tr>\n</table>' },
+       { input : 'style', output : '<style type="text/css" media="screen">\n\t$0\n</style>' }
+]
+       
+Language.complete = [
+       { input : '\'',output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/java.css b/web/js/codepress/languages/java.css
new file mode 100644 (file)
index 0000000..b9c4441
--- /dev/null
@@ -0,0 +1,7 @@
+/*
+ * CodePress color styles for Java syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;font-style:normal;} /* reserved words */
+i, i b, i s {color:#3F7F5F;font-weight:bold;} /* comments */
+s, s b {color:#2A00FF;font-weight:normal;} /* strings */
diff --git a/web/js/codepress/languages/java.js b/web/js/codepress/languages/java.js
new file mode 100644 (file)
index 0000000..f0d620d
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * CodePress regular expressions for Java syntax highlighting
+ */
+// Java
+Language.syntax = [
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>'}, // strings double quote
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>'}, // strings single quote
+       { input : /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/g, output : '<b>$1</b>'}, // reserved words
+       { input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3'}, // comments //   
+       { input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' }// comments /* */
+]
+
+Language.snippets = []
+
+Language.complete = [
+       { input : '\'',output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/javascript.css b/web/js/codepress/languages/javascript.css
new file mode 100644 (file)
index 0000000..acbf49a
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * CodePress color styles for JavaScript syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+u {color:darkblue;font-weight:bold;} /* special words */
+i, i b, i s, i u {color:green;font-weight:normal;} /* comments */
+s, s b, s u {color:#2A00FF;font-weight:normal;} /* strings */
diff --git a/web/js/codepress/languages/javascript.js b/web/js/codepress/languages/javascript.js
new file mode 100644 (file)
index 0000000..66d0fc0
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * CodePress regular expressions for JavaScript syntax highlighting
+ */
+// JavaScript
+Language.syntax = [ 
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single quote
+       { input : /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, output : '<b>$1</b>' }, // reserved words
+       { input : /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover)\b/g, output : '<u>$1</u>' }, // special words
+       { input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3' }, // comments //
+       { input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' } // comments /* */
+]
+
+Language.snippets = [
+       { input : 'dw', output : 'document.write(\'$0\');' },
+       { input : 'getid', output : 'document.getElementById(\'$0\')' },
+       { input : 'fun', output : 'function $0(){\n\t\n}' },
+       { input : 'func', output : 'function $0(){\n\t\n}' }
+]
+
+Language.complete = [
+       { input : '\'',output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/perl.css b/web/js/codepress/languages/perl.css
new file mode 100644 (file)
index 0000000..c2d6d56
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * CodePress color styles for Perl syntax highlighting
+ * By J. Nick Koston
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */
+s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */
+a {color:#006700;font-weight:bold;} /* variables */
+em {color:darkblue;font-weight:bold;} /* functions */
+u {font-weight:bold;} /* special chars */
\ No newline at end of file
diff --git a/web/js/codepress/languages/perl.js b/web/js/codepress/languages/perl.js
new file mode 100644 (file)
index 0000000..06c380d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * CodePress regular expressions for Perl syntax highlighting
+ * By J. Nick Koston
+ */
+
+// Perl
+Language.syntax = [ 
+       { input  : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
+       { input  : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single quote
+       { input  : /([\$\@\%][\w\.]*)/g, output : '<a>$1</a>' }, // vars
+       { input  : /(sub\s+)([\w\.]*)/g, output : '$1<em>$2</em>' }, // functions
+       { input  : /\b(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|do|dump|each|else|elsif|endgrent|endhostent|endnetent|endprotoent|endpwent|eof|eval|exec|exists|exit|fcntl|fileno|find|flock|for|foreach|fork|format|formlinegetc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyaddr|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|goto|grep|hex|hostname|if|import|index|int|ioctl|join|keys|kill|last|lc|lcfirst|length|link|listen|LoadExternals|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgrcv|msgsnd|my|next|no|oct|open|opendir|ordpack|package|pipe|pop|pos|print|printf|push|pwd|qq|quotemeta|qw|rand|read|readdir|readlink|recv|redo|ref|rename|require|reset|return|reverse|rewinddir|rindex|rmdir|scalar|seek|seekdir|select|semctl|semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|stty|study|sub|substr|symlink|syscall|sysopen|sysread|system|syswritetell|telldir|tie|tied|time|times|tr|truncate|uc|ucfirst|umask|undef|unless|unlink|until|unpack|unshift|untie|use|utime|values|vec|waitpid|wantarray|warn|while|write)\b/g, output : '<b>$1</b>' }, // reserved words
+       { input  : /([\(\){}])/g, output : '<u>$1</u>' }, // special chars
+       { input  : /#(.*?)(<br>|<\/P>)/g, output : '<i>#$1</i>$2' } // comments
+]
+
+Language.snippets = []
+
+Language.complete = [
+       { input : '\'',output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/php.css b/web/js/codepress/languages/php.css
new file mode 100644 (file)
index 0000000..23fca5c
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * CodePress color styles for PHP syntax highlighting
+ */
+
+b {color:#000080;} /* tags */
+big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {color:gray;font-weight:normal;} /* comments */
+s, s b, strong s u, strong s cite {color:#5656fa;font-weight:normal;} /* attributes and strings */
+strong a, strong a u {color:#006700;font-weight:bold;} /* variables */
+em {color:#800080;font-style:normal;} /* style */
+ins {color:#800000;} /* script */
+strong u {color:#7F0055;font-weight:bold;} /* reserved words */
+cite, s cite {color:red;font-weight:bold;} /* <?php and ?> */
diff --git a/web/js/codepress/languages/php.js b/web/js/codepress/languages/php.js
new file mode 100644 (file)
index 0000000..1689fba
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * CodePress regular expressions for PHP syntax highlighting
+ */
+
+// PHP
+Language.syntax = [
+       { input : /(&lt;[^!\?]*?&gt;)/g, output : '<b>$1</b>' }, // all tags
+       { input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' }, // style tags
+       { input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g, output : '<ins>$1</ins><ins>$2</ins><ins>$3</ins>' }, // script tags
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>'}, // strings single quote
+       { input : /(&lt;\?)/g, output : '<strong>$1' }, // <?.*
+       { input : /(\?&gt;)/g, output : '$1</strong>' }, // .*?>
+       { input : /(&lt;\?php|&lt;\?=|&lt;\?|\?&gt;)/g, output : '<cite>$1</cite>' }, // php tags
+       { input : /(\$[\w\.]*)/g, output : '<a>$1</a>' }, // vars
+       { input : /\b(false|true|and|or|xor|__FILE__|exception|__LINE__|array|as|break|case|class|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|for|foreach|function|global|if|include|include_once|isset|list|new|print|require|require_once|return|static|switch|unset|use|while|__FUNCTION__|__CLASS__|__METHOD__|final|php_user_filter|interface|implements|extends|public|private|protected|abstract|clone|try|catch|throw|this)\b/g, output : '<u>$1</u>' }, // reserved words
+       { input : /([^:])\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3' }, // php comments //
+       { input : /([^:])#(.*?)(<br|<\/P)/g, output : '$1<i>#$2</i>$3' }, // php comments #
+       { input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' }, // php comments /* */
+       { input : /(&lt;!--.*?--&gt.)/g, output : '<big>$1</big>' } // html comments
+]
+
+Language.snippets = [
+       { input : 'if', output : 'if($0){\n\t\n}' },
+       { input : 'ifelse', output : 'if($0){\n\t\n}\nelse{\n\t\n}' },
+       { input : 'else', output : '}\nelse {\n\t' },
+       { input : 'elseif', output : '}\nelseif($0) {\n\t' },
+       { input : 'do', output : 'do{\n\t$0\n}\nwhile();' },
+       { input : 'inc', output : 'include_once("$0");' },
+       { input : 'fun', output : 'function $0(){\n\t\n}' },    
+       { input : 'func', output : 'function $0(){\n\t\n}' },   
+       { input : 'while', output : 'while($0){\n\t\n}' },
+       { input : 'for', output : 'for($0,,){\n\t\n}' },
+       { input : 'fore', output : 'foreach($0 as ){\n\t\n}' },
+       { input : 'foreach', output : 'foreach($0 as ){\n\t\n}' },
+       { input : 'echo', output : 'echo \'$0\';' },
+       { input : 'switch', output : 'switch($0) {\n\tcase "": break;\n\tdefault: ;\n}' },
+       { input : 'case', output : 'case "$0" : break;' },
+       { input : 'ret0', output : 'return false;' },
+       { input : 'retf', output : 'return false;' },
+       { input : 'ret1', output : 'return true;' },
+       { input : 'rett', output : 'return true;' },
+       { input : 'ret', output : 'return $0;' },
+       { input : 'def', output : 'define(\'$0\',\'\');' },
+       { input : '<?', output : 'php\n$0\n?>' }
+]
+
+Language.complete = [
+       { input : '\'', output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = [
+       { input : '[space]', output : '&nbsp;' },
+       { input : '[enter]', output : '<br />' } ,
+       { input : '[j]', output : 'testing' },
+       { input : '[7]', output : '&amp;' }
+]
\ No newline at end of file
diff --git a/web/js/codepress/languages/ruby.css b/web/js/codepress/languages/ruby.css
new file mode 100644 (file)
index 0000000..edb9028
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * CodePress color styles for Ruby syntax highlighting
+ */
+
+b {color:#7F0055;font-weight:bold;} /* reserved words */
+i, i b, i s, i em, i a, i u {color:gray;font-weight:normal;} /* comments */
+s, s b, s a, s em, s u {color:#2A00FF;font-weight:normal;} /* strings */
+a {color:#006700;font-weight:bold;} /* variables */
+em {color:darkblue;font-weight:bold;} /* functions */
+u {font-weight:bold;} /* special chars */
\ No newline at end of file
diff --git a/web/js/codepress/languages/ruby.js b/web/js/codepress/languages/ruby.js
new file mode 100644 (file)
index 0000000..207f23b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * CodePress regular expressions for Perl syntax highlighting
+ */
+
+// Ruby
+Language.syntax = [
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote 
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single quote
+       { input : /([\$\@\%]+)([\w\.]*)/g, output : '<a>$1$2</a>' }, // vars
+       { input : /(def\s+)([\w\.]*)/g, output : '$1<em>$2</em>' }, // functions
+       { input : /\b(alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\b/g, output : '<b>$1</b>' }, // reserved words
+       { input  : /([\(\){}])/g, output : '<u>$1</u>' }, // special chars
+       { input  : /#(.*?)(<br>|<\/P>)/g, output : '<i>#$1</i>$2' } // comments
+];
+
+Language.snippets = []
+
+Language.complete = [
+       { input : '\'',output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/sql.css b/web/js/codepress/languages/sql.css
new file mode 100644 (file)
index 0000000..92c4b96
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ * CodePress color styles for SQL syntax highlighting
+ * By Merlin Moncure
+ */
+b {color:#0000FF;font-style:normal;font-weight:bold;} /* reserved words */
+u {color:#FF0000;font-style:normal;} /* types */
+a {color:#CD6600;font-style:normal;font-weight:bold;} /* commands */
+i, i b, i u, i a, i s  {color:#A9A9A9;font-weight:normal;font-style:italic;} /* comments */
+s, s b, s u, s a, s i {color:#2A00FF;font-weight:normal;} /* strings */
diff --git a/web/js/codepress/languages/sql.js b/web/js/codepress/languages/sql.js
new file mode 100644 (file)
index 0000000..1d4a21f
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * CodePress regular expressions for SQL syntax highlighting
+ * By Merlin Moncure
+ */
+// SQL
+Language.syntax = [
+       { input : /\'(.*?)(\')/g, output : '<s>\'$1$2</s>' }, // strings single quote
+       { input : /\b(add|after|aggregate|alias|all|and|as|authorization|between|by|cascade|cache|cache|called|case|check|column|comment|constraint|createdb|createuser|cycle|database|default|deferrable|deferred|diagnostics|distinct|domain|each|else|elseif|elsif|encrypted|except|exception|for|foreign|from|from|full|function|get|group|having|if|immediate|immutable|in|increment|initially|increment|index|inherits|inner|input|intersect|into|invoker|is|join|key|language|left|like|limit|local|loop|match|maxvalue|minvalue|natural|nextval|no|nocreatedb|nocreateuser|not|null|of|offset|oids|on|only|operator|or|order|outer|owner|partial|password|perform|plpgsql|primary|record|references|replace|restrict|return|returns|right|row|rule|schema|security|sequence|session|sql|stable|statistics|table|temp|temporary|then|time|to|transaction|trigger|type|unencrypted|union|unique|user|using|valid|value|values|view|volatile|when|where|with|without|zone)\b/gi, output : '<b>$1</b>' }, // reserved words
+       { input : /\b(bigint|bigserial|bit|boolean|box|bytea|char|character|cidr|circle|date|decimal|double|float4|float8|inet|int2|int4|int8|integer|interval|line|lseg|macaddr|money|numeric|oid|path|point|polygon|precision|real|refcursor|serial|serial4|serial8|smallint|text|timestamp|varbit|varchar)\b/gi, output : '<u>$1</u>' }, // types
+       { input : /\b(abort|alter|analyze|begin|checkpoint|close|cluster|comment|commit|copy|create|deallocate|declare|delete|drop|end|execute|explain|fetch|grant|insert|listen|load|lock|move|notify|prepare|reindex|reset|restart|revoke|rollback|select|set|show|start|truncate|unlisten|update)\b/gi, output : '<a>$1</a>' }, // commands
+       { input : /([^:]|^)\-\-(.*?)(<br|<\/P)/g, output: '$1<i>--$2</i>$3' } // comments //    
+]
+
+Language.snippets = [
+       { input : 'select', output : 'select $0 from  where ' }
+]
+
+Language.complete = [
+       { input : '\'', output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = []
+
+
+
diff --git a/web/js/codepress/languages/text.css b/web/js/codepress/languages/text.css
new file mode 100644 (file)
index 0000000..474fe60
--- /dev/null
@@ -0,0 +1,5 @@
+/*
+ * CodePress color styles for Text syntax highlighting
+ */
+
+/* do nothing as expected */
diff --git a/web/js/codepress/languages/text.js b/web/js/codepress/languages/text.js
new file mode 100644 (file)
index 0000000..6534aaf
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * CodePress regular expressions for Text syntax highlighting
+ */
+
+// plain text
+Language.syntax = []
+Language.snippets = []
+Language.complete = []
+Language.shortcuts = []
diff --git a/web/js/codepress/languages/vbscript.css b/web/js/codepress/languages/vbscript.css
new file mode 100644 (file)
index 0000000..e1465e9
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * CodePress color styles for ASP-VB syntax highlighting 
+ * By Martin D. Kirk
+ */
+
+/* tags */
+b {
+       color:#000080;
+} 
+/* comments */
+big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {
+       color:gray;
+       font-weight:normal;
+}
+/* ASP comments */
+strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{
+       color:gray;
+       font-weight:normal;
+}
+ /* attributes */ 
+s, s b, span s u, span s cite, strong span s {
+       color:#5656fa ;
+       font-weight:normal;
+}
+ /* strings */ 
+strong s,strong s b, strong s u, strong s cite {
+       color:#009900;
+       font-weight:normal;
+}
+strong ins{
+       color:#000000;
+       font-weight:bold;
+}
+ /* Syntax */
+strong a, strong a u {
+       color:#0000FF;
+       font-weight:;
+}
+ /* Native Keywords */
+strong u {
+       color:#990099;
+       font-weight:bold;
+}
+/* Numbers */
+strong var{
+       color:#FF0000;
+}
+/* ASP Language */
+span{
+       color:#990000;
+       font-weight:bold;
+}
+strong i,strong a i, strong u i {
+       color:#009999;
+}
+/* style */
+em {
+       color:#800080;
+       font-style:normal;
+}
+ /* script */ 
+ins {
+       color:#800000;
+       font-weight:bold;
+}
+
+/* <?php and ?> */
+cite, s cite {
+       color:red;
+       font-weight:bold;
+}
\ No newline at end of file
diff --git a/web/js/codepress/languages/vbscript.js b/web/js/codepress/languages/vbscript.js
new file mode 100644 (file)
index 0000000..21e78dd
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * CodePress regular expressions for ASP-vbscript syntax highlighting
+ */
+
+// ASP VBScript
+Language.syntax = [
+// all tags
+       { input : /(&lt;[^!%|!%@]*?&gt;)/g, output : '<b>$1</b>' }, 
+// style tags  
+       { input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' }, 
+// script tags 
+       { input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g, output : '<ins>$1</ins><ins>$2</ins><ins>$3</ins>' }, 
+// strings "" and attributes
+       { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, 
+// ASP Comment
+       { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<dfn>\'$1$2</dfn>'}, 
+// <%.*
+       { input : /(&lt;%)/g, output : '<strong>$1' }, 
+// .*%>        
+       { input : /(%&gt;)/g, output : '$1</strong>' }, 
+// <%@...%>    
+       { input : /(&lt;%@)(.+?)(%&gt;)/gi, output : '$1<span>$2</span>$3' }, 
+//Numbers      
+       { input : /\b([\d]+)\b/g, output : '<var>$1</var>' }, 
+// Reserved Words 1 (Blue)
+       { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '<a>$1</a>' }, 
+       { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '<a>$1</a>' }, 
+       { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '<a>$1</a>' }, 
+// Reserved Words 2 (Purple)   
+       { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '<u>$1</u>' },
+       { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '<u>$1</u>' }, 
+       { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '<u>$1</u>' }, 
+// Reserved Words 3 (Turquis)
+       { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '<i>$1</i>' }, 
+       { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '<i>$1</i>' },
+// html comments
+       { input : /(&lt;!--.*?--&gt.)/g, output : '<big>$1</big>' } 
+]
+
+Language.Functions = [ 
+       // Output at index 0, must be the desired tagname surrounding a $1
+       // Name is the index from the regex that marks the functionname
+       {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '<ins>$1</ins>', name : '$3'}
+]
+
+Language.snippets = [
+//Conditional
+       { input : 'if', output : 'If $0 Then\n\t\nEnd If' },
+       { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' },
+       { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'},
+//Response
+       { input : 'rw', output : 'Response.Write( $0 )' },
+       { input : 'resc', output : 'Response.Cookies( $0 )' },
+       { input : 'resb', output : 'Response.Buffer'},
+       { input : 'resflu', output : 'Response.Flush()'},
+       { input : 'resend', output : 'Response.End'},
+//Request
+       { input : 'reqc', output : 'Request.Cookies( $0 )' },
+       { input : 'rq', output : 'Request.Querystring("$0")' },
+       { input : 'rf', output : 'Request.Form("$0")' },
+//FSO
+       { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' },
+       { input : 'setfo', output : 'Set fo = fso.getFolder($0)' },
+       { input : 'setfi', output : 'Set fi = fso.getFile($0)' },
+       { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'},
+       { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'},
+//Server
+       { input : 'mapp', output : 'Server.Mappath($0)' },
+//Loops
+       { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' },
+       { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' },
+       { input : 'do', output : 'Do While($0)\n\t\nLoop' },
+       { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' },
+//ADO
+       { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' },
+       { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' },
+       { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' },
+//Http Request
+       { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' },
+       { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'},
+//Functions
+       { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'},
+       { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'}
+
+]
+
+Language.complete = [
+       //{ input : '\'', output : '\'$0\'' },
+       { input : '"', output : '"$0"' },
+       { input : '(', output : '\($0\)' },
+       { input : '[', output : '\[$0\]' },
+       { input : '{', output : '{\n\t$0\n}' }          
+]
+
+Language.shortcuts = [
+       { input : '[space]', output : '&nbsp;' },
+       { input : '[enter]', output : '<br />' } ,
+       { input : '[j]', output : 'testing' },
+       { input : '[7]', output : '&amp;' }
+]
\ No newline at end of file
diff --git a/web/js/codepress/languages/xsl.css b/web/js/codepress/languages/xsl.css
new file mode 100644 (file)
index 0000000..385eaab
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * CodePress color styles for HTML syntax highlighting
+ * By RJ Bruneel
+ */
+b {color:#000080;} /* tags */
+ins, ins b, ins s, ins em {color:gray;} /* comments */
+s, s b {color:#7777e4;} /* attribute values */
+a {color:#E67300;} /* links */
+u {color:#CC66CC;} /* forms */
+big {color:#db0000;} /* images */
+em, em b {color:#800080;} /* style */
+strong {color:#800000;} /* script */
+tt i {color:darkblue;font-weight:bold;} /* script reserved words */
+xsl {color:green;} /* xsl */
diff --git a/web/js/codepress/languages/xsl.js b/web/js/codepress/languages/xsl.js
new file mode 100644 (file)
index 0000000..e93932a
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * CodePress regular expressions for XSL syntax highlighting
+ * By RJ Bruneel
+ */
+
+Language.syntax = [ // XSL
+       {
+       input : /(&lt;[^!]*?&gt;)/g,
+       output : '<b>$1</b>' // all tags
+       },{
+       input : /(&lt;a.*?&gt;|&lt;\/a&gt;)/g,
+       output : '<a>$1</a>' // links
+       },{
+       input : /(&lt;img .*?&gt;)/g,
+       output : '<big>$1</big>' // images
+       },{
+       input : /(&lt;\/?(button|textarea|form|input|select|option|label).*?&gt;)/g,
+       output : '<u>$1</u>' // forms
+       },{
+       input : /(&lt;style.*?&gt;)(.*?)(&lt;\/style&gt;)/g,
+       output : '<em>$1</em><em>$2</em><em>$3</em>' // style tags
+       },{
+       input : /(&lt;script.*?&gt;)(.*?)(&lt;\/script&gt;)/g,
+       output : '<strong>$1</strong><tt>$2</tt><strong>$3</strong>' // script tags
+       },{     
+       input : /(&lt;xsl.*?&gt;|&lt;\/xsl.*?&gt;)/g,
+       output : '<xsl>$1</xsl>' // xsl
+       },{
+       input : /=(".*?")/g,
+       output : '=<s>$1</s>' // atributes double quote
+       },{
+       input : /=('.*?')/g,
+       output : '=<s>$1</s>' // atributes single quote
+       },{
+       input : /(&lt;!--.*?--&gt.)/g,
+       output : '<ins>$1</ins>' // comments 
+       },{
+       input : /\b(alert|window|document|break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g,
+       output : '<i>$1</i>' // script reserved words
+       }
+];
+
+Language.snippets = [
+       {input : 'aref', output : '<a href="$0"></a>' },
+       {input : 'h1', output : '<h1>$0</h1>' },
+       {input : 'h2', output : '<h2>$0</h2>' },
+       {input : 'h3', output : '<h3>$0</h3>' },
+       {input : 'h4', output : '<h4>$0</h4>' },
+       {input : 'h5', output : '<h5>$0</h5>' },
+       {input : 'h6', output : '<h6>$0</h6>' },
+       {input : 'html', output : '<html>\n\t$0\n</html>' },
+       {input : 'head', output : '<head>\n\t<meta http-equiv="content-type" content="text/html; charset=utf-8" />\n\t<title>$0</title>\n\t\n</head>' },
+       {input : 'img', output : '<img src="$0" width="" height="" alt="" border="0" />' },
+       {input : 'input', output : '<input name="$0" id="" type="" value="" />' },
+       {input : 'label', output : '<label for="$0"></label>' },
+       {input : 'legend', output : '<legend>\n\t$0\n</legend>' },
+       {input : 'link', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },               
+       {input : 'base', output : '<base href="$0" />' }, 
+       {input : 'body', output : '<body>\n\t$0\n</body>' }, 
+       {input : 'css', output : '<link rel="stylesheet" href="$0" type="text/css" media="screen" charset="utf-8" />' },
+       {input : 'div', output : '<div>\n\t$0\n</div>' },
+       {input : 'divid', output : '<div id="$0">\n\t\n</div>' },
+       {input : 'dl', output : '<dl>\n\t<dt>\n\t\t$0\n\t</dt>\n\t<dd></dd>\n</dl>' },
+       {input : 'fieldset', output : '<fieldset>\n\t$0\n</fieldset>' },
+       {input : 'form', output : '<form action="$0" method="" name="">\n\t\n</form>' },
+       {input : 'meta', output : '<meta name="$0" content="" />' },
+       {input : 'p', output : '<p>$0</p>' },
+       {input : 'b', output : '<b>$0</b>' },
+       {input : 'li', output : '<li>$0</li>' },
+       {input : 'ul', output : '<ul>$0</ul>' },
+       {input : 'ol', output : '<ol>$0</ol>' },
+       {input : 'strong', output : '<strong>$0</strong>' },
+       {input : 'br', output : '<br />' },
+       {input : 'script', output : '<script type="text/javascript" language="javascript" charset="utf-8">\n\t$0\t\n</script>' },
+       {input : 'scriptsrc', output : '<script src="$0" type="text/javascript" language="javascript" charset="utf-8"></script>' },
+       {input : 'span', output : '<span>$0</span>' },
+       {input : 'table', output : '<table border="$0" cellspacing="" cellpadding="">\n\t<tr><th></th></tr>\n\t<tr><td></td></tr>\n</table>' },
+       {input : 'style', output : '<style type="text/css" media="screen">\n\t$0\n</style>' },
+       {input : 'xsl:stylesheet', output : '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' },
+       {input : 'xsl:template', output : '<xsl:template>$0</xsl:template>' },
+       {input : 'xsl:for-each', output : '<xsl:for-each select="$0"></xsl:for-each>' },
+       {input : 'xsl:choose', output : '<xsl:choose>$0<\xsl:choose>' },
+       {input : 'xsl:param', output : '<xsl:param name="$0" />' },
+       {input : 'xsl:variable', output : '<xsl:variable name="$0"></xsl:variable>' },
+       {input : 'xsl:if', output : '<xsl:if test="$0"></xsl:if>' },
+       {input : 'xsl:when', output : '<xsl:when test="$0"></xsl:when>' },
+       {input : 'xsl:otherwise', output : '<xsl:otherwise>$0</xsl:otherwise>' },
+       {input : 'xsl:attribute', output : '<xsl:attribute name="$0"></xsl:attribute>' },
+       {input : 'xsl:value-of', output : '<xsl:value-of select="$0"/>' },
+       {input : 'xsl:with-param', output : '<xsl:with-param name="$0" select="" />' },
+       {input : 'xsl:call-template', output : '<xsl:call-template name="$0">' }
+
+];
+       
+Language.complete = [ // Auto complete only for 1 character
+       {input : '\'',output : '\'$0\'' },
+       {input : '"', output : '"$0"' },
+       {input : '(', output : '\($0\)' },
+       {input : '[', output : '\[$0\]' },
+       {input : '{', output : '{\n\t$0\n}' }           
+];
+
+Language.shortcuts = [];
\ No newline at end of file
diff --git a/web/js/codepress/license.txt b/web/js/codepress/license.txt
new file mode 100644 (file)
index 0000000..e80ac68
--- /dev/null
@@ -0,0 +1,458 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
diff --git a/web/js/communication.js b/web/js/communication.js
new file mode 100644 (file)
index 0000000..27f7504
--- /dev/null
@@ -0,0 +1,533 @@
+if (typeof console == "undefined") {
+    console = {
+        dir: function() { }
+               , monitor: function() { }
+               , debug: function() { }
+               , profile: function() { }
+               , log: function() { }
+               , error: function() { }
+               , warn: function() { }
+               , info: function() { }
+               , profileEnd: function() { }
+               , unmonitor: function() { }
+    };
+}
+if (typeof Lseed == "undefined") {
+    Lseed = {};
+}
+
+Lseed.MessageCommands = {
+       RPC: 'RPC'
+       ,ContentRequest: 'ContentRequest'
+};
+
+Lseed.Communication = function() {
+
+       // ----- Framework -----
+       
+       this.RequestCallbacks = {};
+       
+       this.sendMessage = function (cmd, opts) {
+               var params = {};
+               Ext.apply(params, opts, { cmd: cmd });
+               Ext.Ajax.request({
+                       url: 'php/communication.php',
+                       success: this.handleResponse.createDelegate(this)
+                       ,failure: function(response, opts) {
+                               Ext.MessageBox.alert("Fehler", "Es konnte keine Verbindung zum Server hergestellt werden.")
+                                                         .setIcon(Ext.MessageBox.ERROR);
+                       }
+                       ,params: params
+               });
+       };
+
+       this.handleResponse = function (response, opts) {
+               Ext.MessageBox.hide();
+               console.log("'"+response.responseText+"'");
+               try {
+                       if (!response.responseText) {
+                               console.error("empty answer");
+                               return;
+                       }
+                       var obj = Ext.decode(response.responseText);
+                       var cmd = obj.cmd;
+
+                       switch (cmd) {
+                               case 'RPC':
+                                       obj.func.CreateDelegate(this)(obj.data);
+                                       break;
+                               case 'RPC-Response':
+                                       this.RequestCallbacks[obj.calledFunc](obj.data);
+                                       break;
+                               case 'Message':
+                                       this.showMessage(obj.msg, obj.type);
+                                       break;
+                               case 'Content':
+                                       this.stopWaitingForPage();
+                                       
+                                       this.showContent(obj.content, obj.contentname);
+                                       break;
+                       }
+               } catch (e) {
+                       console.error(e);
+               }
+       };
+       
+       this.showMessage = function (msg, type) {
+               var title = "Unbekannte Nachricht";
+               if (type == 'error') {
+                       title = "Fehler";
+               } else if (type == "info") {
+                       title = "Information";
+               }
+               var msgbox = Ext.MessageBox.alert(title, msg);
+               if (type == 'error') {
+                       msgbox.setIcon(Ext.MessageBox.ERROR);
+               } else if (type == "info") {
+                       msgbox.setIcon(Ext.MessageBox.INFO);
+               }
+       };
+       
+       this.AddCallback = function (hook, func) {
+               this.RequestCallbacks[hook] = func;
+       };
+
+
+       // ----- Application -----
+       
+       this.showContent = function (content, contentname) {
+               switch(contentname) {
+                       case "nav":
+                       case "adminnav":
+                               this.loadNavigation(content);
+                               break;
+                       default:
+                               this.loadTab(content, contentname);
+                               break;
+               }
+       };
+       
+       // === LOGIN ===
+       
+       this.isLoggedInCallback = function (loggIn) {
+               if (loggIn) {
+                       Ext.MessageBox.wait("Navigation wird geladen.", "Wird geladen...");
+                       
+                       this.sendMessage(Lseed.MessageCommands.ContentRequest, {content: 'nav'});
+               } else {
+                       this.showLoginDialog();
+               }
+       };
+       
+       this.AuthCallback = function (success) {
+               if (success) {
+                       Ext.MessageBox.wait("Navigation wird geladen.", "Wird geladen...");
+                       
+                       this.sendMessage(Lseed.MessageCommands.ContentRequest, {content: 'nav'});
+               } else {
+                       this.showLoginDialog();
+                       this.showMessage(
+                               "Es trat ein Fehler beim einloggen auf. Bitte überprüfen sie ihre eingaben und versuchen sie es erneut.", 
+                               "error");
+               }
+       };
+
+       this.showLoginDialog = function () {
+               var loginDialog = Ext.getCmp("loginDialog");
+               if (!loginDialog) {
+                       loginDialog = new Ext.Window({
+                               id: 'loginDialog'
+                               ,title: 'Login'
+                               ,modal: true
+                               ,closable: false
+                               ,tbar: ['->',{
+                                       text: 'Register'
+                                       ,icon: 'img/icons/user_add.png'
+                                       ,cls: 'x-btn-text-icon'
+                                       ,handler: function() {
+                                               loginDialog.hide();
+                                               this.showRegisterDialog();
+                                       }.createDelegate(this)
+                               }]
+                               ,items: [{
+                                       id: 'loginDialogForm'
+                                       ,xtype: 'form'
+                                       ,labelWidth: 75
+                                       ,bodyStyle:'padding:5px 5px 0'
+                                       ,width: 350
+                                       ,defaults: {
+                                               width: 230
+                                               ,labelStyle: 'padding-right:5px'
+                                       }
+                                       ,defaultType: 'textfield'
+                                       ,items: [{
+                                               id: 'loginDialogFormUsername'
+                                               ,fieldLabel: 'Benutzername'
+                                               ,name: 'username'
+                                               ,allowBlank:false
+                                       },{
+                                               id: 'loginDialogFormPassword'
+                                               ,fieldLabel: 'Password'
+                                               ,name: 'password'
+                                               ,inputType: 'password'
+                                               ,allowBlank:false
+                                       }]
+                                       ,buttons: [{
+                                               text: 'OK'
+                                               ,handler: this.login.createDelegate(this)
+                                       }]
+                               }]
+                       });
+               }
+               
+               loginDialog.show();
+       };
+       
+       this.login = function() {
+               var cmpUser = Ext.getCmp('loginDialogFormUsername');
+               var cmpPw = Ext.getCmp('loginDialogFormPassword');
+               if (cmpUser && cmpUser.isValid() && 
+                   cmpPw && cmpPw.isValid()) {
+                       var user = cmpUser.getValue();
+                       var pw = cmpPw.getValue();
+                       pw = MD5(pw);
+                       Ext.MessageBox.wait("Authentifiziere.", "Wird geladen...");
+                       
+                       this.sendMessage(Lseed.MessageCommands.RPC, { func: 'Auth', user: user, pw: pw });
+                       this.hideLoginDialog();
+               } else {
+                       this.showMessage("Ungültige Eingabe. Bitte überprüfen.", "error");
+               }
+       };
+       
+       this.logout = function() {
+               Ext.MessageBox.wait("Deauthentifiziere.", "Wird geladen...");
+               
+               this.sendMessage(Lseed.MessageCommands.RPC, { func: 'Logout' });
+               this.clearNavigation();
+               this.closeAllTabs();
+               this.showLoginDialog();
+       };
+
+       this.hideLoginDialog = function () {
+               var cmp = Ext.getCmp('loginDialog');
+               if (cmp) {
+                       cmp.hide();
+               } else {
+                       console.error("Lseed.Communication.hideLoginDialog: loginDialog couldn't be found");
+               }
+       };
+       
+       // === REGISTER ===
+
+       this.showRegisterDialog = function () {
+               var registerDialog = Ext.getCmp("registerDialog");
+               if (!registerDialog) {
+                       registerDialog = new Ext.Window({
+                               id: 'registerDialog'
+                               ,title: 'Register'
+                               ,modal: true
+                               ,closable: true
+                               ,listeners: {
+                                       close: this.showLoginDialog
+                               }
+                               ,items: [{
+                                       id: 'registerDialogForm'
+                                       ,xtype: 'form'
+                                       ,labelWidth: 75
+                                       ,bodyStyle:'padding:5px 5px 0'
+                                       ,width: 350
+                                       ,defaults: {
+                                               width: 230
+                                               ,labelStyle: 'padding-right:5px'
+                                       }
+                                       ,defaultType: 'textfield'
+                                       ,items: [{
+                                               id: 'registerDialogFormUsername'
+                                               ,fieldLabel: 'Benutzername'
+                                               ,name: 'username'
+                                               ,allowBlank:false
+                                       },{
+                                               id: 'registerDialogFormPassword'
+                                               ,fieldLabel: 'Password'
+                                               ,name: 'password'
+                                               ,inputType: 'password'
+                                               ,allowBlank:false
+                                       },{
+                                               id: 'registerDialogFormPasswordRepeat'
+                                               ,fieldLabel: 'Password Wiederholung'
+                                               ,name: 'passwordRepeat'
+                                               ,inputType: 'password'
+                                               ,allowBlank:false
+                                       }]
+                                       ,buttons: [{
+                                               text: 'Register'
+                                               ,handler: this.register.createDelegate(this)
+                                       },{
+                                               text: 'Cancel'
+                                               ,handler: function() {
+                                                       this.hideRegisterDialog();
+                                                       this.showLoginDialog();
+                                               }.createDelegate(this)
+                                       }]
+                               }]
+                       });
+               }
+               
+               registerDialog.show();
+       };
+
+       this.hideRegisterDialog = function () {
+               var cmp = Ext.getCmp('registerDialog');
+               if (cmp) {
+                       cmp.hide();
+               } else {
+                       console.error("Lseed.Communication.hideRegisterDialog: registerDialog couldn't be found");
+               }
+       };
+       
+       this.register = function() {
+               var cmpUser = Ext.getCmp('registerDialogFormUsername');
+               var cmpPw = Ext.getCmp('registerDialogFormPassword');
+               var cmpPwRepeat = Ext.getCmp('registerDialogFormPasswordRepeat');
+               if (cmpUser && cmpUser.isValid() && 
+                   cmpPw && cmpPw.isValid() && 
+                   cmpPwRepeat && cmpPwRepeat.isValid()) {
+                       var user = cmpUser.getValue();
+                       var pw = cmpPw.getValue();
+                       var pwRepeat = cmpPwRepeat.getValue();
+                       if (pw == pwRepeat) {
+                               pw = MD5(pw);
+                               Ext.MessageBox.wait("Registriere.", "Wird geladen...");
+
+                               this.sendMessage(Lseed.MessageCommands.RPC, { func: 'Register', user: user, pw: pw });
+                               this.hideRegisterDialog();
+                       } else {
+                               this.showMessage("Passwörter stimmen nicht überein. Bitte korrigieren.", "error");
+                       }
+               } else {
+                       this.showMessage("Ungültige Eingabe. Bitte überprüfen.", "error");
+               }
+       };
+       
+       this.RegisterCallback = function (data) {
+               if (data.success) {
+                       Ext.MessageBox.wait("Navigation wird geladen.", "Wird geladen...");
+                       
+                       this.sendMessage(Lseed.MessageCommands.ContentRequest, {content: 'nav'});
+               } else {
+                       this.showRegisterDialog();
+                       this.showMessage(
+                               data.msg, 
+                               "error");
+               }
+       };
+       
+       // === Plant Managerment ===
+       
+       this.GetPlantList = function() {
+               Ext.MessageBox.wait("Pflanzen werden geladen.", "Wird geladen...");
+               
+               this.sendMessage(Lseed.MessageCommands.RPC, { func: 'GetPlantList' });
+       };
+       
+       this.GetPlantListCallback = function(data) {
+               var grid = Ext.getCmp("plantlistgrid");
+               if (grid) {
+                       grid.store.loadData(data.list);
+               } else {
+                       console.error("Lseed.Communication.GetPlantList: 'plantlistgrid' could not be found.");
+               }
+       }
+       
+       this.loadNavigation = function(content) {
+               var cmp = Ext.getCmp('navTree');
+               if (cmp) {
+                       cmp.setRootNode(content);
+               } else {
+                       console.error("Lseed.Communication.loadNavigation: 'navTree' does not exist.");
+               }
+       };
+       
+       this.clearNavigation = function() {
+               var cmp = Ext.getCmp('navTree');
+               if (cmp) {
+                       cmp.setRootNode(new Ext.tree.AsyncTreeNode({
+                               expanded: true
+                               ,children: [{
+                                       text: 'Start'
+                                       ,leaf: true
+                               }]
+                       }));
+               } else {
+                       console.error("Lseed.Communication.clearNavigation: 'navTree' does not exist.");
+               }
+       };
+       
+       this.closeAllTabs = function() {
+               var cmp = Ext.getCmp('contentTabPanel');
+               if (cmp) {
+                       var elem = cmp.get(0);
+                       cmp.removeAll();
+                       cmp.add(elem);
+               } else {
+                       console.error("Lseed.Communication.clearNavigation: 'navTree' does not exist.");
+               }
+       };
+       
+       this.loadTab = function (content, name) {
+               var cmp = Ext.getCmp("contentTabPanel");
+               if (cmp) {
+                       cmp.add(content);
+                       this.activateTab(name)
+               } else {
+                       console.error("Lseed.Communication.showTab: 'contentTabPanel' does not exist.");
+               }
+       };
+       
+       this.getTab = function (tabname) {
+               var result = null;
+               
+               var cmp = Ext.getCmp("contentTabPanel");
+               if (cmp) {
+                       result = cmp.findById("ContentPanel_"+tabname);
+               } else {
+                       console.error("Lseed.Communication.activateTab: 'contentTabPanel' does not exist.");
+               }
+               
+               return result;
+       };
+       
+       this.activateTab = function (tabname) {
+               var done = false;
+               
+               var tab = this.getTab(tabname);
+               
+               if (tab) {
+                       var cmp = Ext.getCmp("contentTabPanel");
+                       if (cmp) {
+                               cmp.setActiveTab(tab);
+                               done = true;
+                       } else {
+                               console.error("Lseed.Communication.activateTab: 'contentTabPanel' does not exist.");
+                       }
+               }
+               
+               return done;
+       };
+       
+       this.showTab = function (tabname) {
+               var done = false;
+               
+               done = this.activateTab(tabname);
+                       
+               if (!done) {
+                       this.waitForPage();
+                       
+                       this.sendMessage(Lseed.MessageCommands.ContentRequest, {content: tabname});
+               }
+       };
+       
+       this.waitForPage = function() {
+               var cmp = Ext.getCmp("loadPageProgressbar");
+               if (cmp) {
+                       cmp.show();
+                       cmp.wait({
+                               interval: 200,
+                               increment: 15,
+                               text: 'Lädt...'
+                       });
+               } else {
+                       console.error("Lseed.Communication.waitForPage: loadPageProgressbar is not defined.");
+               }
+       };
+       
+       this.stopWaitingForPage = function() {
+               var cmp = Ext.getCmp("loadPageProgressbar");
+               if (cmp) {
+                       cmp.updateText("");
+                       cmp.reset();
+               } else {
+                       console.error("Lseed.Communication.stopWaitingForPage: loadPageProgressbar is not defined.");
+               }
+       };
+
+       this.Init = function(editor) {
+               Ext.MessageBox.wait("Programmeinstellungen werden geladen.", "Wird geladen...");
+
+               this.AddCallback("IsLoggedIn", this.isLoggedInCallback.createDelegate(this));
+               this.AddCallback("Auth", this.AuthCallback.createDelegate(this));
+               this.AddCallback("Register", this.RegisterCallback.createDelegate(this));
+               this.AddCallback("GetPlantList", this.GetPlantListCallback.createDelegate(this));
+               
+               this.AddCallback("SavePlant", editor.SaveCallback.createDelegate(editor));
+               this.AddCallback("DeletePlant", editor.DeleteCallback.createDelegate(editor));
+               
+               this.sendMessage(Lseed.MessageCommands.RPC, {func: 'IsLoggedIn'});
+       };
+};
+
+
+Lseed.Editor = function() {
+       this.CurrentPlant = {
+               Name: ''
+               ,Definition: ''
+       };
+       
+       this.Save = function(plant) {
+               
+               communication.sendMessage(Lseed.MessageCommands.RPC, { 
+                       func: 'SavePlant'
+                       ,name: plant.data.Name
+                       ,code: plant.data.Code
+               });
+       };
+       
+       this.SaveCallback = function(data) {
+               if (data.success) {
+                       communication.showMessage("Erfolgreich gespeichert.", "info");
+               } else {
+                       communication.showMessage(data.msg, "error");
+               }
+       };
+       
+       this.Test = function(plant, callback) {
+               communication.showMessage("Diese Funktion ist leider momentan nicht verfügbar", "error");
+       };
+       
+       this.TestCallback = function() {
+       };
+       
+       this.CheckSyntax = function(plant, callback) {
+               communication.showMessage("Diese Funktion ist leider momentan nicht verfügbar", "error");
+       };
+       
+       this.CheckSyntaxCallback = function() {
+       };
+       
+       this.Delete = function(plant) {
+               communication.sendMessage(Lseed.MessageCommands.RPC, { 
+                       func: 'DeletePlant'
+                       ,id: plant.data.ID
+               });
+       };
+       
+       this.DeleteCallback = function(data) {
+               if (!data.success) {
+                       communication.showMessage("Diese Pflanze konnte leider nicht gelöscht werden.", "error");
+               }
+               communication.GetPlantList();
+       };
+};
+
+Lseed.Plant = Ext.data.Record.create([{
+       name: 'ID'
+       ,type: 'int'
+}, {
+       name: 'Name'
+       ,type: 'string'
+}, {
+       name: 'Code'
+       ,type: 'string'
+}]);
+
diff --git a/web/js/md5.js b/web/js/md5.js
new file mode 100644 (file)
index 0000000..5c067ee
--- /dev/null
@@ -0,0 +1,404 @@
+/*
+ *  md5.js 1.0b 27/06/96
+ *
+ * Javascript implementation of the RSA Data Security, Inc. MD5
+ * Message-Digest Algorithm.
+ *
+ * Copyright (c) 1996 Henri Torgemane. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for any purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies.
+ *
+ * Of course, this soft is provided "as is" without express or implied
+ * warranty of any kind.
+ *
+ *
+ * Modified with german comments and some information about collisions.
+ * (Ralf Mieke, ralf@miekenet.de, http://mieke.home.pages.de)
+ */
+
+
+
+function array(n) {
+  for(i=0;i<n;i++) this[i]=0;
+  this.length=n;
+}
+
+
+
+/* Einige grundlegenden Funktionen müssen wegen
+ * Javascript Fehlern umgeschrieben werden.
+ * Man versuche z.B. 0xffffffff >> 4 zu berechnen..
+ * Die nun verwendeten Funktionen sind zwar langsamer als die Originale,
+ * aber sie funktionieren.
+ */
+
+function integer(n) { return n%(0xffffffff+1); }
+
+function shr(a,b) {
+  a=integer(a);
+  b=integer(b);
+  if (a-0x80000000>=0) {
+    a=a%0x80000000;
+    a>>=b;
+    a+=0x40000000>>(b-1);
+  } else
+    a>>=b;
+  return a;
+}
+
+function shl1(a) {
+  a=a%0x80000000;
+  if (a&0x40000000==0x40000000)
+  {
+    a-=0x40000000;
+    a*=2;
+    a+=0x80000000;
+  } else
+    a*=2;
+  return a;
+}
+
+function shl(a,b) {
+  a=integer(a);
+  b=integer(b);
+  for (var i=0;i<b;i++) a=shl1(a);
+  return a;
+}
+
+function and(a,b) {
+  a=integer(a);
+  b=integer(b);
+  var t1=(a-0x80000000);
+  var t2=(b-0x80000000);
+  if (t1>=0)
+    if (t2>=0)
+      return ((t1&t2)+0x80000000);
+    else
+      return (t1&b);
+  else
+    if (t2>=0)
+      return (a&t2);
+    else
+      return (a&b);
+}
+
+function or(a,b) {
+  a=integer(a);
+  b=integer(b);
+  var t1=(a-0x80000000);
+  var t2=(b-0x80000000);
+  if (t1>=0)
+    if (t2>=0)
+      return ((t1|t2)+0x80000000);
+    else
+      return ((t1|b)+0x80000000);
+  else
+    if (t2>=0)
+      return ((a|t2)+0x80000000);
+    else
+      return (a|b);
+}
+
+function xor(a,b) {
+  a=integer(a);
+  b=integer(b);
+  var t1=(a-0x80000000);
+  var t2=(b-0x80000000);
+  if (t1>=0)
+    if (t2>=0)
+      return (t1^t2);
+    else
+      return ((t1^b)+0x80000000);
+  else
+    if (t2>=0)
+      return ((a^t2)+0x80000000);
+    else
+      return (a^b);
+}
+
+function not(a) {
+  a=integer(a);
+  return (0xffffffff-a);
+}
+
+/* Beginn des Algorithmus */
+
+    var state = new array(4);
+    var count = new array(2);
+        count[0] = 0;
+        count[1] = 0;
+    var buffer = new array(64);
+    var transformBuffer = new array(16);
+    var digestBits = new array(16);
+
+    var S11 = 7;
+    var S12 = 12;
+    var S13 = 17;
+    var S14 = 22;
+    var S21 = 5;
+    var S22 = 9;
+    var S23 = 14;
+    var S24 = 20;
+    var S31 = 4;
+    var S32 = 11;
+    var S33 = 16;
+    var S34 = 23;
+    var S41 = 6;
+    var S42 = 10;
+    var S43 = 15;
+    var S44 = 21;
+
+    function F(x,y,z) {
+        return or(and(x,y),and(not(x),z));
+    }
+
+    function G(x,y,z) {
+        return or(and(x,z),and(y,not(z)));
+    }
+
+    function H(x,y,z) {
+        return xor(xor(x,y),z);
+    }
+
+    function I(x,y,z) {
+        return xor(y ,or(x , not(z)));
+    }
+
+    function rotateLeft(a,n) {
+        return or(shl(a, n),(shr(a,(32 - n))));
+    }
+
+    function FF(a,b,c,d,x,s,ac) {
+        a = a+F(b, c, d) + x + ac;
+        a = rotateLeft(a, s);
+        a = a+b;
+        return a;
+    }
+
+    function GG(a,b,c,d,x,s,ac) {
+        a = a+G(b, c, d) +x + ac;
+        a = rotateLeft(a, s);
+        a = a+b;
+        return a;
+    }
+
+    function HH(a,b,c,d,x,s,ac) {
+        a = a+H(b, c, d) + x + ac;
+        a = rotateLeft(a, s);
+        a = a+b;
+        return a;
+    }
+
+    function II(a,b,c,d,x,s,ac) {
+        a = a+I(b, c, d) + x + ac;
+        a = rotateLeft(a, s);
+        a = a+b;
+        return a;
+    }
+
+    function transform(buf,offset) {
+        var a=0, b=0, c=0, d=0;
+        var x = transformBuffer;
+
+        a = state[0];
+        b = state[1];
+        c = state[2];
+        d = state[3];
+
+        for (i = 0; i < 16; i++) {
+            x[i] = and(buf[i*4+offset],0xff);
+            for (j = 1; j < 4; j++) {
+                x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8);
+            }
+        }
+
+        /* Runde 1 */
+        a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+        d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+        c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+        b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+        a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+        d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+        c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+        b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+        a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+        d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+        c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+        b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+        a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+        d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+        c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+        b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+        /* Runde 2 */
+        a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+        d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+        c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+        b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+        a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+        d = GG ( d, a, b, c, x[10], S22,  0x2441453); /* 22 */
+        c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+        b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+        a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+        d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+        c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+        b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+        a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+        d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+        c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+        b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+        /* Runde 3 */
+        a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+        d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+        c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+        b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+        a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+        d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+        c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+        b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+        a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+        d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+        c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+        b = HH ( b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
+        a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+        d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+        c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+        b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+        /* Runde 4 */
+        a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+        d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+        c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+        b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+        a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+        d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+        c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+        b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+        a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+        d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+        c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+        b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+        a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+        d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+        c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+        b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+        state[0] +=a;
+        state[1] +=b;
+        state[2] +=c;
+        state[3] +=d;
+
+    }
+    /* Mit der Initialisierung von Dobbertin:
+       state[0] = 0x12ac2375;
+       state[1] = 0x3b341042;
+       state[2] = 0x5f62b97c;
+       state[3] = 0x4ba763ed;
+       gibt es eine Kollision:
+
+       begin 644 Message1
+       M7MH=JO6_>MG!X?!51$)W,CXV!A"=(!AR71,<X`Y-IIT9^Z&8L$2N'Y*Y:R.;
+       39GIK9>TF$W()/MEHR%C4:G1R:Q"=
+       `
+       end
+
+       begin 644 Message2
+       M7MH=JO6_>MG!X?!51$)W,CXV!A"=(!AR71,<X`Y-IIT9^Z&8L$2N'Y*Y:R.;
+       39GIK9>TF$W()/MEHREC4:G1R:Q"=
+       `
+       end
+    */
+    function init() {
+        count[0]=count[1] = 0;
+        state[0] = 0x67452301;
+        state[1] = 0xefcdab89;
+        state[2] = 0x98badcfe;
+        state[3] = 0x10325476;
+        for (i = 0; i < digestBits.length; i++)
+            digestBits[i] = 0;
+    }
+
+    function update(b) {
+        var index,i;
+
+        index = and(shr(count[0],3) , 0x3f);
+        if (count[0]<0xffffffff-7)
+          count[0] += 8;
+        else {
+          count[1]++;
+          count[0]-=0xffffffff+1;
+          count[0]+=8;
+        }
+        buffer[index] = and(b,0xff);
+        if (index  >= 63) {
+            transform(buffer, 0);
+        }
+    }
+
+    function finish() {
+        var bits = new array(8);
+        var        padding;
+        var        i=0, index=0, padLen=0;
+
+        for (i = 0; i < 4; i++) {
+            bits[i] = and(shr(count[0],(i * 8)), 0xff);
+        }
+        for (i = 0; i < 4; i++) {
+            bits[i+4]=and(shr(count[1],(i * 8)), 0xff);
+        }
+        index = and(shr(count[0], 3) ,0x3f);
+        padLen = (index < 56) ? (56 - index) : (120 - index);
+        padding = new array(64);
+        padding[0] = 0x80;
+        for (i=0;i<padLen;i++)
+          update(padding[i]);
+        for (i=0;i<8;i++)
+          update(bits[i]);
+
+        for (i = 0; i < 4; i++) {
+            for (j = 0; j < 4; j++) {
+                digestBits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);
+            }
+        }
+    }
+
+/* Ende des MD5 Algorithmus */
+
+function hexa(n) {
+ var hexa_h = "0123456789abcdef";
+ var hexa_c="";
+ var hexa_m=n;
+ for (hexa_i=0;hexa_i<8;hexa_i++) {
+   hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
+   hexa_m=Math.floor(hexa_m/16);
+ }
+ return hexa_c;
+}
+
+
+var ascii="01234567890123456789012345678901" +
+          " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
+          "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+
+function MD5(nachricht)
+{
+ var l,s,k,ka,kb,kc,kd;
+
+ init();
+ for (k=0;k<nachricht.length;k++) {
+   l=nachricht.charAt(k);
+   update(ascii.lastIndexOf(l));
+ }
+ finish();
+ ka=kb=kc=kd=0;
+ for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8));
+ for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8));
+ for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-8)*8));
+ for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*8));
+ s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
+ return s;
+}
diff --git a/web/php/communication.php b/web/php/communication.php
new file mode 100644 (file)
index 0000000..e367d00
--- /dev/null
@@ -0,0 +1,408 @@
+<?php
+       header("Content-type: text/html; charset=utf-8");
+
+       session_start();
+       if (get_magic_quotes_gpc()) { $_POST = array_map( 'stripslashes', $_POST ); }
+
+       // DB
+       function CreateConnection() {
+               $db = @new mysqli( 'localhost', 'lseed', 'GCp:rtAaN8nwTFMP', 'lseed' );;
+               if (mysqli_connect_errno() != 0) {
+                       die( "Argh what did you do? -> SERVERERR=0");
+               }
+               return $db;
+       }
+       function CreateUser($user, $md5pw) {
+               $result = false;
+               $db = CreateConnection();
+
+               $stmt = $db -> prepare("INSERT INTO user (Name, Password, IsAdmin) VALUES (?, ?, ?)");
+               $isadmin = false;
+               $stmt->bind_param("ssb", $user, $md5pw, $isadmin);
+               $stmt->execute();
+
+               if ($stmt->affected_rows == 1) {
+                       $result = true;
+               }
+
+               $db->close();
+
+               return $result;
+       }
+       function GetUser($user) {
+               $result = null;
+               $db = CreateConnection();
+
+               $stmt = $db->prepare("SELECT ID, Name, Password, IsAdmin FROM user WHERE Name=?");
+               $stmt->bind_param("s", $user);
+               $stmt->execute();
+               $stmt->bind_result( $id, $name, $pw, $isadmin);
+
+               if ($stmt->fetch()) {
+                       $result = new User($id, $name, $pw, $isadmin);
+               }
+
+       $db->close();
+
+               return $result;
+       }
+       function InsertNewPlant($userid, $name, $code) {
+               $result = false;
+               $db = CreateConnection();
+
+               $stmt = $db -> prepare("INSERT INTO plant (UserID, Name, Code) VALUES (?, ?, ?)");
+               $stmt->bind_param("dss", $userid, $name, $code);
+               $stmt->execute();
+
+               if ($stmt->affected_rows == 1) {
+                       $result = true;
+               }
+
+               $db->close();
+
+               return $result;
+       }
+       function UpdatePlant($plant) {
+               $result = false;
+               $db = CreateConnection();
+
+               $stmt = $db->prepare("UPDATE plant SET Code=? WHERE ID=?");
+               $stmt->bind_param("sd", $code, $plant->ID);
+               $stmt->execute();
+
+               if ($stmt->affected_rows == 1) {
+                       $result = true;
+               }
+
+               $db->close();
+
+               return $result;
+       }
+       function DropPlant($plant) {
+               $result = false;
+               $db = CreateConnection();
+
+               $stmt = $db->prepare("DELETE FROM plant WHERE ID=?");
+               $stmt->bind_param("d", $plant->ID);
+               $stmt->execute();
+
+               if ($stmt->affected_rows == 1) {
+                       $result = true;
+               }
+
+               $db->close();
+
+               return $result;
+       }
+       function GetPlant($userid, $name) {
+               $result = null;
+               $db = CreateConnection();
+
+               $stmt = $db->prepare("SELECT ID, UserID, Name, Code FROM plant WHERE UserID=? AND Name=?");
+               $stmt->bind_param("ds", $userid, $name);
+               $stmt->execute();
+               $stmt->bind_result( $id, $userid, $name, $code);
+
+               if ($stmt->fetch()) {
+                       $result = new Plant($id, $userid, $name, $code);
+               }
+
+               $db->close();
+
+               return $result;
+       }
+       function GetPlantsForUser($userid) {
+               $result = array();
+               $db = CreateConnection();
+
+               $stmt = $db->prepare("SELECT ID, UserID, Name, Code FROM plant WHERE UserID=?");
+               $stmt->bind_param("d", $userid);
+               $stmt->execute();
+               $stmt->bind_result( $id, $userid, $name, $code);
+
+               while ($stmt->fetch()) {
+                       $plant = new Plant($id, $userid, $name, $code);
+                       $result[] = $plant;
+               }
+
+               $db->close();
+               //echo count($result);
+
+               return $result;
+
+       }
+
+       //Plant management
+
+       function SavePlant($name, $code) {
+               $result = "{ success: true, msg: '' }";
+
+               $user = GetUser($_SESSION['user']);
+               $plant = GetPlant($user->ID, $name);
+               if ($plant == null) {
+                       if (!InsertNewPlant($user->ID, $name, $code)) {
+                               $result = "{ success: false, msg: 'Pflanze konnte nicht erstellt werden.' }";
+                       }
+               } else {
+                       $plant->Code = $code;
+                       if (!UpdatePlant($plant)) {
+                               $result = "{ success: false, msg: 'Pflanze konnte nicht aktualisiert werden.' }";
+                       }
+               }
+
+               return $result;
+       }
+
+       function GetPlantList() {
+               $result = "{ list: [] }";
+
+               $userid = GetUser($_SESSION['user'])->ID;
+               $list = GetPlantsForUser($userid);
+
+               if (count($list) > 0) {
+                       $result = "{ list: [";
+                       $first = true;
+                       foreach ($list as $plant) {
+                               if (!$first) {
+                                       $result .= ", ";
+                               }
+                               //$result .= "{ ID: " . $plant->ID . ", Name: '" . $plant->Name . "', Code: '" . $plant->Code . "' }";
+                               $result .= $plant->ToJson();
+                               $first = false;
+                       }
+                       $result .= "] }";
+               }
+
+               return $result;
+       }
+       
+       function DeletePlant($id) {
+               $result = "{ success: false }";
+
+               $userid = GetUser($_SESSION['user'])->ID;
+               $list = GetPlantsForUser($userid);
+               
+               $plantToBeDeleted = null;
+               foreach ($list as $plant) {
+                       if ($plant->ID == $id) {
+                               $plantToBeDeleted = $plant;
+                               break;
+                       }
+               }
+               if ($plantToBeDeleted != null) {
+                       if (DropPlant($plantToBeDeleted)) {
+                               $result = "{ success: true }";
+                       }
+               }
+
+               return $result;
+       }
+
+       //Communication
+
+       function RPCAnswer($calledFunc, $data) {
+               echo "{ cmd: 'RPC-Response', calledFunc: '".$calledFunc."', data: ".$data." }";
+       }
+
+       function ReturnContent($content) {
+               switch ($content) {
+                       case "myplants":
+                       case "createplant":
+                       case "testplant":
+                               LoadContent($content);
+                               break;
+                       case "nav":
+                               if (IsAdmin() != "false") {
+                                       LoadContent("adminnav");
+                               } else {
+                                       LoadContent($content);
+                               }
+                       break;
+                       case "debug":
+                               if (IsAdmin() != "false") {
+                                       LoadContent($content);
+                               }
+                       break;
+               }
+       }
+
+       function LoadContent($content) {
+                       echo "{ cmd: 'Content', contentname: '".$content."', content: ";
+                       readfile( "page/".$content.".pg" );
+                       echo "}";
+       }
+
+       function ReturnMessage($msg, $type) {
+               echo "{ cmd: 'Message', type: '".$type."', msg: '".$msg."' }";
+       }
+
+       function ReturnRequest($func) {
+               echo "{ cmd: 'RPC', func: ".$func." }";
+       }
+
+       function IsLoggedIn() {
+               $result = "false";
+               if (isset($_SESSION['user']) and isset($_SESSION['pw'])) {
+                       $user = $_SESSION['user'];
+                       $md5pw = $_SESSION['pw'];
+
+                       $userobj = GetUser($user);
+                       if ($userobj != null and $userobj->Password == $md5pw) {
+                               $result = "true";
+                       }
+               }
+
+               return $result;
+       }
+
+       function IsAdmin() {
+               $result = "false";
+               if (isset($_SESSION['user']) and isset($_SESSION['pw'])) {
+                       $user = $_SESSION['user'];
+
+                       $userobj = GetUser($user);
+                       if ($userobj != null and $userobj->IsAdmin) {
+                               $result = "true";
+                       }
+               }
+
+               return $result;
+       }
+
+       function LogIn($user, $md5pw) {
+               $result = "false";
+               $userobj = GetUser($user);
+
+               if ($userobj != null and $userobj->Password == $md5pw) {
+                       $_SESSION['user'] = $user;
+                       $_SESSION['pw'] = $md5pw;
+
+                       $result = "true";
+               }
+
+               return $result;
+       }
+
+       function LogOut() {
+               $_SESSION['user'] = "";
+               $_SESSION['pw'] = "";
+       }
+
+       function Register($user, $md5pw) {
+               $result = "{ success: true, msg: '' }";
+               $userobj = GetUser($user);
+
+               if ($userobj == null) {
+                       if (!CreateUser($user, $md5pw)) {
+                               $result = "{ success: false, msg: 'Benutzer konnte nicht erstellt werden.' }";
+                       } else {
+                               LogIn($user, $md5pw);
+                       }
+               } else {
+                       $result = "{ success: false, msg: 'Benutzername bereits vergeben.' }";
+               }
+
+               return $result;
+       }
+
+       switch ($_POST["cmd"]) {
+               case "RPC":
+                       switch ($_POST["func"]) {
+                               case "IsLoggedIn":
+                                       $res = IsLoggedIn();
+                                       RPCAnswer($_POST["func"], $res);
+                                       break;
+
+                               case "Auth":
+                                       $res = LogIn($_POST["user"], $_POST["pw"]);
+                                       RPCAnswer($_POST["func"], $res);
+                                       break;
+
+                               case "Logout":
+                                       LogOut();
+                                       echo "{}";
+                                       break;
+
+                               case "Register":
+                                       $res = Register($_POST["user"], $_POST["pw"]);
+                                       RPCAnswer($_POST["func"], $res);
+                                       break;
+
+                               case "SavePlant":
+                                       $res = SavePlant($_POST["name"], $_POST["code"]);
+                                       RPCAnswer($_POST["func"], $res);
+                                       break;
+
+                               case "CreatePlant":
+                                       break;
+
+                               case "GetPlantList":
+                                       $res = GetPlantList();
+                                       RPCAnswer($_POST["func"], $res);
+                                       break;
+
+                               case "DeletePlant":
+                                       $res = DeletePlant($_POST["id"]);
+                                       RPCAnswer($_POST["func"], $res);
+                                       break;
+
+                               case "TestPlant":
+                                       break;
+                       }
+                       break;
+
+               case "ContentRequest":
+                       if (IsLoggedIn() != "false") {
+                               ReturnContent($_POST["content"]);
+                       } else {
+                               $func = <<<EOS
+function() {
+       this.showLoginDialog();
+       this.showMessage('Sie sind nicht eingeloggt bitte einloggen', 'error');
+}
+EOS;
+                               ReturnRequest($func);
+                       }
+                       break;
+       }
+
+       class User
+       {
+           public $ID;
+           public $Name;
+           public $Password;
+           public $IsAdmin;
+
+               public function __construct($id, $user, $md5pw, $isadmin) {
+                       $this->ID = $id;
+                       $this->Name = $user;
+                       $this->Password = $md5pw;
+                       $this->IsAdmin = $isadmin;
+               }
+       }
+
+       class Plant
+       {
+           public $ID;
+           public $UserID;
+           public $Name;
+           public $Code;
+
+               public function __construct($id, $userid, $name, $code) {
+                       $this->ID = $id;
+                       $this->UserID = $userid;
+                       $this->Name = $name;
+                       $this->Code = $code;
+               }
+
+               public function ToJson() {
+                       return "{ ID: " . $this->ID . ", Name: '" . $this->Name . "', Code: '" . $this->Code . "' }";
+               }
+
+               public function ToJsonArray() {
+                       return "[ " . $this->ID . ", '" . $this->Name . "', '" . $this->Code . "' ]";
+               }
+       }
+
+
+?>
\ No newline at end of file
diff --git a/web/php/page/adminnav.pg b/web/php/page/adminnav.pg
new file mode 100644 (file)
index 0000000..c5dedf0
--- /dev/null
@@ -0,0 +1,25 @@
+{
+       expanded: true
+       ,children:
+       [{
+               id: 'start'
+               ,text: "Start"
+               ,leaf: true
+       },{
+               id: 'createplant'
+               ,text: "Neue Pflanze erstellen"
+               ,leaf: true
+       },{
+               id: 'myplants'
+               ,text: "Meine Pflanzen"
+               ,leaf: true
+       },{
+               id: 'testplant'
+               ,text: "Pflanze testen"
+               ,leaf: true
+       },{
+               id: 'debug'
+               ,text: "Debug"
+               ,leaf: true
+       }]
+}
\ No newline at end of file
diff --git a/web/php/page/createplant.pg b/web/php/page/createplant.pg
new file mode 100644 (file)
index 0000000..8e29d8c
--- /dev/null
@@ -0,0 +1,65 @@
+{
+       id: 'ContentPanel_createplant'
+       ,closable: true
+       ,style: 'padding: 5px;'
+       ,title: 'Neue Pflanze erstellen'
+       ,layout: 'form'
+       ,labelWidth: 100
+       ,baseCls: 'x-plain'
+       ,bodyStyle:'padding:5px;'
+       ,defaults: {
+               bodyStyle:'padding:5px;'
+       }
+       ,tbar: [{
+               text: "Save"
+               ,icon: 'img/icons/disk.png'
+               ,cls: 'x-btn-text-icon'
+               ,handler: function() {
+                       var namefield = Ext.getCmp("plantdefinitionnamefield");
+                       var planteditor = Ext.getCmp("plantdefinitioneditor");
+                       if (namefield.isValid()) {
+                       
+                               var plant = new Lseed.Plant({
+                                       Name: namefield.getValue() 
+                                       ,Code: planteditor.getValue()
+                               });
+                               editor.Save(plant);
+                       } else {
+                               communication.showMessage("Ihre Pflanze benötigt einen Namen.", "error");
+                       }
+               }
+       },{
+               text: "Test"
+               ,icon: 'img/icons/magnifier.png'
+               ,cls: 'x-btn-text-icon'
+               ,handler: editor.Test.createDelegate(editor)
+       },{
+               text: "CheckSyntax"
+               ,icon: 'img/icons/accept.png'
+               ,cls: 'x-btn-text-icon'
+               ,handler: editor.CheckSyntax.createDelegate(editor)
+       }]
+       ,items: [{
+               id: "plantdefinitionnamefield"
+               ,xtype: 'textfield'
+               ,name: 'name'
+               ,allowBlank: false
+               ,fieldLabel: 'Name der Pflanze'
+               ,anchor:'100%'
+               ,enableKeyEvents: true
+               ,listeners: {
+                       keyup: editor.NameChanged.createDelegate(editor)
+               }
+       },{
+               id: "plantdefinitioneditor"
+               ,xtype: 'textarea'
+               ,name: 'code'
+               ,fieldLabel: 'Pflanzendefinition'
+               ,anchor:'100% -50'
+               ,enableKeyEvents: true
+               ,listeners: {
+                       keyup: editor.DefinitionChanged.createDelegate(editor)
+               }
+               ,value: 'RULE "MyRule"\nGROW BY 1'
+       }]
+}
\ No newline at end of file
diff --git a/web/php/page/debug.pg b/web/php/page/debug.pg
new file mode 100644 (file)
index 0000000..0bbaa28
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       id: 'ContentPanel_debug'
+       ,closable: true
+       ,style: 'padding: 5px;'
+       ,title: 'Debug'
+       ,html: 'TODO'
+}
\ No newline at end of file
diff --git a/web/php/page/myplants.pg b/web/php/page/myplants.pg
new file mode 100644 (file)
index 0000000..e3ee84f
--- /dev/null
@@ -0,0 +1,121 @@
+{
+       id: 'ContentPanel_myplants'
+       ,closable: true
+       ,style: 'padding: 5px;'
+       ,title: 'Meine Pflanzen'
+       ,layout: 'fit'
+       ,items: [{
+               id: "plantlistgrid"
+               ,title: "Mein Pflanzen"
+               ,xtype: 'grid'
+               ,autoExpandColumn: 'Code'
+               ,plugins: [new Ext.ux.RowEditor({
+                       id: 'plantlistgridEditor'
+                       ,saveText: 'Update'
+               })]
+               ,view: new Ext.grid.GroupingView({
+                       markDirty: false  
+               })
+               ,tbar: [{
+                       id: 'plantlistDeletePlant'
+                       ,text: 'Delete'
+                       ,icon: 'img/icons/cross.png'
+                       ,cls: 'x-btn-text-icon'
+                       ,disabled: true
+                       ,handler: function(){
+                               Ext.getCmp("plantlistgridEditor").stopEditing();
+                               var grid = Ext.getCmp("plantlistgrid");
+                               var s = grid.getSelectionModel().getSelections();
+                               for(var i = 0, r; r = s[i]; i++) {
+                                   grid.getStore().remove(r);
+                               }
+                       }
+               },{
+                       id: 'plantlistTestPlant'
+                       ,text: 'Test'
+                       ,icon: 'img/icons/magnifier.png'
+                       ,cls: 'x-btn-text-icon'
+                       ,disabled: true
+                       ,handler: editor.Test.createDelegate(editor, ['plantlistgrid'], true)
+               },{
+                       id: 'plantlistRefresh'
+                       ,text: 'Refresh'
+                       ,icon: 'img/icons/arrow_refresh.png'
+                       ,cls: 'x-btn-text-icon'
+                       ,handler: communication.GetPlantList.createDelegate(communication)
+               }]
+               ,store: new Ext.data.GroupingStore({
+                       reader: new Ext.data.JsonReader({fields: Lseed.Plant})
+                       ,sortInfo: {field: 'Name', direction: 'ASC'}
+                       ,data: []
+                       ,listeners: {
+                               add: function(sender, records, index) {
+                               },
+                               remove: function(sender, record, index) {
+                                       editor.Delete(record);
+                               },
+                               update: function(sender, record, operation) {
+                                       if (operation == Ext.data.Record.EDIT) {
+                                       } else if (Ext.data.Record.REJECT) {
+                                       } else if (Ext.data.Record.COMMIT) {
+                                       }
+                               }
+                       }
+               })
+               ,columns: [
+                       new Ext.grid.RowNumberer()
+                       ,{
+                               id: 'ID'
+                               ,header: 'ID'
+                               ,width: 200
+                               ,sortable: true
+                               ,dataIndex: 'ID'
+                       },{
+                               id: 'Name'
+                               ,header: 'Name'
+                               ,width: 200
+                               ,sortable: true
+                               ,dataIndex: 'Name'
+                               ,editor: {
+                                       xtype: 'textfield'
+                                       ,allowBlank: false
+                               }
+                       },{
+                               id: 'Code'
+                               ,header: 'Code'
+                               ,width: 200
+                               ,sortable: true
+                               ,dataIndex: 'Code'
+                               ,editor: {
+                                       xtype: 'textfield'
+                                       ,allowBlank: true
+                               }
+                       },{
+                               id: 'Active'
+                               ,header: 'Active'
+                               ,width: 200
+                               ,sortable: true
+                               ,dataIndex: 'Active'
+                               ,editor: {
+                                       xtype: 'checkbox'
+                               }
+                       }
+               ]
+               ,sm: new Ext.grid.RowSelectionModel({
+                       singleSelect:true
+                       ,listeners: {
+                               rowselect: function() {
+                                       Ext.getCmp("plantlistDeletePlant").enable();
+                                       Ext.getCmp("plantlistTestPlant").enable();
+                               }
+                               ,rowdeselect: function() {
+                                       Ext.getCmp("plantlistDeletePlant").disable();
+                                       Ext.getCmp("plantlistTestPlant").disable();
+                               }
+                       }
+               })
+       }]
+       ,listeners: {
+               show: communication.GetPlantList.createDelegate(communication)
+       }
+}
\ No newline at end of file
diff --git a/web/php/page/nav.pg b/web/php/page/nav.pg
new file mode 100644 (file)
index 0000000..1b42df4
--- /dev/null
@@ -0,0 +1,21 @@
+{
+       expanded: true
+       ,children:
+       [{
+               id: 'start'
+               ,text: "Start"
+               ,leaf: true
+       },{
+               id: 'createplant'
+               ,text: "Neue Pflanze erstellen"
+               ,leaf: true
+       },{
+               id: 'myplants'
+               ,text: "Meine Pflanzen"
+               ,leaf: true
+       },{
+               id: 'testplant'
+               ,text: "Pflanze testen"
+               ,leaf: true
+       }]
+}
\ No newline at end of file
diff --git a/web/php/page/testplant.pg b/web/php/page/testplant.pg
new file mode 100644 (file)
index 0000000..09a0506
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       id: 'ContentPanel_testplant'
+       ,closable: true
+       ,style: 'padding: 5px;'
+       ,title: 'Pflanze testen'
+       ,html: 'TODO'
+}
\ No newline at end of file
diff --git a/web/php/phpinfo.php b/web/php/phpinfo.php
new file mode 100644 (file)
index 0000000..c9f5eeb
--- /dev/null
@@ -0,0 +1 @@
+<?php phpinfo(); ?>
\ No newline at end of file
diff --git a/web/setup/script00.sql b/web/setup/script00.sql
new file mode 100644 (file)
index 0000000..ef1037b
--- /dev/null
@@ -0,0 +1,29 @@
+CREATE DATABASE `lseed` ;
+
+CREATE USER 'lseed'@'localhost' IDENTIFIED BY 'GCp:rtAaN8nwTFMP';
+
+REVOKE ALL PRIVILEGES ON * . * FROM 'lseed'@'localhost';
+REVOKE GRANT OPTION ON * . * FROM 'lseed'@'localhost';
+GRANT SELECT, INSERT, UPDATE, DELETE ON * . *
+TO 'lseed'@'localhost'
+WITH MAX_QUERIES_PER_HOUR 0
+MAX_CONNECTIONS_PER_HOUR 0
+MAX_UPDATES_PER_HOUR 0
+
+CREATE TABLE `User` (
+       `ID` INT( 255 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+       `Name` VARCHAR( 255 ) NOT NULL ,
+       `Password` VARCHAR( 255 ) NOT NULL ,
+       `IsAdmin` BOOL NOT NULL ,
+       INDEX ( `Name` )
+) ENGINE = MYISAM ;
+
+CREATE TABLE `plant` (
+       `ID` INT( 255 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+       `UserID` INT( 255 ) NOT NULL ,
+       `Name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
+       `Code` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
+       INDEX ( `UserID` )
+) ENGINE = MYISAM ;
+
+
diff --git a/web/test.html b/web/test.html
new file mode 100644 (file)
index 0000000..9113a84
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html>
+       <head>
+               <title>L-Seed test</title>
+               <script type="text/javascript" src="js/codepress/codepress.js"></script>
+                       </head>
+       <body>
+
+
+               <textarea id="testarea" class="codepress javascript" style="height:300px; width:100%"></textarea>
+       </body>
+</html>
\ No newline at end of file