Show
Ignore:
Timestamp:
2007-06-07 23:50:35 (2 years ago)
Author:
MaierMan
Message:

last pre-merge round of bugfixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/maierman/manager-trees/chrome/content/common/bindings.xml

    r393 r394  
    8080                <content> 
    8181                        <xul:vbox flex="1"> 
    82                         <xul:menulist anonid="list" editable="true" xbl:inherits="readonly,disabled=readonly,flex,tooltiptext,oninput=onchange,onselect=onchange"> 
     82                        <xul:menulist anonid="list" editable="true" xbl:inherits="readonly,disabled,flex,tooltiptext,oninput=onchange,onselect=onchange"> 
    8383                                <xul:menupopup anonid="popup" xbl:inherits="onselect=onchange,oncommand=onchange"/> 
    8484                        </xul:menulist> 
  • branches/maierman/manager-trees/chrome/content/common/internalFunctions.js

    r393 r394  
    295295                } 
    296296                var rv = Date.parse(str); 
    297                 if (isNaN(rv)) { 
     297                if (!isFinite(rv)) { 
    298298                        throw new Error("invalid date"); 
    299299                } 
     
    330330         * @author Nils 
    331331         */ 
    332         makeNumber: function U_makeNumber(rv, digits) { 
     332        formatNumber: function U_formatNumber(rv, digits) { 
    333333                rv = _atos(rv); 
    334334                if (typeof(digits) != 'number') { 
     
    348348                var s = Math.floor(aDelta % 60); 
    349349                if (h) { 
    350                         return this.makeNumber(h, 2) + ":" + this.makeNumber(m, 2) + ":" + this.makeNumber(s, 2); 
    351                 } 
    352                 return this.makeNumber(m, 2) + ":" + this.makeNumber(s, 2); 
     350                        return this.formatNumber(h, 2) + ":" + this.formatNumber(m, 2) + ":" + this.formatNumber(s, 2); 
     351                } 
     352                return this.formatNumber(m, 2) + ":" + this.formatNumber(s, 2); 
    353353        } 
    354354}; 
     
    598598                step = stop - start > 0 ? 1 : -1;  
    599599        } 
    600         if (isNaN(start) || isNaN(stop) || isNaN(step) || step == 0) { 
     600        if (!isFinite(start) || !isFinite(stop) || !isFinite(step) || step == 0) { 
    601601                throw Components.results.NS_ERROR_INVALID_ARG; 
    602602        } 
  • branches/maierman/manager-trees/chrome/content/dta/manager.js

    r393 r394  
    5353const REFRESH_FREQ = 1000; 
    5454const REFRESH_NFREQ = 1000 / REFRESH_FREQ; 
     55const STREAMS_FREQ = 100; 
    5556 
    5657var Dialog = { 
     
    8788                                                if (d.totalSize > 0) { 
    8889                                                        var remaining = Math.ceil((d.totalSize - d.partialSize) / ((d.partialSize - i.lastBytes) * REFRESH_NFREQ)); 
    89                                                         if (isNaN(remaining)) { 
     90                                                        if (!isFinite(remaining)) { 
    9091                                                                d.status = _("unknown"); 
    9192                                                        } 
     
    376377                return this._urls[0].charset; 
    377378        }, 
    378         replace: function um_replace(url, newUrl) { 
    379                 for (var i = 0, e = this._urls.length; i < e; ++i) { 
    380                         if (this._urls[i].url == url) { 
    381                                 this._urls[i] = newUrl; 
    382                                 break; 
    383                         } 
    384                 } 
    385         }, 
    386379        markBad: function um_markBad(url) { 
    387380                if (this._urls.length > 1) { 
     
    433426        encoding: null, 
    434427        fileName: null, 
    435         acceptRanges: false
     428        acceptRanges: 'bytes'
    436429        contentlength: 0, 
    437430        time: null, 
     
    510503                                if (value) { 
    511504                                        this.fileName = value[2].getUsableFileName(); 
    512                                         Debug.dump("found fn:" + this.fileName); 
    513505                                } 
    514506                        } 
     
    732724        set destinationName(nv) { 
    733725                this.destinationNameOverride = nv; 
     726                this._destinationFile = this.destinationPath + this.destinationName; 
    734727                this.invalidate(); 
    735728                return nv; 
     
    914907        }, 
    915908 
    916         removeFromInProgressList: function QI_removeFromInProgressList() { 
    917                 //this.speeds = new Array(); 
    918                 for (var i=0; i<inProgressList.length; i++) 
    919                         if (this==inProgressList[i].d) { 
    920                                 inProgressList.splice(i, 1); 
    921                                 break; 
    922                         } 
    923         }, 
    924          
    925909        refreshPartialSize: function QI_refreshPartialSize(){ 
    926910                var size = 0; 
     
    946930 
    947931                try { 
     932                        if (!this.checkNameConflict()) { 
     933                                return; 
     934                        } 
    948935                        var destination = new FileFactory(this.destinationPath); 
    949936                        Debug.dump(this.fileName + ": Move " + this.tmpFile.path + " to " + this.destinationFile); 
     
    952939                                destination.create(Ci.nsIFile.DIRECTORY_TYPE, 0766); 
    953940                        } 
    954                         this.checkFilenameConflict(); 
    955941                        var df = destination.clone(); 
    956942                        df.append(this.destinationName); 
     
    11111097                         
    11121098                        var replacements = { 
    1113                                 "\\*name\\*": name, 
    1114                                 "\\*ext\\*": ext, 
    1115                                 "\\*text\\*": this.description, 
    1116                                 "\\*url\\*": uri.host, 
    1117                                 "\\*subdirs\\*": uripath, 
    1118                                 "\\*refer\\*": this.refPage.host, 
    1119                                 "\\*qstring\\*": query, 
    1120                                 "\\*curl\\*": (uri.host + ((uripath=="")?"":(SYSTEMSLASH + uripath))), 
    1121                                 "\\*num\\*": Utils.makeNumber(this.numIstance), 
    1122                                 "\\*hh\\*": Utils.makeNumber(this.startDate.getHours(), 2), 
    1123                                 "\\*mm\\*": Utils.makeNumber(this.startDate.getMinutes(), 2), 
    1124                                 "\\*ss\\*": Utils.makeNumber(this.startDate.getSeconds(), 2), 
    1125                                 "\\*d\\*": Utils.makeNumber(this.startDate.getDate(), 2), 
    1126                                 "\\*m\\*": Utils.makeNumber(this.startDate.getMonth(), 2), 
    1127                                 "\\*y\\*": String(this.startDate.getFullYear()) 
    1128                         } 
    1129  
    1130                         for (i in replacements) { 
    1131                                 mask = mask.replace(new RegExp(i, "gi"), replacements[i]); 
    1132                         } 
     1099                                "name": name, 
     1100                                "ext": ext, 
     1101                                "text": this.description, 
     1102                                "url": uri.host, 
     1103                                "subdirs": uripath, 
     1104                                "refer": this.refPage.host, 
     1105                                "qstring": query, 
     1106                                "curl": (uri.host + ((uripath=="")?"":(SYSTEMSLASH + uripath))), 
     1107                                "num": Utils.formatNumber(this.numIstance), 
     1108                                "hh": Utils.formatNumber(this.startDate.getHours(), 2), 
     1109                                "mm": Utils.formatNumber(this.startDate.getMinutes(), 2), 
     1110                                "ss": Utils.formatNumber(this.startDate.getSeconds(), 2), 
     1111                                "d": Utils.formatNumber(this.startDate.getDate(), 2), 
     1112                                "m": Utils.formatNumber(this.startDate.getMonth(), 2), 
     1113                                "y": String(this.startDate.getFullYear()) 
     1114                        } 
     1115                        function replacer(type) { 
     1116                                var t = type.slice(1, u.length - 2).toLowerCase(); 
     1117                                if (t in replacements) { 
     1118                                        return replacements[t]; 
     1119                                } 
     1120                                return type; 
     1121                        } 
     1122                         
     1123                        mask = mask.replace(/\*\w+\*/gi, replacer); 
    11331124 
    11341125                        this._destinationFile = mask = this.pathName.addFinalSlash() + mask.removeBadChars().removeFinalChar(".").trim(); 
     
    11431134                } 
    11441135                this._icon = null; 
    1145         }, 
    1146  
    1147         checkFilenameConflict: function  QI_checkFileNameConflict() { 
    1148                 return 0; 
    1149                 var dn = this.destinationName, ds = this.destinationPath; 
    1150                 var dest = new FileFactory(ds + dn), newDest = dest.clone(); 
    1151  
    1152                 // figure out an unique name 
    1153                 var basename = dn, ext = '', pos = basename.lastIndexOf('.'); 
     1136                this.checkNameConflict();                
     1137        }, 
     1138 
     1139        checkNameConflict: function  QI_checkFileNameConflict() { 
     1140 
     1141                function askForRenaming(t, s1, s2, s3) { 
     1142                        if (Prefs.onConflictingFilenames == 3) { 
     1143                                if (Prefs.askEveryTime) { 
     1144                                        var passingArguments = new Object(); 
     1145                                        passingArguments.text = t; 
     1146                                        passingArguments.s1 = s1; 
     1147                                        passingArguments.s2 = s2; 
     1148                                        passingArguments.s3 = s3; 
     1149                 
     1150                                        window.openDialog( 
     1151                                                "chrome://dta/content/dta/dialog.xul","_blank","chrome,centerscreen,resizable=no,dialog,modal,close=no,dependent", 
     1152                                                passingArguments 
     1153                                        ); 
     1154                 
     1155                                        // non faccio registrare il timeout 
     1156                                        inProgressList.forEach(function(o) { o.d.timeLastProgress = Utils.getTimestamp(); }); 
     1157                 
     1158                                        Prefs.askEveryTime = (passingArguments.temp == 0) ? true : false; 
     1159                                        Prefs.sessionPreference = passingArguments.scelta; 
     1160                                } 
     1161                                return Prefs.sessionPreference; 
     1162                        } 
     1163                        return Prefs.onConflictingFilenames; 
     1164                } 
     1165                 
     1166                let dn = this.destinationName, ds = this.destinationPath, df = this.destinationFile; 
     1167                let dest = new FileFactory(df), newDest = dest.clone(); 
     1168 
     1169                if (!this.is(RUNNING, FINISHING) || !dest.exists()) { 
     1170                        return true; 
     1171                } 
     1172                         
     1173                let basename = dn, ext = '', pos = basename.lastIndexOf('.'); 
    11541174                if (pos != -1) { 
    11551175                        ext = basename.slice(pos); 
    11561176                        basename = basename.slice(0, pos); 
    11571177                } 
    1158                 for (var i = 1; isInProgress(newDest.path, this) != -1 || newDest.exists(); ++i) { 
    1159                         newDest.leafName = basename + "_" +  Utils.makeNumber(i) + ext; 
    1160                 } 
    1161                 if (newDest.path == dest.path) { 
    1162                         return; 
     1178                for (let i = 1;; ++i) { 
     1179                        newDest.leafName = basename + "_" +  Utils.formatNumber(i) + ext; 
     1180                       if (!newDest.exists()) { 
     1181                               break; 
     1182                        } 
    11631183                } 
    11641184                newDest = newDest.leafName; 
     
    11711191 
    11721192                var s = -1, p; 
    1173                 if (dest.exists()) { 
    1174                         s = askForRenaming( 
    1175                                 _('alreadyexists', [dn, ds]) + " " + _('whatdoyouwith', [shortUrl]), 
    1176                                 mc(_('reninto', [newDest]), 0), 
    1177                                 mc(_('overwrite'), 1), 
    1178                                 mc(_('skip'), 2) 
    1179                         ); 
    1180                 } 
    1181                 else if (this.is(FINISHING)) { 
    1182                         s = askForRenaming( 
    1183                                 _("alreadyexists", [dn, ds]) + " " + _("whatdoyoucomplete", [shortUrl]), 
    1184                                 mc(_('reninto', [newDest]), 0), 
    1185                                 mc(_('overwrite'), 1), 
    1186                                 mc(_('cancel'), 4) 
    1187                         ); 
    1188                 } 
    1189                 else if (-1 != (p = isInProgress(dest.path, this))) { 
    1190                         s = askForRenaming( 
    1191                                 _("samedestination", [shortUrl, dn, inProgressList[p].d.urlManager.url]) + " " + _("whatdoyou"), 
    1192                                 mc(_('reninto', [newDest]), 0), 
    1193                                 mc(_('skipfirst'), 2), 
    1194                                 mc(_('cancelsecond'), 3) 
    1195                         ); 
    1196                 } 
    1197                 if (s < 0) { 
    1198                         return; 
    1199                 } 
    1200  
    1201                 if (s == 0) { 
    1202                         this.destinationName = newDest; 
    1203                 } 
    1204                 else if (s == 1) { 
    1205                         dest.remove(false); 
    1206                 } 
    1207                 else if (s == 2) { 
    1208                         this.cancel(_('skipped')); 
    1209                 } 
    1210                 else if (s == 3) { 
    1211                         inProgressList[p].d.cancel(); 
    1212                 } 
    1213                 else { 
    1214                         this.cancel(); 
     1193                s = askForRenaming( 
     1194                        _('alreadyexists', [dn, ds]) + " " + _('whatdoyouwith', [shortUrl]), 
     1195                        mc(_('reninto', [newDest]), 0), 
     1196                        mc(_('overwrite'), 1), 
     1197                        mc(_('skip'), 2) 
     1198                ); 
     1199                 
     1200                switch (s) { 
     1201                        case 0: this.destinationName = newDest; return true; 
     1202                        case 1: return true; 
     1203                        case 3: inProgressList[p].d.cancel(); return true; 
     1204                        default: this.cancel(_('skipped')); return false; 
    12151205                } 
    12161206        }, 
     
    13041294                        chunk.isRunning = true; 
    13051295                        download.state = RUNNING; 
     1296                        download.checkNameConflict(); 
    13061297                        chunk.download = new Download(download, chunk, header); 
    13071298                        ++download.activeChunks; 
     
    14151406Chunk.prototype = { 
    14161407        isRunning: false, 
     1408        get isStarter() { 
     1409                return this.end <= 0; 
     1410        }, 
    14171411        get start() { 
    14181412                return this._start; 
     
    14351429        }, 
    14361430        get complete() { 
    1437                 return this._total == this._written || this._end == -1; 
     1431                if (this._end == -1) { 
     1432                        return this.written != 0; 
     1433                } 
     1434                return this._total == this.written; 
    14381435        }, 
    14391436        get parent() { 
     
    15181515        toString: function() { 
    15191516                let len = this.parent.totalSize ? String(this.parent.totalSize).length  : 10;  
    1520                 return Utils.makeNumber(this.start, len) 
     1517                return Utils.formatNumber(this.start, len) 
    15211518                        + "/" 
    1522                         + Utils.makeNumber(this.end, len) 
     1519                        + Utils.formatNumber(this.end, len) 
    15231520                        + "/" 
    1524                         + Utils.makeNumber(this.total, len) 
     1521                        + Utils.formatNumber(this.total, len) 
    15251522                        + " running:" 
    15261523                        + this.isRunning 
    15271524                        + " written/remain:" 
    1528                         + Utils.makeNumber(this.written, len) 
     1525                        + Utils.formatNumber(this.written, len) 
    15291526                        + "/" 
    1530                         + Utils.makeNumber(this.remainder, len); 
     1527                        + Utils.formatNumber(this.remainder, len); 
    15311528        } 
    15321529} 
    15331530 
    1534 function Download(d, c, headerHack) { 
     1531function Download(d, c, getInfo) { 
    15351532 
    15361533        this.d = d; 
    15371534        this.c = c; 
    1538         this.isHeaderHack = headerHack
     1535        this.isInfoGetter = getInfo
    15391536        this.url = d.urlManager.getURL(); 
    15401537        var referrer = d.refPage; 
     
    15511548                // no-op 
    15521549        } 
    1553         if (referrer) { 
    1554                 try { 
    1555                         var http = this._chan.QueryInterface(Ci.nsIHttpChannel); 
    1556                         //http.setRequestHeader('Accept-Encoding', 'none', false); 
    1557                         if (c.start + c.written > 0) { 
    1558                                 http.setRequestHeader('Range', 'bytes=' + (c.start + c.written) + "-", false); 
    1559                         } 
    1560                         if (typeof(referrer) == 'string') { 
    1561                                 referrer = this._ios.newURI(referrer, null, null); 
    1562                         } 
     1550        try { 
     1551                var http = this._chan.QueryInterface(Ci.nsIHttpChannel); 
     1552                if (c.start + c.written > 0) { 
     1553                        http.setRequestHeader('Range', 'bytes=' + (c.start + c.written) + "-", false); 
     1554                } 
     1555                if (typeof(referrer) == 'string') { 
     1556                        referrer = this._ios.newURI(referrer, null, null); 
     1557                } 
     1558                if (referrer instanceof Ci.nsIURI) { 
    15631559                        http.referrer = referrer; 
    15641560                } 
    1565                 catch (ex) { 
    1566  
    1567                 } 
     1561                http.setRequestHeader('Keep-Alive', '', false); 
     1562                http.setRequestHeader('Connection', 'close', false); 
     1563        } 
     1564        catch (ex) { 
     1565 
    15681566        } 
    15691567        this.c.isRunning = true; 
     
    16791677                        this._chan == newChannel; 
    16801678                        this._redirectedTo = newChannel.URI.spec; 
    1681                          
     1679                        this.url.url = this._redirectedTo; 
     1680                        this.d.filename = this.url.usable.getUsableFileName(); 
    16821681                } 
    16831682                catch (ex) { 
     
    17691768                var d = this.d; 
    17701769                 
    1771                 let code = 503, status = 'Server returned nothing'; 
     1770                let code = 0, status = 'Server returned nothing'; 
    17721771                try { 
    17731772                        code = aChannel.responseStatus; 
     
    17781777                } 
    17791778                 
    1780                 if (code >= 400) { 
     1779                if (!code || code >= 400) { 
    17811780                        if (!this.handleError()) { 
    17821781                                Debug.dump("handleError: Cannot recover from problem!", code); 
    17831782                                var file = d.fileName.length > 50 ? d.fileName.substring(0, 50) + "..." : d.fileName; 
     1783                                code = Utils.formatNumber(code, 3); 
    17841784                                d.fail( 
    17851785                                        _("error", [code]), 
     
    17951795                if (aChannel.responseStatus != 206 && c.start + c.written != 0) { 
    17961796                        Debug.dump(d + ": Server returned a " + aChannel.responseStatus + " response instead of 206... Normal mode"); 
    1797                         vis = {value: '', visitHeader: function(a,b) { this.value += a + ': ' + b + "\n"; }}; 
    1798                         aChannel.visitRequestHeaders(vis); 
    1799                         Debug.dump("Request Headers\n\n" + vis.value); 
    1800                         vis.value = ''; 
    1801                         aChannel.visitResponseHeaders(vis); 
    1802                         Debug.dump("Response Headers\n\n" + vis.value); 
    1803                         d.hasToBeRedownloaded = true; 
    1804                         d.reDownload(); 
    1805                         return; 
     1797                        Debug.dump(c, this.url.url); 
     1798 
     1799                        if (!this.handleError()) { 
     1800                                vis = {value: '', visitHeader: function(a,b) { this.value += a + ': ' + b + "\n"; }}; 
     1801                                aChannel.visitRequestHeaders(vis); 
     1802                                Debug.dump("Request Headers\n\n" + vis.value); 
     1803                                vis.value = ''; 
     1804                                aChannel.visitResponseHeaders(vis); 
     1805                                Debug.dump("Response Headers\n\n" + vis.value); 
     1806                                d.hasToBeRedownloaded = true; 
     1807                                d.reDownload(); 
     1808                                return; 
     1809                        } 
    18061810                } 
    18071811 
     
    18111815                } 
    18121816                catch (ex) { 
    1813                         Debug.dump("header failed! " + d.fileName, ex); 
     1817                        Debug.dump("header failed! " + d, ex); 
    18141818                        // restart download from the beginning 
    18151819                        d.hasToBeRedownloaded = true; 
     
    18181822                } 
    18191823                 
    1820                 // this.isHeaderHack = it's the chunk that has to test response headers 
    1821                 if (!this.isHeaderHack) { 
     1824                if (!this.isInfoGetter) { 
    18221825                        return; 
    18231826                } 
     
    19381941                        } 
    19391942 
    1940                         if (this.isHeaderHack) { 
     1943                        if (this.isInfoGetter) { 
    19411944                                // Checks for available disk space. 
    19421945                                 
     
    19901993                                } 
    19911994                                c.end = d.totalSize - 1; 
    1992                                 this.isHeaderHack = false; 
    1993                         } 
    1994  
    1995                         d.checkFilenameConflict(); 
    1996          
     1995                                delete this.getInfo; 
     1996                        } 
     1997                         
    19971998                        if (d.isResumable) { 
    19981999                                d.resumeDownload(); 
     
    20182019                // check if we're complete now 
    20192020                let shouldFinish = false; 
    2020                 if (d.is(RUNNING) && !d.chunks.some(function(e) { return e.isRunning; })) { 
     2021                if (d.is(RUNNING) && d.chunks.every(function(e) { return e.complete; })) { 
    20212022                        if (!d.resumeDownload()) { 
    20222023                                d.dumpScoreboard(); 
     
    20392040                        return; 
    20402041                } 
    2041                  
    2042                 // ok, chunk passed all the integrity checks! 
    20432042 
    20442043                if (!d.is(RUNNING)) { 
    20452044                        d.speed = ''; 
    2046                         d.removeFromInProgressList(); 
    2047                 } 
    2048  
     2045                        for (let i = 0, e = inProgressList.length; i < e; ++i) { 
     2046                                if (d == inProgressList[i].d) { 
     2047                                        inProgressList.splice(i, 1); 
     2048                                        break; 
     2049                                } 
     2050                        } 
     2051                } 
     2052                 
    20492053                // rude way to determine disconnection: if connection is closed before download is started we assume a server error/disconnection 
    2050                 if (!this.started && d.isResumable && !d.is(CANCELED, PAUSED)) { 
    2051                         if (!this.handleError()) { 
     2054                if (c.isStarter && !shouldFinish) { 
     2055                        if (!d.urlManager.markBad(this.url)) { 
    20522056                                Debug.dump(d + ": Server error or disconnection (type 1)"); 
    20532057                                d.status = _("srver"); 
    20542058                                d.speed = ''; 
    20552059                                d.setPaused(); 
    2056                         } 
    2057                         return;                  
     2060                                return; 
     2061                        } 
     2062                        else { 
     2063                                Debug.dump("caught bad server"); 
     2064                                d.chunks = []; 
     2065                        } 
    20582066                } 
    20592067 
     
    20632071                        d.finishDownload(); 
    20642072                } 
    2065                 else if (d.is(RUNNING) && d.isResumable) { 
    2066                         // if all the download space has already been occupied by chunks (= !resumeDownload) 
     2073                else { 
    20672074                        d.resumeDownload(); 
    20682075                } 
     
    21752182        return -1; 
    21762183} 
    2177  
    2178 function askForRenaming(t, s1, s2, s3) { 
    2179         if (Prefs.onConflictingFilenames == 3) { 
    2180                 if (Prefs.askEveryTime) { 
    2181                         var passingArguments = new Object(); 
    2182                         passingArguments.text = t; 
    2183                         passingArguments.s1 = s1; 
    2184                         passingArguments.s2 = s2; 
    2185                         passingArguments.s3 = s3; 
    2186  
    2187                         window.openDialog( 
    2188                                 "chrome://dta/content/dta/dialog.xul","_blank","chrome,centerscreen,resizable=no,dialog,modal,close=no,dependent", 
    2189                                 passingArguments 
    2190                         ); 
    2191  
    2192                         // non faccio registrare il timeout 
    2193                         inProgressList.forEach(function(o) { o.d.timeLastProgress = Utils.getTimestamp(); }); 
    2194  
    2195                         Prefs.askEveryTime = (passingArguments.temp == 0) ? true : false; 
    2196                         Prefs.sessionPreference = passingArguments.scelta; 
    2197                 } 
    2198                 return Prefs.sessionPreference; 
    2199         } 
    2200         return Prefs.onConflictingFilenames; 
    2201 } 
  • branches/maierman/manager-trees/chrome/content/dta/manager/decompressor.js

    r390 r394  
    117117                this.download.invalidate(); 
    118118                var thisp = this; 
    119                 Dialog.setTimer(this._uuid, function() { thisp._invalidate(); }, 200); 
     119                Dialog.setTimer(this._uuid, function() { thisp._invalidate(); }, STREAMS_FREQ); 
    120120        },       
    121121        onStartRequest: function(r, c) { 
     
    159159                        } 
    160160                        this.download.partialSize = offset; 
    161                         this.download.invalidate(); 
    162161                } 
    163162                catch (ex) { 
  • branches/maierman/manager-trees/chrome/content/dta/manager/info.js

    r393 r394  
    1515 
    1616var Dialog = { 
     17        get isFullyDisabled() { 
     18                return $('directory', 'renaming', 'hash').every( 
     19                        function(e) { 
     20                                return e.hasAttribute('disabled'); 
     21                        } 
     22                ); 
     23        }, 
    1724        load: function DTA_load() { 
    1825                make_(); 
     
    4148                                $("infoURL").value = $("sourcePage").value = "---"; 
    4249                                $("hash").setAttribute('readonly', 'true'); 
     50                                $("hash").setAttribute('disabled', 'true'); 
    4351         
    4452                                var mask = downloads[0].mask; 
     
    6371                        }                                
    6472                        if (downloads.every(function(d) { return d.is(COMPLETE, FINISHING); })) { 
    65                                 $('directory', 'renaming', 'mask').forEach(function(e) { e.setAttribute('readonly', 'true'); }); 
    66                                 $('browsedir').setAttribute('disabled', 'true'); 
    67                         } 
    68                         if ($('directory', 'renaming', 'hash').every(function(e) { return e.hasAttribute('readonly'); })) { 
     73                                $('directory', 'renaming', 'mask', 'browsedir').forEach( 
     74                                        function(e) { 
     75                                                e.setAttribute('readonly', 'true'); 
     76                                                e.setAttribute('disabled', 'true'); 
     77                                        } 
     78                                ); 
     79                        } 
     80                        if (this.isFullyDisabled) { 
    6981                                $('dTaDownloadInfo').buttons = 'accept'; 
    7082                        }                        
     
    7587        }, 
    7688        accept: function DTA_accept() { 
    77                 if ($('directory', 'renaming', 'hash').every(function(e) { return e.hasAttribute('readonly'); })) { 
     89                if (this.isFullyDisabled) { 
    7890                        return true; 
    7991                }                
     
    137149                compl.addColorStop(1, 'rgba(0,199,56,255)'); 
    138150                 
    139                 var join = "#A5FE2C"; 
    140                  
    141151                var cancel = canvas.createLinearGradient(0,0,0,16); 
    142152                cancel.addColorStop(0, 'rgba(151,58,2,100)'); 
     
    150160                canvas.fillRect(0,0,300,20); 
    151161 
    152                 if (d.is(COMPLETE)) { 
     162                if (d.is(COMPLETE, FINISHING)) { 
    153163                        canvas.fillStyle = compl; 
    154164                        canvas.fillRect(0,0,300,20); 
     
    167177                                function(c) { 
    168178                                        this.canvas.fillStyle = prog; 
    169                                         this.canvas.fillRect(Math.round(c.start/d.totalSize*300),0,Math.round(c.size/d.totalSize*300),20); 
     179                                        this.canvas.fillRect( 
     180                                                Math.ceil(c.start / d.totalSize * 300), 
     181                                                0, 
     182                                                Math.ceil(c.written / d.totalSize * 300), 
     183                                                20 
     184                                        ); 
    170185                                }, 
    171186                                this 
    172187                        ); 
    173                         canvas.fillStyle = join; 
    174                         canvas.fillRect(0,16,Math.round(d.chunks[d.firstChunk].chunkSize/d.totalSize*300),4); 
    175188                } 
    176189                setTimeout('Dialog.draw();', 150); 
  • branches/maierman/manager-trees/chrome/content/dta/manager/metalinker.js

    r384 r394  
    113113                                        if (url.hasAttribute('preference')) { 
    114114                                                var a = new Number(url.getAttribute('preference')); 
    115                                                 if (!isNaN(a)) { 
     115                                                if (isFinite(a)) { 
    116116                                                        preference = a; 
    117117                                                } 
  • branches/maierman/manager-trees/chrome/content/dta/manager/sessionmanager.js

    r385 r394  
    8484                ); 
    8585                e.state = d.is(COMPLETE, CANCELED) ? d.state : PAUSED; 
     86                if (d.destinationNameOverride) { 
     87                        e.destinationName = d.destinationNameOverride; 
     88                } 
    8689 
    8790                e.referrer = d.refPage.spec; 
     
    198201                                [ 
    199202                                        'fileName', 
     203                                        'destinationName', 
    200204                                        'isResumable', 
    201205                                        'state', 
  • branches/maierman/manager-trees/chrome/content/dta/manager/verificator.js

    r390 r394  
    8989                this.download.invalidate(); 
    9090                var thisp = this; 
    91                 Dialog.setTimer(this._uuid, function() { thisp._invalidate(); }, 200); 
     91                Dialog.setTimer(this._uuid, function() { thisp._invalidate(); }, STREAMS_FREQ); 
    9292        }, 
    9393        QueryInterface: function(iid) { 
  • branches/maierman/manager-trees/chrome/content/integration/saveas.js

    r370 r394  
    5050                        this.referrer = this.url; 
    5151                } 
     52                this.url = new DTA_URL(this.url); 
    5253 
    5354                this.ddDirectory = document.getElementById('tdtalist'); 
     
    9394                // take care of FlashGot... for now. 
    9495                // need to negotiate with the author (and possible other extension authors) 
    95                 if (gFlashGotDMDialog) 
    96                 { 
     9