|
From: <net...@us...> - 2012-12-25 22:29:38
|
Revision: 1247
http://openautomation.svn.sourceforge.net/openautomation/?rev=1247&view=rev
Author: netzkind
Date: 2012-12-25 22:29:23 +0000 (Tue, 25 Dec 2012)
Log Message:
-----------
finished milestone 3; please see editor/DEVELOPMENT.txt for details; anyways, this should already be usable; saving is enabled
Modified Paths:
--------------
CometVisu/trunk/editor-gfx/Buttons_Visu_sprite.psd
CometVisu/trunk/visu/editor/DEVELOPMENT.txt
CometVisu/trunk/visu/editor/index.html
CometVisu/trunk/visu/editor/init.js
CometVisu/trunk/visu/editor/lib/Configuration.js
CometVisu/trunk/visu/editor/lib/Editor.css
CometVisu/trunk/visu/editor/lib/Editor.js
CometVisu/trunk/visu/editor/lib/Messages.js
CometVisu/trunk/visu/editor/lib/Schema.js
CometVisu/trunk/visu/editor/lib/editor_sprite.png
CometVisu/trunk/visu/visu_config_demo.xml
Added Paths:
-----------
CometVisu/trunk/visu/editor/bin/
CometVisu/trunk/visu/editor/bin/save_config.php
CometVisu/trunk/visu/editor/dataproviders/
CometVisu/trunk/visu/editor/dataproviders/DataProviderConfig.js
CometVisu/trunk/visu/editor/dataproviders/dpt_list.json
CometVisu/trunk/visu/editor/dataproviders/list_all_addresses.php
CometVisu/trunk/visu/editor/dataproviders/list_all_rrds.php
CometVisu/trunk/visu/editor/dependencies/
CometVisu/trunk/visu/editor/dependencies/json2.js
CometVisu/trunk/visu/editor/lib/ActiveInput.js
CometVisu/trunk/visu/editor/lib/DataProvider.js
CometVisu/trunk/visu/editor/lib/ListenerEvent.js
Modified: CometVisu/trunk/editor-gfx/Buttons_Visu_sprite.psd
===================================================================
(Binary files differ)
Modified: CometVisu/trunk/visu/editor/DEVELOPMENT.txt
===================================================================
--- CometVisu/trunk/visu/editor/DEVELOPMENT.txt 2012-12-25 09:52:55 UTC (rev 1246)
+++ CometVisu/trunk/visu/editor/DEVELOPMENT.txt 2012-12-25 22:29:23 UTC (rev 1247)
@@ -2,7 +2,6 @@
* loading the XSD is done in Javascript. The Schema-Loader knows a certain set an structure of an XSD. If "unknown"
XSD-features are being used in the schema, the Schema-Loader may not know about them, and the editor will thus fail.
* the Schema care a little for bounds. It does, however, not support 'multi-dimensional'-bounds.
-* has no f'ing clue about mixed items - seriously, how are you supposed to display a mixed element in a tree?
* user-feedback is done using window.alert() - this works accross all devices and browsers, has no ux-issues on small
screens, and enforces the users attention.
* XSD is fucked up. minOccurs on elements in a choice are ignored if said choice is bounded otherwise
@@ -19,17 +18,19 @@
- node-attributes can be edited
- node children can be added, removed
-* MS3 - week 49/50 2012
- - nodes have copy & paste, move.
+* MS3 - week 52 2012
+ - nodes have copy&paste, move.
- configuration can be saved
- attributes like rrd, addr can be selected from a list; said list is loaded from the server
- - attributes like styling, mapping can be selected from a dynamic list; list is based on actual configuration
+ - attributes like styling, mapping can be selected from a dynamic list; list is based on current configuration
-* MS4 - week 52 2012
+* MS4 - early 2013
+ - better check bounds of configuration, including multi-dimensional bounds, sequences?
- preview for a selected node without the need of replacing the configuration on the server
=== TODO ===
+
* MS1:
- done
@@ -37,17 +38,13 @@
- done
* MS3:
- - frontend: have copy&paste for nodes incl. children
- - frontend: have move for nodes incl. children (drag&drop?; mind touch-devices!)
- - frontend: save configuration
- - backend (save the xml; php)
- - cross-reference: have select-lists for mapping, stylings, ... defined by the config itself
- - allow for multi-dimensional bounds, as well as sequence?
+ - done
* MS4:
+ - allow for multi-dimensional bounds, as well as sequence?
- frontend: preview node incl. children
=== IDEAS ===
* read xsd:annotation and xsd:documentation including xml:lang for tooltips/...
-* allow for mixed nodes (see http://stackoverflow.com/questions/937640/how-to-access-xml-text-node-in-jquery)
+* transparently exchange whitespaces with for text-nodes to make sure the user gets what he entered ...
Added: CometVisu/trunk/visu/editor/bin/save_config.php
===================================================================
--- CometVisu/trunk/visu/editor/bin/save_config.php (rev 0)
+++ CometVisu/trunk/visu/editor/bin/save_config.php 2012-12-25 22:29:23 UTC (rev 1247)
@@ -0,0 +1,155 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Save a serialized representation of a configuration to its file.
+ * Serialization is done by means of JSON.
+ *
+ *
+ * LICENSE: This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
+ *
+ * @category editor
+ * @package CometVisu
+ * @author Julian Makowski (julian at makowskis dot de)
+ * @copyright 2012 Julian Makowski
+ * @license GPLv3 or later, http://opensource.org/licenses/gpl-license.php
+ * @version SVN: $Id$
+ * @link http://cometvisu.de
+ * @since 2012-12-12
+ */
+
+define('CONFIG_FILENAME', '../../visu_config%s.xml');
+
+// get everything the user has provided ...
+$strJson = (true === isset($_POST['data'])) ? $_POST['data'] : null;
+$strConfig = (true === isset($_POST['config'])) ? $_POST['config'] : null;
+
+$strConfigSuffix = preg_replace('/^visu_config_?(.*?)\.xml$/', '$1', $strConfig);
+
+// clean-up filename, we want no security-holes. work with a whitelist.
+$strConfigCleaned = preg_replace("/[^\-\_0-9da-z]/i", "", $strConfigSuffix);
+
+// generate the configurations filename
+$strConfigFilename = sprintf(CONFIG_FILENAME, $strConfigCleaned);
+// .. as a fully qualified filename
+$strConfigFQFilename = realpath($strConfigFilename);
+
+if (false === is_writeable($strConfigFQFilename)) {
+ exitWithResponse(false, 'config-file is not writeable by webserver-process; please chmod/chown config-file \'' . $strConfigFQFilename . '\'.');
+}
+
+// bail out if no json/configuration-data was provided
+if (true === empty($strJson)) {
+ exitWithResponse(false, 'no configuration-content given');
+}
+
+// decode json
+$arrData = json_decode(stripslashes($strJson), true);
+
+try {
+ /** die alten Mappings und stylings übernehmen */
+ $objDOM = new DOMDocument('1.0', 'UTF-8');
+ $objDOM->formatOutput = true;
+
+
+ foreach ($arrData as $arrRootNodeData) {
+ $objDOM->appendChild(createDOMFromData($objDOM, $arrRootNodeData));
+ }
+
+
+ // stupid hacking. create the xml twice to receive nice newlines and indentation ...
+ $strXML = $objDOM->saveXML();
+ $objXML = new DOMDocument();
+ $objXML->preserveWhiteSpace = false;
+ $objXML->formatOutput = true;
+ $objXML->loadXML($strXML);
+
+ // save the XML to its configuration file
+ $handle = fopen($strConfigFQFilename, "w");
+ fputs($handle, $objXML->saveXML());
+ fclose($handle);
+} catch (Exception $e) {
+ exitWithResponse(false, 'error: ' . $e->getMessage());
+}
+
+exitWithResponse(true, 'all good');
+
+/**
+ * create the DOM from a node
+ *
+ * @param object $objMasterDOM master-DOM
+ * @param array $arrConfig the configuration received from the editor, or a part of it
+ * @returns object DOM-object
+ * @throws InvalidArgumentException
+ */
+function createDOMFromData($objMasterDOM, $arrConfig) {
+
+ if (false === isset($arrConfig['nodeName'])) {
+ throw new InvalidArgumentException('node has no name, ' . var_export($arrConfig, true));
+ }
+
+ if ($arrConfig['nodeName'] == '#text') {
+ // this is a masqueraded text-only node
+ $objXMLElement = $objMasterDOM->createTextNode($arrConfig['nodeValue']);
+ return $objXMLElement;
+ }
+
+ // create a new DOM-Element
+ $objXMLElement = $objMasterDOM->createElement($arrConfig['nodeName']);
+
+ if (false === empty($arrConfig['attributes'])) {
+ // add all of our attributes
+ foreach ($arrConfig['attributes'] as $strName => $mixValue) {
+ $objXMLElement->setAttribute($strName, $mixValue);
+ }
+ }
+
+ if (false === empty($arrConfig['children'])) {
+ // create and add new nodes for all of our children
+ foreach ($arrConfig['children'] as $arrChildData) {
+ $objXMLElement->appendChild(createDOMFromData($objMasterDOM, $arrChildData));
+ }
+ }
+
+
+ if (false === empty($arrConfig['nodeValue'])) {
+ // set the node value, if any
+ $objCDATA = $objMasterDOM->createTextNode($arrConfig['nodeValue']);
+ $objXMLElement->appendChild($objCDATA);
+ }
+
+
+ return $objXMLElement;
+}
+
+/**
+ * create and send a response.
+ * This function will issue an exit command!
+ *
+ * @param boolean $boolSuccess was the operating successful?
+ * @param string $strMessage a message, if any
+ */
+function exitWithResponse($boolSuccess, $strMessage = '') {
+ header('Content-type: application/json');
+ $arrResponse = array(
+ 'success' => (bool)$boolSuccess,
+ 'message' => (string)$strMessage
+ );
+
+ print json_encode($arrResponse);
+ exit;
+}
+
+?>
+
Added: CometVisu/trunk/visu/editor/dataproviders/DataProviderConfig.js
===================================================================
--- CometVisu/trunk/visu/editor/dataproviders/DataProviderConfig.js (rev 0)
+++ CometVisu/trunk/visu/editor/dataproviders/DataProviderConfig.js 2012-12-25 22:29:23 UTC (rev 1247)
@@ -0,0 +1,100 @@
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Provide a configuration/list of available data-providers for attributes.
+ *
+ * May be used for any attribute which is defined in the schema/xsd and referenced by a globally defined type
+ *
+ *
+ * LICENSE: This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
+ *
+ * @category editor
+ * @package CometVisu
+ * @author Julian Makowski (julian at makowskis dot de)
+ * @copyright 2012 Julian Makowski
+ * @license GPLv3 or later, http://opensource.org/licenses/gpl-license.php
+ * @version SVN: $Id$
+ * @link http://cometvisu.de
+ * @since 2012-10-17
+ */
+
+var DataProviderConfig = {
+ 'elementValues': {
+ 'address': {
+ url: 'editor/dataproviders/list_all_addresses.php',
+ cache: true,
+ userInputAllowed: true,
+ grouped: true,
+ },
+ },
+ 'attributes': {
+ 'rrd': {
+ url: 'editor/dataproviders/list_all_rrds.php',
+ cache: true,
+ userInputAllowed: true,
+ },
+
+ 'ga': {
+ url: 'editor/dataproviders/list_all_addresses.php',
+ cache: true,
+ userInputAllowed: true,
+ grouped: true,
+ },
+ 'transform': {
+ url: 'editor/dataproviders/dpt_list.json',
+ cache: true,
+ userInputAllowed: false,
+ },
+ 'styling': {
+ live: function() {
+ var stylings = [];
+ // find all current stylings and their names
+ $('#config').find('.element > .name.nodeType_styling .nameValue').each(function () {
+ var text = $(this).text();
+
+ // create an object for this styling
+ var styling = {value: text, label: text};
+
+ // push it to the stack
+ stylings.push(styling);
+ });
+
+ // and off we go.
+ return stylings;
+ },
+ cache: false,
+ userInputAllowed: false,
+ },
+ 'mapping': {
+ live: function() {
+ var stylings = [];
+ // find all current mappings and their names
+ $('#config').find('.element > .name.nodeType_mapping .nameValue').each(function () {
+ var text = $(this).text();
+
+ // create an object for this styling
+ var styling = {value: text, label: text};
+
+ // push it to the stack
+ stylings.push(styling);
+ });
+
+ // and off we go.
+ return stylings;
+ },
+ cache: false,
+ userInputAllowed: false,
+ },
+ },
+};
Added: CometVisu/trunk/visu/editor/dataproviders/dpt_list.json
===================================================================
--- CometVisu/trunk/visu/editor/dataproviders/dpt_list.json (rev 0)
+++ CometVisu/trunk/visu/editor/dataproviders/dpt_list.json 2012-12-25 22:29:23 UTC (rev 1247)
@@ -0,0 +1 @@
+[{"value":"DPT:1.001","label":"DPT_Switch"},{"value":"DPT:1.002","label":"DPT_Bool"},{"value":"DPT:1.003","label":"DPT_Enable"},{"value":"DPT:1.004","label":"DPT_Ramp"},{"value":"DPT:1.005","label":"DPT_Alarm"},{"value":"DPT:1.006","label":"DPT_BinaryValue"},{"value":"DPT:1.007","label":"DPT_Step"},{"value":"DPT:1.008","label":"DPT_UpDown"},{"value":"DPT:1.009","label":"DPT_OpenClose"},{"value":"DPT:1.010","label":"DPT_Start"},{"value":"DPT:1.011","label":"DPT_State"},{"value":"DPT:1.012","label":"DPT_Invert"},{"value":"DPT:1.013","label":"DPT_DimSendStyle"},{"value":"DPT:1.014","label":"DPT_InputSource"},{"value":"DPT:1.015","label":"DPT_Reset"},{"value":"DPT:1.016","label":"DPT_Ack"},{"value":"DPT:1.017","label":"DPT_Trigger"},{"value":"DPT:1.018","label":"DPT_Occupancy"},{"value":"DPT:1.019","label":"DPT_Window_Door"},{"value":"DPT:1.021","label":"DPT_LogicalFunction"},{"value":"DPT:1.022","label":"DPT_Scene_AB"},{"value":"DPT:1.023","label":"DPT_ShutterBlinds_Mode"},{"value":"DPT:1.100","label":"DPT_Heat\/Cool"},{"value":"DPT:2.001","label":"DPT_Switch_Control"},{"value":"DPT:2.002","label":"DPT_Bool_Control"},{"value":"DPT:2.003","label":"DPT_Enable_Control"},{"value":"DPT:2.004","label":"DPT_Ramp_Control"},{"value":"DPT:2.005","label":"DPT_Alarm_Control"},{"value":"DPT:2.006","label":"DPT_BinaryValue_Control"},{"value":"DPT:2.007","label":"DPT_Step_Control"},{"value":"DPT:2.008","label":"DPT_Direction1_Control"},{"value":"DPT:2.009","label":"DPT_Direction2_Control"},{"value":"DPT:2.010","label":"DPT_Start_Control"},{"value":"DPT:2.011","label":"DPT_State_Control"},{"value":"DPT:2.012","label":"DPT_Invert_Control"},{"value":"DPT:3.007","label":"DPT_Control_Dimming"},{"value":"DPT:3.008","label":"DPT_Control_Blinds"},{"value":"DPT:4.001","label":"DPT_Char_ASCII"},{"value":"DPT:4.002","label":"DPT_Char_8859_1"},{"value":"DPT:5.001","label":"DPT_Scaling"},{"value":"DPT:5.003","label":"DPT_Angle"},{"value":"DPT:5.004","label":"DPT_Percent_U8"},{"value":"DPT:5.005","label":"DPT_DecimalFactor"},{"value":"DPT:5.006","label":"DPT_Tariff"},{"value":"DPT:5.010","label":"DPT_Value_1_Ucount"},{"value":"DPT:6.001","label":"DPT_Percent_V8"},{"value":"DPT:6.010","label":"DPT_Value_1_Count"},{"value":"DPT:6.020","label":"DPT_Status_Mode3"},{"value":"DPT:7.001","label":"DPT_Value_2_Ucount"},{"value":"DPT:7.002","label":"DPT_TimePeriodMsec"},{"value":"DPT:7.003","label":"DPT_TimePeriod10MSec"},{"value":"DPT:7.004","label":"DPT_TimePeriod100MSec"},{"value":"DPT:7.005","label":"DPT_TimePeriodSec"},{"value":"DPT:7.006","label":"DPT_TimePeriodMin"},{"value":"DPT:7.007","label":"DPT_TimePeriodHrs"},{"value":"DPT:7.010","label":"DPT_PropDataType"},{"value":"DPT:7.011","label":"DPT_Length_mm"},{"value":"DPT:7.012","label":"DPT_UElCurrentmA"},{"value":"DPT:7.013","label":"DPT_Brightness"},{"value":"DPT:8.001","label":"DPT_Value_2_Count"},{"value":"DPT:8.002","label":"DPT_DeltaTimeMsec"},{"value":"DPT:8.003","label":"DPT_DeltaTime10MSec"},{"value":"DPT:8.004","label":"DPT_DeltaTime100MSec"},{"value":"DPT:8.005","label":"DPT_DeltaTimeSec"},{"value":"DPT:8.006","label":"DPT_DeltaTimeMin"},{"value":"DPT:8.007","label":"DPT_DeltaTimeHrs"},{"value":"DPT:8.010","label":"DPT_Percent_V16"},{"value":"DPT:8.011","label":"DPT_Rotation_Angle"},{"value":"DPT:9.001","label":"DPT_Value_Temp"},{"value":"DPT:9.002","label":"DPT_Value_Tempd"},{"value":"DPT:9.003","label":"DPT_Value_Tempa"},{"value":"DPT:9.004","label":"DPT_Value_Lux"},{"value":"DPT:9.005","label":"DPT_Value_Wsp"},{"value":"DPT:9.006","label":"DPT_Value_Pres"},{"value":"DPT:9.007","label":"DPT_Value_Humidity"},{"value":"DPT:9.008","label":"DPT_Value_AirQuality"},{"value":"DPT:9.010","label":"DPT_Value_Time1"},{"value":"DPT:9.011","label":"DPT_Value_Time2"},{"value":"DPT:9.020","label":"DPT_Value_Volt"},{"value":"DPT:9.021","label":"DPT_Value_Curr"},{"value":"DPT:9.022","label":"DPT_PowerDensity"},{"value":"DPT:9.023","label":"DPT_KelvinPerPercent"},{"value":"DPT:9.024","label":"DPT_Power"},{"value":"DPT:9.025","label":"DPT_Value_Volume_Flow"},{"value":"DPT:9.026","label":"DPT_Rain_Amount"},{"value":"DPT:9.027","label":"DPT_Value_Temp_F"},{"value":"DPT:9.028","label":"DPT_Value_Wsp_kmh"},{"value":"DPT:10.001","label":"DPT_TimeOfDay"},{"value":"DPT:11.001","label":"DPT_Date"},{"value":"DPT:12.001","label":"DPT_Value_4_Ucount"},{"value":"DPT:13.001","label":"DPT_Value_4_Count"},{"value":"DPT:13.010","label":"DPT_ActiveEnergy"},{"value":"DPT:13.011","label":"DPT_ApparantEnergy"},{"value":"DPT:13.012","label":"DPT_ReactiveEnergy"},{"value":"DPT:13.013","label":"DPT_ActiveEnergy_kWh"},{"value":"DPT:13.014","label":"DPT_ApparantEnergy_kVAh"},{"value":"DPT:13.015","label":"DPT_ReactiveEnergy_kVARh"},{"value":"DPT:13.100","label":"DPT_LongDeltaTimeSec"},{"value":"DPT:14.000","label":"DPT_Value_Acceleration"},{"value":"DPT:14.001","label":"DPT_Value_Acceleration_Angular"},{"value":"DPT:14.002","label":"DPT_Value_Activation_Energy"},{"value":"DPT:14.003","label":"DPT_Value_Activity"},{"value":"DPT:14.004","label":"DPT_Value_Mol"},{"value":"DPT:14.005","label":"DPT_Value_Amplitude"},{"value":"DPT:14.006","label":"DPT_Value_AngleRad"},{"value":"DPT:14.007","label":"DPT_Value_AngleDeg"},{"value":"DPT:14.008","label":"DPT_Value_Angular_Momentum"},{"value":"DPT:14.009","label":"DPT_Value_Angular_Velocity"},{"value":"DPT:14.010","label":"DPT_Value_Area"},{"value":"DPT:14.011","label":"DPT_Value_Capacitance"},{"value":"DPT:14.012","label":"DPT_Value_Charge_DensitySurface"},{"value":"DPT:14.013","label":"DPT_Value_Charge_DensityVolume"},{"value":"DPT:14.014","label":"DPT_Value_Compressibility"},{"value":"DPT:14.015","label":"DPT_Value_Conductance"},{"value":"DPT:14.016","label":"DPT_Value_Electrical_Conductivity"},{"value":"DPT:14.017","label":"DPT_Value_Density"},{"value":"DPT:14.018","label":"DPT_Value_Electric_Charge"},{"value":"DPT:14.019","label":"DPT_Value_Electric_Current"},{"value":"DPT:14.020","label":"DPT_Value_Electric_CurrentDensity"},{"value":"DPT:14.021","label":"DPT_Value_Electric_DipoleMoment"},{"value":"DPT:14.022","label":"DPT_Value_Electric_Displacement"},{"value":"DPT:14.023","label":"DPT_Value_Electric_FieldStrength"},{"value":"DPT:14.024","label":"DPT_Value_Electric_Flux"},{"value":"DPT:14.025","label":"DPT_Value_Electric_FluxDensity"},{"value":"DPT:14.026","label":"DPT_Value_Electric_Polarization"},{"value":"DPT:14.027","label":"DPT_Value_Electric_Potential"},{"value":"DPT:14.028","label":"DPT_Value_Electric_PotentialDifference"},{"value":"DPT:14.029","label":"DPT_Value_ElectromagneticMoment"},{"value":"DPT:14.030","label":"DPT_Value_Electromotive_Force"},{"value":"DPT:14.031","label":"DPT_Value_Energy"},{"value":"DPT:14.032","label":"DPT_Value_Force"},{"value":"DPT:14.033","label":"DPT_Value_Frequency"},{"value":"DPT:14.034","label":"DPT_Value_Angular_Frequency"},{"value":"DPT:14.035","label":"DPT_Value_Heat_Capacity"},{"value":"DPT:14.036","label":"DPT_Value_Heat_FlowRate"},{"value":"DPT:14.037","label":"DPT_Value_Heat_Quantity"},{"value":"DPT:14.038","label":"DPT_Value_Impedance"},{"value":"DPT:14.039","label":"DPT_Value_Length"},{"value":"DPT:14.040","label":"DPT_Value_Light_Quantity"},{"value":"DPT:14.041","label":"DPT_Value_Luminance"},{"value":"DPT:14.042","label":"DPT_Value_Luminous_Flux"},{"value":"DPT:14.043","label":"DPT_Value_Luminous_Intensity"},{"value":"DPT:14.044","label":"DPT_Value_Magnetic_FieldStrength"},{"value":"DPT:14.045","label":"DPT_Value_Magnetic_Flux"},{"value":"DPT:14.046","label":"DPT_Value_Magnetic_FluxDensity"},{"value":"DPT:14.047","label":"DPT_Value_Magnetic_Moment"},{"value":"DPT:14.048","label":"DPT_Value_Magnetic_Polarization"},{"value":"DPT:14.049","label":"DPT_Value_Magnetization"},{"value":"DPT:14.050","label":"DPT_Value_MagnetomotiveForce"},{"value":"DPT:14.051","label":"DPT_Value_Mass"},{"value":"DPT:14.052","label":"DPT_Value_MassFlux"},{"value":"DPT:14.053","label":"DPT_Value_Momentum"},{"value":"DPT:14.054","label":"DPT_Value_Phase_AngleRad"},{"value":"DPT:14.055","label":"DPT_Value_Phase_AngleDeg"},{"value":"DPT:14.056","label":"DPT_Value_Power"},{"value":"DPT:14.057","label":"DPT_Value_Power_Factor"},{"value":"DPT:14.058","label":"DPT_Value_Pressure"},{"value":"DPT:14.059","label":"DPT_Value_Reactance"},{"value":"DPT:14.060","label":"DPT_Value_Resistance"},{"value":"DPT:14.061","label":"DPT_Value_Resistivity"},{"value":"DPT:14.062","label":"DPT_Value_SelfInductance"},{"value":"DPT:14.063","label":"DPT_Value_SolidAngle"},{"value":"DPT:14.064","label":"DPT_Value_Sound_Intensity"},{"value":"DPT:14.065","label":"DPT_Value_Speed"},{"value":"DPT:14.066","label":"DPT_Value_Stress"},{"value":"DPT:14.067","label":"DPT_Value_Surface_Tension"},{"value":"DPT:14.068","label":"DPT_Value_Common_Temperature"},{"value":"DPT:14.069","label":"DPT_Value_Absolute_Temperature"},{"value":"DPT:14.070","label":"DPT_Value_TemperatureDifference"},{"value":"DPT:14.071","label":"DPT_Value_Thermal_Capacity"},{"value":"DPT:14.072","label":"DPT_Value_Thermal_Conductivity"},{"value":"DPT:14.073","label":"DPT_Value_ThermoelectricPower"},{"value":"DPT:14.074","label":"DPT_Value_Time"},{"value":"DPT:14.075","label":"DPT_Value_Torque"},{"value":"DPT:14.076","label":"DPT_Value_Volume"},{"value":"DPT:14.077","label":"DPT_Value_Volume_Flux"},{"value":"DPT:14.078","label":"DPT_Value_Weight"},{"value":"DPT:14.079","label":"DPT_Value_Work"},{"value":"DPT:15.000","label":"DPT_Access_Data"},{"value":"DPT:16.000","label":"DPT_String_ASCII"},{"value":"DPT:16.001","label":"DPT_String_8859_1"},{"value":"DPT:17.001","label":"DPT_SceneNumber"},{"value":"DPT:18.001","label":"DPT_SceneControl"},{"value":"DPT:19.001","label":"DPT_DateTime"},{"value":"DPT:20.001","label":"DPT_SCLOMode"},{"value":"DPT:20.002","label":"DPT_BuildingMode"},{"value":"DPT:20.003","label":"DPT_OccMode"},{"value":"DPT:20.004","label":"DPT_Priority"},{"value":"DPT:20.005","label":"DPT_LightApplicationMode"},{"value":"DPT:20.006","label":"DPT_ApplicationArea"},{"value":"DPT:20.007","label":"DPT_AlarmClassType"},{"value":"DPT:20.008","label":"DPT_PSUMode"},{"value":"DPT:20.011","label":"DPT_ErrorClass_System"},{"value":"DPT:20.012","label":"DPT_ErrorClass_HVAC"},{"value":"DPT:20.013","label":"DPT_Time_Delay"},{"value":"DPT:20.014","label":"DPT_Beaufort_Wind_Force_Scale"},{"value":"DPT:20.017","label":"DPT_SensorSelect"},{"value":"DPT:20.100","label":"DPT_FuelType"},{"value":"DPT:20.101","label":"DPT_BurnerType"},{"value":"DPT:20.102","label":"DPT_HVACMode"},{"value":"DPT:20.103","label":"DPT_DHWMode"},{"value":"DPT:20.104","label":"DPT_LoadPriority"},{"value":"DPT:20.105","label":"DPT_HVACContrMode"},{"value":"DPT:20.106","label":"DPT_HVACEmergMode"},{"value":"DPT:20.107","label":"DPT_ChangeoverMode"},{"value":"DPT:20.108","label":"DPT_ValveMode"},{"value":"DPT:20.109","label":"DPT_DamperMode"},{"value":"DPT:20.110","label":"DPT_HeaterMode"},{"value":"DPT:20.111","label":"DPT_FanMode"},{"value":"DPT:20.112","label":"DPT_MasterSlaveMode"},{"value":"DPT:20.113","label":"DPT_StatusRoomSetp"},{"value":"DPT:20.600","label":"DPT_Behaviour_Lock_Unlock"},{"value":"DPT:20.601","label":"DPT_Behaviour_Bus_Power_Up_Down"},{"value":"DPT:20.1000","label":"DPT_CommMode"},{"value":"DPT:20.1001","label":"DPT_AddInfoTypes"},{"value":"DPT:20.1002","label":"DPT_RF_ModeSelect"},{"value":"DPT:20.1003","label":"DPT_RF_FilterSelect"},{"value":"DPT:21.001","label":"DPT_StatusGen"},{"value":"DPT:21.002","label":"DPT_Device_Control"},{"value":"DPT:21.100","label":"DPT_ForceSign"},{"value":"DPT:21.101","label":"DPT_ForceSignCool"},{"value":"DPT:21.102","label":"DPT_StatusRHC"},{"value":"DPT:21.103","label":"DPT_StatusSDHWC"},{"value":"DPT:21.104","label":"DPT_FuelTypeSet"},{"value":"DPT:21.105","label":"DPT_StatusRCC"},{"value":"DPT:21.106","label":"DPT_StatusAHU"},{"value":"DPT:21.1000","label":"DPT_RF_ModeInfo"},{"value":"DPT:21.1001","label":"DPT_RF_FilterInfo"},{"value":"DPT:21.1010","label":"DPT_Channel_Activation_8"},{"value":"DPT:22.100","label":"DPT_StatusDHWC"},{"value":"DPT:22.101","label":"DPT_StatusRHCC"},{"value":"DPT:22.1000","label":"DPT_Media"},{"value":"DPT:22.1010","label":"DPT_Channel_Activation_16"},{"value":"DPT:23.001","label":"DPT_OnOff_Action"},{"value":"DPT:23.002","label":"DPT_Alarm_Reaction"},{"value":"DPT:23.003","label":"DPT_UpDown_Action"},{"value":"DPT:23.102","label":"DPT_HVAC_PB_Action"},{"value":"DPT:24.001","label":"DPT_VarString_8859_1"},{"value":"DPT:25.1000","label":"DPT_DoubleNibble"},{"value":"DPT:26.001","label":"DPT_SceneInfo"},{"value":"DPT:27.001","label":"DPT_CombinedInfoOnOff"},{"value":"DPT:28.001","label":"DPT_UTF-8"},{"value":"DPT:29.010","label":"DPT_ActiveEnergy_V64"},{"value":"DPT:29.011","label":"DPT_ApparantEnergy_V64"},{"value":"DPT:29.012","label":"DPT_ReactiveEnergy_V64"},{"value":"DPT:30.1010","label":"DPT_Channel_Activation_24"},{"value":"DPT:31.101","label":"DPT_PB_Action_HVAC_Extended"},{"value":"DPT:200.100","label":"DPT_Heat\/Cool_Z"},{"value":"DPT:200.101","label":"DPT_BinaryValue_Z"},{"value":"DPT:201.100","label":"DPT_HVACMode_Z"},{"value":"DPT:201.102","label":"DPT_DHWMode_Z"},{"value":"DPT:201.104","label":"DPT_HVACContrMode_Z"},{"value":"DPT:201.105","label":"DPT_EnablH\/Cstage_Z"},{"value":"DPT:201.107","label":"DPT_BuildingMode_Z"},{"value":"DPT:201.108","label":"DPT_OccMode_Z"},{"value":"DPT:201.109","label":"DPT_HVACEmergMode_Z"},{"value":"DPT:202.001","label":"DPT_RelValue_Z"},{"value":"DPT:202.002","label":"DPT_UCountValue8_Z"},{"value":"DPT:203.002","label":"DPT_TimePeriodMsec_Z"},{"value":"DPT:203.003","label":"DPT_TimePeriod10Msec_Z"},{"value":"DPT:203.004","label":"DPT_TimePeriod100Msec_Z"},{"value":"DPT:203.005","label":"DPT_TimePeriodSec_Z"},{"value":"DPT:203.006","label":"DPT_TimePeriodMin_Z"},{"value":"DPT:203.007","label":"DPT_TimePeriodHrs_Z"},{"value":"DPT:203.011","label":"DPT_UFlowRateLiter\/h_Z"},{"value":"DPT:203.012","label":"DPT_UCountValue16_Z"},{"value":"DPT:203.013","label":"DPT_UElCurrent?A_Z"},{"value":"DPT:203.014","label":"DPT_PowerKW_Z"},{"value":"DPT:203.015","label":"DPT_AtmPressureAbs_Z"},{"value":"DPT:203.017","label":"DPT_PercentU16_Z"},{"value":"DPT:203.100","label":"DPT_HVACAirQual_Z"},{"value":"DPT:203.101","label":"DPT_WindSpeed_Z"},{"value":"DPT:203.102","label":"DPT_SunIntensity_Z"},{"value":"DPT:203.104","label":"DPT_HVACAirFlowAbs_Z"},{"value":"DPT:204.001","label":"DPT_RelSignedValue_Z"},{"value":"DPT:205.002","label":"DPT_DeltaTimeMsec_Z"},{"value":"DPT:205.003","label":"DPT_DeltaTime10Msec_Z"},{"value":"DPT:205.004","label":"DPT_DeltaTime100Msec_Z"},{"value":"DPT:205.005","label":"DPT_DeltaTimeSec_Z"},{"value":"DPT:205.006","label":"DPT_DeltaTimeMin_Z"},{"value":"DPT:205.007","label":"DPT_DeltaTimeHrs_Z"},{"value":"DPT:205.100","label":"DPT_TempHVACAbs_Z"},{"value":"DPT:205.101","label":"DPT_TempHVACRel_Z"},{"value":"DPT:205.102","label":"DPT_HVACAirFlowRel_Z"},{"value":"DPT:206.100","label":"DPT_HVACModeNext"},{"value":"DPT:206.102","label":"DPT_DHWModeNext"},{"value":"DPT:206.104","label":"DPT_OccModeNext"},{"value":"DPT:206.105","label":"DPT_BuildingModeNext"},{"value":"DPT:207.100","label":"DPT_StatusBUC"},{"value":"DPT:207.101","label":"DPT_LockSign"},{"value":"DPT:207.102","label":"DPT_ValueDemBOC"},{"value":"DPT:207.104","label":"DPT_ActPosDemAbs"},{"value":"DPT:207.105","label":"DPT_StatusAct"},{"value":"DPT:209.100","label":"DPT_StatusHPM"},{"value":"DPT:209.101","label":"DPT_TempRoomDemAbs"},{"value":"DPT:209.102","label":"DPT_StatusCPM"},{"value":"DPT:209.103","label":"DPT_StatusWTC"},{"value":"DPT:210.100","label":"DPT_TempFlowWaterDemAbs"},{"value":"DPT:211.100","label":"DPT_EnergyDemWater"},{"value":"DPT:212.100","label":"DPT_TempRoomSetpSetShift[3]"},{"value":"DPT:212.101","label":"DPT_TempRoomSetpSet[3]"},{"value":"DPT:213.100","label":"DPT_TempRoomSetpSet[4]"},{"value":"DPT:213.101","label":"DPT_TempDHWSetpSet[4]"},{"value":"DPT:213.102","label":"DPT_TempRoomSetpSetShift[4]"},{"value":"DPT:214.100","label":"DPT_PowerFlowWaterDemHPM"},{"value":"DPT:214.101","label":"DPT_PowerFlowWaterDemCPM"},{"value":"DPT:215.100","label":"DPT_StatusBOC"},{"value":"DPT:215.101","label":"DPT_StatusCC"},{"value":"DPT:216.100","label":"DPT_SpecHeatProd"},{"value":"DPT:217.001","label":"DPT_Version"},{"value":"DPT:218.001","label":"DPT_VolumeLiter_Z"},{"value":"DPT:219.001","label":"DPT_AlarmInfo"},{"value":"DPT:220.100","label":"DPT_TempHVACAbsNext"},{"value":"DPT:221.001","label":"DPT_SerNum"},{"value":"DPT:222.100","label":"DPT_TempRoomSetpSetF16[3]"},{"value":"DPT:222.101","label":"DPT_TempRoomSetpSetShiftF16[3]"},{"value":"DPT:223.100","label":"DPT_EnergyDemAir"},{"value":"DPT:224.100","label":"DPT_TempSupply"},{"value":"DPT:225.001","label":"DPT_ScalingSpeed"},{"value":"DPT:225.002","label":"DPT_Scaling_Step_Time"},{"value":"DPT:229.001","label":"DPT_MeteringValue"},{"value":"DPT:230.1000","label":"DPT_MBus_Address"},{"value":"DPT:231.001","label":"DPT_Locale_ASCII"},{"value":"DPT:232.600","label":"DPT_Colour_RGB"},{"value":"DPT:234.001","label":"DPT_LanguageCodeAlpha2_ASCII"},{"value":"DPT:234.002","label":"DPT_RegionCodeAlpha2_ASCII"}]
\ No newline at end of file
Added: CometVisu/trunk/visu/editor/dataproviders/list_all_addresses.php
===================================================================
--- CometVisu/trunk/visu/editor/dataproviders/list_all_addresses.php (rev 0)
+++ CometVisu/trunk/visu/editor/dataproviders/list_all_addresses.php 2012-12-25 22:29:23 UTC (rev 1247)
@@ -0,0 +1,109 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Provide a list of all system-known addresses for the attribute 'addr'.
+ *
+ * Will also provide hints for the attribute 'transform' as well as use user-readable names when available.
+ *
+ * This file will output a json-encoded object with multiple dimensions.
+ * Each last node will have:
+ * - value: the value for this node
+ * - label: a user-readable description/title of this node
+ * - hints: an object, defining a list of attributes that will be set on the same element in the editor, when this value
+ * is selected.
+ *
+ *
+ * LICENSE: This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
+ *
+ * @category editor
+ * @package CometVisu
+ * @author Julian Makowski (julian at makowskis dot de)
+ * @copyright 2012 Julian Makowski
+ * @license GPLv3 or later, http://opensource.org/licenses/gpl-license.php
+ * @version SVN: $Id$
+ * @link http://cometvisu.de
+ * @since 2012-10-17
+ */
+
+define('FILE_GA', "/etc/wiregate/eibga.conf");
+define('FILE_HG', "/etc/wiregate/eibga_hg.conf");
+define('FILE_MG', "/etc/wiregate/eibga_mg.conf");
+
+// list of group-addresses, main-groups and middle-groups
+$arrGA = array();
+$arrHG = array();
+$arrMG = array();
+
+if (true === file_exists(FILE_GA) && filesize(FILE_GA) > 0) {
+ // read list of known group addresses
+ $arrGA = parse_ini_file(FILE_GA, true);
+}
+if (true === file_exists(FILE_HG) && filesize(FILE_HG) > 0) {
+ // read list of known main groups
+ $arrHG = parse_ini_file(FILE_HG, true);
+}
+if (true === file_exists(FILE_MG) && filesize(FILE_MG) > 0) {
+ // read list of known middle groups
+ $arrMG = parse_ini_file(FILE_MG, true);
+}
+
+
+// create a list of ALL group-addresses, multi-dimensional
+$arrAdresses = array();
+
+// sort the group addresses
+uksort($arrGA, 'GASort');
+
+foreach ($arrGA as $strGA => $arrData) {
+ $arrGAParts = explode("/", $strGA, 3);
+
+ $strHG = "";
+ if (true === isset($arrHG[$arrGAParts[0]])) {
+ $strHG = utf8_encode($arrHG[$arrGAParts[0]]['name']);
+ }
+
+ $strMG = "";
+ if (true === isset($arrMG[$arrGAParts[1]])) {
+ $strMG = utf8_encode($arrMG[$arrGAParts[1]]['name']);
+ }
+
+ $arrAdresses[$strHG . " " . $strMG][] = array(
+ 'value' => $strGA,
+ 'label' => utf8_encode($arrData['name']),
+ 'hints' => array(
+ 'transform' => "DPT:" . $arrData['DPTSubId'],
+ ),
+ );
+}
+
+Header("Content-type: application/json");
+print json_encode($arrAdresses);
+exit;
+
+
+/**
+ * Sort two GroupAddresses, natural sorting
+ *
+ * @param string $a
+ * @param string $b
+ */
+function GASort($a, $b) {
+ $strA = preg_replace('/(^|\/)(\d)(\/|$)/', '${1}0${2}${3}', $a);
+ $strB = preg_replace('/(^|\/)(\d)(\/|$)/', '${1}0${2}${3}', $b);
+
+ return strcmp($strA, $strB);
+}
+
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/editor/dataproviders/list_all_rrds.php
===================================================================
--- CometVisu/trunk/visu/editor/dataproviders/list_all_rrds.php (rev 0)
+++ CometVisu/trunk/visu/editor/dataproviders/list_all_rrds.php 2012-12-25 22:29:23 UTC (rev 1247)
@@ -0,0 +1,71 @@
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Provide a list of all system-known rrd-files for the attribute 'rrd'.
+ *
+ *
+ * This file will output a json-encoded object with multiple dimensions.
+ * Each last node will have:
+ * - value: the value for this node
+ * - label: a user-readable description/title of this node
+ * - hints: an object, defining a list of attributes that will be set on the same element in the editor, when this value
+ * is selected. There are NONE for this file
+ *
+ *
+ * LICENSE: This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
+ *
+ * @category editor
+ * @package CometVisu
+ * @author Julian Makowski (julian at makowskis dot de)
+ * @copyright 2012 Julian Makowski
+ * @license GPLv3 or later, http://opensource.org/licenses/gpl-license.php
+ * @version SVN: $Id$
+ * @link http://cometvisu.de
+ * @since 2012-10-17
+ */
+
+define('FILE_GA', "/etc/wiregate/eibga.conf");
+define('FILE_OW', "/etc/wiregate/owsensors.conf");
+define('DIR_RRD', "/var/www/rrd/*.rrd");
+
+// list of known one-wire-sensors
+$arrSensors = array();
+if (true === file_exists(FILE_OW)) {
+ $arrSensors = parse_ini_file(FILE_OW, true);
+}
+
+// list of all known group-addresses
+$arrGA = array();
+if (true === file_exists(FILE_GA)) {
+ $arrGA = parse_ini_file(FILE_GA, true);
+}
+
+$arrData = array();
+
+foreach (glob(DIR_RRD) as $strFilename) {
+ $strFileBasename = basename($strFilename);
+ $arrRRDParts = explode("_", $strFileBasename, 2);
+
+ $arrData[] = array(
+ 'value' => utf8_encode($strFileBasename),
+ 'label' => utf8_encode($arrSensors[$arrRRDParts[0]]['name']),
+ );
+}
+
+Header("Content-type: application/json");
+print json_encode($arrData);
+exit;
+
+?>
Added: CometVisu/trunk/visu/editor/dependencies/json2.js
===================================================================
--- CometVisu/trunk/visu/editor/dependencies/json2.js (rev 0)
+++ CometVisu/trunk/visu/editor/dependencies/json2.js 2012-12-25 22:29:23 UTC (rev 1247)
@@ -0,0 +1,486 @@
+/*
+ json2.js
+ 2012-10-08
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, regexp: true */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+if (typeof JSON !== 'object') {
+ JSON = {};
+}
+
+(function () {
+ 'use strict';
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf())
+ ? this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z'
+ : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string'
+ ? c
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0
+ ? '[]'
+ : gap
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+ : '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0
+ ? '{}'
+ : gap
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+ : '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function'
+ ? walk({'': j}, '')
+ : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
Modified: CometVisu/trunk/visu/editor/index.html
===================================================================
--- CometVisu/trunk/visu/editor/index.html 2012-12-25 09:52:55 UTC (rev 1246)
+++ CometVisu/trunk/visu/editor/index.html 2012-12-25 22:29:23 UTC (rev 1247)
@@ -1,32 +1,29 @@
<!DOCTYPE html>
<html>
<head>
- <title></title>
+ <title>CometVisu - configuration editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="../dependencies/jquery.js" type="text/javascript"></script>
+ <script src="dependencies/json2.js" type="text/javascript"></script>
+ <script src="dataproviders/DataProviderConfig.js" type="text/javascript"></script>
+ <script src="lib/DataProvider.js" type="text/javascript"></script>
<script src="lib/Messages.js" type="text/javascript"></script>
<script src="lib/Result.js" type="text/javascript"></script>
+ <script src="lib/ListenerEvent.js" type="text/javascript"></script>
<script src="lib/Schema.js" type="text/javascript"></script>
<script src="lib/Configuration.js" type="text/javascript"></script>
+ <script src="lib/ActiveInput.js" type="text/javascript"></script>
<script src="lib/Editor.js" type="text/javascript"></script>
<script src="init.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="lib/Editor.css" />
<base href="../" />
</head>
- <body>
- <div>TODO write content</div>
+ <body style="margin: 0; padding: 0;">
<h1>Editor</h1>
- <p><b>all of this is work in progress</b></p>
- <p>once this is ready, it will be an xsd-aware, form-driven editor for the CometVisu-configuration with a
- tree-like representation of the configuration</p>
- <p>WYSIWIG will be dropped in favour of the xsd-awareness, which will hopefully make this editor withstand
- even massive changes to the visu, the templateengine or the configuration-schema. Any plugin and feature
- which is well defined in the xsd will be supported out-of-the-box (as long as no Ninja-XSD is used...)</p>
-
- <pre>
+ <p>If you keep seeing this text, then there is something wrong with the cable, and/or Javascript is inactive,
+ and/or there is some heavy problem with this editor. Anyways, please report (and tell us which browser you are
+ using).</p>
- </pre>
-
</body>
</html>
Modified: CometVisu/trunk/visu/editor/init.js
===================================================================
--- CometVisu/trunk/visu/editor/init.js 2012-12-25 09:52:55 UTC (rev 1246)
+++ CometVisu/trunk/visu/editor/init.js 2012-12-25 22:29:23 UTC (rev 1247)
@@ -49,6 +49,23 @@
alert(result.message);
});
+
+ $(document).unbind('configuration_saving_error').bind('configuration_saving_error', function (event, result) {
+ // something went wrong
+ // we can not fix it, so let's simply inform the user, and leave.
+ alert(result.message);
+ });
+
+
+ $(document).unbind('configuration_saving_success').bind('configuration_saving_success', function (event) {
+ // everything is cool, configuration was saved
+ // @TODO: maybe implement some sort of "traffic light" that goes to gr...
[truncated message content] |