[Zope-CVS] CVS: Packages/Moztop/moztop/content/ContentObjects/Folder - MetaData.js:1.1 MetaData.xul:1.5
Stephan Richter
srichter@cbu.edu
Wed, 15 Jan 2003 21:07:06 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/ContentObjects/Folder
In directory cvs.zope.org:/tmp/cvs-serv25997/moztop/content/ContentObjects/Folder
Modified Files:
MetaData.xul
Added Files:
MetaData.js
Log Message:
- Got editing of Folder Meta Data working nicely. This required grabbing
another Window's document object, which I finally got working.
- Added .cvsignore file in moztop/content, so I could hide setup.js.
- Updated Makefile to remove .cvsignore files when making a distro.
- Updated CHANGES.txt.
=== Added File Packages/Moztop/moztop/content/ContentObjects/Folder/MetaData.js ===
function getDocumentOfWindowWithId(id) {
var win = null;
var wmediator =
Components.classes['@mozilla.org/appshell/window-mediator;1'].
getService(Components.interfaces.nsIWindowMediator);
var openwindows = wmediator.getEnumerator(null);
while (openwindows.hasMoreElements()) {
win = openwindows.getNext();
if (win.document.getElementById(id) != null) {
return win.document
}
}
return null
}
function getActiveContentObjectPath() {
doc = getDocumentOfWindowWithId("moztop-main-window");
var tabs = doc.getElementById("active-contents-tabs");
return tabs.selectedItem.getAttribute('label')
}
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 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');
}
};
function loadMetaData() {
path = getActiveContentObjectPath();
var xmlRpc = getXmlRpc();
xmlRpc.init(ZOPE3_URL + path + '/');
xmlRpc.asyncCall(LoadListener, null, 'getMetaData', [], 0);
}
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');
}
};
function saveMetaData() {
path = getActiveContentObjectPath();
var xmlRpc = getXmlRpc();
xmlRpc.init(ZOPE3_URL + 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);
}
=== Packages/Moztop/moztop/content/ContentObjects/Folder/MetaData.xul 1.4 => 1.5 ===
--- Packages/Moztop/moztop/content/ContentObjects/Folder/MetaData.xul:1.4 Wed Jan 15 15:51:53 2003
+++ Packages/Moztop/moztop/content/ContentObjects/Folder/MetaData.xul Wed Jan 15 21:06:33 2003
@@ -4,7 +4,12 @@
<?xml-stylesheet href="chrome://moztop/skin" type="text/css"?>
<window
- xmlns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ 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="MetaData.js"/>
<groupbox>
<caption label="Edit"/>
@@ -25,17 +30,17 @@
</row>
<row>
<label value="Created on:" />
- <label value="01/01/2003" />
+ <label id="field_created" value="01/01/2003" />
</row>
<row>
<label value="Last modified on:" />
- <label value="01/01/2003" />
+ <label id="field_modified" value="01/01/2003" />
</row>
</rows>
</grid>
<box orient="horizontal">
- <button onclick="" label="Save" />
- <button onclick="" label="Refresh" />
+ <button onclick="saveMetaData()" label="Save" />
+ <button onclick="loadMetaData()" label="Refresh" />
<spring flex="100%" />
</box>
</groupbox>