[Zope-CVS] CVS: Packages/Moztop/moztop/content/ContentObjects/Image - MetaData.js:1.1 MetaData.xul:1.1 Preview.js:1.1 Preview.xul:1.1 Security.xul:1.1 Upload.js:1.1 Upload.xul:1.1
Stephan Richter
srichter@cbu.edu
Thu, 16 Jan 2003 04:55:42 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/ContentObjects/Image
In directory cvs.zope.org:/tmp/cvs-serv24088/moztop/content/ContentObjects/Image
Added Files:
MetaData.js MetaData.xul Preview.js Preview.xul Security.xul
Upload.js Upload.xul
Log Message:
- We now have the sense of a first static TypeRegistry. Much more work is
needed in this area.
- If you have an image, you can now save its meta data and see the Upload
screen. Trying to open the File Picker somehow crashes my Mozilla.
- All types that Zope supports are now listed and can be handled in the
contents.rdf file.
=== Added File Packages/Moztop/moztop/content/ContentObjects/Image/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/01/16 09:55:38 srichter 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/ContentObjects/Image/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/ContentObjects/Image/Preview.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: Preview.js,v 1.1 2003/01/16 09:55:38 srichter 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/ContentObjects/Image/Preview.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="Preview.js"/>
<iframe id="preview-frame" flex="1"/>
<box orient="horizontal">
<button onclick="loadPreview();" label="Reload Content" />
<spring flex="100%" />
</box>
</window>
=== Added File Packages/Moztop/moztop/content/ContentObjects/Image/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/ContentObjects/Image/Upload.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.
*
******************************************************************************
Upload Tab specific Javascript functions.
$Id: Upload.js,v 1.1 2003/01/16 09:55:38 srichter Exp $
******************************************************************************/
function handleFilePicker() {
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, "Select a File", nsIFilePicker.modeOpen);
var res=fp.show();
// if (res==nsIFilePicker.returnOK){
// var thefile=fp.file;
// }
}
=== Added File Packages/Moztop/moztop/content/ContentObjects/Image/Upload.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"
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="Upload.js"/>
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<label value="Size:" />
<label id="field_size" value="? x ?; 1kB" />
</row>
<row>
<label control="field_title" value="Title"/>
<textbox id="field_title" flex="1"/>
</row>
<row>
<label control="field_upload" value="File to Upload"/>
<box orient="horizontal">
<textbox id="field_upload" flex="1"/>
<button onclick="handleFilePicker();" label="File..." />
</box>
</row>
</rows>
</grid>
<box orient="horizontal">
<button onclick="save()" label="Save" />
<button onclick="refresh()" label="Refresh" />
<spring flex="100%" />
</box>
</window>