Changeset 590

Show
Ignore:
Timestamp:
04/07/09 02:00:40 (8 months ago)
Author:
ashot
Message:

merge desktopr/flash dev with jerome's changes, first flash src check in

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/api.js

    r544 r590  
    6969                                }, null, 'http://' + SITE_HOST + '/services/auth/' + 
    7070                                        (fresh ? 'fresh/' : ''), true); 
    71                                 document.getElementById('auth_url').value = url; 
     71                                //document.getElementById('auth_url').value = url; 
    7272                                pages.go('auth'); 
    7373                        } 
     
    369369 
    370370                                // Update the lists of available sets 
     371                                /* 
    371372                                var ii = meta.sets.length; 
    372373                                var prefixes = ['single', 'batch']; 
     
    412413                                        } 
    413414                                } 
    414                 unblock_normalize(); 
     415                                unblock_normalize(); 
     416                                */ 
     417 
    415418                        } 
    416419                        status.clear(); 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/buttons.js

    r540 r590  
    22 * Flickr Uploadr 
    33 * 
    4  * Copyright (c) 2007-2009 Yahoo! Inc.  All rights reserved.  This library is 
     4 * Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
    55 * free software; you can redistribute it and/or modify it under the terms of 
    66 * the GNU General Public License (GPL), version 2 only.  This library is 
     
    1313        login: { 
    1414                click: function() { 
    15                         if ('small button' != document.getElementById('login').className) { 
    16                                 return; 
    17                        
     15                        //if ('small button' != document.getElementById('login').className) { 
     16                                //return; 
     17                        //
    1818                        if (users.nsid) { 
    1919                                settings.show(); 
     
    2323                }, 
    2424                enable: function() { 
    25                         document.getElementById('login').className = 'small button'; 
    26                         document.getElementById('big_login').className = 'button'; 
     25                        //document.getElementById('login').className = 'small button'; 
     26                        //document.getElementById('big_login').className = 'button'; 
    2727                }, 
    2828                disable: function() { 
    29                         document.getElementById('login').className = 'small disabled_button'; 
    30                         document.getElementById('big_login').className = 'disabled_button'; 
     29                        //document.getElementById('login').className = 'small disabled_button'; 
     30                        //document.getElementById('big_login').className = 'disabled_button'; 
    3131                } 
    3232        }, 
     
    4141        remove: { 
    4242                enable: function() { 
    43                         document.getElementById('t_remove').className = 'button'; 
     43                        //document.getElementById('t_remove').className = 'button'; 
    4444                }, 
    4545                disable: function() { 
    46                         document.getElementById('t_remove').className = 'disabled_button'; 
     46                        //document.getElementById('t_remove').className = 'disabled_button'; 
    4747                } 
    4848        }, 
     
    5252                        if (users.nsid && 'boolean' == typeof users.is_pro && 
    5353                                0 < photos.count) { 
    54                                 document.getElementById('button_upload').className = 'button'; 
    55                                 document.getElementById('button_upload').style.display = 'block'
    56                                 document.getElementById('menu_upload').disabled = false; 
     54                                //document.getElementById('button_upload').className = 'button'; 
     55                                //document.getElementById('menu_upload').disabled = false
     56                                //document.getElementById('menu_upload').disabled = false; 
    5757                        } 
    5858                }, 
    5959                disable: function() { 
    60                         document.getElementById('button_upload').className = 'disabled_button'; 
    61                         document.getElementById('button_upload').style.display = 'none'
    62                         document.getElementById('menu_upload').disabled = true; 
     60                        //document.getElementById('button_upload').className = 'disabled_button'; 
     61                        //document.getElementById('menu_upload').disabled = true
     62                        //document.getElementById('menu_upload').disabled = true; 
    6363                }, 
    6464                click: function() { 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/clh.js

    r501 r590  
    2020                queue = comp.getQueue(); 
    2121        } 
    22         photos.add(queue.split('|||||'), silent); 
     22        var Q = queue.split('|||||'); 
     23        if(Q.length > 0) 
     24                photos.add(Q, silent); 
    2325}; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/conf.js

    r583 r590  
    22 * Flickr Uploadr 
    33 * 
    4  * Copyright (c) 2007-2009 Yahoo! Inc.  All rights reserved.  This library is 
     4 * Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
    55 * free software; you can redistribute it and/or modify it under the terms of 
    66 * the GNU General Public License (GPL), version 2 only.  This library is 
     
    3030        // What version am I? 
    3131        version: '3.x', 
     32        base_url:'', 
    3233 
    3334        app_ini: {}, 
     
    4748        }, 
    4849 
    49     // Size of threads pool for thumbnailing 
    50     maxThreadsCount: 5, 
    51  
     50        // Size of threads pool for thumbnailing 
     51        maxThreadsCount: 1, 
    5252        // Scrolling threshold for dragging (pixels); 
    5353        scroll: 20, 
     
    8080        tickets_retry_count: 10, 
    8181 
    82  
    83  
    8482        // 
    8583        // Feature switches 
     
    9088        socket_uploadr: true, 
    9189 
    92  
    93  
    9490        // 
    9591        // Not advised to change below here 
     
    9894        // Size of thumbnails 
    9995        //   Changing this will require CSS tweaks 
    100         thumb_size: 100, 
     96        thumb_size: 200, 
    10197 
    10298        // Upload mode 
     
    109105 
    110106        // Load are parse the application.ini file 
    111         load_ini: function(){ 
    112 //                      window.openDialog('http://beta2.flickr.com','_blank','modal'); 
     107        load_ini: function(bu){ 
    113108 
     109                conf.base_url = bu; 
     110                 
    114111                var f = Components.classes["@mozilla.org/file/directory_service;1"] 
    115112                        .getService(Components.interfaces.nsIProperties) 
     
    153150                } 
    154151 
    155  
     152                 
    156153                // use some of the parsed options 
    157154 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js

    r510 r590  
    4040 
    4141        // Write an object into a file as JSON 
    42         write: function(name, data) { 
    43                 var profile = Cc['@mozilla.org/file/directory_service;1'] 
    44                         .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 
    45                 profile.append(name); 
     42        write: function(name, data, f) { 
     43                if(!f){ 
     44                        var profile = Cc['@mozilla.org/file/directory_service;1'] 
     45                                .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 
     46                        profile.append(name); 
     47                } 
     48                else{ 
     49                        profile = f; 
     50                } 
    4651                var _stream = Cc['@mozilla.org/network/file-output-stream;1'] 
    4752                        .createInstance(Ci.nsIFileOutputStream); 
     
    8085                _stream.close(); 
    8186        }, 
     87         
     88        write_to_flash_player_trust: function(){ 
     89                 
     90                var f = Cc['@mozilla.org/file/directory_service;1'] 
     91                        .getService(Ci.nsIProperties).get('Desk', Ci.nsIFile); 
     92                 
     93                var install_path = Cc['@mozilla.org/file/directory_service;1'] 
     94                        .getService(Ci.nsIProperties).get('AChrom', Ci.nsIFile).path; 
     95                 
     96                if(install_path.match(/^\//)){//if on mac 
     97                        var fil = Cc['@mozilla.org/file/local;1'] 
     98                                .createInstance(Ci.nsILocalFile); 
     99                        fil.initWithPath(f.path+'/../Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust/') 
     100                        fil.append('flickr_uploadr.cfg'); 
     101                        //f.append(name); 
     102                        if(!fil.exists()){ 
     103                                fil.create(fil.NORMAL_FILE_TYPE, 0666); 
     104                                file.write('flickr_uploadr.cfg', install_path, fil); 
     105                        } 
     106                } 
     107        }, 
    82108 
    83109        // File size in kilobytes 
     
    94120        }, 
    95121 
    96     // Delete 
    97     remove: function(name) { 
    98         try { 
    99             var file = Cc['@mozilla.org/file/directory_service;1'] 
     122       // Delete 
     123       remove: function(name) { 
     124               try { 
     125                       var file = Cc['@mozilla.org/file/directory_service;1'] 
    100126                                .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 
    101127                        file.append(name); 
    102128                        if (file.exists()) { 
    103                             file.remove(false); 
     129                               file.remove(false); 
    104130                        } 
    105         } catch (err) { 
    106             Components.utils.reportError(new Date().toUTCString() +err); 
    107         } 
    108     } 
     131                } catch (err) { 
     132                    Components.utils.reportError(new Date().toUTCString() +err); 
     133                } 
     134        }, 
     135               
     136        save_from_url: function(url, file_name){ 
     137                var ioserv = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);  
     138                var channel = ioserv.newChannel(url+'?'+Math.random(), 0, null);  
     139                var stream = channel.open();  
     140                 
     141                if (channel instanceof Components.interfaces.nsIHttpChannel && channel.responseStatus != 200) {  
     142                        return false;  
     143                } 
     144                 
     145                var bstream = Components.classes["@mozilla.org/binaryinputstream;1"]  
     146                .createInstance(Components.interfaces.nsIBinaryInputStream);  
     147                bstream.setInputStream(stream);  
     148                 
     149 
     150                var size = 0; 
     151                var file_data = ""; 
     152                while(size = bstream.available()) { 
     153                        file_data += bstream.readBytes(size); 
     154                } 
     155                file.save_to_chrome(file_data, file_name) 
     156                return true; 
     157        }, 
     158         
     159        save_to_chrome: function(data, file_name){ 
     160                var profile = Cc['@mozilla.org/file/directory_service;1'] 
     161                        .getService(Ci.nsIProperties).get('AChrom', Ci.nsILocalFile); 
     162                 
     163                profile.append('content'); 
     164                profile.append('uploadr'); 
     165                try{ 
     166                        for(var i=0;i<file_name.length;i++) 
     167                                profile.append(file_name[i]); 
     168                } 
     169                catch(err){ 
     170                        profile.initWithPath(profile.path + file_name); 
     171                } 
     172                 
     173                var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); 
     174                stream.init(profile, 0x02 | 0x08 | 0x20, 0600, 0); // write, create, truncate 
     175                                         
     176                stream.write(data, data.length); 
     177                 
     178                if (stream instanceof Ci.nsISafeOutputStream) { 
     179                        stream.finish(); 
     180                } else { 
     181                        stream.close(); 
     182                } 
     183                 
     184                 
     185        }, 
     186               
     187        compute_file_hash: function(path){ 
     188                var f = Components.classes["@mozilla.org/file/local;1"] 
     189                                  .createInstance(Components.interfaces.nsILocalFile); 
     190                f.initWithPath(path); 
     191                var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]            
     192                                        .createInstance(Components.interfaces.nsIFileInputStream); 
     193                // open for reading 
     194                istream.init(f, 0x01, 0444, 0); 
     195                var ch = Components.classes["@mozilla.org/security/hash;1"] 
     196                                   .createInstance(Components.interfaces.nsICryptoHash); 
     197                // we want to use the MD5 algorithm 
     198                ch.init(ch.MD5); 
     199                // this tells updateFromStream to read the entire file 
     200                const PR_UINT32_MAX = 0xffffffff; 
     201                ch.updateFromStream(istream, PR_UINT32_MAX); 
     202                // pass false here to get binary data back 
     203                var hash = ch.finish(false); 
     204 
     205                // return the two-digit hexadecimal code for a byte 
     206                function toHexString(charCode) 
     207                { 
     208                  return ("0" + charCode.toString(16)).slice(-2); 
     209                } 
     210 
     211                // convert the binary hash data to a hex string. 
     212                var s = [toHexString(hash.charCodeAt(i)) for (i in hash)].join(""); 
     213                // s now contains your hash in hex 
     214                return s; 
     215        }, 
     216               
     217        get_standard_path: function(s){ 
     218                try{ 
     219              var f = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get(s, Ci.nsIFile) 
     220                }catch(e){ 
     221                Components.utils.reportError(String(s)); 
     222                        Components.utils.reportError(e); 
     223                        return ''; 
     224                } 
     225              return f.path; 
     226        }, 
     227               
     228        get_excluded_directories: function(){ 
     229                return [file.get_standard_path('AChrom'), file.get_standard_path('TmpD'), file.get_standard_path('ProfLD')] 
     230        } 
     231               
    109232}; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js

    r544 r590  
    7676                        } 
    7777                } 
    78         unblock_normalize(); 
     78               unblock_normalize(); 
    7979        } 
    8080 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/main.xul

    r508 r590  
    44Flickr Uploadr 
    55 
    6 Copyright (c) 2007-2009 Yahoo! Inc.  All rights reserved.  This library is 
     6Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
    77free software; you can redistribute it and/or modify it under the terms of 
    88the GNU General Public License (GPL), version 2 only.  This library is 
     
    1111 
    1212--> 
     13<!DOCTYPE window [ 
     14  <!ENTITY % mainDTD SYSTEM "chrome://uploadr/locale/main.dtd"> 
     15  %mainDTD; 
     16  <!ENTITY % settingsDTD SYSTEM "chrome://uploadr/content/settings.dtd"> 
     17  %settingsDTD; 
     18]> 
     19 
    1320<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
    1421<?xml-stylesheet href="chrome://uploadr/skin/main.css" type="text/css"?> 
    1522<!--<?xml-stylesheet href="chrome://hacks/skin/hacks.css" type="text/css"?>--> 
    16 <?xul-overlay href="chrome://uploadr/content/photos.xul"?
    17 <?xul-overlay href="chrome://uploadr/content/help.xul"?> 
     23<!--<?xul-overlay href="chrome://uploadr/content/photos.xul"?>--
     24<?xul-overlay href="&base.url;help.xul"?> 
    1825<?xul-overlay href="chrome://hacks/content/keyboard.xul"?> 
    19 <!DOCTYPE window SYSTEM "chrome://uploadr/locale/main.dtd"> 
     26 
     27 
    2028<window id="main" title="&title;" width="960" height="700" windowtype="app" 
    2129        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
    2230        xmlns:html="http://www.w3.org/1999/xhtml" 
    23         onload="conf.load_ini(); threads.init(); users.load(); photos.load(); ui.init(); ui.users_updated();" 
     31        onload="conf.load_ini('&base.url;'); threads.init(); users.load();    ui.users_updated();" 
    2432        onclose="return exit();" persist="screenX screenY width height sizemode" 
    25 
     33>        
     34<!-- removed photos.load(); ui.init(); from onload, flash calls them--> 
     35 
    2636  <stringbundleset> 
    2737    <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 
     38    <stringbundle id="locale" src="chrome://uploadr/content/main.prefs" /> 
    2839  </stringbundleset> 
     40  <head> 
     41           
    2942  <script src="chrome://global/content/globalOverlay.js" /> 
    3043  <script src="chrome://global/content/nsDragAndDrop.js" /> 
    3144  <script src="chrome://global/content/nsUserSettings.js" /> 
    32   <script src="chrome://uploadr/content/ui.js" />   
    33   <script src="chrome://uploadr/content/conf.js" /> 
    34   <script src="chrome://uploadr/content/clh.js" /> 
    35   <script src="chrome://uploadr/content/upgrade.js" /> 
    36   <script src="chrome://uploadr/content/file.js" /> 
    37   <script src="chrome://uploadr/content/threads.js" /> 
    38   <script src="chrome://uploadr/content/flickr.js" /> 
    39   <script src="chrome://uploadr/content/api.js" /> 
    40   <script src="chrome://uploadr/content/upload.js" /> 
    41   <script src="chrome://uploadr/content/photos.js" /> 
    42   <script src="chrome://uploadr/content/meta.js" /> 
    43   <script src="chrome://uploadr/content/settings.js" /> 
    44   <script src="chrome://uploadr/content/users.js" /> 
    45   <script src="chrome://uploadr/content/drag.js" /> 
    46   <script src="chrome://uploadr/content/grid.js" /> 
    47   <script src="chrome://uploadr/content/mouse.js" /> 
    48   <script src="chrome://uploadr/content/keyboard.js" /> 
    49   <script src="chrome://uploadr/content/buttons.js" /> 
    50   <script src="chrome://uploadr/content/extension.js" /> 
     45   
     46  <script src="&base.url;conf.js" /> 
     47  <script src="&base.url;clh.js" /> 
     48  <script src="&base.url;threads.js" /> 
     49  <script src="&base.url;upgrade.js" /> 
     50  <script src="&base.url;file.js" /> 
     51  <script src="&base.url;flickr.js" /> 
     52  <script src="&base.url;api.js" /> 
     53  <script src="&base.url;upload.js" /> 
     54  <script src="&base.url;photos.js" /> 
     55  <script src="&base.url;meta.js" /> 
     56  <script src="&base.url;settings.js" /> 
     57  <script src="&base.url;users.js" /> 
     58  <script src="&base.url;ui.js" /> 
     59  <script src="&base.url;drag.js" /> 
     60  <script src="&base.url;grid.js" /> 
     61  <script src="&base.url;mouse.js" /> 
     62  <script src="&base.url;keyboard.js" /> 
     63  <script src="&base.url;buttons.js" /> 
     64  <script src="&base.url;extension.js" /> 
     65   
     66  </head> 
    5167  <!--<script src="chrome://venkman/content/venkman-overlay.js"/>--> 
    5268  <keyset id="key"> 
     
    7894          <menuitem label="&menu.upload.add;" key="key_add" accesskey="A" oncommand="photos.add_dialog();" /> 
    7995          <menuitem id="menu_upload" label="&menu.upload;" key="key_upload" accesskey="U" oncommand="photos.upload();" /> 
     96          <menuitem label="Clear Index" accesskey="X" oncommand="photos.removeAll();photos.load();ui.init()" /> 
    8097          <menuitem id="menu_FileQuitItem" label="&menu.upload.exit;" key="key_quit" accesskey="Q" oncommand="exit();" /> 
    8198        </menupopup> 
     
    112129  <vbox flex="1"> 
    113130 
    114     <!-- Header --> 
    115     <hbox id="head"> 
    116       <hbox id="tools"> 
    117         <vbox> 
    118           <spacer flex="1" /> 
    119           <html:div id="t_add" class="button" onclick="photos.add_dialog();"> 
    120             <html:div>&tools.add;</html:div> 
    121           </html:div> 
    122           <spacer flex="1" /> 
    123         </vbox> 
    124         <vbox> 
    125           <spacer flex="1" /> 
    126           <html:div id="t_remove" class="disabled_button" onclick="photos.remove();"> 
    127             <html:div>&tools.remove;</html:div> 
    128           </html:div> 
    129           <spacer flex="1" /> 
    130         </vbox> 
    131         <vbox> 
    132           <spacer flex="1" /> 
    133           <html:div id="t_clear" class="disabled_button" onclick="photos.removeAll();"> 
    134             <html:div>&tools.clear;</html:div> 
    135           </html:div> 
    136           <spacer flex="1" /> 
    137         </vbox> 
    138         <html:div class="toolbarseparator" /> 
    139         <vbox> 
    140           <html:div id="t_rotate_l" class="disabled" onclick="photos.rotate(-90);" /> 
    141         </vbox> 
    142         <vbox> 
    143           <html:div id="t_rotate_r" class="disabled" onclick="photos.rotate(90);" /> 
    144         </vbox> 
    145       </hbox> 
    146       <box> 
    147         <html:p id="free"> </html:p> 
    148       </box> 
    149       <box flex="1" /> 
    150       <vbox id="bw_remaining"> 
    151         <html:p>&bandwidth.remaining;</html:p> 
    152         <html:h3 id="bw_remaining_mb"> </html:h3> 
    153       </vbox> 
    154       <vbox id="bw_batch"> 
    155         <html:p>&bandwidth.batch;</html:p> 
    156         <html:h3 id="bw_batch_mb"> </html:h3> 
    157       </vbox> 
    158       <box id="logo" /> 
    159     </hbox> 
     131     
     132           
     133          <stack flex="1"> 
     134    <vbox  id="page_photos" flex="1"> 
     135            <html:embed id="the_swf" flex="1"/> 
     136    </vbox> 
     137     
    160138 
    161     <!-- Placeholder for photos and metadata overlay --> 
    162     <vbox id="page_photos" flex="1" /> 
    163139 
    164140    <!-- Page to show during authorization --> 
     
    181157    <!-- Placeholder for help page --> 
    182158    <vbox id="page_help" flex="1" /> 
     159    </stack> 
    183160 
    184161    <!-- Upload progress bar and (hidden) upload queue --> 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js

    r546 r590  
    8585 
    8686                        // Blank slate metadata 
    87                         document.getElementById('batch_title').value = ''; 
    88                         document.getElementById('batch_description').value = ''; 
    89                         document.getElementById('batch_tags').value = ''; 
    90                         document.getElementById('batch_is_public').value = 2; 
    91                         var is_friend = document.getElementById('batch_is_friend'); 
    92                         is_friend.checked = false; 
    93                         is_friend.disabled = true; 
    94                         var is_family = document.getElementById('batch_is_family'); 
    95                         is_family.checked = false; 
    96                         is_family.disabled = true; 
    97                         document.getElementById('batch_content_type').value = 0; 
    98                         document.getElementById('batch_hidden').value = 0; 
     87                        var s = photos.selected; 
     88                        var title = photos.list[s[0]].title; 
     89                        var description = photos.list[s[0]].description; 
     90                        var tags = photos.list[s[0]].tags; 
     91                        var is_public = photos.list[s[0]].is_public; 
     92                        var is_friend = photos.list[s[0]].is_friend; 
     93                        var is_family = photos.list[s[0]].is_family; 
     94                        var content_type = photos.list[s[0]].content_type; 
     95                        var hidden = photos.list[s[0]].hidden; 
     96                        var safety_level = photos.list[s[0]].safety_level; 
     97                        for(var j in s){ 
     98                                if(title != photos.list[s[j]].title) 
     99                                        title = ''; 
     100                                if(description != photos.list[s[j]].description) 
     101                                        description = ''; 
     102                                if(tags != photos.list[s[j]].tags) 
     103                                        tags = ''; 
     104                                if(is_public != photos.list[s[j]].is_public) 
     105                                        is_public = 2; 
     106                                if(is_friend != photos.list[s[j]].is_friend) 
     107                                        is_friend = 0; 
     108                                if(is_family != photos.list[s[j]].is_family) 
     109                                        is_family = 0; 
     110                                if(content_type != photos.list[s[j]].content_type) 
     111                                        content_type = 0; 
     112                                if(hidden != photos.list[s[j]].hidden) 
     113                                        hidden = 0; 
     114                                if(safety_level != photos.list[s[j]].safety_level) 
     115                                        safety_level = 0; 
     116                        } 
     117                         
     118                        document.getElementById('batch_title').value = title; 
     119                        document.getElementById('batch_description').value = description; 
     120                        document.getElementById('batch_tags').value = tags; 
     121                        document.getElementById('batch_is_public').value = is_public; 
     122                         
     123                        if(is_public!=0){ 
     124                                var is_friend = document.getElementById('batch_is_friend'); 
     125                                is_friend.checked = false; 
     126                                is_friend.disabled = true; 
     127                                var is_family = document.getElementById('batch_is_family'); 
     128                                is_family.checked = false; 
     129                                is_family.disabled = true; 
     130                        } 
     131                        else{ 
     132                                var is_friend = document.getElementById('batch_is_friend'); 
     133                                is_friend.checked = is_friend; 
     134                                is_friend.disabled = !is_friend; 
     135                                var is_family = document.getElementById('batch_is_family'); 
     136                                is_family.checked = is_family; 
     137                                is_family.disabled = !is_family; 
     138                        } 
     139                         
     140                        document.getElementById('batch_content_type').value = content_type; 
     141                        document.getElementById('batch_hidden').value = hidden; 
    99142                        var safety_level = document.getElementById('batch_safety_level'); 
    100143                        safety_level.value = 0; 
    101                         safety_level.selectedItem.label = ''; 
     144                        //safety_level.selectedItem.label = ''; 
    102145 
    103146                        // Clear the old sets list 
     
    275318                        var p = photos.list[id]; 
    276319                        if (null == p) { 
    277                             unblock_normalize(); 
     320                               unblock_normalize(); 
    278321                                return; 
    279322                        } 
     
    349392 
    350393                // Single photo or group of photos? 
    351             block_normalize(); 
     394               block_normalize(); 
    352395                var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 
    353         unblock_normalize(); 
     396               unblock_normalize(); 
    354397         
    355398                if (1 == parseInt(value)) { 
     
    631674                        } 
    632675                } 
    633         unblock_normalize(); 
     676               unblock_normalize(); 
    634677        }, 
    635678 
     
    667710                                } 
    668711                        } 
    669             unblock_normalize(); 
     712                       unblock_normalize(); 
    670713                        // If there are videos then bother them 
    671714                        if (v_count) { 
     
    741784                                                photos._remove(); 
    742785                                        } 
    743                     unblock_normalize(); 
     786                                       unblock_normalize(); 
    744787                                        // If remove is blocked then we know photos.normalize 
    745788                                        // will be called as it is unblocked 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js

    r559 r590  
    2929                        meta.abandon(); 
    3030                } 
    31         unblock_normalize(); 
     31               unblock_normalize(); 
    3232         
    3333                // If we clicked on an image that isn't an error and isn't loading 
     
    104104                                meta.batch(); 
    105105                        } 
    106             unblock_normalize(); 
     106                       unblock_normalize(); 
    107107                } 
    108108                // If we clicked the revert to sorted button 
     
    287287                                                'selected dragging'; 
    288288                                } 
    289                 unblock_normalize(); 
     289                               unblock_normalize(); 
    290290                                mouse.dragging = 2; 
    291291                        } 
     
    433433                // If we're reordering 
    434434                if (null == mouse.anchor) { 
    435                     block_normalize(); 
     435                       block_normalize(); 
    436436                        var list = document.getElementById('photos_list'); 
    437437                        if (3 == mouse.dragging) { 
     
    544544                        unblock_normalize(); 
    545545                } 
    546  
    547546                mouse.anchor = null; 
    548547        }, 
     
    554553        show_photos: function() { 
    555554                mouse._photos_visible = true; 
    556                 document.getElementById('page_photos').style.display = '-moz-box'; 
     555                document.getElementById('the_swf').style.visibility = 'visible'; 
    557556                document.getElementById('page_queue').style.display = 'none'; 
    558557                document.getElementById('footer').className = 'photos'; 
     
    560559        show_queue: function() { 
    561560                mouse._photos_visible = false; 
    562                 document.getElementById('page_photos').style.display = 'none'; 
     561                document.getElementById('the_swf').style.visibility = 'hidden'; 
    563562                document.getElementById('page_queue').style.display = '-moz-box'; 
    564563                document.getElementById('footer').className = 'queue'; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js

    r583 r590  
    99 */ 
    1010 
     11 
    1112var photos = { 
    1213 
     
    1516        count: 0, 
    1617        videoCount: 0, 
     18        the_swf:null, 
     19        file:null, 
    1720        errors: 0, 
    1821        selected: [], 
     
    2124        batch_size: 0, 
    2225        video_batch_size: 0, 
     26        calling_swf: false, 
     27        to_call_swf: [], 
     28        wait_time: 2000, 
     29        thumb_queue: [], 
     30        thumb_thread_counter: 0, 
     31        waiting_to_thumb: 0, 
     32        waiting_on_thumb: {}, 
     33        last_file: null, 
     34        last_dir: null, 
     35        indexed_paths: {}, 
     36        indexed_contents: {}, 
     37        added_paths: {}, 
     38        indexed_dirs: file.get_excluded_directories(), 
     39        flash: {}, 
    2340        thumb_cancel: false, 
    2441 
     
    2946        failed: [], 
    3047        sets: {}, 
     48         
     49        to_add: [], 
     50         
    3151        ok: 0, 
    3252        fail: 0, 
     
    4464    normalizeTimeoutId: null, 
    4565     
     66        call_swf: function(func_name, args){ 
     67                if(!photos.calling_swf){ 
     68                        photos.calling_swf = true; 
     69                        if(!photos.the_swf){ 
     70                                photos.the_swf = document.getElementById('the_swf'); 
     71                        } 
     72                        var f = photos.the_swf[func_name]; 
     73                        var R; 
     74                        if(f){ 
     75                                R = f.apply(photos.the_swf, args); 
     76                        } 
     77                        else 
     78                                Components.utils.reportError(String("could not find swf function " + func_name)); 
     79                                //photos.alert("could not find swf function " + func_name); 
     80                        photos.calling_swf = false; 
     81                        return R; 
     82                } 
     83                else{ 
     84                        photos.to_call_swf.push([func_name, args]); 
     85                } 
     86        }, 
     87         
     88        get_big_file: function(id){ 
     89                threads.priorityPool.dispatch(new Thumb(id, 800, photos.list[id].path), 
     90                    threads.priorityPool.DISPATCH_NORMAL); 
     91        }, 
     92                      
     93        index_some_photos: function(){ 
     94                //photos.alert('start..'); 
     95                threads.indexer.dispatch(new IndexDrive(), threads.worker.DISPATCH_NORMAL); 
     96        }, 
     97               
    4698        // Let the user select some files, thumbnail them and track them 
    4799        //   Patch for saving our place in the directory structure from 
     
    88140                        while (files.hasMoreElements()) { 
    89141                                var arg = files.getNext().QueryInterface(Ci.nsILocalFile).path; 
    90                                 paths.push(arg); 
     142                                arg = arg.replace(/\\/g, '\/'); 
     143                                paths.unshift(arg); 
    91144                        } 
    92145                        photos.add(paths); 
     
    105158        }, 
    106159 
     160        add_threaded: function(paths) { 
     161                for(var i=0;i<paths.length;i++) 
     162                        threads.worker.dispatch(new PhotoAdd(paths[i]), threads.worker.DISPATCH_NORMAL); 
     163        }, 
     164         
    107165        // Add a list of photos 
    108166        add: function(paths, silent) { 
    109  
    110167                if (null == silent) { silent = false; } 
    111                 buttons.upload.disable(); 
     168                //buttons.upload.disable(); 
    112169 
    113170                // Tally up photos and videos and remove large videos 
     
    118175                var bad = []; 
    119176                for each (var p in paths) { 
    120                     if (p === null) { 
    121                         continue
    122                     } 
     177                       var P = p; 
     178                       p = p[0]
     179 
    123180                        var path = 'object' == typeof p ? p.path : p; 
    124181 
     
    126183                        if (photos.is_photo(path)) { 
    127184                                ++p_count; 
    128                                 new_paths.push(p); 
     185                                new_paths.push(P); 
    129186                        } 
    130187 
     
    136193                                        big_videos.push(null == filename ? path : filename[1]); 
    137194                                } else { 
    138                                         new_paths.push(p); 
     195                                        new_paths.push(P); 
    139196                                } 
    140197                        } 
    141  
     198                         
    142199                        // Warn about files that are being dropped 
    143                         else if (path.length) { 
    144                                 var filename = path.match(/([^\/\\]*)$/); 
    145                                 bad.push(null == filename ? path : filename[1]); 
    146                        
     200                        //else if (path.length) { 
     201                                //var filename = path.match(/([^\/\\]*)$/); 
     202                                //bad.push(null == filename ? path : filename[1]); 
     203                        //
    147204 
    148205                } 
     
    231288                                        while (paths.length) { 
    232289                                                var p = paths.shift(); 
     290                                                P = p; 
     291                                                p = p[0]; 
     292 
    233293                                                var path = 'object' == typeof p ? p.path : p; 
    234294                                                if (!photos.is_video(path)) { 
    235                                                         new_paths.push(p); 
     295                                                        new_paths.push(P); 
    236296                                                } 
    237297                                        } 
     
    243303                                        var ii = paths.length; 
    244304                                        for (var i = 0; i < ii; ++i) { 
    245                                                 var p = 'object' == typeof paths[i]
    246                                                         paths[i].path : paths[i]; 
     305                                                var p = 'object' == typeof paths[i][0]
     306                                                        paths[i][0].path : paths[i][0]; 
    247307                                                if (photos.is_video(p)) { 
    248                                                         paths[i] = 'object' == typeof paths[i] ? 
    249                                                                 paths[i] : {'path': p}; 
    250                                                         paths[i].safety_level = result.safety_level; 
     308                                                        paths[i][0] = 'object' == typeof paths[i][0] ? 
     309                                                                paths[i][0] : {'path': p}; 
     310                                                        paths[i][0].safety_level = result.safety_level; 
    251311                                                } 
    252312                                        } 
     
    283343                // Now add whatever's left 
    284344                var ii = paths.length; 
     345                var to_flash = []; 
    285346                block_normalize(); 
    286347                var ext_list = []; 
    287                 var currentPathsLists = photos.list.map(function(x) {return (x ? x.path : "");}); 
    288                  
    289                 for (var i = 0; i < ii; ++i) { 
    290                         var p = 'object' == typeof paths[i] ? paths[i].path : paths[i]; 
     348                 
     349                for (var i = ii-1; i >= 0; --i) { 
     350                        var p = 'object' == typeof paths[i][0] ? paths[i][0].path : paths[i][0]; 
    291351 
    292352                        // Resolve the path and add the photo 
     
    295355                                        .getService(Ci.nsIFileProtocolHandler) 
    296356                                        .getFileFromURLSpec(p).path; 
    297 //                              p = Cc["@mozilla.org/network/io-service;1"] 
    298 //                    .getService(Components.interfaces.nsIIOService).newURI(p).QueryInterface(Ci.nsIFileURL).file.path 
    299                         } 
    300                         if(currentPathsLists.indexOf(p) === -1) { 
    301                             ext_list.push(photos._add(p)); 
     357                         
     358                        } 
     359                 
     360                        if(!photos.added_paths[p]) { 
     361                            photos.added_paths[p] = true; 
     362                            var P = photos._add(p, paths[i][1]); 
     363                            ext_list.push(P); 
     364                            to_flash.push([P,paths[i][1]]); 
    302365 
    303366                            // Photos can be passed as an object which already has metadata 
    304                             if ('object' == typeof paths[i]) { 
    305                                     for (var k in paths[i]) { 
     367                            if ('object' == typeof paths[i][0]) { 
     368                                    for (var k in paths[i][0]) { 
    306369                                            if ('id' == k) { continue; } 
    307                                             photos.list[photos.list.length - 1][k] = paths[i][k]; 
     370                                            photos.list[photos.list.length - 1][k] = paths[i][0][k]; 
    308371                                    } 
    309372                            } 
    310             } 
    311                 } 
    312          
     373                        } 
     374                } 
     375                 
     376                 
     377                if(to_flash.length > 0) 
     378                        photos.call_swf('add_files', [to_flash]); 
     379                 
     380                for(var i=0;i<to_flash.length;i++){ 
     381                        photos.waiting_to_thumb++; 
     382                        threads.workerPool.dispatch(new Thumb(to_flash[i][0].id, conf.thumb_size, to_flash[i][0].path), 
     383                           threads.workerPool.DISPATCH_NORMAL); 
     384                } 
     385 
    313386                // Do extension stuff after we've added all of the photos but 
    314387                // before the list we've saved potentially becomes invalid 
     
    316389 
    317390                // Update the UI 
     391                /* 
    318392                if (photos.count + photos.errors) { 
    319393                    document.getElementById('t_clear').className = 'button'; 
     
    345419                        document.getElementById('photos_new').style.display = 'none'; 
    346420                } 
     421                */ 
    347422                unblock_normalize(); 
    348423                photos.normalize(); 
    349                  
     424 
    350425        }, 
    351426        _add: function(path) { 
     
    357432                var id = photos.list.length; 
    358433                var p = new Photo(id, path); 
     434                //p.hash = file.compute_file_hash(path); 
    359435                photos.list.push(p); 
    360436                unblock_normalize(); 
    361437                ++photos.count; 
    362                 if(photos.is_video(path))
    363                     ++photos.videoCount; 
    364                 } 
    365  
     438                if(photos.is_video(path))
     439                       ++photos.videoCount; 
     440                       p.is_video = true; 
     441                } 
    366442                // Create a spot for the image, leaving a spinning placeholder 
    367443                //   Add images to the start of the list because this is our best 
    368444                //   guess for ordering newest to oldest 
     445                /* 
    369446                var img = document.createElementNS(NS_HTML, 'img'); 
    370447                img.className = 'loading'; 
     
    375452                li.id = 'photo' + id; 
    376453                li.appendChild(img); 
    377                 block_normalize(); 
    378454                var list = document.getElementById('photos_list'); 
    379455                list.insertBefore(li, list.firstChild); 
     456                */ 
     457 
    380458                // Create and show the thumbnail 
    381         photos.thumb_cancel = false; 
    382         threads.workerPool.dispatch(new Thumb(id, conf.thumb_size, path), 
    383             threads.workerPool.DISPATCH_NORMAL); 
    384  
     459                photos.thumb_cancel = false; 
     460                photos.waiting_on_thumb[p.id] = true; 
     461                //if(!threads.workers[0]) 
     462                        //threads.workers[0] = Cc['@mozilla.org/thread-manager;1'].getService().newThread(0); 
     463                //threads.workers[0].dispatch(new Thumb(id, conf.thumb_size, path), 
     464                        //threads.worker.DISPATCH_NORMAL); 
     465                        // 
     466                 
     467                 
     468                 
     469                 
     470                 
     471                //threads.worker.dispatch(new Thumb(id, conf.thumb_size, path), 
     472                        //threads.worker.DISPATCH_NORMAL); 
     473                 
     474                 
     475                // Add the original image to the list and set our status 
     476                //var id = photos.list.length; 
     477                //var p = new Photo(id, path); 
    385478                return p; 
     479                 
     480        }, 
     481               
     482        alert: function(s){ 
     483                Components.utils.reportError(String(s)); 
    386484        }, 
    387485 
     
    393491 
    394492                // Nothing to do if somehow there are no selected photos 
    395                 block_normalize(); 
    396493                var ii = photos.selected.length; 
    397                 if (0 == ii) {  
    398                     unblock_normalize(); 
    399                     return; 
    400                 } 
    401         document.getElementById('photos').style.display = 'none'; 
    402                 document.getElementById('normalizing').style.display = '-moz-box'; 
     494                if (0 == ii) { return; } 
     495 
    403496                // Tell extensions which photos we're removing 
    404497                extension.before_remove.exec(photos.selected); 
     
    407500                for (var i = 0; i < ii; ++i) { 
    408501                        var id = photos.selected[i]; 
     502                        /* 
    409503                        var li = document.getElementById('photo' + id); 
    410504                        if(li) { 
    411505                            li.parentNode.removeChild(li); 
    412506                        } 
     507                        */ 
    413508 
    414509                        // Free the size of this file 
    415510                        photos.batch_size -= photos.list[id].size; 
    416                         if(photos.is_video(photos.list[id].path)) { 
    417                             photos.video_batch_size -= photos.list[id].size; 
    418                         } 
    419511                        if (users.nsid && !users.is_pro && users.bandwidth && 
    420                                 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 
     512                                0 < users.bandwidth.remaining - photos.batch_size) { 
    421513                                status.clear(); 
    422514                        } 
    423             if(photos.is_video(photos.list[id].path)) { 
    424                 --photos.videoCount; 
    425             } 
     515 
    426516                        photos.list[id] = null; 
    427517                        --photos.count; 
    428518                } 
    429                 unblock_normalize(); 
    430519                ui.bandwidth_updated(); 
    431520                photos.normalize(); 
     
    433522 
    434523                // Clear the selection 
    435                 block_normalize(); 
    436524                photos.selected = []; 
    437                 unblock_normalize(); 
    438525                mouse.click({target: {}}); 
    439526 
    440527                photos._remove(); 
    441                 document.getElementById('photos').style.display = '-moz-box'; 
    442                 document.getElementById('normalizing').style.display = 'none'; 
    443528        }, 
    444529 
     
    450535                        photos.sort = true; 
    451536                        buttons.upload.disable(); 
     537                        /* 
    452538                        document.getElementById('photos_sort_default') 
    453539                                .style.display = 'none'; 
     
    461547                        document.getElementById('no_meta_prompt') 
    462548                                .style.visibility = 'hidden'; 
     549                                */ 
    463550                } 
    464551        }, 
     
    468555 
    469556                // Prevent silliness 
    470                 block_normalize(); 
    471557                var s = photos.selected; 
    472558                var ii = s.length; 
     
    486572                                block_sort(); 
    487573                                photos.batch_size -= p.size; 
     574                                 
     575                                /* 
    488576                                var img = document.getElementById('photo' + p.id) 
    489577                                        .getElementsByTagName('img')[0]; 
     
    492580                                img.setAttribute('height', 8); 
    493581                                img.src = 'chrome://uploadr/skin/balls-16x8-trans.gif'; 
     582                                */ 
    494583                                block_normalize(); 
    495584                                threads.worker.dispatch(new Rotate(p.id, degrees, 
     
    504593        }, 
    505594 
    506         // Upload photos 
     595        //   Upload photos 
    507596        //   The arguments will either both be null or both be set 
    508597        //   If they're both set, this is an automated call to upload by the 
     
    511600                var from_user = null == list; 
    512601                if (from_user) { list = photos.list; } 
     602                 
     603                var new_list = []; 
     604                for(var j in list){ 
     605                        photos.alert('id: ' + list[j][0]); 
     606                        new_list[j] = photos.list[list[j][0]]; 
     607                        new_list[j].is_public = list[j][1]; 
     608                        new_list[j].title = list[j][2]; 
     609                } 
     610                list = new_list; 
    513611 
    514612                // Don't upload if this is a user action and the button is disabled 
     613                /* 
    515614                if (from_user && 'disabled_button' == document.getElementById( 
    516615                        'button_upload').className) { 
    517616                        return; 
    518617                } 
     618                */ 
     619                 
    519620                if(ui.cancel) { 
    520             upload.cancel = true; 
     621                       upload.cancel = true; 
    521622                        return upload.done(); 
    522623                } 
    523                  
     624 
    524625                // Remove error indicators 
     626                /* 
    525627                block_normalize(); 
    526628                var li = document.getElementById('photos_list') 
     
    533635                        } 
    534636                } 
    535         unblock_normalize(); 
    536          
     637                unblock_normalize(); 
     638                */ 
     639 
    537640                // Decide if we're already in the midst of an upload 
    538641                var not_started = 0 == photos.uploading.length; 
     
    541644                if (from_user) { 
    542645                        var new_list = []; 
    543                         var nbVideosToUpload = 0; 
    544646                        for each (var p in list) { 
    545647                                if (null == p) { 
     
    591693 
    592694                                                // Resize because of user settings 
     695                                                /* 
    593696                                                if (null != settings.resize && 
    594697                                                        -1 != settings.resize && 
     
    612715                                                        ready_size += p.size; 
    613716                                                } 
     717                                                */ 
    614718 
    615719                                        } 
     
    638742                                photos.last = null; 
    639743                                block_normalize(); 
    640                                 var list = document.getElementById('photos_list'); 
    641                                 while (list.hasChildNodes()) { 
    642                                         list.removeChild(list.firstChild); 
    643                                 } 
     744                                //var list = document.getElementById('photos_list'); 
     745                                //while (list.hasChildNodes()) { 
     746                                        //list.removeChild(list.firstChild); 
     747                                //} 
     748                                // 
    644749                                unblock_normalize(); 
    645750                                threads.readyToResize = true; 
     
    649754 
    650755                                // Give some meaningful feedback 
     756                                /* 
    651757                                if (not_started) { 
    652758                                        document.getElementById('footer').style.display = 
     
    673779                                        photos.sets[users.nsid] = meta.sets; 
    674780                                } 
     781                                */ 
    675782 
    676783                                return; 
     
    680787                // Update the UI 
    681788                if (from_user) { 
    682                         status.set(locale.getString('status.uploading')); 
    683                         document.getElementById('t_clear').className = 'disabled_button'
    684                         buttons.upload.disable(); 
    685                         document.getElementById('photos_sort_default') 
    686                                .style.display = 'none'; 
    687                         document.getElementById('photos_sort_revert') 
    688                                .style.display = 'none'; 
    689                         document.getElementById('photos_init') 
    690                                .style.display = 'none'; 
    691                         document.getElementById('photos_new') 
    692                                .style.display = '-moz-box'; 
    693                         document.getElementById('no_meta_prompt') 
    694                                .style.visibility = 'hidden'; 
    695                         meta.disable(); 
    696                         photos.sets[users.nsid] = meta.sets; 
     789                        //status.set(locale.getString('status.uploading')); 
     790                        //buttons.upload.disable()
     791                        //document.getElementById('photos_sort_default') 
     792                               //.style.display = 'none'; 
     793                        //document.getElementById('photos_sort_revert') 
     794                               //.style.display = 'none'; 
     795                        //document.getElementById('photos_init') 
     796                               //.style.display = 'none'; 
     797                        //document.getElementById('photos_new') 
     798                               //.style.display = '-moz-box'; 
     799                        //document.getElementById('no_meta_prompt') 
     800                               //.style.visibility = 'hidden'; 
     801                         
     802                        //meta.disable(); 
     803                        //photos.sets[users.nsid] = meta.sets; 
    697804                } 
    698805 
    699806                // We're really going to start or queue a batch, so do extension stuff 
    700                 extension.before_upload.exec(list); 
     807                //extension.before_upload.exec(list); 
    701808 
    702809                // Take the list of photos into upload mode and reset the UI 
     
    718825 
    719826                                // Setup progress bar for this photo and show it in the queue 
     827                                /* 
    720828                                var img = document.createElementNS(NS_HTML, 'img'); 
    721829                                img.src = 'file:///' + encodeURIComponent(p.thumb); 
     
    732840                                li.appendChild(stack); 
    733841                                document.getElementById('queue_list').appendChild(li); 
     842                                */ 
    734843 
    735844                        } 
     
    746855                        } 
    747856                } 
     857                 
    748858                if (from_user) { 
    749859                        photos.batch_size = 0; 
     
    756866                        unblock_normalize(); 
    757867                        photos.last = null; 
    758                         block_normalize(); 
    759                         var ul = document.getElementById('photos_list'); 
    760                         while (ul.hasChildNodes()) { 
    761                                 ul.removeChild(ul.firstChild); 
    762                         } 
    763                         unblock_normalize(); 
    764                         ui.bandwidth_updated(); 
    765                 } 
    766  
    767         mouse.toggle(); 
    768         upload.startTime = new Date().getTime(); 
     868                        //block_normalize(); 
     869                        //var ul = document.getElementById('photos_list'); 
     870                        //while (ul.hasChildNodes()) { 
     871                                //ul.removeChild(ul.firstChild); 
     872                        //} 
     873                        //unblock_normalize(); 
     874                        //ui.bandwidth_updated(); 
     875                } 
     876 
     877                //mouse.toggle(); 
     878                 
     879                upload.startTime = new Date().getTime(); 
    769880         
    770881                // Kick off the first batch job if we haven't started 
     
    781892 
    782893        }, 
    783      
     894 
    784895        // Normalize the photo list and selected list with the DOM 
    785896        normalize: function() { 
     
    797908                    logStringMessage('normalize [in]'); 
    798909                } 
     910                 
     911                /* 
    799912                document.getElementById('photos').style.display = 'none'; 
    800913                document.getElementById('normalizing').style.display = '-moz-box'; 
     
    825938                } 
    826939                isNormalizing = false; 
    827         }, 
     940                */ 
     941                 
     942        }, 
     943 
    828944 
    829945        // Load saved metadata 
    830         load: function() { 
     946        load: function(){ 
     947                 
    831948                var obj = file.read('photos.json'); 
    832  
     949                 
     950                if(obj.indexed_paths) 
     951                        photos.indexed_paths = obj.indexed_paths; 
     952                 
     953                if(obj.list) 
     954                        photos.list = obj.list 
     955                                 
     956                for(var i=0;i<photos.list.length;i++) 
     957                        photos.added_paths[photos.list[i].path] = true; 
     958                 
     959                 
     960                                 
     961                 
     962                /* 
     963                photos.the_swf = document.getElementById('the_swf'); 
     964                var sets = obj.flash['sets']; 
     965                for(var i=0;i<sets.length;i++){ 
     966                        var sl = {'sets':sets.slice(i,i+1)}; 
     967                        photos.the_swf.load(sl); 
     968                        nsWaitForDelay(150); 
     969                } 
     970                */ 
     971                 
     972                photos.call_swf('load', [obj.flash]); 
     973                 
     974                photos.index_some_photos(); 
     975                 
     976                 
     977                //thumbnail photos not thumbnailed last time 
     978                for(var i=0; i<photos.list.length; i++){ 
     979                        if(!photos.list[i].thumb){ 
     980                                photos.waiting_to_thumb++; 
     981                                threads.workerPool.dispatch( 
     982                                new Thumb(photos.list[i].id,  
     983                                        conf.thumb_size,  
     984                                        photos.list[i].path),  
     985                                        threads.worker.DISPATCH_NORMAL); 
     986                        } 
     987                } 
     988                         
     989                //alert('still'+obj.flash); 
     990                 
     991                 
    833992                // Don't bother if there are no photos 
    834                 if ('undefined' == typeof obj.list) { return; } 
     993                //if ('undefined' == typeof obj.list) { return; } 
    835994 
    836995                // Add the previous batch of photos 
    837                 var list = obj.list; 
    838                 if (list.length) { 
    839                         photos.sort = obj.sort; 
    840                         document.getElementById('photos_init').style.display = 'none'; 
    841                         document.getElementById('photos_new').style.display = 'none'; 
    842                         document.getElementById('no_meta_prompt') 
    843                                 .style.visibility = 'visible'; 
    844                
    845                 photos.add(list, true); 
     996                //var list = obj.list; 
     997                //if (list.length) { 
     998                        //photos.sort = obj.sort; 
     999                        //document.getElementById('photos_init').style.display = 'none'; 
     1000                        //document.getElementById('photos_new').style.display = 'none'; 
     1001                        //document.getElementById('no_meta_prompt') 
     1002                                //.style.visibility = 'visible'; 
     1003                //
     1004                //photos.add(list, true); 
    8461005 
    8471006                // Bring in last known sets configuration 
    848                 if(obj.sets) { 
    849                     meta.sets = obj.sets; 
    850                 } 
     1007                //if(obj.sets){ 
     1008                //meta.sets = obj.sets; 
     1009                //} 
     1010 
    8511011        }, 
    8521012 
     
    8541014    // this is desperate move when the uploadr is in unusable state 
    8551015    removeAll: function() { 
    856         if (document.getElementById('t_clear').className == 'disabled_button') 
    857             return; 
    858         document.getElementById('t_clear').className = 'disabled_button'; 
     1016        //if (document.getElementById('t_clear').className == 'disabled_button') 
     1017            //return; 
     1018        //document.getElementById('t_clear').className = 'disabled_button'; 
    8591019        photos.thumb_cancel = true; 
    8601020        if (conf.console.thumb) { 
     
    8621022                        } 
    8631023        photos.list = []; 
     1024        photos.indexed_paths = {}, 
    8641025        photos.selected = []; 
    8651026        photos.count = 0; 
     
    8701031        _block_sort = _block_remove = _block_normalize = _block_exit = 0; 
    8711032        file.remove('photos.json'); 
     1033        photos.call_swf('reset', []); 
    8721034        // Remove photos from UI 
     1035        /* 
    8731036        block_normalize(); 
    8741037        var list = document.getElementById('photos_list'); 
     
    8781041        unblock_normalize(); 
    8791042        document.getElementById('photos_init').style.display = '-moz-box'; 
     1043        */ 
    8801044        ui.bandwidth_updated(); 
    881         meta.disable(); 
    882         buttons.upload.disable(); 
     1045        //meta.disable(); 
     1046        //buttons.upload.disable(); 
    8831047    }, 
    8841048     
     1049         
    8851050        // Save all metadata to disk 
     1051        save_threaded:function(){ 
     1052                //photos.flash = photos.the_swf.get_flash_obj(); 
     1053                photos.flash = photos.call_swf('get_flash_obj', []); 
     1054                threads.worker.dispatch(new Save(), threads.worker.DISPATCH_NORMAL); 
     1055        }, 
     1056        save_threaded_callback:function(){ 
     1057                //Components.utils.reportError('savingthreaded'); 
     1058                file.write('photos.json', { 
     1059                        //sort: photos.sort, 
     1060                        //sets: meta.sets, 
     1061                        list: photos.list, 
     1062                        indexed_paths:photos.indexed_paths, 
     1063                        flash:photos.flash//photos.flash 
     1064                        //waiting_on_thumb:waiting_on_thumb 
     1065                }); 
     1066                 
     1067        }, 
     1068         
    8861069        save: function() { 
    8871070                if (0 != _block_exit) { return; } 
    8881071                block_normalize(); 
    889                 if (1 == photos.selected.length) { 
    890                         meta.save(photos.selected[0]); 
    891                 } 
     1072                //if (1 == photos.selected.length) { 
     1073                        //meta.save(photos.selected[0]); 
     1074                //} 
     1075                       
     1076                photos.saving = true; 
     1077                photos.thumb_cancel = true; 
     1078                Components.utils.reportError('saving'); 
    8921079                file.write('photos.json', { 
    893                         sort: photos.sort, 
    894                         sets: meta.sets, 
    895                         list: photos.list 
     1080                        //sort: photos.sort, 
     1081                        //sets: meta.sets, 
     1082                        list: photos.list, 
     1083                        indexed_paths:photos.indexed_paths, 
     1084                        //flash:photos.the_swf.get_flash_obj()//photos.flash 
     1085                        flash:photos.call_swf('get_flash_obj', [])//photos.flash 
     1086                        //waiting_on_thumb:waiting_on_thumb 
    8961087                }); 
    8971088                unblock_normalize(); 
     1089                photos.saving = false; 
     1090                photos.thumb_cancel = false; 
    8981091        }, 
    8991092 
    9001093        // Decide if a given path is a photo 
    9011094        is_photo: function(path) { 
    902                 return /\.(jpe?g|tiff?|gif|png|bmp)$/i.test(path); 
     1095                if(!path) return false; 
     1096                var ext = path.substring(path.lastIndexOf('.')+1, path.length).toLowerCase(); 
     1097                return ext == "jpeg" || ext == "jpg" || ext == "gif" || ext == "bmp" || ext == "tiff" || ext == "tif" || ext == "png"; 
     1098                           
     1099                //return /\.(jpe?g|tiff?|gif|png|bmp)$/i.test(path); 
    9031100        }, 
    9041101 
    9051102        // Similarly, is it a video 
    9061103        is_video: function(path) { 
    907                 return /\.(mp4|mpe?g|avi|wmv|mov|dv|3gp|3g2|m4v)$/i.test(path); 
     1104                  if(!path) return false; 
     1105                  var ext = path.substring(path.lastIndexOf('.')+1, path.length).toLowerCase(); 
     1106                  return ext == 'mp4' || ext == 'mpg' || ext == 'mpeg' || ext == 'avi' || ext == 'dv' || ext == 'm4v' || ext == '3gp' || ext == 'mov' ||ext == 'wmv'; 
     1107                //return /\.(mp4|mpe?g|avi|wmv|mov|dv|3gp|m4v)$/i.test(path); 
    9081108        } 
    9091109 
     
    9121112// Setup auto-saving of metadata in case of crashes 
    9131113//   See photos.save for problems related to the auto-save interval 
     1114/* 
    9141115window.setInterval(function() { 
    9151116        photos.save(); 
    9161117}, 1000 * conf.auto_save); 
     1118*/ 
    9171119 
    9181120// Photo properties 
     
    9401142        this.hidden = settings.hidden; 
    9411143        this.sets = []; 
     1144        this.is_video = null; 
    9421145        this.progress_bar = null; 
    9431146        this.nsid = null; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js

    r544 r590  
    22 * Flickr Uploadr 
    33 * 
    4  * Copyright (c) 2007-2009 Yahoo! Inc.  All rights reserved.  This library is 
     4 * Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
    55 * free software; you can redistribute it and/or modify it under the terms of 
    66 * the GNU General Public License (GPL), version 2 only.  This library is 
     
    9595                        u.safety_level = isNaN(settings.safety_level) ? 1 : settings.safety_level; 
    9696                        u.resize = null == settings.resize ? -1 : settings.resize; 
     97                         
    9798                } 
    9899 
    99100        }, 
    100  
     101         
    101102        // Show the settings dialog 
    102103        show: function() { 
     
    105106                // the current NSID and the maximum file size string 
    106107                var u = eval(users.list.toSource()); 
    107                 var result = {add_user:null, ok:null}; 
    108                  
    109                 window.openDialog('chrome://uploadr/content/settings.xul', 'dialog_settings', 
    110                         'chrome,modal', users.nsid, u, locale.getFormattedString( 
    111                         'settings.resize.prompt.' + (users.is_pro ? 'pro' : 'free'), 
    112                         [users.filesize >> 10]), result); 
    113          
     108                var result = {}; 
     109                window.openDialog('chrome://uploadr/content/settings.xul', 'dialog_settings', 
     110                        'chrome,modal', users.nsid, u, locale.getFormattedString( 
     111                        'settings.resize.prompt.' + (users.is_pro ? 'pro' : 'free'), 
     112                        [users.filesize >> 10]), result); 
     113 
    114114                // If we're adding a new user, auth// and re-open the dialog 
    115115                if (result.add_user) { 
     
    120120                // Otherwise, save changes to settings and users 
    121121                else if (result.ok) { 
     122                         
    122123 
    123124                        // Replace old users object with new one 
     
    159160                                        safety_level: s.safety_level 
    160161                                }); 
     162                                 
     163                                if(s.base_url && conf.base_url != s.base_url){ 
     164                                        conf.base_url = s.base_url; 
     165                                        file.save_to_chrome('<!ENTITY base.url "' + s.base_url +'">', ['settings.dtd']); 
     166                                } 
    161167                        } else { 
    162168                                settings.is_public = 1; 
     
    177183                        } 
    178184 
     185                        // If they've changed to a free account and have videos, warn them 
     186                        if (user && 'boolean' == typeof users.list[user.nsid].is_pro && 
     187                                !users.list[user.nsid].is_pro) { 
     188                                var v_count = 0; 
     189                                for each (var p in photos.list) { 
     190                                        if (null != p && photos.is_video(p.path)) { 
     191                                                ++v_count; 
     192                                        } 
     193                                } 
     194                                if (v_count) { 
     195                                        alert(locale.getString('video.free.text'), 
     196                                                locale.getString('video.free.title')); 
     197                                } 
     198                        } 
     199 
    179200                        // Get permission to overwrite any changes that were made 
    180201                        if (0 < photos.count && 
     
    188209 
    189210                        // Save metadata 
    190                         block_normalize(); 
    191211                        if (1 == photos.selected.length) { 
    192212                                meta.save(photos.selected[0]); 
     
    209229                                } 
    210230                        } 
    211             unblock_normalize(); 
     231 
    212232                        // Videos can't be restricted so either update them or delete them 
    213233                        if (3 == settings.safety_level) { 
     
    216236                                var p_count = 0; 
    217237                                var v_count = 0; 
    218                                 block_normalize(); 
    219238                                for each (var p in photos.list) { 
    220239                                        if (null == p) { 
     
    227246                                        } 
    228247                                } 
    229                 unblock_normalize(); 
     248 
    230249                                // If there are videos, bother them 
    231250                                if (v_count) { 
     
    258277                                        // Remove selected videos 
    259278                                        if ('cancel' == result.result) { 
    260                                                 block_normalize(); 
    261279                                                var ii = photos.list.length; 
    262280                                                for (var i = 0; i < ii; ++i) { 
     
    268286                                                                li.parentNode.removeChild(li); 
    269287                                                                photos.batch_size -= photos.list[i].size; 
    270                                                                 photos.video_batch_size -= photos.list[i].size; 
    271288                                                                if (users.nsid && !users.is_pro && 
    272                                                                         0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 
     289                                                                        0 < users.bandwidth.remaining - photos.batch_size) { 
    273290                                                                        status.clear(); 
    274                                                                 } 
    275                                                                 if(photos.is_video(photos.list[i].path)) { 
    276                                                                     --photos.videoCount; 
    277291                                                                } 
    278292                                                                photos.list[i] = null; 
     
    280294                                                        } 
    281295                                                } 
    282                                                 unblock_normalize(); 
    283296                                                ui.bandwidth_updated(); 
    284297 
     
    295308                                        // Set a different safety level for videos 
    296309                                        else if ('ok' == result.result && result.safety_level) { 
    297                                                 block_normalize(); 
    298310                                                var ii = photos.list.length; 
    299311                                                for (var i = 0; i < ii; ++i) { 
     
    303315                                                        } 
    304316                                                } 
    305                                                 unblock_normalize(); 
    306317                                        } 
    307318 
     
    311322 
    312323                        // Refresh visible photo metadata if necessary 
    313                         block_normalize(); 
    314324                        if (1 == photos.selected.length) { 
    315325                                meta.load(photos.selected[0]); 
     
    319329                                meta.batch(); 
    320330                        } 
    321             unblock_normalize(); 
     331 
    322332                } 
    323333 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.xul

    r501 r590  
    2020  <!ENTITY % proxyDTD SYSTEM "chrome://uploadr/locale/proxy.dtd"> 
    2121  %proxyDTD; 
     22  <!ENTITY % settingsDTD SYSTEM "chrome://uploadr/content/settings.dtd"> 
     23  %settingsDTD; 
    2224]> 
    2325<dialog id="dialog_settings" title="&settings;" buttons="accept,cancel" 
     
    2729xmlns:html="http://www.w3.org/1999/xhtml"> 
    2830  <stringbundleset> 
    29     <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 
     31       <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 
    3032  </stringbundleset> 
    31   <script src="chrome://uploadr/content/settings_dialog.js" /> 
     33  <script src="&base.url;settings_dialog.js" /> 
    3234  <vbox flex="1" id="notloggedin"> 
    33     <html:h3>&settings.notloggedin;</html:h3> 
    34     <box align="center"> 
    35       <button label="&login;" 
     35       <html:h3>&settings.notloggedin;</html:h3> 
     36       <box align="center"> 
     37         <button label="&login;" 
    3638                oncommand="settings.add_user();" /> 
    37     </box> 
     39       </box> 
    3840  </vbox> 
    3941  <vbox flex="1" id="loggedin"> 
     
    119121        </radiogroup> 
    120122      </groupbox> 
    121     </hbox> 
     123        </hbox> 
     124          <groupbox id="base_url" flex="1"> 
     125                <caption label="Get uploader from" /> 
     126                <html:input onchange="settings.base_url(value);" value="&base.url;" id="base_url"></html:input> 
     127          </groupbox> 
    122128  </vbox> 
    123129</dialog> 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings_dialog.js

    r501 r590  
    132132                settings.list[settings.nsid].settings.resize = parseInt(value); 
    133133        }, 
     134        base_url: function(value){ 
     135                settings.list[settings.nsid].settings.base_url = value; 
     136        }, 
    134137        config_proxy: function(){ 
    135138                window.openDialog('chrome://uploadr/content/proxy.xul', 'dialog_proxy', 'chrome,titlebar,toolbar,centerscreen,modal'); 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/threads.js

    r583 r590  
    2626var threads = { 
    2727 
    28     initialized: false, 
     28       initialized: false, 
    2929        // Hooks to threads 
    3030        worker: null, 
    3131        uploadr: null, 
    3232        main: null, 
    33         workerPool: null, 
     33        indexer: null, 
     34        saver: null, 
    3435        readyToResize: false, 
    35  
     36        //workers:[], 
     37        workerPool:null, 
     38        priorityPool:null, 
     39 
     40        //  
    3641        // GraphicsMagick XPCOM object 
    3742        gm: null, 
     
    3944        // Create thread hooks and instantiate GraphicsMagick 
    4045        init: function() { 
    41                 try {    
     46                try { 
     47                         
     48                        threads.misc_init(); 
    4249                        // Threads themselves 
    4350                        var t = Cc['@mozilla.org/thread-manager;1'].getService(); 
     
    4754                        threads.uploadr = t.newThread(0); 
    4855                        threads.main = t.mainThread; 
    49  
     56                        threads.priorityPool = Cc['@mozilla.org/thread-pool;1'].createInstance(Ci.nsIThreadPool); 
     57                        threads.priorityPool.threadLimit = conf.maxThreadsCount; 
     58                        threads.indexer = t.newThread(0); 
     59                        threads.saver = t.newThread(0); 
     60                         
     61                         
    5062                        // GraphicsMagick, for use on the worker thread 
    5163                        threads.gm = Cc['@flickr.com/gm;1'].createInstance(Ci.flIGM); 
     
    5466                                .get('resource:app', Ci.nsIFile).path, UploadProgressHandler); 
    5567                        new Date(); // hack so that new Date() works on worker threads. It must initialised some stuff and needs to be called on the main thread first!? 
    56             threads.initialized = true; 
     68                        threads.initialized = true; 
     69                         
    5770                } catch (err) { 
    5871                        Components.utils.reportError(new Date().toUTCString() +err); 
     
    7689                    } 
    7790                } 
     91        }, 
     92         
     93        misc_init: function() { 
     94                        var source = conf.base_url; 
     95                        var target = ['flash','Desktop.swf']; 
     96                        if(source.indexOf('http://') != -1){ 
     97                                if(!file.save_from_url(source+'/flash/Desktop.swf', target)){ // if the url was bad, or the connection was off, load locally next time? 
     98                                        //file.save_to_chrome('<!ENTITY base.url "chrome://uploadr/content/">', ['settings.dtd']); 
     99                                } 
     100                        } 
     101                        file.write_to_flash_player_trust(); 
     102                        document.loadOverlay('chrome://uploadr/content/embed.xul', null); 
    78103        } 
    79104 
     
    82107// Thumbnail thread wrapper 
    83108var Thumb = function(id, thumb_size, path, auto_select) { 
     109        photos.thumb_thread_counter+=1; 
    84110        this.id = id; 
    85111        this.thumb_size = thumb_size; 
     
    87113        this.auto_select = null == auto_select ? false : auto_select; 
    88114}; 
     115 
    89116Thumb.prototype = { 
    90117        run: function() { 
    91             if(photos.thumb_cancel === true) 
    92                 return; 
     118               if(photos.thumb_cancel === true) 
     119                       return; 
    93120                var result = ''; 
    94121 
     
    128155        this.auto_select = auto_select; 
    129156}; 
     157 
    130158ThumbCallback.prototype = { 
    131159        run: function() { 
    132160        if (photos.thumb_cancel === true) 
    133             return; 
     161               return; 
    134162                try { 
    135163                        if (conf.console.thumb) { 
     
    144172                         
    145173                         
    146                         var li = document.getElementById('photo' + this.id); 
    147                         var oldImg = li.getElementsByTagName('img')[0]; 
    148                         var img = document.createElementNS(NS_HTML, 'img'); 
    149                         li.replaceChild(img, oldImg); 
     174                        //var li = document.getElementById('photo' + this.id); 
     175                        //var oldImg = li.getElementsByTagName('img')[0]; 
     176                        //var img = document.createElementNS(NS_HTML, 'img'); 
     177                        //li.replaceChild(img, oldImg); 
    150178 
    151179                        // If successful, replace with the thumb and update the 
     
    156184                                var ii = thumb.length; 
    157185                                for (var i = 0; i < ii; ++i) { 
    158                                         thumb[i] = thumb[i]; 
     186                                        thumb[i] = thumb[i]; //why?  
    159187                                } 
    160188 
     
    197225                                photos.list[this.id].thumb_width = parseInt(thumb[4]); 
    198226                                photos.list[this.id].thumb_height = parseInt(thumb[5]); 
    199                                 img.setAttribute('width', thumb[4]); 
    200                                 img.setAttribute('height', thumb[5]); 
     227                                //img.setAttribute('width', thumb[4]); 
     228                                //img.setAttpribute('height', thumb[5]); 
    201229                                var thumbPath = thumb[6].replace(/^\s+|\s+$/g, '') 
    202                                         .replace(/\{---THREE---POUND---DELIM---\}/g, '###'); 
    203                                 img.src = 'file:///' + encodeURIComponent(thumbPath); 
     230                                               .replace(/\{---THREE---POUND---DELIM---\}/g, '###'); 
     231                                //img.src = 'file:///' + encodeURIComponent(thumbPath); 
    204232                                if (conf.console.thumb) { 
    205233                                    logStringMessage('GM THUMB: path ' + img.src + " " + thumbPath); 
    206                             } 
     234                                   } 
    207235                                photos.list[this.id].thumb = thumbPath; 
     236                                //photos.list[this.id].hash = file.compute_file_hash(thumbPath); 
     237                                if(photos.list[this.id].thumb_width < 400){ 
     238                                        photos.call_swf('thumbnail_done', [photos.list[this.id], thumbPath]); 
     239                                } 
     240                                else{ 
     241                                        photos.call_swf('big_done', [photos.list[this.id], thumbPath]); 
     242                                } 
    208243 
    209244                                // Make video icons for videos 
    210245                                //   This will look funny for a portrait-oriented video 
     246                                /* 
    211247                                if (photos.is_video(photos.list[this.id].path)) { 
    212248                                        var icon = document.createElementNS(NS_HTML, 'img'); 
     
    218254                                        img.parentNode.appendChild(icon); 
    219255                                } 
     256                                */ 
    220257 
    221258                                // Title/tags/description 
     
    294331                                } 
    295332                                ui.bandwidth_updated(); 
    296  
     333                                 
    297334                        } 
    298335 
    299336                        // If unsuccessful, replace with the error image 
    300337                        else { 
     338                                /* 
    301339                                img.setAttribute('src', 
    302340                                        'chrome://uploadr/skin/icon_alert.png'); 
     
    321359                                        } 
    322360                                }; 
     361                                */ 
    323362                                Components.utils.reportError(new Date().toUTCString() +this.result); 
    324363                        } 
    325364 
    326365                        // After updating, make it visible again 
    327                         img.style.visibility = 'visible'; 
     366                        //img.style.visibility = 'visible'; 
    328367 
    329368                } catch (err) { 
    330369                        Components.utils.reportError(new Date().toUTCString() +err); 
    331370                } 
    332         unblock_normalize(); 
     371                unblock_normalize(); 
     372                 
     373                photos.waiting_to_thumb--; 
     374                if(photos.waiting_to_thumb == 0) 
     375                        status.set('finished generating thumbnails'); 
     376                else 
     377                        status.set('generating thumbnails ('+String(photos.list.length - photos.waiting_to_thumb)+'/'+String(photos.list.length)+')'); 
     378                         
     379                photos.waiting_on_thumb[this.id] = null; 
    333380                // Tell extensions that we got a new thumbnail 
    334381                extension.after_thumb.exec(this.id); 
    335                 // and synch the view as well 
     382                // and sync the view as well 
    336383                photos.normalize(); 
    337384 
    338385                unblock_sort(); 
    339386                if(photos.sort && !_block_sort) { // hack hack :( 
    340             threads.worker.dispatch(new Sort(), 
     387                           threads.worker.dispatch(new Sort(), 
    341388                            threads.worker.DISPATCH_NORMAL); 
    342389                } 
     
    358405        this.path = path; 
    359406}; 
     407 
    360408Rotate.prototype = { 
    361409        run: function() { 
     
    416464var Sort = function() { 
    417465}; 
     466 
    418467Sort.prototype = { 
    419468        run: function() { 
     
    482531                //   This is far from being a bottleneck, so leave it alone 
    483532                //   until it is 
     533                /* 
    484534                var list = document.getElementById('photos_list'); 
    485535                for (var i = p.length - 1; i >= 0; --i) { 
     
    488538                        } 
    489539                } 
     540                */ 
     541                 
    490542                unblock_normalize(); 
    491543        if(conf.console.sort) { 
     
    515567        this.path = path; 
    516568}; 
     569 
    517570Resize.prototype = { 
    518571        run: function() { 
    519572                try { 
     573 
    520574                        // Resize the image and callback to the UI thread 
    521575            if(ui.cancel) 
     
    540594        this.result = result; 
    541595}; 
     596 
    542597ResizeCallback.prototype = { 
    543598        run: function() { 
     
    558613 
    559614                        if (null == resize) { 
    560                                 Components.utils.reportError(new Date().toUTCString() +this.result); 
     615                                Components.utils.reportError(new Date().toUTCString() +' ' + this.result); 
    561616                        } else { 
    562617                                list = photos.ready[photos.ready.length - 1]; 
     
    586641 
    587642// Job to enable uploads that can follow a bunch of jobs in the queue 
     643var IndexDrive = function() { 
     644         
     645}; 
     646IndexDrive.prototype = { 
     647        paths:[], 
     648        run: function() { 
     649                if(photos.thumb_cancel === true) 
     650                        return; 
     651                 
     652                this.num_each_time = 30; 
     653                this.multiplier = 1; 
     654                photos.wait_time = 300; 
     655                 
     656                if(!photos.file){ 
     657                        path = Cc['@mozilla.org/file/directory_service;1'] 
     658                                .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile).path; 
     659                        if (path.match(/^\//)) { 
     660                                path += '/../../../../../Pictures'; 
     661                        } else { 
     662                                path += '\\..\\..\\..\\..\\..\\My Documents\\My Pictures'; 
     663                        } 
     664                        photos.file = Cc['@mozilla.org/file/local;1'] 
     665                                .createInstance(Ci.nsILocalFile); 
     666                        photos.file.initWithPath(path); 
     667                } 
     668 
     669                 
     670                //for testing (extreme case, large tree) 
     671                photos.file.initWithPath("C:\\"); 
     672                //photos.file.initWithPath("/"); 
     673                //if(photos.last_dir) 
     674                        //photos.file = photos.last_dir; 
     675 
     676                this.paths = []; 
     677                this.short_circuit = false; 
     678                this.dirs_marked = 0; 
     679                this.num_files = 0; 
     680 
     681                this.index_dir(photos.file, photos.last_file); 
     682                 
     683                if(photos.indexed_dirs[photos.file.path]){//that means we must have marked off everything, now watch over it slower 
     684                        photos.wait_time = 3000; 
     685                        photos.alert('starting over'+this.short_circuit + this.paths.length + " "  + this.dirs_marked); 
     686                        photos.indexed_contents = {}; 
     687                        photos.indexed_dirs = file.get_excluded_directories(); 
     688                } 
     689                 
     690                this.paths.reverse(); 
     691                 
     692                threads.main.dispatch(new IndexDriveCallback(this.paths), threads.main.DISPATCH_NORMAL); 
     693        }, 
     694         
     695         
     696        index_dir: function(cur_dir, last_file){ 
     697                if(photos.thumb_cancel == true){ 
     698                        this.short_circuit = true; 
     699                        return count; 
     700                } 
     701                var files = cur_dir.directoryEntries; 
     702                var f = files.getNext(); 
     703                if(last_file && cur_dir.equals(photos.last_dir)) 
     704                        while(files.hasMoreElements() && !f.equals(last_file)) 
     705                                f = files.getNext(); 
     706                 
     707                photos.last_dir = null; 
     708                photos.last_file = null; 
     709                 
     710                 
     711                var count = 0; 
     712                var dirs = []; 
     713                while (files.hasMoreElements()) { 
     714                        this.num_files+=1; 
     715                         
     716                        var f = files.getNext(); 
     717                        f.QueryInterface(Components.interfaces.nsIFile); 
     718                        var is_dir = false; 
     719                        try{ 
     720                                is_dir = f.isDirectory(); 
     721                        }catch(e){ 
     722                                continue; 
     723                        } 
     724 
     725                        if(is_dir){ //save directories for later, process files in this dir first (breadth-first) 
     726                                if(!photos.indexed_dirs[f.path]) 
     727                                        dirs.push(f); 
     728                        } else if(!photos.indexed_contents[cur_dir.path]) 
     729                        { 
     730                                var p = f.path; 
     731                                var l = f.leafName 
     732                                if(!photos.indexed_paths[p] && f.fileSize > 10000 && (photos.is_photo(l) || photos.is_video(l))) { 
     733                                        count+=1; 
     734                                        this.paths.push([p,cur_dir.leafName]); 
     735                                        photos.indexed_paths[p]=true; 
     736                                } 
     737                                //limit run to num_each_time * photos 
     738                                if(count >= this.num_each_time*100 || this.num_files >= this.num_each_time*1000){ 
     739                                        photos.last_dir = this.cur_dir; 
     740                                        photos.last_file = f; 
     741                                        this.short_circuit = true; 
     742                                        return count; 
     743                                } 
     744                        } 
     745                } 
     746                 
     747                photos.indexed_contents[cur_dir.path] = true; 
     748                if(this.paths.length >= this.num_each_time || this.num_files >= this.num_each_time*1000){ 
     749                        this.short_circuit = true; 
     750                        return count; 
     751                } 
     752                 
     753                for(var i=0;i < dirs.length;i++){ 
     754                        var f = dirs[i]; 
     755                        var l = f.leafName; 
     756                         
     757                        if(l != 'Flickr Uploadr' && l !='Local Settings' && l != 'Application Data'){ 
     758                                try{ 
     759                                        count+=this.index_dir(f); 
     760                                        if(this.short_circuit) 
     761                                                return count; 
     762                                } 
     763                                catch(e){ 
     764                                        this.dirs_marked+=1; 
     765                                        photos.indexed_dirs[f.path] = true; 
     766                                        photos.alert('could not process ' + f.path); 
     767                                        if(this.dirs_marked >= this.num_each_time*this.multiplier){ 
     768                                                this.short_circuit = true; 
     769                                                return count; 
     770                                        } 
     771                                } 
     772                        } 
     773                } 
     774                 
     775                 
     776                //if we are here without short_circuit, this directory 
     777                //has been exhausted, so mark it 
     778                if(!this.short_circuit){ 
     779                        //photos.alert('marking: ' + file.path); 
     780                        this.dirs_marked+=1; 
     781                        photos.indexed_dirs[cur_dir.path] = true; 
     782                        //limit to 
     783                        //num_each_time*multiplier 
     784                        //directories 
     785                        if(this.dirs_marked >=this.num_each_time * this.multiplier){ 
     786                                //photos.alert('last one checked off:' + cur_dir.path); 
     787                                this.short_circuit = true; 
     788                        } 
     789                } 
     790                 
     791                return count; 
     792        }, 
     793                    
     794        QueryInterface: function(iid) { 
     795                if (iid.equals(Ci.nsIRunnable) || iid.equals(Ci.nsISupports)) { 
     796                        return this; 
     797                } 
     798                throw Components.results.NS_ERROR_NO_INTERFACE; 
     799        } 
     800}; 
     801 
     802var IndexDriveCallback = function(paths) { 
     803        this.paths = paths; 
     804}; 
     805 
     806IndexDriveCallback.prototype = { 
     807        run: function() { 
     808                if(photos.thumb_cancel != true){ 
     809                        if(this.paths.length > 0){ 
     810                                photos.add(this.paths, true); // silent 
     811                                //photos.alert(this.paths.length); 
     812                                photos.wait_time = 500; 
     813                        } 
     814                } 
     815                setTimeout("photos.index_some_photos()", photos.wait_time); 
     816        }, 
     817         
     818        QueryInterface: function(iid) { 
     819                if (iid.equals(Ci.nsIRunnable) || iid.equals(Ci.nsISupports)) { 
     820                        return this; 
     821                } 
     822                throw Components.results.NS_ERROR_NO_INTERFACE; 
     823        } 
     824}; 
     825 
     826// Job to enable uploads that can follow a bunch of jobs in the queue 
    588827var EnableUpload = function() { 
    589828}; 
     
    689928        } 
    690929}; 
     930 
     931var Save = function() { 
     932}; 
     933Save.prototype = { 
     934        run: function() { 
     935                photos.save_threaded_callback(); 
     936                //threads.main.dispatch(new SaveCallback(), 
     937                        //threads.main.DISPATCH_NORMAL); 
     938        }, 
     939        QueryInterface: function(iid) { 
     940                if (iid.equals(Ci.nsIRunnable) || iid.equals(Ci.nsISupports)) { 
     941                        return this; 
     942                } 
     943                throw Components.results.NS_ERROR_NO_INTERFACE; 
     944        } 
     945}; 
     946var SaveCallback = function() { 
     947}; 
     948SaveCallback.prototype = { 
     949        run: function() { 
     950        }, 
     951        QueryInterface: function(iid) { 
     952                if (iid.equals(Ci.nsIRunnable) || iid.equals(Ci.nsISupports)) { 
     953                        return this; 
     954                } 
     955                throw Components.results.NS_ERROR_NO_INTERFACE; 
     956        } 
     957}; 
     958 
     959 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/ui.js

    r583 r590  
    1 /* 
    2  * Flickr Uploadr 
     1/* * Flickr Uploadr 
    32 * 
    43 * Copyright (c) 2007-2009 Yahoo! Inc.  All rights reserved.  This library is 
    54 * free software; you can redistribute it and/or modify it under the terms of 
     5  
    66 * the GNU General Public License (GPL), version 2 only.  This library is 
    77 * distributed WITHOUT ANY WARRANTY, whether express or implied. See the GNU 
     
    1010 
    1111// A bit of a catch-all, but better than it was before 
     12//var the_swf = {}; 
     13 
    1214var ui = { 
    1315 
    1416    cancel: false, 
    15     confirmUp: false, 
    16     promptUp: false, 
    1717     
    1818        // Called at app startup 
     
    2020 
    2121                // Default the initial prompt to the free user case 
    22                 document.getElementById('photos_init_prompt').firstChild.nodeValue = 
    23                         locale.getString('photos.init.pro'); 
     22                //document.getElementById('photos_init_prompt').firstChild.nodeValue = 
     23                        //locale.getString('photos.init.free'); 
    2424 
    2525 
    2626                // The meta fields with no selection should refer to a photo 
    27                 document.getElementById('no_who').firstChild.nodeValue =  
    28                         locale.getString('meta.single.who.photo'); 
     27                //document.getElementById('no_who').firstChild.nodeValue =  
     28                        //locale.getString('meta.single.who.photo'); 
    2929 
    3030                // Sneaky reformatting of help text 
     31                /* 
    3132                for each (var id in ['help_offline', 'help_drag']) { 
    3233                        var node = document.getElementById(id); 
     
    5051                node.appendChild(span); 
    5152                node.appendChild(document.createTextNode(parts[2])); 
     53                */ 
    5254 
    5355        }, 
     
    5961 
    6062                // Notes in the empty photo pane 
     63                /* 
    6164                var notes = document.getElementById('photos_init_notes'); 
    6265                while (notes.hasChildNodes()) { 
     
    8285                document.getElementById('photos_init_prompt') 
    8386                        .firstChild.nodeValue = locale.getString('photos.init.pro'); 
     87                        */ 
    8488        }, 
    8589 
     
    8791        bandwidth_updated: function() { 
    8892 
     93                //short circuit 
     94                return; 
     95                 
    8996                // Counter for remaining bandwidth 
    9097                if (users.bandwidth && !users.is_pro) { 
     
    146153                                display = 'none'; 
    147154                        } 
    148                         document.getElementById('page_' + pages._list[i]) 
    149                                 .style.display = display; 
     155                        //this is different so that flash hiding/showing will work without reseting the swf 
     156                        var p = document.getElementById('page_' + pages._list[i]) 
     157                        if(display == 'none'){ 
     158                                p.style.visibility = 'hidden'; 
     159                                if(pages._list[i]!='photos') 
     160                                        p.style.display = display 
     161                        } 
     162                        else{ 
     163                                p.style.visibility = 'visible' 
     164                                p.style.display = display; 
     165                        //document.getElementById('page_' + pages._list[i]) 
     166                                //.style.display = display; 
     167                        } 
    150168                } 
    151169 
    152170                // Only the photos page has the toolbar 
     171                /* 
    153172                if ('photos' == id) { 
    154173                        document.getElementById('tools').style.display = '-moz-box'; 
     
    158177                        document.getElementById('bw_batch').style.display = 'none'; 
    159178                } 
     179                */ 
    160180 
    161181        }, 
     
    202222 
    203223                about: function() { 
    204                     //photos.normalize(); 
    205224                        window.openDialog('chrome://uploadr/content/about.xul', 
    206225                                'about-dialog', 'chrome,modal,centerscreen', 
     
    372391var isNormalizing = false; 
    373392var block_normalize = function() { 
     393        /* 
    374394    while(isNormalizing) { 
    375395        logStringMessage('block_normalize while already normalizing'); 
     
    378398            .currentThread.processNextEvent(true); 
    379399    }     
     400    */ 
    380401        ++_block_normalize; 
    381402}; 
     
    383404var unblock_normalize = function() { 
    384405        --_block_normalize; 
     406        /* 
    385407        if(_block_normalize < 0) { 
    386408            logStringMessage("extra unblock_normalize :-("); 
    387409        } 
    388 }; 
     410        */ 
     411}; 
     412 
    389413var _block_exit = 0; 
    390414var block_exit = function() { 
     
    409433                return false; 
    410434        } 
     435         
     436        // Shutdown threads 
     437        try{ 
     438                photos.thumb_cancel = true; 
     439                ui.cancel = true; 
     440                upload.cancel = true; 
     441        } 
     442        catch(e){ 
     443                Components.utils.reportError(e); 
     444        } 
     445         
     446        try{ 
     447                threads.worker.shutdown(); 
     448                threads.indexer.shutdown(); 
     449                threads.uploadr.shutdown(); 
     450                threads.workerPool.shutdown(); 
     451                threads.priorityPool.shutdown(); 
     452        } 
     453        catch(e){ 
     454                Components.utils.reportError(e); 
     455        } 
     456         
     457        //grab stuff from swf 
     458        //the_swf = document.getElementById('the_swf'); 
     459        photos.flash = photos.call_swf('get_flash_obj', []); 
     460         
    411461 
    412462        // Save state 
    413         photos.save(); 
    414         settings.save(); 
    415         users.save(); 
     463        try{ 
     464                photos.save(); 
     465                settings.save(); 
     466                users.save(); 
     467        } 
     468        catch(e){ 
     469                Components.utils.reportError(e); 
     470        } 
    416471 
    417472        // Remove the images and TEMP directories if there are no photos left 
     473        /* 
    418474        if (0 == photos.count) { 
    419475                try { 
     
    440496                } catch (err) {} 
    441497        } 
    442  
    443         // Shutdown threads 
    444         photos.thumb_cancel = true; 
    445         ui.cancel = true; 
    446         upload.cancel = true; 
    447         try { 
    448             threads.worker.shutdown(); 
    449             threads.workerPool.shutdown(); 
    450             threads.uploadr.shutdown(); 
    451         } 
    452         catch (err) {} 
     498        */ 
     499 
     500         
     501        try{ 
     502                threads.saver.shutdown(); 
     503        } 
     504        catch(e){ 
     505                Components.utils.reportError(e); 
     506        } 
     507         
    453508 
    454509        // Finally exit 
    455510        var e = Cc['@mozilla.org/toolkit/app-startup;1'] 
    456511                .getService(Ci.nsIAppStartup); 
     512         
    457513        e.quit(Ci.nsIAppStartup.eForceQuit); 
    458514 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js

    r559 r590  
    7777        // Upload a photo 
    7878        start: function(id) { 
     79             
    7980            //reset upload progress 
    8081            upload.progress_id = -1; 
    8182 
    8283                // Update the UI 
     84                /* 
    8385                if (null == upload.progress_bar) { 
    8486                        document.getElementById('footer').style.display = '-moz-box'; 
     
    8890                        progress_text.value = ''; 
    8991                } 
     92                */ 
    9093 
    9194                var photo = photos.uploading[id]; 
     
    154157                } 
    155158                upload.progress_zero = 0; 
     159                photos.call_swf('update_upload_progress', [photos.uploading[id].id, 1]); 
     160 
    156161        // If no ticket came back, fail this photo 
    157162                if ('object' != typeof rsp || 'ok' != rsp.getAttribute('stat')) { 
     
    210215                // Otherwise, spin for a ticket 
    211216                if (null != photos.uploading[id]) { 
    212                         photos.uploading[id].progress_bar.done(true); 
     217                        //photos.uploading[id].progress_bar.done(true); 
    213218                        upload.tickets[rsp.getElementsByTagName('ticketid')[0] 
    214219                                .firstChild.nodeValue] = { 
     
    221226                                window.clearTimeout(upload.tickets_handle); 
    222227                                upload.tickets_handle = null; 
    223                         upload.tickets_delta = 1000; 
     228                               upload.tickets_delta = 1000; 
    224229                        } 
    225230                        upload.tickets_retry_count = 0; 
     
    242247        // Finish a synchronous upload 
    243248        _sync: function(rsp, id) { 
    244          
     249 
    245250                // Stop checking progress if we're in synchronous mode 
    246251                if ('sync' == conf.mode) { 
     
    251256                        upload.progress_zero = 0; 
    252257                } 
    253          
     258 
    254259                // How did the upload go? 
    255260                var photo_id; 
     
    265270                if ('ok' == stat) { 
    266271                        if (null != photos.uploading[id]) { 
    267                                 photos.uploading[id].progress_bar.done(true); 
     272                                //photos.uploading[id].progress_bar.done(true); 
    268273                                ++photos.ok; 
    269274                        } 
     
    409414                    status.set(locale.getString('status.uploading') + ' ' +  
    410415                        (1000 * photos.kb.sent / (currentTime-upload.startTime)).toFixed(1) + ' KB/s'); 
    411                 photos.uploading[id].progress_bar.update(1 - 
    412                                 a / upload.progress_total); 
    413                 } 
     416                //photos.uploading[id].progress_bar.update(1 - 
     417                                //a / upload.progress_total); 
     418                } 
     419                 
     420                        photos.call_swf('update_upload_progress', [photos.uploading[id].id, 1-a/upload.progress_total]); 
     421                         
    414422                var percent = Math.max(0, Math.min(1, 
    415423                        photos.kb.sent / photos.kb.total)); 
     424                 
    416425                if (null != upload.progress_bar) { 
    417                         upload.progress_bar.update(percent); 
    418                 } 
     426                        //upload.progress_bar.update(percent); 
     427                } 
     428                 
    419429                if (100 == Math.round(100 * percent)) { 
    420                         document.getElementById('progress_text').value = 
    421                                 locale.getString('upload.waiting.status'); 
     430                        //document.getElementById('progress_text').value = 
     431                                //locale.getString('upload.waiting.status'); 
    422432                        upload.processing = true; 
    423433                } else { 
    424                         document.getElementById('progress_text').value = 
    425                                 locale.getFormattedString('upload.progress.status', [ 
    426                                         id + 1, 
    427                                         photos.uploading.length, 
    428                                         Math.round(100 * percent) 
    429                                 ]); 
     434                        //document.getElementById('progress_text').value = 
     435                                //locale.getFormattedString('upload.progress.status', [ 
     436                                        //id + 1, 
     437                                        //photos.uploading.length, 
     438                                        //Math.round(100 * percent) 
     439                                //]); 
    430440                } 
    431441 
     
    475485                        6 == parseInt(rsp.getElementsByTagName('err')[0] 
    476486                        .getAttribute('code'))) { 
    477                         document.getElementById('progress').style.display = 'none'; 
     487                        //document.getElementById('progress').style.display = 'none'; 
    478488                        var f = photos.failed; 
    479489                        for each (var p in photos.uploading) { 
     
    482492                        var ii = f.length; 
    483493                        if (0 != ii) { 
    484                                 document.getElementById('photos_init') 
    485                                         .style.display = 'none'; 
    486                                 document.getElementById('photos_new') 
    487                                         .style.display = 'none'; 
     494                                //document.getElementById('photos_init') 
     495                                        //.style.display = 'none'; 
     496                                //document.getElementById('photos_new') 
     497                                        //.style.display = 'none'; 
    488498                                if (photos.sort) { 
    489                                         document.getElementById('photos_sort_default') 
    490                                                 .style.display = 'block'; 
    491                                         document.getElementById('photos_sort_revert') 
    492                                                 .style.display = 'none'; 
     499                                        //document.getElementById('photos_sort_default') 
     500                                                //.style.display = 'block'; 
     501                                        //document.getElementById('photos_sort_revert') 
     502                                                //.style.display = 'none'; 
    493503                                } else { 
    494                                         document.getElementById('photos_sort_default') 
    495                                                 .style.display = 'none'; 
    496                                         document.getElementById('photos_sort_revert') 
    497                                                 .style.display = 'inline'; 
     504                                        //document.getElementById('photos_sort_default') 
     505                                                //.style.display = 'none'; 
     506                                        //document.getElementById('photos_sort_revert') 
     507                                                //.style.display = 'inline'; 
    498508                                } 
    499509                        } 
     
    513523                                } 
    514524                        } 
    515             unblock_normalize(); 
     525                       unblock_normalize(); 
    516526             
    517527                        photos.uploading = []; 
     
    550560                // Update the UI 
    551561                if (null != upload.progress_bar) { 
    552                     upload.progress_bar.update(1); 
     562                    //upload.progress_bar.update(1); 
    553563                } 
    554564                var text = document.getElementById('progress_text'); 
     
    561571                } 
    562572                mouse.show_photos(); 
    563                 var queue = document.getElementById('queue_list'); 
    564                 while (queue.hasChildNodes()) { 
    565                         queue.removeChild(queue.firstChild); 
    566                
     573                //var queue = document.getElementById('queue_list'); 
     574                //while (queue.hasChildNodes()) { 
     575                        //queue.removeChild(queue.firstChild); 
     576                //
    567577                status.clear(); 
    568578 
     
    608618        // Finally give the user feedback on their upload 
    609619        finalize: function() { 
    610             if(conf.console.upload) { 
    611             logStringMessage('finalize'); 
    612                 } 
    613620                status.clear(); 
    614621 
     
    700707         
    701708                // Hide the progress bar now that the user has realized we're done 
    702                 document.getElementById('progress_bar').style.width = '0'; 
    703                 document.getElementById('footer').style.display = 'none'; 
     709                //document.getElementById('progress_bar').style.width = '0'; 
     710                //document.getElementById('footer').style.display = 'none'; 
    704711 
    705712                // If requested, open the site 
    706713                if (go_to_flickr) { 
    707714                        launch_browser('http://' + SITE_HOST + '/photos/' + users.nsid); 
     715                        //launch_browser('http://' + SITE_HOST + '/photos/upload/done/?b=' + 
     716                                //upload.timestamps.earliest + '-' + upload.timestamps.latest + 
     717                                //'-' + users.nsid); 
    708718                } 
    709719 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js

    r541 r590  
    8787 
    8888                        // Update the UI 
     89                        /* 
    8990                        document.getElementById('username').firstChild.nodeValue = 
    9091                                locale.getFormattedString('username', [users.username]) + '  '; 
     
    9596                        status.set(locale.getString('status.ready')); 
    9697                        meta.login(); 
     98                        */ 
    9799 
    98100                        // Check the command line 
     
    125127 
    126128                // Update the UI 
     129                /* 
    127130                document.getElementById('username').firstChild.nodeValue = 
    128131                        locale.getString('notloggedin') + '  '; 
     
    137140                        'http://flickr.com/images/buddyicon.jpg'; 
    138141                document.getElementById('photostream_pro').style.display = 'none'; 
     142                */ 
     143                photos.call_swf('logged_in', [null]); 
    139144 
    140145        }, 
     
    165170                                users.nbVids, users.videosize, users.sets); 
    166171                } 
     172                photos.call_swf("logged_in", [users.list[users.nsid]]); 
    167173 
    168174        }, 
     
    193199        save: function() { 
    194200                file.write('users.json', users.list); 
    195         } 
     201        }, 
     202               
     203        current_user:function(){ 
     204                if(!users.nsid) 
     205                        return null 
     206                else 
     207                        return users.list[users.nsid]; 
     208        } 
    196209 
    197210};