Changeset 1083

Show
Ignore:
Timestamp:
2008-09-10 06:08:27 (2 months ago)
Author:
MaierMan
Message:
  • Mediator as module
  • Mediator now handles songbird correctly
  • showNotice() in Mediator
  • Notice fixes
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/about/about.xul

    r1078 r1083  
    6969                Components.utils.import('resource://dta/version.jsm', DTA); 
    7070                function openTab(url) { 
    71                         DTA_Mediator.openTab(url); 
     71                        DTA_Mediator.open(url); 
    7272                        self.close(); 
    7373                } 
     
    7979                } 
    8080                function openNotice() { 
    81                         openTab('chrome://dta/content/about/about.html#privacy'); 
     81                        DTA.mediator.showNotice(window); 
    8282                } 
    8383  ]]></script> 
  • trunk/chrome/content/about/notice.html

    • Property svn:mergeinfo set
    r1078 r1083  
    44<head> 
    55        <title>About DownThemAll!</title> 
     6        <script type="text/javascript"> 
     7                // We need to "convert" the links" 
     8                var Mediator = { 
     9                        open: function(url) { 
     10                                this.openUrl(window, url); 
     11                        } 
     12                }; 
     13                Components.utils.import('resource://dta/mediator.jsm', Mediator); 
     14                function load() { 
     15                        links = document.links; 
     16                        for (var i = 0; i < links.length; ++i) { 
     17                                var link = links[i]; 
     18                                link.addEventListener('click', function() { Mediator.open(link.url); }, true); 
     19                                link.url = link.getAttribute('href'); 
     20                                link.setAttribute('href', ''); 
     21                        } 
     22                        scrollTo(0, 0); 
     23                } 
     24                addEventListener('DOMContentLoaded', load, true); 
     25        </script> 
    626        <style type="text/css"> 
    727                * {  
     
    1232                        color: #333; 
    1333                        line-height: 128%; 
    14                  } 
    15                  
    16                 a { 
    17                         color: #333; 
     34                        background-color: white; 
    1835                } 
    19                 a:hover { 
    20                         color: #663300; 
     36                body { 
     37                        margin: 0; 
     38                        padding: 15px; 
     39                        padding-bottom: 3em; 
    2140                } 
    22                  
     41                 
    2342                p { 
    2443                        margin: 15px; 
     
    2645                        margin-bottom: 5px; 
    2746                        line-height: 150%; 
    28                 } 
    29                  
    30                 ul { 
    31                         margin: 6px 15px 5px 20px; 
    32                         padding: 5px; 
    33                 } 
    34                  
    35                 ul ul { 
    36                         margin-top: 0px; 
    37                 } 
    38                  
    39                 li { 
    40                         margin-top: 6px; 
    41                         margin-bottom: 6px; 
    4247                } 
    4348                 
     
    5459                } 
    5560                 
    56                 table { 
    57                         text-align: left; 
    58                         margin-left: auto; 
    59                         margin-top: 5px; 
    60                         margin-bottom: 5px; 
    61                         margin-right: auto; 
    62                         width: 85%; 
    63                         border-collapse: collapse; 
    64                         border-bottom: #ddd solid 3px; 
    65                 } 
    66                  
    67                 td { 
    68                         vertical-align: top; 
    69                         margin-bottom: 3px; 
    70                         padding-bottom: 3px; 
    71                         padding-right: 20px; 
    72                         padding-left: 10px; 
    73                         border-bottom: #ddd solid 1px; 
    74                 } 
    75                  
    76                 th { 
    77                         text-align: center; 
    78                         font-weight: bold; 
    79                         border-top: #FFE391 solid 1px; 
    80                         border-bottom: #FFE391 solid 1px; 
    81                         background-color: #FFF9DF; 
    82                 } 
    83                  
    8461                strong { 
    8562                        font-style: normal; 
     
    8764                } 
    8865                 
    89                 code { 
    90                         font-family: monospace !important; 
    91                         background-color: #f3f3f3; 
    92                         padding: 1px; 
    93                         border-top: 1px solid #e3e3e3; 
    94                         border-bottom: 1px solid #e3e3e3; 
     66                a { 
     67                        text-decoration: underline; 
    9568                } 
    9669                 
    97                 pre { 
     70                #license { 
    9871                        font-family: monospace !important; 
    9972                        overflow: auto; 
    100                         background-color: #fff9df; 
    101                         border: 1px solid #ffe391; 
    102                         margin: 15px; 
    103                 } 
    104                  
    105                 pre#license { 
    10673                        background-color: transparent; 
    10774                        margin: 0px; 
    10875                        border-width: 0px; 
    109                         font-size: 90%; 
    11076                } 
    111                          
    112                 #main { 
    113                         margin: 0; 
    114                         padding: 15px; 
    115                         padding-top: 42px; 
    116                         padding-bottom: 3em; 
    117                         background: white url(chrome://dta/skin/common/logo.png) no-repeat right top; 
    118                 } 
     77                #license, #license a { 
     78                        font-size: 85%; 
     79                }                
     80                </style>         
     81</head> 
     82 
     83<body> 
     84        <!-- Fake anchor so that xul:iframe will not reposition  --> 
     85        <h1 id="privacy">Privacy Notice<a href="#"></a></h1> 
     86        <p>DownThemAll protects your privacy.</p> 
     87        <p>You can remove complete, canceled, and unfinished downloads from the download window by changing the settings in the Preferences->Privacy panel.</p> 
     88        <p>You can enable diagnostic messages which will be logged to both the error console and written to the dta_log.txt file (contained in the dTa folder) by the Preferences->Privacy panel. Diagnostic messages will likely contain sensitive information like URLs, file paths, filenames you're downloading, or even cookie information. This option is DISABLED by default to protect your privacy. If you submit a diagnostic message, you may wish to censor this sensitive information.</p> 
     89        <p>DownThemAll connects to our website to get news, donation messages, and latest version number. This feature can be disabled by changing the setting in the Preferences->Privacy panel.</p> 
     90        <p>This notice is always available from this help and additionally linked on the About window.</p> 
     91         
     92        <h1 id="copyright">Copyright and License</h1> 
     93        <div id="license"> 
     94                <p>Copyright (C) 2004-2007 Federico Parodi and Stefano Verna<br/> 
     95                Copyright (C) 2007-2008 Nils Maier, Federico Parodi and Stefano Verna</p> 
    11996                 
    120                 .shortcut { 
    121                         padding: 1px 3px; 
    122                         background-color: #EFEAD1; 
    123                         border: 1px solid #DFD299; 
    124                         -moz-border-radius: 4px; 
    125                 } 
    126         </style>         
    127 </head> 
    128 <body> 
     97                <p>DownThemAll! is licensed under <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GPL 2.0</a>. See the GPL file. This applies to all source code files.</p> 
    12998 
    130 <div id="main"> 
    131         <h1 id="copyright">Copyright and License</h1> 
    132         <pre id="license">Copyright (C) 2004-2007 Federico Parodi and Stefano Verna  
    133 Copyright (C) 2007-2008 Nils Maier, Federico Parodi and Stefano Verna 
    134  
    135 DownThemAll! is licensed under <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GPL 2.0</a>. See the GPL file. 
    136 This applies to all source code files. 
    137  
    138 Individual files may have different licenses. 
    139 See the corresponding repository files available from 
    140 <a href="http://code.downthemall.net/repos/">http://code.downthemall.net/repos/</a> 
    141 Many files are tri-licensed under a MPL 1.1/GPL 2.0/LGPL 2.1 license; 
    142 See the MPL, GPL, LGPL files respectively. 
    143  
    144 Most important parts from the GPL 2.0: 
    145  
    146  NO WARRANTY 
    147  
    148   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 
     99                <p>Individual files may have different licenses. See the corresponding repository files available from <a href="http://code.downthemall.net/repos/">http://code.downthemall.net/repos/</a>. 
     100                 Many files are tri-licensed under a MPL 1.1/GPL 2.0/LGPL 2.1 license; See the MPL, GPL, LGPL files respectively.</p> 
     101                  
     102                <p>Most important parts from the GPL 2.0:</p> 
     103                 
     104                <h3>NO WARRANTY</h3> 
     105                <p>11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 
    149106FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN 
    150107OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 
     
    154111TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE 
    155112PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 
    156 REPAIR OR CORRECTION. 
     113REPAIR OR CORRECTION.</p> 
    157114 
    158   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 
     115               <p>12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 
    159116WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 
    160117REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 
     
    164121YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 
    165122PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 
    166 POSSIBILITY OF SUCH DAMAGES. 
     123POSSIBILITY OF SUCH DAMAGES.</p> 
    167124 
     125                <h3>Icons and buttons</h3> 
     126                <p>Icons and buttons are based on the works of Mike Matas, Jakub Steiner and Mark James</p> 
     127                <ul> 
     128                        <li>© Michael Matas,</li> 
     129                        <li>© Jakub Steiner, © Novell, Inc.</li> 
     130                        <li>© Mark James (famfamfam silk icons)</li> 
     131                </ul> 
     132        </div> 
    168133 
    169 dTa contains pieces of code taken from: 
    170 Linky * Copyright (C) 2002-2003 Henrik Gemal 
    171  
    172 Icons and buttons are based on the works of Mike Matas, Jakub Steiner and Mark James 
    173  * (C) Michael Matas, 
    174  * (C) Jakub Steiner, (C) Novell, Inc. 
    175  * (C) Mark James (famfamfam silk icons) 
    176 </pre> 
    177  
    178         <h1 id="privacy">Privacy Notice</h1> 
    179         <p>DownThemAll protects your privacy.</p> 
    180         <p>You can remove complete, canceled, and unfinished downloads from the download window by changing the settings in the Preferences->Privacy panel.</p> 
    181         <p>You can enable diagnostic messages which will be logged to both the error console and written to the dta_log.txt file (contained in the dTa folder) by the Preferences->Privacy panel. Diagnostic messages will likely contain sensitive information like URLs, file paths, filenames you're downloading, or even cookie information. This option is DISABLED by default to protect your privacy. If you submit a diagnostic message, you may wish to censor this sensitive information.</p> 
    182         <p>DownThemAll connects to our website to get news, donation messages, and latest version number. This feature can be disabled by changing the setting in the Preferences->Privacy panel.</p> 
    183         <p>This notice is always available from this help and additionally linked on the About window.</p> 
    184          
    185134        <h2 id="contact">Contacts</h2> 
    186135        <p>We like to receive your feedback, suggestions or offers to help.</p> 
    187136        <p>Please see our <a href="http://www.downthemall.net/main/contacts/">Contact page</a> online.</p> 
    188          
    189 </div> 
    190137</body> 
    191138</html> 
  • trunk/chrome/content/about/notice.xul

    r1078 r1083  
    1111        title="DownThemAll! - License and Privacy Notice" 
    1212        buttons="accept,cancel" 
    13         buttonlabelaccept="&accept;" 
    1413        buttonlabelcancel="&decline;" 
    1514        ondialogaccept="return accept();" 
     
    1716        width="500" height="420" 
    1817        style="padding: 0px 0px 3px 0px;" 
     18        acceptLabel="&accept;" 
    1919> 
    2020        <script type="application/javascript"><![CDATA[ 
    2121                 
    2222                function load(evt) { 
    23                         if (evt.originalTarget.location.href.search(/about\.html$/) != -1) { 
    24                                 var doc = document.getElementById('frame').contentDocument; 
    25                                 var head = doc.getElementById('header') 
    26                                 head.parentNode.removeChild(head); 
     23                        if (!window.arguments || !window.arguments.length) { 
     24                                document.documentElement.getButton('cancel').hidden = true; 
    2725                        } 
     26                        else { 
     27                                button = document.documentElement.getButton('accept'); 
     28                                button.setAttribute('label', document.documentElement.getAttribute('acceptLabel')); 
     29                        } 
     30                        document.getElementById('frame').contentWindow.scrollTo(0, 0); 
    2831                } 
    2932                function accept() { 
     33                        if (!window.arguments || !window.arguments.length) { 
     34                                return true; 
     35                        } 
     36                         
    3037                        let Preferences = {}; 
    3138                        Components.utils.import('resource://dta/preferences.jsm', Preferences); 
     
    4249                } 
    4350                function cancel() { 
    44                         if (!confirm(_("conf"))) { 
     51                        if (!window.arguments || !window.arguments.length) { 
     52                                return true; 
     53                        }                
     54                        if (!confirm(document.getElementById('bundle').getString('conf'))) { 
    4555                                return false; 
    4656                        } 
     
    6171        ]]></script> 
    6272        <stringbundleset> 
    63                 <stringbundle src="chrome://dta/locale/notice.properties"/> 
     73                <stringbundle id="bundle" src="chrome://dta/locale/notice.properties"/> 
    6474        </stringbundleset> 
    65         <iframe id="frame" src="chrome://dta/content/about/about.html" flex="1"/> 
     75        <hbox style="background: white url(chrome://dta/skin/common/logo.png) no-repeat top right; height: 43px;"/> 
     76        <iframe id="frame" style="background: white;" src="chrome://dta/content/about/notice.html" flex="1"/> 
    6677</dialog> 
  • trunk/chrome/content/common/overlayFunctions.js

    r1078 r1083  
    359359        openManager : function (quite) { 
    360360                try { 
    361                         var win = DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 
     361                        var win = DTA_Mediator.getMostRecent('DTA:Manager'); 
    362362                        if (win) { 
    363363                                if (!quite) { 
     
    371371                                "chrome, centerscreen, resizable=yes, dialog=no, all, modal=no, dependent=no" 
    372372                        ); 
    373                         return DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 
     373                        return DTA_Mediator.getMostRecent('DTA:Manager'); 
    374374                } catch(ex) { 
    375375                        DTA_debug.log("openManager():", ex); 
     
    379379 
    380380        sendToDown : function(start, links) { 
    381                 var win = DTA_Mediator.getByUrl("chrome://dta/content/dta/manager.xul"); 
     381                var win = DTA_Mediator.getMostRecent('DTA:Manager'); 
    382382                if (win) { 
    383383                        win.self.startDownloads(start, links); 
     
    393393        } 
    394394} 
    395 var DTA_Mediator = { 
    396         _m: Components.classes["@mozilla.org/appshell/window-mediator;1"] 
    397           .getService(Components.interfaces.nsIWindowMediator), 
    398         _ios: Components.classes["@mozilla.org/network/io-service;1"] 
    399           .getService(Components.interfaces.nsIIOService), 
    400  
    401         getMostRecent: function(name)   { 
    402                 var names = ['navigator:browser', 'mail:messageWindow', 'mail:3pane']; 
    403                 if (name) { 
    404                         names.unshift(name); 
    405                 } 
    406                 var rv = null; 
    407                 names.some( 
    408                         function(name) { 
    409                                 rv = this._m.getMostRecentWindow(name); 
    410                                 return rv; 
    411                         }, 
    412                         this 
    413                 ); 
    414                 return rv; 
    415         }, 
    416         getByUrl: function(url) { 
    417                 if (!url) { 
    418                         return null; 
    419                 } 
    420                 if (url instanceof DTA_URL) { 
    421                         url = url.url; 
    422                 } 
    423                 if (url instanceof Components.interfaces.nsIURI) { 
    424                         url = url.spec; 
    425                 } 
    426                 var enumerator = this._m.getEnumerator(null); 
    427                 while (enumerator.hasMoreElements()) { 
    428                         var win = enumerator.getNext(); 
    429                         if (win.location == url) { 
    430                                 return win; 
    431                         } 
    432                 } 
    433                 return null; 
    434         }, 
    435         getAllByType: function(type) { 
    436                 var rv = []; 
    437                 var enumerator = this._m.getEnumerator(type); 
    438                 while (enumerator.hasMoreElements()) { 
    439                         rv.push(enumerator.getNext()); 
    440                 } 
    441                 return rv; 
    442         }, 
    443         openTab: function WM_openTab(url, ref) { 
    444                 if (!url) { 
    445                         return; 
    446                 } 
    447                 var win = this.getMostRecent(); 
    448                 if (!win) { 
    449                         window.open(); 
    450                         win = this.getMostRecent(); 
    451                 } 
    452                 if (url instanceof DTA_URL) { 
    453                         url = url.url; 
    454                 } 
    455                 if (ref instanceof DTA_URL) { 
    456                         ref = ref.url; 
    457                 } 
    458                 if (!url instanceof Components.interfaces.nsIURI) { 
    459                         throw new Error("Cannot open non nsIURI"); 
    460                 } 
    461                 if (ref && !(ref instanceof Components.interfaces.nsIURI)) { 
    462                         try { 
    463                                 ref = DTA_AddingFunctions.ios.newURI(ref, null, null); 
    464                         } 
    465                         catch (ex) { 
    466                                 DTA_debug.log(ref, ex); 
    467                                 ref = null; 
    468                         } 
    469                 } 
    470                 try { 
    471                         if ('delayedOpenTab' in win) { 
    472                                 win.delayedOpenTab(url, ref); 
    473                                 return; 
    474                         } 
    475                         win.getBrowser().addTab(url, ref); 
    476                 }                
    477                 // thunderbird? 
    478                 catch (ex) { 
    479                         try { 
    480                                 var ps = Components.classes['@mozilla.org/uriloader/external-protocol-service;1'] 
    481                                         .getService(Components.interfaces.nsIExternalProtocolService); 
    482                                 ps.loadUrl(url); 
    483                         } 
    484                         catch (ex) { 
    485                                 DTA_debug.log("cannot open link", ex); 
    486                         }                        
    487                 } 
    488         }, 
    489         removeTab: function WM_removeTab(url) { 
    490                 function chk(browser, url) { 
    491                         if (browser.currentURI.spec == url) { 
    492                                 return true; 
    493                         } 
    494                         var frames = browser.contentWindow.frames; 
    495                         if (frames && frames.length) { 
    496                                 for (var i = 0; i < frames.length; i++) { 
    497                                         if (frames[i].location && frames[i].location == url) { 
    498                                                 return true; 
    499                                         } 
    500                                 } 
    501                         } 
    502                         return false; 
    503                 };               
    504                  
    505                 var enumerator = this._m.getEnumerator("navigator:browser"); 
    506                 while (enumerator.hasMoreElements()) { 
    507                         var win = enumerator.getNext(); 
    508                         var browser = win.getBrowser(); 
    509                         for (var i = browser.browsers.length - 1; i >= 0; --i) { 
    510                                 if (chk(browser.getBrowserAtIndex(i), url)) { 
    511                                         browser.removeTab(browser.mTabContainer.childNodes[i]); 
    512                                         return; 
    513                                 } 
    514                         } 
    515                 } 
    516         } 
    517 }; 
     395 
     396let DTA_Mediator = { 
     397        open: function DTA_Mediator_open(url, ref) { 
     398                this.openUrl(window, url, ref); 
     399        } 
     400
     401Components.utils.import('resource://dta/mediator.jsm', DTA_Mediator); 
    518402 
    519403/** 
  • trunk/chrome/content/dta/manager.js

    r1078 r1083  
    188188        }, 
    189189         
     190        openDonate: function D_openDonate() { 
     191                try { 
     192                        DTA_Mediator.open('http://www.downthemall.net/howto/donate/'); 
     193                } 
     194                catch(ex) { 
     195                        alert(ex); 
     196                } 
     197        }, 
     198         
    190199        start: function D_start() { 
    191200                if ("arguments" in window) { 
  • trunk/chrome/content/dta/manager.xul

    r1078 r1083  
    2222 
    2323<window 
    24         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"  
     24        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
     25        windowtype="DTA:Manager"  
    2526        onload="Dialog.init();"  
    2627        title="DownThemAll!"   
     
    140141                                        <toolbarbutton label="&movebottom.label;" id="toolmovebottom" oncommand="Tree.bottom();"  /> 
    141142                                        <spacer flex="1" /> 
    142                                         <image chromedir="&locale.dir;" id="tooldonate" oncommand="DTA_Mediator.openTab('http://www.downthemall.net/howto/donate/');" tooltiptext="&tooldonate.tooltiptext;" /> 
     143                                        <image chromedir="&locale.dir;" id="tooldonate" onclick="Dialog.openDonate();" tooltiptext="&tooldonate.tooltiptext;" /> 
    143144                          </toolbar> 
    144145                        </toolbox> 
  • trunk/chrome/content/dta/manager/metalinker.js

    r1039 r1083  
    416416        }, 
    417417        openLink: function(e) { 
    418                 DTA_Mediator.openTab(e.link); 
     418                DTA_Mediator.open(e.link); 
    419419        }, 
    420420        select: function(type) { 
  • trunk/chrome/content/dta/select.js

    r1078 r1083  
    759759                        tree.selection.getRangeAt(r, start, end); 
    760760                        for (var i = start.value; i <= end.value; ++i) { 
    761                                 DTA_Mediator.openTab(tree._links[i].url.url, tree._links[i].referrer); 
     761                                DTA_Mediator.open(tree._links[i].url.url, tree._links[i].referrer); 
    762762                        } 
    763763                } 
  • trunk/chrome/content/preferences/prefs.js

    r1078 r1083  
    9393        showLog: function() { 
    9494                if (Debug.file.exists()) { 
    95                         DTA_Mediator.openTab("file://" + Debug.file.path); 
     95                        DTA_Mediator.open("file://" + Debug.file.path); 
    9696                } 
    9797        }, 
     
    112112        }, 
    113113        showNotice: function() { 
    114                 DTA_Mediator.openTab('chrome://dta/content/about/about.html#privacy'); 
     114                DTA_Mediator.showNotice(window); 
    115115        } 
    116116}; 
     
    186186        }, 
    187187        openMinTrayR: function() { 
    188                 DTA_Mediator.openTab('http://tn123.ath.cx/mintrayr/?fromdta'); 
     188                DTA_Mediator.open('http://tn123.ath.cx/mintrayr/?fromdta'); 
    189189        } 
    190190};