From 6a164cc5204677594b5955ca09ed592a83ce43ca Mon Sep 17 00:00:00 2001 From: "morse%netscape.com" Date: Sun, 26 Sep 1999 09:51:20 +0000 Subject: [PATCH] fix signonviewer bugs 14703 and 14916, approved chofmann --- build/mac/NGLayoutBuildList.pm | 1 + .../wallet/signonviewer/MANIFEST_PROPERTIES | 1 - extensions/wallet/signonviewer/MANIFEST_SKIN | 0 extensions/wallet/signonviewer/Makefile.in | 3 +- .../wallet/signonviewer/SignonViewer.css | 92 +++ .../wallet/signonviewer/SignonViewer.dtd | 14 + .../wallet/signonviewer/SignonViewer.js | 656 +++++------------- .../wallet/signonviewer/SignonViewer.xul | 171 +++-- extensions/wallet/signonviewer/makefile.win | 4 + .../wallet/signonviewer/nsSignonViewer.cpp | 16 - 10 files changed, 411 insertions(+), 547 deletions(-) create mode 100644 extensions/wallet/signonviewer/MANIFEST_SKIN create mode 100644 extensions/wallet/signonviewer/SignonViewer.css create mode 100644 extensions/wallet/signonviewer/SignonViewer.dtd diff --git a/build/mac/NGLayoutBuildList.pm b/build/mac/NGLayoutBuildList.pm index ffdd72875fa..ab4436b0288 100644 --- a/build/mac/NGLayoutBuildList.pm +++ b/build/mac/NGLayoutBuildList.pm @@ -1369,6 +1369,7 @@ sub MakeResourceAliases() _InstallResources(":mozilla:extensions:wallet:src:MANIFEST_PROPERTIES", "$wallet_chrome_dir:locale:en-US:", 0); _InstallResources(":mozilla:extensions:wallet:cookieviewer:MANIFEST_SKIN", "$wallet_chrome_dir:skin:default:", 0); + _InstallResources(":mozilla:extensions:wallet:signonviewer:MANIFEST_SKIN", "$wallet_chrome_dir:skin:default:", 0); { my($pref_chrome_dir) = "$chrome_dir" . "Pref"; diff --git a/extensions/wallet/signonviewer/MANIFEST_PROPERTIES b/extensions/wallet/signonviewer/MANIFEST_PROPERTIES index 90d5bd111f1..e69de29bb2d 100644 --- a/extensions/wallet/signonviewer/MANIFEST_PROPERTIES +++ b/extensions/wallet/signonviewer/MANIFEST_PROPERTIES @@ -1 +0,0 @@ -SignonViewer.properties diff --git a/extensions/wallet/signonviewer/MANIFEST_SKIN b/extensions/wallet/signonviewer/MANIFEST_SKIN new file mode 100644 index 00000000000..e69de29bb2d diff --git a/extensions/wallet/signonviewer/Makefile.in b/extensions/wallet/signonviewer/Makefile.in index 3488542ec35..bd2e1174b4d 100644 --- a/extensions/wallet/signonviewer/Makefile.in +++ b/extensions/wallet/signonviewer/Makefile.in @@ -40,5 +40,6 @@ include $(topsrcdir)/config/rules.mk install:: $(TARGETS) $(INSTALL) $(srcdir)/SignonViewer.xul $(srcdir)/SignonViewer.js $(DIST)/bin/chrome/wallet/content/default - $(INSTALL) $(srcdir)/SignonViewer.properties $(DIST)/bin/chrome/wallet/locale/en-US + $(INSTALL) $(srcdir)/SignonViewer.properties $(srcdir)/SignonViewer.dtd $(DIST)/bin/chrome/wallet/locale/en-US + $(INSTALL) $(srcdir)/SignonViewer.css $(DIST)/bin/chrome/wallet/skin/default diff --git a/extensions/wallet/signonviewer/SignonViewer.css b/extensions/wallet/signonviewer/SignonViewer.css new file mode 100644 index 00000000000..eb3a1c47214 --- /dev/null +++ b/extensions/wallet/signonviewer/SignonViewer.css @@ -0,0 +1,92 @@ +window { + min-width: 400px; + min-height: 400px; +} + +box.tabpanel { + border: 1px outset #CCCCDD; + padding: 10px; +} + +tab { + padding-left: 10px; + padding-right: 10px; +} + +treehead > treerow > treecell { + border: 1px outset #CCCCDD; + padding-top: 1px; + padding-bottom: 1px; + padding-left: 5px; + padding-right: 5px; + background-color: #CCCCDD; + color: #000000; +} + +treechildren > treeitem > treerow > treecell { + border-right: 1px solid #CCCCDD; + border-bottom: 1px solid #CCCCDD; + color: inherit; + padding-left: 10px; + padding-top: 1px; + padding-bottom: 1px; +} + +treechildren > treeitem > treerow > treecell.fieldcell { + border-right: 1px solid #CCCCDD; + border-bottom: 1px solid #CCCCDD; + color: inherit; + padding: 0px; + margin: 0px; +} + + +treechildren > treeitem > treerow [selectedrow ~= false] { + background-color: white; + color: black; +} + +treechildren > treeitem > treerow [selectedrow ~= true] { + background-color: #666699; + color: white; +} + +tree#infotree treechildren > treeitem > treerow [selectedrow ~= false] { + background-color: white; + color: black; +} + +tree#infotree treechildren > treeitem > treerow [selectedrow ~= true] { + background-color: white; + color: black; +} + +tree { + border: 1px inset #CCCCDD; +} + +a { + color: #0000FF; + text-decoration: underline; +} + +a:hover { + color: #FF0000; + text-decoration: underline; +} + +tree treechildren > treeitem > treerow[selectedrow=true] > treecell > a:link { + color: #FFFFFF; +} + +tree treechildren > treeitem > treerow[selectedrow ~= true] > treecell > a:hover { + color: #FFFFFF; +} + +input.dispcell { + border: none; + background-color: #CCCCDD; + height: 12px; + font-family: tahoma; + font-size: 10px; +} \ No newline at end of file diff --git a/extensions/wallet/signonviewer/SignonViewer.dtd b/extensions/wallet/signonviewer/SignonViewer.dtd new file mode 100644 index 00000000000..bd607ab3981 --- /dev/null +++ b/extensions/wallet/signonviewer/SignonViewer.dtd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/extensions/wallet/signonviewer/SignonViewer.js b/extensions/wallet/signonviewer/SignonViewer.js index 71ac4307b0c..18eb085bad9 100644 --- a/extensions/wallet/signonviewer/SignonViewer.js +++ b/extensions/wallet/signonviewer/SignonViewer.js @@ -1,490 +1,180 @@ - /* for localization */ - var Bundle = srGetStrBundle("chrome://wallet/locale/SignonViewer.properties"); - var logonsSavedTab = Bundle.GetStringFromName("logonsSavedTab"); - var logonsNotSavedTab = Bundle.GetStringFromName("logonsNotSavedTab"); - var formsNotPreviewedTab = Bundle.GetStringFromName("formsNotPreviewedTab"); - var formsNotSavedTab = Bundle.GetStringFromName("formsNotSavedTab"); - var logonsSaved = Bundle.GetStringFromName("logonsSaved"); - var siteUsername = Bundle.GetStringFromName("siteUsername"); - var logonsNotSaved = Bundle.GetStringFromName("logonsNotSaved"); - var formsNotPreviewed = Bundle.GetStringFromName("formsNotPreviewed"); - var formsNotSaved = Bundle.GetStringFromName("formsNotSaved"); - var removeCmdLabel = Bundle.GetStringFromName("removeCmdLabel"); - var okCmdLabel = Bundle.GetStringFromName("okCmdLabel"); - var cancelCmdLabel = Bundle.GetStringFromName("cancelCmdLabel"); +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + * + * Contributor(s): + * Ben Goodger + */ - /* for xpconnect */ +/*** =================== INITIALISATION CODE =================== ***/ - var signonviewer = - Components.classes - ["component://netscape/signonviewer/signonviewer-world"].createInstance(); - signonviewer = signonviewer.QueryInterface(Components.interfaces.nsISignonViewer); +// globals +var signonviewer = null; +var signonList = []; +var rejectList = []; +var nopreviewList = []; +var nocaptureList = []; +var goneSS = ""; // signon +var goneIS = ""; // ignored site +var goneFR = ""; // form preview +var goneNC = ""; // nocapture - function DoGetSignonList() - { - return signonviewer.GetSignonValue(); +// function : ::Startup(); +// purpose : initialises interface, calls init functions for each page +function Startup() +{ + signonviewer = Components.classes["component://netscape/signonviewer/signonviewer-world"].createInstance(); + signonviewer = signonviewer.QueryInterface(Components.interfaces.nsISignonViewer); + + doSetOKCancel(onOK, null); // init ok event handler + + LoadSignons(); + LoadReject(); + LoadNopreview(); +} + +/*** =================== SAVED SIGNONS CODE =================== ***/ + +// function : ::LoadSignons(); +// purpose : reads signons from interface and loads into tree +function LoadSignons() +{ + signonList = signonviewer.GetSignonValue(); + var delim = signonList[0]; + signonList = signonList.split(delim); + for(var i = 1; i < signonList.length; i++) + { + var currSignon = TrimString(signonList[i]); + // TEMP HACK until morse fixes signon viewer functions + currSignon = RemoveHTMLFormatting(currSignon); + var site = currSignon.substring(0,currSignon.lastIndexOf(":")); + var user = currSignon.substring(currSignon.lastIndexOf(":")+1,currSignon.length); + AddItem("savesignonlist",[site,user],"signon_",i-1); + } +} + +/*** =================== IGNORED SIGNONS CODE =================== ***/ + +// function : ::LoadReject(); +// purpose : reads rejected sites from interface and loads into tree +function LoadReject() +{ + rejectList = signonviewer.GetRejectValue(); + var delim = rejectList[0]; + rejectList = rejectList.split(delim); + for(var i = 1; i < rejectList.length; i++) + { + var currSignon = TrimString(rejectList[i]); + // TEMP HACK until morse fixes signon viewer functions + currSignon = RemoveHTMLFormatting(currSignon); + var site = currSignon.substring(0,currSignon.lastIndexOf(":")); + var user = currSignon.substring(currSignon.lastIndexOf(":")+1,currSignon.length); + AddItem("ignoredlist",[site,user],"reject_",i-1); + } +} + +/*** =================== NO PREVIEW FORMS CODE =================== ***/ + +// function : ::LoadNopreview(); +// purpose : reads non-previewed forms from interface and loads into tree +function LoadNopreview() +{ + nopreviewList = signonviewer.GetNopreviewValue(); + var delim = nopreviewList[0]; + nopreviewList = nopreviewList.split(delim); + for(var i = 1; i < nopreviewList.length; i++) + { + var currSignon = TrimString(nopreviewList[i]); + // TEMP HACK until morse fixes signon viewer functions + currSignon = RemoveHTMLFormatting(currSignon); + var form = currSignon.substring(currSignon.lastIndexOf(":")+1,currSignon.length); + AddItem("nopreviewlist",[form],"nopreview_",i-1); + } +} + +function onOK() +{ + var result = "|goneS|"+goneSS+"|goneR|"+goneIS; + result += "|goneC|"+goneNC+"|goneP|"+goneFR+"|"; + signonviewer.SetValue(result, window); + return true; +} + +/*** =================== UTILITY FUNCTIONS =================== ***/ + +// function : ::RemoveHTMLFormatting(); +// purpose : removes HTML formatting from input stream +function RemoveHTMLFormatting(which) +{ + var ignoreon = false; + var rv = ""; + for(var i = 0; i < which.length; i++) + { + if(which.charAt(i) == "<") + ignoreon = true; + if(which.charAt(i) == ">") { + ignoreon = false; + continue; } + if(ignoreon) + continue; + rv += which.charAt(i); + } + return rv; +} - function DoGetRejectList() - { - return signonviewer.GetRejectValue(); - } +/*** =================== TREE MANAGEMENT CODE =================== ***/ - function DoGetNopreviewList() - { - return signonviewer.GetNopreviewValue(); - } +// function : ::AddItem(); +// purpose : utility function for adding items to a tree. +function AddItem(children,cells,prefix,idfier) +{ + var kids = document.getElementById(children); + var item = document.createElement("treeitem"); + var row = document.createElement("treerow"); + for(var i = 0; i < cells.length; i++) + { + var cell = document.createElement("treecell"); + var text = document.createTextNode(cells[i]); + cell.appendChild(text); + row.appendChild(cell); + } + item.appendChild(row); + item.setAttribute("id",prefix + idfier); + kids.appendChild(item); +} - function DoGetNocaptureList() - { - return signonviewer.GetNocaptureValue(); - } - - function DoSave(value) - { - signonviewer.SetValue(value, window); - } - - /* end of xpconnect stuff */ - - index_frame = 0; - title_frame = 1; - spacer1_frame = 2; - list_frame = 3; - spacer2_frame = 4; - button_frame = 5; - - var signon_mode; - var signonList = []; - var rejectList = []; - var nopreviewList = []; - var nocaptureList = []; - deleted_signons = new Array; - deleted_rejects = new Array; - deleted_nopreviews = new Array; - deleted_nocaptures = new Array; - - function DeleteItemSelected() { - if (signon_mode == 0) { - DeleteSignonSelected(); - } else if (signon_mode == 1) { - DeleteRejectSelected(); - } else if (signon_mode == 2) { - DeleteNopreviewSelected(); - } else if (signon_mode == 3) { - DeleteNocaptureSelected(); - } - } - - function DeleteSignonSelected() { - selname = top.frames[list_frame].document.fSelectSignon.selname; - goneS = top.frames[button_frame].document.buttons.goneS; - var p; - var i; - for (i=selname.options.length; i>0; i--) { - if (selname.options[i-1].selected) { - selname.options[i-1].selected = 0; - goneS.value = goneS.value + selname.options[i-1].value + ","; - deleted_signons[selname.options[i-1].value] = 1; - selname.remove(i-1); - } - } - } - - function DeleteRejectSelected() { - selname = top.frames[list_frame].document.fSelectReject.selname; - goneR = top.frames[button_frame].document.buttons.goneR; - var p; - var i; - for (i=selname.options.length; i>0; i--) { - if (selname.options[i-1].selected) { - selname.options[i-1].selected = 0; - goneR.value = goneR.value + selname.options[i-1].value + ","; - deleted_rejects[selname.options[i-1].value] = 1; - selname.remove(i-1); - } - } - } - - function DeleteNopreviewSelected() { - selname = top.frames[list_frame].document.fSelectNopreview.selname; - goneP = top.frames[button_frame].document.buttons.goneP; - var p; - var i; - for (i=selname.options.length; i>0; i--) { - if (selname.options[i-1].selected) { - selname.options[i-1].selected = 0; - goneP.value = goneP.value + selname.options[i-1].value + ","; - deleted_nopreviews[selname.options[i-1].value] = 1; - selname.remove(i-1); - } - } - } - - function DeleteNocaptureSelected() { - selname = top.frames[list_frame].document.fSelectNocapture.selname; - goneC = top.frames[button_frame].document.buttons.goneC; - var p; - var i; - for (i=selname.options.length; i>0; i--) { - if (selname.options[i-1].selected) { - selname.options[i-1].selected = 0; - goneC.value = goneC.value + selname.options[i-1].value + ","; - deleted_nocaptures[selname.options[i-1].value] = 1; - selname.remove(i-1); - } - } - } - - function loadSignons(){ - signon_mode = 0; - top.frames[index_frame].document.open(); - top.frames[index_frame].document.write( - "" + - "" + - "" + - "" + - "" + -// "" + -// "" + - "" + -// "" + - "" + - "" + - "
" + - "" + - "" + logonsSavedTab + "" + - "" + - "" + - "" + - "" + logonsNotSavedTab + "" + - "" + - "
" + - "" + - "" + formsNotPreviewedTab + "" + - "" + - "" + -// "" + -// "" + formsNotSavedTab + "" + -// "" + -// "   
" + - "" - ); - top.frames[index_frame].document.close(); - - top.frames[title_frame].document.open(); - top.frames[title_frame].document.write - (" " + logonsSaved + ""); - top.frames[title_frame].document.close(); - - loadSignonsList(); - } - - function loadSignonsList(){ - top.frames[list_frame].document.open(); - top.frames[list_frame].document.write( - "
" + - "

" + - "" + siteUsername + "" + - "" + - "" + - "" + - "" + - "
" + - "
" + - "

" + - "" + - "

" + - "
" + - "
" + - "

" + - "
" - ); - top.frames[list_frame].document.close(); - } - - function loadRejects(){ - signon_mode = 1; - top.frames[index_frame].document.open(); - top.frames[index_frame].document.write( - "" + - "" + - "" + - "" + - "" + - "" + -// "" + -// "" + - "" + -// "" + - "" + - "" + - "
" + - "" + - "" + logonsSavedTab + "" + - "" + - "" + - "" + - "" + logonsNotSavedTab + "" + - "" + - "   
" + - "" + - "" + formsNotPreviewedTab + "" + - "" + - "" + -// "" + -// "" + formsNotSavedTab + "" + -// "" + -// "   
" + - "" - ); - top.frames[index_frame].document.close(); - - top.frames[title_frame].document.open(); - top.frames[title_frame].document.write - (" " + logonsNotSaved + ""); - top.frames[title_frame].document.close(); - - loadRejectsList(); - } - - function loadRejectsList(){ - top.frames[list_frame].document.open(); - top.frames[list_frame].document.write( - "
" + - "

" + - "" + - "" + - "" + - "" + - "
" + - "
" + - "

" + - "" + - "

" + - "
" + - "
" + - "

" + - "
" - ); - top.frames[list_frame].document.close(); - } - - function loadNopreviews(){ - signon_mode = 2; - top.frames[index_frame].document.open(); - top.frames[index_frame].document.write( - "" + - "" + - "" + - "" + - "" + -// "" + -// "" + - "" + -// "" + - "" + - "" + - "
" + - "" + - "" + logonsSavedTab + "" + - "" + - "" + - "" + - "" + logonsNotSavedTab + "" + - "" + - "
" + - "" + - "" + formsNotPreviewedTab + "" + - "" + - "" + -// "" + -// "" + formsNotSavedTab + "" + -// "" + -// "   
" + - "" - ); - top.frames[index_frame].document.close(); - - top.frames[title_frame].document.open(); - top.frames[title_frame].document.write - (" " + formsNotPreviewed + ""); - top.frames[title_frame].document.close(); - - loadNopreviewsList(); - } - - function loadNopreviewsList(){ - top.frames[list_frame].document.open(); - top.frames[list_frame].document.write( - "
" + - "

" + - "" + - "" + - "" + - "" + - "
" + - "
" + - "

" + - "" + - "

" + - "
" + - "
" + - "

" + - "
" - ); - top.frames[list_frame].document.close(); - } - - function loadNocaptures(){ - signon_mode = 3; - top.frames[index_frame].document.open(); - top.frames[index_frame].document.write( - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "
" + - "" + - "" + logonsSavedTab + "" + - "" + - "" + - "" + - "" + logonsNotSavedTab + "" + - "" + - "
" + - "" + - "" + formsNotPreviewedTab + "" + - "" + - "" + - "" + - "" + formsNotSavedtab + "" + - "" + - "   
" + - "" - ); - top.frames[index_frame].document.close(); - - top.frames[title_frame].document.open(); - top.frames[title_frame].document.write - (" " + formsNotSaved + ""); - top.frames[title_frame].document.close(); - - loadNocapturesList(); - } - - function loadNocapturesList(){ - top.frames[list_frame].document.open(); - top.frames[list_frame].document.write( - "
" + - "

" + - "" + - "" + - "" + - "" + - "
" + - "
" + - "

" + - "" + - "

" + - "
" + - "
" + - "

" + - "
" - ); - top.frames[list_frame].document.close(); - } - - function loadButtons(){ - top.frames[button_frame].document.open(); - top.frames[button_frame].document.write( - "
" + - "
" + - " " + - "" + - "
" + - "" + - "   " + - "" + - "
" + - "" + - "" + - "" + - "" + - "" + - "" + - "
" - ); - top.frames[button_frame].document.close(); - } - - function loadFrames(){ - list = DoGetSignonList(); - BREAK = list[0]; - signonList = list.split(BREAK); - list = DoGetRejectList(); - BREAK = list[0]; - rejectList = list.split(BREAK); - list = DoGetNopreviewList(); - BREAK = list[0]; - nopreviewList = list.split(BREAK); - list = DoGetNocaptureList(); - BREAK = list[0]; - nocaptureList = list.split(BREAK); - loadSignons(); - loadButtons(); - } - - function Save(){ - var goneS = top.frames[button_frame].document.buttons.goneS; - var goneR = top.frames[button_frame].document.buttons.goneR; - var goneP = top.frames[button_frame].document.buttons.goneP; - var goneC = top.frames[button_frame].document.buttons.goneC; - var result = "|goneS|"+goneS.value+"|goneR|"+goneR.value; - result += "|goneC|"+goneC.value+"|goneP|"+goneP.value+"|"; - DoSave(result); - } - - function Cancel(){ - var result = "|goneS||goneR||goneC||goneP||"; - DoSave(result); - } +// function : ::DeleteItemSelected(); +// purpose : deletes all the signons that are selected +function DeleteItemSelected(tree, prefix, kids) { + var delnarray = []; + var rv = ""; + var cookietree = document.getElementById(tree); + selitems = cookietree.selectedItems; + for(var i = 0; i < selitems.length; i++) + { + delnarray[i] = document.getElementById(selitems[i].getAttribute("id")); + var itemid = parseInt(selitems[i].getAttribute("id").substring(prefix.length,selitems[i].getAttribute("id").length)); + rv += (itemid + ","); + } + for(var i = 0; i < delnarray.length; i++) + { + document.getElementById(kids).removeChild(delnarray[i]); + } + return rv; +} \ No newline at end of file diff --git a/extensions/wallet/signonviewer/SignonViewer.xul b/extensions/wallet/signonviewer/SignonViewer.xul index 4e9133110bf..6f078e7d128 100644 --- a/extensions/wallet/signonviewer/SignonViewer.xul +++ b/extensions/wallet/signonviewer/SignonViewer.xul @@ -1,49 +1,128 @@ - - + -