2000-03-21 03:16:39 +00:00
|
|
|
var gSubscribeTree = null;
|
2000-03-17 23:08:51 +00:00
|
|
|
var okCallback = null;
|
2000-03-21 03:16:39 +00:00
|
|
|
var gChangeTable = {};
|
|
|
|
var gServerURI = null;
|
2000-04-01 01:56:16 +00:00
|
|
|
var RDF = null;
|
2000-04-20 03:41:30 +00:00
|
|
|
var gSubscribeDS = null;
|
2000-03-17 18:28:31 +00:00
|
|
|
|
2000-04-02 19:58:09 +00:00
|
|
|
function Stop()
|
|
|
|
{
|
|
|
|
dump("Stop()\n");
|
|
|
|
dump("we need to stop the news url that is running.\n");
|
|
|
|
}
|
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
function onServerClick(event)
|
|
|
|
{
|
|
|
|
var item = event.target;
|
|
|
|
gServerURI = item.id;
|
|
|
|
|
|
|
|
SetUpTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
function SetUpServerMenu()
|
|
|
|
{
|
|
|
|
dump("SetUpServerMenu()\n");
|
|
|
|
|
|
|
|
var serverMenu = document.getElementById("serverMenu");
|
|
|
|
var menuitems = serverMenu.getElementsByAttribute("id", gServerURI);
|
|
|
|
|
|
|
|
serverMenu.selectedItem = menuitems[0];
|
|
|
|
}
|
|
|
|
|
2000-04-01 01:56:16 +00:00
|
|
|
function SetUpTree()
|
2000-03-28 04:03:25 +00:00
|
|
|
{
|
2000-04-13 21:56:28 +00:00
|
|
|
dump("SetUpTree()\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
var folder = GetMsgFolderFromUri(gServerURI);
|
|
|
|
var server = folder.server;
|
|
|
|
|
2000-04-23 01:19:51 +00:00
|
|
|
try {
|
|
|
|
subscribableServer = server.QueryInterface(Components.interfaces.nsISubscribableServer);
|
|
|
|
subscribableServer.populateSubscribeDatasource(null /* eventual, a nsIMsgWindow */);
|
2000-03-28 04:03:25 +00:00
|
|
|
|
2000-04-23 01:19:51 +00:00
|
|
|
dump("root subscribe tree at: "+ gServerURI +"\n");
|
|
|
|
gSubscribeTree.setAttribute('ref',gServerURI);
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to populate subscribe ds: " + ex + "\n");
|
|
|
|
}
|
2000-03-28 04:03:25 +00:00
|
|
|
}
|
|
|
|
|
2000-03-17 18:28:31 +00:00
|
|
|
function SubscribeOnLoad()
|
|
|
|
{
|
2000-03-18 17:27:40 +00:00
|
|
|
dump("SubscribeOnLoad()\n");
|
2000-03-28 04:03:25 +00:00
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
gSubscribeTree = document.getElementById('subscribetree');
|
2000-03-17 18:28:31 +00:00
|
|
|
|
2000-03-17 23:08:51 +00:00
|
|
|
doSetOKCancel(subscribeOK,subscribeCancel);
|
|
|
|
|
|
|
|
// look in arguments[0] for parameters
|
|
|
|
if (window.arguments && window.arguments[0]) {
|
|
|
|
if ( window.arguments[0].title ) {
|
|
|
|
top.window.title = window.arguments[0].title;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( window.arguments[0].okCallback ) {
|
|
|
|
top.okCallback = window.arguments[0].okCallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window.arguments[0].preselectedURI) {
|
2000-04-20 03:41:30 +00:00
|
|
|
var uri = window.arguments[0].preselectedURI;
|
|
|
|
dump("subscribe: got a uri," + uri + "\n");
|
|
|
|
folder = GetMsgFolderFromUri(uri);
|
|
|
|
gServerURI = folder.server.serverURI;
|
2000-03-17 23:08:51 +00:00
|
|
|
}
|
2000-04-13 21:56:28 +00:00
|
|
|
else {
|
|
|
|
dump("subscribe: no uri\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
var serverMenu = document.getElementById("serverMenu");
|
|
|
|
var menuitems = serverMenu.getElementsByTagName("menuitem");
|
|
|
|
gServerURI = menuitems[1].id;
|
2000-04-13 21:56:28 +00:00
|
|
|
}
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
SetUpServerMenu();
|
|
|
|
SetUpTree();
|
|
|
|
|
|
|
|
RDF = Components.classes["component://netscape/rdf/rdf-service"].getService();
|
|
|
|
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
|
|
|
|
|
|
|
gSubscribeDS = RDF.GetDataSource("rdf:subscribe");
|
2000-03-17 23:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeOK()
|
|
|
|
{
|
|
|
|
dump("in subscribeOK()\n")
|
|
|
|
if (top.okCallback) {
|
2000-03-21 03:16:39 +00:00
|
|
|
top.okCallback(top.gServerURI,top.gChangeTable);
|
2000-03-17 23:08:51 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeCancel()
|
|
|
|
{
|
2000-04-02 19:58:09 +00:00
|
|
|
dump("in subscribeCancel()\n");
|
|
|
|
Stop();
|
2000-03-17 23:08:51 +00:00
|
|
|
return true;
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 07:11:27 +00:00
|
|
|
function SetState(uri,name,state,stateStr)
|
2000-03-17 18:28:31 +00:00
|
|
|
{
|
2000-04-20 07:11:27 +00:00
|
|
|
dump("SetState(" + uri +"," + name + "," + state + "," + stateStr + ")\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
if (!uri || !stateStr) return;
|
2000-04-01 01:56:16 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
var src = RDF.GetResource(uri, true);
|
|
|
|
var prop = RDF.GetResource("http://home.netscape.com/NC-rdf#Subscribed", true);
|
2000-04-20 03:41:30 +00:00
|
|
|
var oldLiteral = gSubscribeDS.GetTarget(src, prop, true);
|
2000-04-14 05:34:49 +00:00
|
|
|
dump("oldLiteral="+oldLiteral+"\n");
|
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
oldValue = oldLiteral.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
|
|
|
dump("oldLiteral.Value="+oldValue+"\n");
|
|
|
|
if (oldValue != stateStr) {
|
|
|
|
var newLiteral = RDF.GetLiteral(stateStr);
|
|
|
|
gSubscribeDS.Change(src, prop, oldLiteral, newLiteral);
|
|
|
|
StateChanged(name,state);
|
2000-04-14 05:34:49 +00:00
|
|
|
}
|
2000-03-28 04:03:25 +00:00
|
|
|
}
|
2000-04-01 01:56:16 +00:00
|
|
|
catch (ex) {
|
|
|
|
dump("failed: " + ex + "\n");
|
2000-03-21 01:03:25 +00:00
|
|
|
}
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
|
|
|
|
2000-04-14 05:34:49 +00:00
|
|
|
function StateChanged(name,state)
|
2000-03-21 03:16:39 +00:00
|
|
|
{
|
2000-04-14 05:34:49 +00:00
|
|
|
dump("StateChanged(" + name + "," + state + ")\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
dump("start val=" +gChangeTable[name] + "\n");
|
2000-03-21 03:16:39 +00:00
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
if (gChangeTable[name] == undefined) {
|
|
|
|
dump(name+" not in table yet\n");
|
|
|
|
gChangeTable[name] = state;
|
2000-03-21 03:16:39 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-04-20 03:41:30 +00:00
|
|
|
var oldValue = gChangeTable[name];
|
|
|
|
dump(name+" already in table\n");
|
|
|
|
if (oldValue != state) {
|
|
|
|
gChangeTable[name] = undefined;
|
|
|
|
}
|
2000-03-21 03:16:39 +00:00
|
|
|
}
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
dump("end val=" +gChangeTable[name] + "\n");
|
2000-03-21 03:16:39 +00:00
|
|
|
}
|
|
|
|
|
2000-03-21 01:03:25 +00:00
|
|
|
function SetSubscribeState(state)
|
2000-03-17 18:28:31 +00:00
|
|
|
{
|
2000-04-01 01:56:16 +00:00
|
|
|
dump("SetSubscribedState()\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
|
|
|
var stateStr;
|
|
|
|
if (state) {
|
|
|
|
stateStr = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stateStr = 'false';
|
|
|
|
}
|
2000-04-01 01:56:16 +00:00
|
|
|
|
|
|
|
try {
|
2000-03-21 01:03:25 +00:00
|
|
|
dump("subscribe button clicked\n");
|
2000-04-20 03:41:30 +00:00
|
|
|
|
2000-03-21 03:16:39 +00:00
|
|
|
var groupList = gSubscribeTree.selectedItems;
|
2000-03-21 01:03:25 +00:00
|
|
|
for (i=0;i<groupList.length;i++) {
|
|
|
|
group = groupList[i];
|
|
|
|
uri = group.getAttribute('id');
|
|
|
|
dump(uri + "\n");
|
2000-04-14 05:34:49 +00:00
|
|
|
name = group.getAttribute('name');
|
|
|
|
dump(name + "\n");
|
2000-04-20 07:11:27 +00:00
|
|
|
SetState(uri,name,state,stateStr);
|
2000-03-21 01:03:25 +00:00
|
|
|
}
|
2000-04-01 01:56:16 +00:00
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("SetSubscribedState failed: " + ex + "\n");
|
|
|
|
}
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 06:59:43 +00:00
|
|
|
function ReverseStateFromNode(node)
|
|
|
|
{
|
|
|
|
var stateStr;
|
|
|
|
var state;
|
|
|
|
|
|
|
|
if (node.getAttribute('Subscribed') == "true") {
|
|
|
|
stateStr = "false";
|
|
|
|
state = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stateStr = "true";
|
|
|
|
state = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var uri = node.getAttribute('id');
|
2000-04-20 07:11:27 +00:00
|
|
|
var name = node.getAttribute('name');
|
|
|
|
SetState(uri, name, state, stateStr);
|
2000-04-20 06:59:43 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 03:41:30 +00:00
|
|
|
function ReverseState(uri)
|
|
|
|
{
|
|
|
|
dump("ReverseState("+uri+")\n");
|
|
|
|
}
|
|
|
|
|
2000-03-17 18:28:31 +00:00
|
|
|
function SubscribeOnClick(event)
|
|
|
|
{
|
2000-04-20 03:41:30 +00:00
|
|
|
if (event.clickCount == 2) {
|
2000-04-20 06:59:43 +00:00
|
|
|
ReverseStateFromNode(event.target.parentNode.parentNode);
|
2000-04-20 03:41:30 +00:00
|
|
|
}
|
2000-03-17 18:28:31 +00:00
|
|
|
}
|
2000-03-28 04:03:25 +00:00
|
|
|
|
|
|
|
function RefreshList()
|
|
|
|
{
|
|
|
|
dump("refresh list\n");
|
|
|
|
}
|
2000-04-02 19:58:09 +00:00
|
|
|
|