[Zope-CVS] CVS: Packages/Moztop/moztop/content/Content/SQLScript - Cache.js:1.1 Cache.xul:1.1 MetaData.js:1.1 MetaData.xul:1.1 Security.xul:1.1 Source.js:1.1 Source.xul:1.1 Test.js:1.1 Test.xul:1.1

Paul Everitt paul@zope.com
Sat, 15 Feb 2003 05:44:26 -0500


Update of /cvs-repository/Packages/Moztop/moztop/content/Content/SQLScript
In directory cvs.zope.org:/tmp/cvs-serv15538/SQLScript

Added Files:
	Cache.js Cache.xul MetaData.js MetaData.xul Security.xul 
	Source.js Source.xul Test.js Test.xul 
Log Message:
Rearranging directories, landing first cut at XBL

=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Cache.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Content Tab specific Javascript functions. 

$Id: Cache.js,v 1.1 2003/02/15 10:44:24 paul Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* XML-RPC setup stuff. */
function getClient() {
    return Components.classes['@mozilla.org/xml-rpc/client;1']
        .createInstance(Components.interfaces.nsIXmlRpcClient);
}

var xmlRpcClient;
function getXmlRpc() {
    if (!xmlRpcClient) xmlRpcClient = getClient();
    return xmlRpcClient;
}

var SaveListener = {
    onResult: function(client, ctxt, result) {
	alert('Saved');
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Uploading the file to the server. */
function saveSource() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    var source = xmlRpc.createType(xmlRpc.STRING, {});
    source.data = document.getElementById("field_source").value;
    xmlRpc.asyncCall(SaveListener, null, 'setZPTSource', [source], 1);
}

/* Load image info */
var LoadListener = {
    onResult: function(client, ctxt, result) {
        result = result.QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_source").value = result.data;
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Refresh the info. */
function updateSource() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    xmlRpc.asyncCall(LoadListener, null, 'getZPTSource', [], 0);
}



=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Cache.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   orient="vertical"
   onload="return false; updateSource();"
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="Cache.js"/>

  <groupbox>
    <caption label="Edit"/>

    <grid>
      <columns>
        <column/>
        <column flex="1"/>
      </columns>
      <rows>
        <row>
          <label control="field_maxEntries" value="Maximum cached entries"/>
          <textbox id="field_maxEntries" value="" flex="1" />
        </row>
        <row>
          <label control="field_maxAge" value="Maximum cached entries"/>
          <textbox id="field_maxAge" value="" flex="1" />
        </row>
        <row>
          <label control="field_cleanupInterval" 
                 value="Time between cache cleanups"/>
          <textbox id="field_cleanupInterval" value="" flex="1" />
        </row>
      </rows>
    </grid>
    <box orient="horizontal">
      <button onclick="saveSource()" label="Save" />
      <button onclick="updateSource()" label="Refresh" />
      <spring flex="100%" />
    </box>
  </groupbox>

  <groupbox>
    <caption label="Statistics"/>

  </groupbox>

</window>

=== Added File Packages/Moztop/moztop/content/Content/SQLScript/MetaData.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Meta Data Tab specific Javascript functions. With them you can load and save
the meta data.

$Id: MetaData.js,v 1.1 2003/02/15 10:44:24 paul Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* XML-RPC setup stuff. */
function getClient() {
    return Components.classes['@mozilla.org/xml-rpc/client;1']
        .createInstance(Components.interfaces.nsIXmlRpcClient);
}

var xmlRpcClient;
function getXmlRpc() {
    if (!xmlRpcClient) xmlRpcClient = getClient();
    return xmlRpcClient;
}

/* XML-RPC listener for loading meta data. */
var LoadListener = {
    onResult: function(client, ctxt, result) {
        result = result.QueryInterface(
	    Components.interfaces.nsIDictionary);
	title = result.getValue('title').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_title").value = title;

	desc = result.getValue('description').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_description").value = desc;

	created = result.getValue('created').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_created").value = created;

	modified = result.getValue('modified').QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_modified").value = modified;
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Load meta data from server. */
function loadMetaData() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    xmlRpc.asyncCall(LoadListener, null, 'getMetaData', [], 0);
}


/* XML-RPC listener for saving meta data. */
var SaveListener = {
    onResult: function(client, ctxt, result) {
	loadMetaData();
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Save meta data to server. */
function saveMetaData() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    var title = xmlRpc.createType(xmlRpc.STRING, {});
    title.data = document.getElementById("field_title").value;
    var desc = xmlRpc.createType(xmlRpc.STRING, {});
    desc.data = document.getElementById("field_description").value;
    xmlRpc.asyncCall(SaveListener, null, 'setMetaData', [title, desc], 2);
}


=== Added File Packages/Moztop/moztop/content/Content/SQLScript/MetaData.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
    xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    onload="loadMetaData();">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="MetaData.js"/>

  <groupbox>
    <caption label="Edit"/>

    <grid flex="1">
      <columns>
        <column/>
        <column flex="1"/>
      </columns>
      <rows>
        <row>
          <label control="field_title" value="Title"/>
          <textbox id="field_title" flex="1"/>
        </row>
        <row>
          <label control="field_description" value="Description"/>
          <textbox id="field_description" flex="1"/>
        </row>
        <row>
          <label value="Created on:" />
	  <label id="field_created" value="01/01/2003" />
        </row>
        <row>
          <label value="Last modified on:" />
	  <label id="field_modified" value="01/01/2003" />
        </row>
      </rows>
    </grid>
    <box orient="horizontal">
      <button onclick="saveMetaData()" label="Save" />
      <button onclick="loadMetaData()" label="Refresh" />
      <spring flex="100%" />
    </box>
  </groupbox>

</window>

=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Security.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <label value="Security" />
    <image src="chrome://moztop/content/moztop.png" />

</window>

=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Source.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Content Tab specific Javascript functions. 

$Id: Source.js,v 1.1 2003/02/15 10:44:24 paul Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* XML-RPC setup stuff. */
function getClient() {
    return Components.classes['@mozilla.org/xml-rpc/client;1']
        .createInstance(Components.interfaces.nsIXmlRpcClient);
}

var xmlRpcClient;
function getXmlRpc() {
    if (!xmlRpcClient) xmlRpcClient = getClient();
    return xmlRpcClient;
}

var SaveListener = {
    onResult: function(client, ctxt, result) {
	alert('Saved');
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Uploading the file to the server. */
function saveSource() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    var source = xmlRpc.createType(xmlRpc.STRING, {});
    source.data = document.getElementById("field_source").value;
    xmlRpc.asyncCall(SaveListener, null, 'setZPTSource', [source], 1);
}

/* Load image info */
var LoadListener = {
    onResult: function(client, ctxt, result) {
        result = result.QueryInterface(
	    Components.interfaces.nsISupportsCString);
	document.getElementById("field_source").value = result.data;
    },
    onFault: function(client, ctxt, fault) {
        alert('Fault! ' + fault + '\n');
    },
    onError: function(client, ctxt, status, errorMsg) {
        alert('Error! <(' + status.toString(16) + ') ' + errorMsg + '>\n');
    }
};

/* Refresh the info. */
function updateSource() {
    path = getActiveContentObjectPath();
    var xmlRpc = getXmlRpc();
    xmlRpc.init(XMLRPC_BASE + path + '/');
    xmlRpc.asyncCall(LoadListener, null, 'getZPTSource', [], 0);
}



=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Source.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   orient="vertical"
   onload="return false; updateSource();"
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="Source.js"/>


    <grid>
      <columns>
        <column/>
        <column flex="1"/>
      </columns>
      <rows>
        <row>
          <label control="field_arguments" value="Arguments"/>
          <textbox id="field_arguments" value="" 
              flex="1" multiline="true"
	      style="height: 5em; font-family: monospace; font-size: 12pt"/>
        </row>
        <row>
          <label control="field_source" value="Template Source"/>
          <textbox id="field_source" value="" 
              flex="1" multiline="true"
	      style="height: 20em; font-family: monospace; font-size: 12pt"/>
        </row>
      </rows>
    </grid>
    <box orient="horizontal">
      <button onclick="saveSource()" label="Save" />
      <button onclick="updateSource()" label="Refresh" />
      <spring flex="100%" />
    </box>


</window>

=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Test.js ===
/*****************************************************************************
*
* Copyright (c) 2002, 2003 Zope Corporation and Contributors.
* All Rights Reserved.
*
* This software is subject to the provisions of the Zope Public License,
* Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
* WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
******************************************************************************
Preview Tab specific Javascript functions. 

$Id: Test.js,v 1.1 2003/02/15 10:44:24 paul Exp $

******************************************************************************/

/* Retrieve path of active content object. */
function getActiveContentObjectPath() {
    doc = getDocumentOfWindowWithId("moztop-main-window");
    var tabs = doc.getElementById("active-contents-tabs");
    return tabs.selectedItem.getAttribute('label')
}

/* Load preview in IFrame */
function loadPreview() {
    iframe = document.getElementById('preview-frame');
    iframe.setAttribute('src', HTML_BASE + getActiveContentObjectPath());
}


=== Added File Packages/Moztop/moztop/content/Content/SQLScript/Test.xul ===
<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>

<window
   orient = "vertical"
   onload = "loadPreview();"
   xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript" 
          src="chrome://moztop/content/setup.js"/>
  <script type="application/x-javascript" 
          src="chrome://moztop/content/global.js"/>
  <script type="application/x-javascript" src="Test.js"/>

   <iframe id="preview-frame" flex="1"/>
   <box orient="horizontal">
     <button onclick="loadPreview();" label="Reload Content" />
     <spring flex="100%" />
   </box>

</window>