Changeset 592

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

reverting, changes were meant for branch, not trunk

Files:

Legend:

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

    r590 r592  
    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                                 /* 
    372371                                var ii = meta.sets.length; 
    373372                                var prefixes = ['single', 'batch']; 
     
    413412                                        } 
    414413                                } 
    415                                 unblock_normalize(); 
    416                                 */ 
    417  
     414                unblock_normalize(); 
    418415                        } 
    419416                        status.clear(); 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/buttons.js

    r590 r592  
    22 * Flickr Uploadr 
    33 * 
    4  * Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
     4 * Copyright (c) 2007-2009 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('menu_upload').disabled = false
    56                                 //document.getElementById('menu_upload').disabled = false; 
     54                                document.getElementById('button_upload').className = 'button'; 
     55                                document.getElementById('button_upload').style.display = 'block'
     56                                document.getElementById('menu_upload').disabled = false; 
    5757                        } 
    5858                }, 
    5959                disable: function() { 
    60                         //document.getElementById('button_upload').className = 'disabled_button'; 
    61                         //document.getElementById('menu_upload').disabled = true
    62                         //document.getElementById('menu_upload').disabled = true; 
     60                        document.getElementById('button_upload').className = 'disabled_button'; 
     61                        document.getElementById('button_upload').style.display = 'none'
     62                        document.getElementById('menu_upload').disabled = true; 
    6363                }, 
    6464                click: function() { 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/clh.js

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

    r590 r592  
    22 * Flickr Uploadr 
    33 * 
    4  * Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
     4 * Copyright (c) 2007-2009 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:'', 
    3332 
    3433        app_ini: {}, 
     
    4847        }, 
    4948 
    50         // Size of threads pool for thumbnailing 
    51         maxThreadsCount: 1, 
     49    // Size of threads pool for thumbnailing 
     50    maxThreadsCount: 5, 
     51 
    5252        // Scrolling threshold for dragging (pixels); 
    5353        scroll: 20, 
     
    8080        tickets_retry_count: 10, 
    8181 
     82 
     83 
    8284        // 
    8385        // Feature switches 
     
    8890        socket_uploadr: true, 
    8991 
     92 
     93 
    9094        // 
    9195        // Not advised to change below here 
     
    9498        // Size of thumbnails 
    9599        //   Changing this will require CSS tweaks 
    96         thumb_size: 200, 
     100        thumb_size: 100, 
    97101 
    98102        // Upload mode 
     
    105109 
    106110        // Load are parse the application.ini file 
    107         load_ini: function(bu){ 
     111        load_ini: function(){ 
     112//                      window.openDialog('http://beta2.flickr.com','_blank','modal'); 
    108113 
    109                 conf.base_url = bu; 
    110                  
    111114                var f = Components.classes["@mozilla.org/file/directory_service;1"] 
    112115                        .getService(Components.interfaces.nsIProperties) 
     
    150153                } 
    151154 
    152                  
     155 
    153156                // use some of the parsed options 
    154157 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js

    r590 r592  
    4040 
    4141        // Write an object into a file as JSON 
    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                 } 
     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); 
    5146                var _stream = Cc['@mozilla.org/network/file-output-stream;1'] 
    5247                        .createInstance(Ci.nsIFileOutputStream); 
     
    8580                _stream.close(); 
    8681        }, 
    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         }, 
    10882 
    10983        // File size in kilobytes 
     
    12094        }, 
    12195 
    122        // Delete 
    123        remove: function(name) { 
    124                try { 
    125                        var file = Cc['@mozilla.org/file/directory_service;1'] 
     96    // Delete 
     97    remove: function(name) { 
     98        try { 
     99            var file = Cc['@mozilla.org/file/directory_service;1'] 
    126100                                .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 
    127101                        file.append(name); 
    128102                        if (file.exists()) { 
    129                                file.remove(false); 
     103                            file.remove(false); 
    130104                        } 
    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                
     105        } catch (err) { 
     106            Components.utils.reportError(new Date().toUTCString() +err); 
     107        } 
     108    } 
    232109}; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js

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

    r590 r592  
    44Flickr Uploadr 
    55 
    6 Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
     6Copyright (c) 2007-2009 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  
    2013<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
    2114<?xml-stylesheet href="chrome://uploadr/skin/main.css" type="text/css"?> 
    2215<!--<?xml-stylesheet href="chrome://hacks/skin/hacks.css" type="text/css"?>--> 
    23 <!--<?xul-overlay href="chrome://uploadr/content/photos.xul"?>--
    24 <?xul-overlay href="&base.url;help.xul"?> 
     16<?xul-overlay href="chrome://uploadr/content/photos.xul"?
     17<?xul-overlay href="chrome://uploadr/content/help.xul"?> 
    2518<?xul-overlay href="chrome://hacks/content/keyboard.xul"?> 
    26  
    27  
     19<!DOCTYPE window SYSTEM "chrome://uploadr/locale/main.dtd"> 
    2820<window id="main" title="&title;" width="960" height="700" windowtype="app" 
    2921        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
    3022        xmlns:html="http://www.w3.org/1999/xhtml" 
    31         onload="conf.load_ini('&base.url;'); threads.init(); users.load();    ui.users_updated();" 
     23        onload="conf.load_ini(); threads.init(); users.load(); photos.load(); ui.init(); ui.users_updated();" 
    3224        onclose="return exit();" persist="screenX screenY width height sizemode" 
    33 >        
    34 <!-- removed photos.load(); ui.init(); from onload, flash calls them--> 
    35  
     25
    3626  <stringbundleset> 
    3727    <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 
    38     <stringbundle id="locale" src="chrome://uploadr/content/main.prefs" /> 
    3928  </stringbundleset> 
    40   <head> 
    41            
    4229  <script src="chrome://global/content/globalOverlay.js" /> 
    4330  <script src="chrome://global/content/nsDragAndDrop.js" /> 
    4431  <script src="chrome://global/content/nsUserSettings.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> 
     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" /> 
    6751  <!--<script src="chrome://venkman/content/venkman-overlay.js"/>--> 
    6852  <keyset id="key"> 
     
    9478          <menuitem label="&menu.upload.add;" key="key_add" accesskey="A" oncommand="photos.add_dialog();" /> 
    9579          <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()" /> 
    9780          <menuitem id="menu_FileQuitItem" label="&menu.upload.exit;" key="key_quit" accesskey="Q" oncommand="exit();" /> 
    9881        </menupopup> 
     
    129112  <vbox flex="1"> 
    130113 
    131      
    132            
    133           <stack flex="1"> 
    134     <vbox  id="page_photos" flex="1"> 
    135             <html:embed id="the_swf" flex="1"/> 
    136     </vbox> 
    137      
    138  
     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> 
     160 
     161    <!-- Placeholder for photos and metadata overlay --> 
     162    <vbox id="page_photos" flex="1" /> 
    139163 
    140164    <!-- Page to show during authorization --> 
     
    157181    <!-- Placeholder for help page --> 
    158182    <vbox id="page_help" flex="1" /> 
    159     </stack> 
    160183 
    161184    <!-- Upload progress bar and (hidden) upload queue --> 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js

    r590 r592  
    8585 
    8686                        // Blank slate metadata 
    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; 
     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; 
    14299                        var safety_level = document.getElementById('batch_safety_level'); 
    143100                        safety_level.value = 0; 
    144                         //safety_level.selectedItem.label = ''; 
     101                        safety_level.selectedItem.label = ''; 
    145102 
    146103                        // Clear the old sets list 
     
    318275                        var p = photos.list[id]; 
    319276                        if (null == p) { 
    320                                unblock_normalize(); 
     277                            unblock_normalize(); 
    321278                                return; 
    322279                        } 
     
    392349 
    393350                // Single photo or group of photos? 
    394                block_normalize(); 
     351            block_normalize(); 
    395352                var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 
    396                unblock_normalize(); 
     353        unblock_normalize(); 
    397354         
    398355                if (1 == parseInt(value)) { 
     
    674631                        } 
    675632                } 
    676                unblock_normalize(); 
     633        unblock_normalize(); 
    677634        }, 
    678635 
     
    710667                                } 
    711668                        } 
    712                        unblock_normalize(); 
     669            unblock_normalize(); 
    713670                        // If there are videos then bother them 
    714671                        if (v_count) { 
     
    784741                                                photos._remove(); 
    785742                                        } 
    786                                        unblock_normalize(); 
     743                    unblock_normalize(); 
    787744                                        // If remove is blocked then we know photos.normalize 
    788745                                        // will be called as it is unblocked 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js

    r590 r592  
    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 
    546547                mouse.anchor = null; 
    547548        }, 
     
    553554        show_photos: function() { 
    554555                mouse._photos_visible = true; 
    555                 document.getElementById('the_swf').style.visibility = 'visible'; 
     556                document.getElementById('page_photos').style.display = '-moz-box'; 
    556557                document.getElementById('page_queue').style.display = 'none'; 
    557558                document.getElementById('footer').className = 'photos'; 
     
    559560        show_queue: function() { 
    560561                mouse._photos_visible = false; 
    561                 document.getElementById('the_swf').style.visibility = 'hidden'; 
     562                document.getElementById('page_photos').style.display = 'none'; 
    562563                document.getElementById('page_queue').style.display = '-moz-box'; 
    563564                document.getElementById('footer').className = 'queue'; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js

    r590 r592  
    99 */ 
    1010 
    11  
    1211var photos = { 
    1312 
     
    1615        count: 0, 
    1716        videoCount: 0, 
    18         the_swf:null, 
    19         file:null, 
    2017        errors: 0, 
    2118        selected: [], 
     
    2421        batch_size: 0, 
    2522        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: {}, 
    4023        thumb_cancel: false, 
    4124 
     
    4629        failed: [], 
    4730        sets: {}, 
    48          
    49         to_add: [], 
    50          
    5131        ok: 0, 
    5232        fail: 0, 
     
    6444    normalizeTimeoutId: null, 
    6545     
    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                
    9846        // Let the user select some files, thumbnail them and track them 
    9947        //   Patch for saving our place in the directory structure from 
     
    14088                        while (files.hasMoreElements()) { 
    14189                                var arg = files.getNext().QueryInterface(Ci.nsILocalFile).path; 
    142                                 arg = arg.replace(/\\/g, '\/'); 
    143                                 paths.unshift(arg); 
     90                                paths.push(arg); 
    14491                        } 
    14592                        photos.add(paths); 
     
    158105        }, 
    159106 
    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          
    165107        // Add a list of photos 
    166108        add: function(paths, silent) { 
     109 
    167110                if (null == silent) { silent = false; } 
    168                 //buttons.upload.disable(); 
     111                buttons.upload.disable(); 
    169112 
    170113                // Tally up photos and videos and remove large videos 
     
    175118                var bad = []; 
    176119                for each (var p in paths) { 
    177                        var P = p; 
    178                        p = p[0]
    179  
     120                    if (p === null) { 
     121                        continue
     122                    } 
    180123                        var path = 'object' == typeof p ? p.path : p; 
    181124 
     
    183126                        if (photos.is_photo(path)) { 
    184127                                ++p_count; 
    185                                 new_paths.push(P); 
     128                                new_paths.push(p); 
    186129                        } 
    187130 
     
    193136                                        big_videos.push(null == filename ? path : filename[1]); 
    194137                                } else { 
    195                                         new_paths.push(P); 
    196                                 } 
    197                         } 
    198                          
     138                                        new_paths.push(p); 
     139                                } 
     140                        } 
     141 
    199142                        // Warn about files that are being dropped 
    200                         //else if (path.length) { 
    201                                 //var filename = path.match(/([^\/\\]*)$/); 
    202                                 //bad.push(null == filename ? path : filename[1]); 
    203                         //
     143                        else if (path.length) { 
     144                                var filename = path.match(/([^\/\\]*)$/); 
     145                                bad.push(null == filename ? path : filename[1]); 
     146                       
    204147 
    205148                } 
     
    288231                                        while (paths.length) { 
    289232                                                var p = paths.shift(); 
    290                                                 P = p; 
    291                                                 p = p[0]; 
    292  
    293233                                                var path = 'object' == typeof p ? p.path : p; 
    294234                                                if (!photos.is_video(path)) { 
    295                                                         new_paths.push(P); 
     235                                                        new_paths.push(p); 
    296236                                                } 
    297237                                        } 
     
    303243                                        var ii = paths.length; 
    304244                                        for (var i = 0; i < ii; ++i) { 
    305                                                 var p = 'object' == typeof paths[i][0]
    306                                                         paths[i][0].path : paths[i][0]; 
     245                                                var p = 'object' == typeof paths[i]
     246                                                        paths[i].path : paths[i]; 
    307247                                                if (photos.is_video(p)) { 
    308                                                         paths[i][0] = 'object' == typeof paths[i][0] ? 
    309                                                                 paths[i][0] : {'path': p}; 
    310                                                         paths[i][0].safety_level = result.safety_level; 
     248                                                        paths[i] = 'object' == typeof paths[i] ? 
     249                                                                paths[i] : {'path': p}; 
     250                                                        paths[i].safety_level = result.safety_level; 
    311251                                                } 
    312252                                        } 
     
    343283                // Now add whatever's left 
    344284                var ii = paths.length; 
    345                 var to_flash = []; 
    346285                block_normalize(); 
    347286                var ext_list = []; 
     287                var currentPathsLists = photos.list.map(function(x) {return (x ? x.path : "");}); 
    348288                 
    349                 for (var i = ii-1; i >= 0; --i) { 
    350                         var p = 'object' == typeof paths[i][0] ? paths[i][0].path : paths[i][0]; 
     289                for (var i = 0; i < ii; ++i) { 
     290                        var p = 'object' == typeof paths[i] ? paths[i].path : paths[i]; 
    351291 
    352292                        // Resolve the path and add the photo 
     
    355295                                        .getService(Ci.nsIFileProtocolHandler) 
    356296                                        .getFileFromURLSpec(p).path; 
    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]]); 
     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)); 
    365302 
    366303                            // Photos can be passed as an object which already has metadata 
    367                             if ('object' == typeof paths[i][0]) { 
    368                                     for (var k in paths[i][0]) { 
     304                            if ('object' == typeof paths[i]) { 
     305                                    for (var k in paths[i]) { 
    369306                                            if ('id' == k) { continue; } 
    370                                             photos.list[photos.list.length - 1][k] = paths[i][0][k]; 
     307                                            photos.list[photos.list.length - 1][k] = paths[i][k]; 
    371308                                    } 
    372309                            } 
    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  
     310            } 
     311                } 
     312         
    386313                // Do extension stuff after we've added all of the photos but 
    387314                // before the list we've saved potentially becomes invalid 
     
    389316 
    390317                // Update the UI 
    391                 /* 
    392318                if (photos.count + photos.errors) { 
    393319                    document.getElementById('t_clear').className = 'button'; 
     
    419345                        document.getElementById('photos_new').style.display = 'none'; 
    420346                } 
    421                 */ 
    422347                unblock_normalize(); 
    423348                photos.normalize(); 
    424  
     349                 
    425350        }, 
    426351        _add: function(path) { 
     
    432357                var id = photos.list.length; 
    433358                var p = new Photo(id, path); 
    434                 //p.hash = file.compute_file_hash(path); 
    435359                photos.list.push(p); 
    436360                unblock_normalize(); 
    437361                ++photos.count; 
    438                 if(photos.is_video(path))
    439                        ++photos.videoCount; 
    440                        p.is_video = true; 
    441                 } 
     362                if(photos.is_video(path))
     363                    ++photos.videoCount; 
     364                } 
     365 
    442366                // Create a spot for the image, leaving a spinning placeholder 
    443367                //   Add images to the start of the list because this is our best 
    444368                //   guess for ordering newest to oldest 
    445                 /* 
    446369                var img = document.createElementNS(NS_HTML, 'img'); 
    447370                img.className = 'loading'; 
     
    452375                li.id = 'photo' + id; 
    453376                li.appendChild(img); 
     377                block_normalize(); 
    454378                var list = document.getElementById('photos_list'); 
    455379                list.insertBefore(li, list.firstChild); 
    456                 */ 
    457  
    458380                // Create and show the thumbnail 
    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); 
     381        photos.thumb_cancel = false; 
     382        threads.workerPool.dispatch(new Thumb(id, conf.thumb_size, path), 
     383            threads.workerPool.DISPATCH_NORMAL); 
     384 
    478385                return p; 
    479                  
    480         }, 
    481                
    482         alert: function(s){ 
    483                 Components.utils.reportError(String(s)); 
    484386        }, 
    485387 
     
    491393 
    492394                // Nothing to do if somehow there are no selected photos 
     395                block_normalize(); 
    493396                var ii = photos.selected.length; 
    494                 if (0 == ii) { return; } 
    495  
     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'; 
    496403                // Tell extensions which photos we're removing 
    497404                extension.before_remove.exec(photos.selected); 
     
    500407                for (var i = 0; i < ii; ++i) { 
    501408                        var id = photos.selected[i]; 
    502                         /* 
    503409                        var li = document.getElementById('photo' + id); 
    504410                        if(li) { 
    505411                            li.parentNode.removeChild(li); 
    506412                        } 
    507                         */ 
    508413 
    509414                        // Free the size of this file 
    510415                        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                        } 
    511419                        if (users.nsid && !users.is_pro && users.bandwidth && 
    512                                 0 < users.bandwidth.remaining - photos.batch_size) { 
     420                                0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 
    513421                                status.clear(); 
    514422                        } 
    515  
     423            if(photos.is_video(photos.list[id].path)) { 
     424                --photos.videoCount; 
     425            } 
    516426                        photos.list[id] = null; 
    517427                        --photos.count; 
    518428                } 
     429                unblock_normalize(); 
    519430                ui.bandwidth_updated(); 
    520431                photos.normalize(); 
     
    522433 
    523434                // Clear the selection 
     435                block_normalize(); 
    524436                photos.selected = []; 
     437                unblock_normalize(); 
    525438                mouse.click({target: {}}); 
    526439 
    527440                photos._remove(); 
     441                document.getElementById('photos').style.display = '-moz-box'; 
     442                document.getElementById('normalizing').style.display = 'none'; 
    528443        }, 
    529444 
     
    535450                        photos.sort = true; 
    536451                        buttons.upload.disable(); 
    537                         /* 
    538452                        document.getElementById('photos_sort_default') 
    539453                                .style.display = 'none'; 
     
    547461                        document.getElementById('no_meta_prompt') 
    548462                                .style.visibility = 'hidden'; 
    549                                 */ 
    550463                } 
    551464        }, 
     
    555468 
    556469                // Prevent silliness 
     470                block_normalize(); 
    557471                var s = photos.selected; 
    558472                var ii = s.length; 
     
    572486                                block_sort(); 
    573487                                photos.batch_size -= p.size; 
    574                                  
    575                                 /* 
    576488                                var img = document.getElementById('photo' + p.id) 
    577489                                        .getElementsByTagName('img')[0]; 
     
    580492                                img.setAttribute('height', 8); 
    581493                                img.src = 'chrome://uploadr/skin/balls-16x8-trans.gif'; 
    582                                 */ 
    583494                                block_normalize(); 
    584495                                threads.worker.dispatch(new Rotate(p.id, degrees, 
     
    593504        }, 
    594505 
    595         //   Upload photos 
     506        // Upload photos 
    596507        //   The arguments will either both be null or both be set 
    597508        //   If they're both set, this is an automated call to upload by the 
     
    600511                var from_user = null == list; 
    601512                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; 
    611513 
    612514                // Don't upload if this is a user action and the button is disabled 
    613                 /* 
    614515                if (from_user && 'disabled_button' == document.getElementById( 
    615516                        'button_upload').className) { 
    616517                        return; 
    617518                } 
    618                 */ 
     519                if(ui.cancel) { 
     520            upload.cancel = true; 
     521                        return upload.done(); 
     522                } 
    619523                 
    620                 if(ui.cancel) { 
    621                         upload.cancel = true; 
    622                         return upload.done(); 
    623                 } 
    624  
    625524                // Remove error indicators 
    626                 /* 
    627525                block_normalize(); 
    628526                var li = document.getElementById('photos_list') 
     
    635533                        } 
    636534                } 
    637                 unblock_normalize(); 
    638                 */ 
    639  
     535        unblock_normalize(); 
     536         
    640537                // Decide if we're already in the midst of an upload 
    641538                var not_started = 0 == photos.uploading.length; 
     
    644541                if (from_user) { 
    645542                        var new_list = []; 
     543                        var nbVideosToUpload = 0; 
    646544                        for each (var p in list) { 
    647545                                if (null == p) { 
     
    693591 
    694592                                                // Resize because of user settings 
    695                                                 /* 
    696593                                                if (null != settings.resize && 
    697594                                                        -1 != settings.resize && 
     
    715612                                                        ready_size += p.size; 
    716613                                                } 
    717                                                 */ 
    718614 
    719615                                        } 
     
    742638                                photos.last = null; 
    743639                                block_normalize(); 
    744                                 //var list = document.getElementById('photos_list'); 
    745                                 //while (list.hasChildNodes()) { 
    746                                         //list.removeChild(list.firstChild); 
    747                                 //} 
    748                                 // 
     640                                var list = document.getElementById('photos_list'); 
     641                                while (list.hasChildNodes()) { 
     642                                        list.removeChild(list.firstChild); 
     643                                } 
    749644                                unblock_normalize(); 
    750645                                threads.readyToResize = true; 
     
    754649 
    755650                                // Give some meaningful feedback 
    756                                 /* 
    757651                                if (not_started) { 
    758652                                        document.getElementById('footer').style.display = 
     
    779673                                        photos.sets[users.nsid] = meta.sets; 
    780674                                } 
    781                                 */ 
    782675 
    783676                                return; 
     
    787680                // Update the UI 
    788681                if (from_user) { 
    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; 
     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; 
    804697                } 
    805698 
    806699                // We're really going to start or queue a batch, so do extension stuff 
    807                 //extension.before_upload.exec(list); 
     700                extension.before_upload.exec(list); 
    808701 
    809702                // Take the list of photos into upload mode and reset the UI 
     
    825718 
    826719                                // Setup progress bar for this photo and show it in the queue 
    827                                 /* 
    828720                                var img = document.createElementNS(NS_HTML, 'img'); 
    829721                                img.src = 'file:///' + encodeURIComponent(p.thumb); 
     
    840732                                li.appendChild(stack); 
    841733                                document.getElementById('queue_list').appendChild(li); 
    842                                 */ 
    843734 
    844735                        } 
     
    855746                        } 
    856747                } 
    857                  
    858748                if (from_user) { 
    859749                        photos.batch_size = 0; 
     
    866756                        unblock_normalize(); 
    867757                        photos.last = null; 
    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(); 
     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(); 
    880769         
    881770                // Kick off the first batch job if we haven't started 
     
    892781 
    893782        }, 
    894  
     783     
    895784        // Normalize the photo list and selected list with the DOM 
    896785        normalize: function() { 
     
    908797                    logStringMessage('normalize [in]'); 
    909798                } 
    910                  
    911                 /* 
    912799                document.getElementById('photos').style.display = 'none'; 
    913800                document.getElementById('normalizing').style.display = '-moz-box'; 
     
    938825                } 
    939826                isNormalizing = false; 
    940                 */ 
    941                  
    942         }, 
    943  
     827        }, 
    944828 
    945829        // Load saved metadata 
    946         load: function(){ 
    947                  
     830        load: function() { 
    948831                var obj = file.read('photos.json'); 
    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                  
     832 
    992833                // Don't bother if there are no photos 
    993                 //if ('undefined' == typeof obj.list) { return; } 
     834                if ('undefined' == typeof obj.list) { return; } 
    994835 
    995836                // Add the previous batch of photos 
    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); 
     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); 
    1005846 
    1006847                // Bring in last known sets configuration 
    1007                 //if(obj.sets){ 
    1008                 //meta.sets = obj.sets; 
    1009                 //} 
    1010  
     848                if(obj.sets) { 
     849                    meta.sets = obj.sets; 
     850                } 
    1011851        }, 
    1012852 
     
    1014854    // this is desperate move when the uploadr is in unusable state 
    1015855    removeAll: function() { 
    1016         //if (document.getElementById('t_clear').className == 'disabled_button') 
    1017             //return; 
    1018         //document.getElementById('t_clear').className = 'disabled_button'; 
     856        if (document.getElementById('t_clear').className == 'disabled_button') 
     857            return; 
     858        document.getElementById('t_clear').className = 'disabled_button'; 
    1019859        photos.thumb_cancel = true; 
    1020860        if (conf.console.thumb) { 
     
    1022862                        } 
    1023863        photos.list = []; 
    1024         photos.indexed_paths = {}, 
    1025864        photos.selected = []; 
    1026865        photos.count = 0; 
     
    1031870        _block_sort = _block_remove = _block_normalize = _block_exit = 0; 
    1032871        file.remove('photos.json'); 
    1033         photos.call_swf('reset', []); 
    1034872        // Remove photos from UI 
    1035         /* 
    1036873        block_normalize(); 
    1037874        var list = document.getElementById('photos_list'); 
     
    1041878        unblock_normalize(); 
    1042879        document.getElementById('photos_init').style.display = '-moz-box'; 
    1043         */ 
    1044880        ui.bandwidth_updated(); 
    1045         //meta.disable(); 
    1046         //buttons.upload.disable(); 
     881        meta.disable(); 
     882        buttons.upload.disable(); 
    1047883    }, 
    1048884     
    1049          
    1050885        // 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          
    1069886        save: function() { 
    1070887                if (0 != _block_exit) { return; } 
    1071888                block_normalize(); 
    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'); 
     889                if (1 == photos.selected.length) { 
     890                        meta.save(photos.selected[0]); 
     891                } 
    1079892                file.write('photos.json', { 
    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 
     893                        sort: photos.sort, 
     894                        sets: meta.sets, 
     895                        list: photos.list 
    1087896                }); 
    1088897                unblock_normalize(); 
    1089                 photos.saving = false; 
    1090                 photos.thumb_cancel = false; 
    1091898        }, 
    1092899 
    1093900        // Decide if a given path is a photo 
    1094901        is_photo: function(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); 
     902                return /\.(jpe?g|tiff?|gif|png|bmp)$/i.test(path); 
    1100903        }, 
    1101904 
    1102905        // Similarly, is it a video 
    1103906        is_video: function(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); 
     907                return /\.(mp4|mpe?g|avi|wmv|mov|dv|3gp|3g2|m4v)$/i.test(path); 
    1108908        } 
    1109909 
     
    1112912// Setup auto-saving of metadata in case of crashes 
    1113913//   See photos.save for problems related to the auto-save interval 
    1114 /* 
    1115914window.setInterval(function() { 
    1116915        photos.save(); 
    1117916}, 1000 * conf.auto_save); 
    1118 */ 
    1119917 
    1120918// Photo properties 
     
    1142940        this.hidden = settings.hidden; 
    1143941        this.sets = []; 
    1144         this.is_video = null; 
    1145942        this.progress_bar = null; 
    1146943        this.nsid = null; 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js

    r590 r592  
    22 * Flickr Uploadr 
    33 * 
    4  * Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is 
     4 * Copyright (c) 2007-2009 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                          
    9897                } 
    9998 
    10099        }, 
    101          
     100 
    102101        // Show the settings dialog 
    103102        show: function() { 
     
    106105                // the current NSID and the maximum file size string 
    107106                var u = eval(users.list.toSource()); 
    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  
     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         
    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                          
    123122 
    124123                        // Replace old users object with new one 
     
    160159                                        safety_level: s.safety_level 
    161160                                }); 
    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                                 } 
    167161                        } else { 
    168162                                settings.is_public = 1; 
     
    183177                        } 
    184178 
    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  
    200179                        // Get permission to overwrite any changes that were made 
    201180                        if (0 < photos.count && 
     
    209188 
    210189                        // Save metadata 
     190                        block_normalize(); 
    211191                        if (1 == photos.selected.length) { 
    212192                                meta.save(photos.selected[0]); 
     
    229209                                } 
    230210                        } 
    231  
     211            unblock_normalize(); 
    232212                        // Videos can't be restricted so either update them or delete them 
    233213                        if (3 == settings.safety_level) { 
     
    236216                                var p_count = 0; 
    237217                                var v_count = 0; 
     218                                block_normalize(); 
    238219                                for each (var p in photos.list) { 
    239220                                        if (null == p) { 
     
    246227                                        } 
    247228                                } 
    248  
     229                unblock_normalize(); 
    249230                                // If there are videos, bother them 
    250231                                if (v_count) { 
     
    277258                                        // Remove selected videos 
    278259                                        if ('cancel' == result.result) { 
     260                                                block_normalize(); 
    279261                                                var ii = photos.list.length; 
    280262                                                for (var i = 0; i < ii; ++i) { 
     
    286268                                                                li.parentNode.removeChild(li); 
    287269                                                                photos.batch_size -= photos.list[i].size; 
     270                                                                photos.video_batch_size -= photos.list[i].size; 
    288271                                                                if (users.nsid && !users.is_pro && 
    289                                                                         0 < users.bandwidth.remaining - photos.batch_size) { 
     272                                                                        0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 
    290273                                                                        status.clear(); 
     274                                                                } 
     275                                                                if(photos.is_video(photos.list[i].path)) { 
     276                                                                    --photos.videoCount; 
    291277                                                                } 
    292278                                                                photos.list[i] = null; 
     
    294280                                                        } 
    295281                                                } 
     282                                                unblock_normalize(); 
    296283                                                ui.bandwidth_updated(); 
    297284 
     
    308295                                        // Set a different safety level for videos 
    309296                                        else if ('ok' == result.result && result.safety_level) { 
     297                                                block_normalize(); 
    310298                                                var ii = photos.list.length; 
    311299                                                for (var i = 0; i < ii; ++i) { 
     
    315303                                                        } 
    316304                                                } 
     305                                                unblock_normalize(); 
    317306                                        } 
    318307 
     
    322311 
    323312                        // Refresh visible photo metadata if necessary 
     313                        block_normalize(); 
    324314                        if (1 == photos.selected.length) { 
    325315                                meta.load(photos.selected[0]); 
     
    329319                                meta.batch(); 
    330320                        } 
    331  
     321            unblock_normalize(); 
    332322                } 
    333323 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.xul

    r590 r592  
    2020  <!ENTITY % proxyDTD SYSTEM "chrome://uploadr/locale/proxy.dtd"> 
    2121  %proxyDTD; 
    22   <!ENTITY % settingsDTD SYSTEM "chrome://uploadr/content/settings.dtd"> 
    23   %settingsDTD; 
    2422]> 
    2523<dialog id="dialog_settings" title="&settings;" buttons="accept,cancel" 
     
    2927xmlns:html="http://www.w3.org/1999/xhtml"> 
    3028  <stringbundleset> 
    31        <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 
     29    <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 
    3230  </stringbundleset> 
    33   <script src="&base.url;settings_dialog.js" /> 
     31  <script src="chrome://uploadr/content/settings_dialog.js" /> 
    3432  <vbox flex="1" id="notloggedin"> 
    35        <html:h3>&settings.notloggedin;</html:h3> 
    36        <box align="center"> 
    37          <button label="&login;" 
     33    <html:h3>&settings.notloggedin;</html:h3> 
     34    <box align="center"> 
     35      <button label="&login;" 
    3836                oncommand="settings.add_user();" /> 
    39        </box> 
     37    </box> 
    4038  </vbox> 
    4139  <vbox flex="1" id="loggedin"> 
     
    121119        </radiogroup> 
    122120      </groupbox> 
    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> 
     121    </hbox> 
    128122  </vbox> 
    129123</dialog> 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings_dialog.js

    r590 r592  
    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         }, 
    137134        config_proxy: function(){ 
    138135                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

    r590 r592  
    2626var threads = { 
    2727 
    28        initialized: false, 
     28    initialized: false, 
    2929        // Hooks to threads 
    3030        worker: null, 
    3131        uploadr: null, 
    3232        main: null, 
    33         indexer: null, 
    34         saver: null, 
     33        workerPool: null, 
    3534        readyToResize: false, 
    36         //workers:[], 
    37         workerPool:null, 
    38         priorityPool:null, 
    39  
    40         //  
     35 
    4136        // GraphicsMagick XPCOM object 
    4237        gm: null, 
     
    4439        // Create thread hooks and instantiate GraphicsMagick 
    4540        init: function() { 
    46                 try { 
    47                          
    48                         threads.misc_init(); 
     41                try {    
    4942                        // Threads themselves 
    5043                        var t = Cc['@mozilla.org/thread-manager;1'].getService(); 
     
    5447                        threads.uploadr = t.newThread(0); 
    5548                        threads.main = t.mainThread; 
    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                          
     49 
    6250                        // GraphicsMagick, for use on the worker thread 
    6351                        threads.gm = Cc['@flickr.com/gm;1'].createInstance(Ci.flIGM); 
     
    6654                                .get('resource:app', Ci.nsIFile).path, UploadProgressHandler); 
    6755                        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!? 
    68                         threads.initialized = true; 
    69                          
     56            threads.initialized = true; 
    7057                } catch (err) { 
    7158                        Components.utils.reportError(new Date().toUTCString() +err); 
     
    8976                    } 
    9077                } 
    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); 
    10378        } 
    10479 
     
    10782// Thumbnail thread wrapper 
    10883var Thumb = function(id, thumb_size, path, auto_select) { 
    109         photos.thumb_thread_counter+=1; 
    11084        this.id = id; 
    11185        this.thumb_size = thumb_size; 
     
    11387        this.auto_select = null == auto_select ? false : auto_select; 
    11488}; 
    115  
    11689Thumb.prototype = { 
    11790        run: function() { 
    118                if(photos.thumb_cancel === true) 
    119                        return; 
     91            if(photos.thumb_cancel === true) 
     92                return; 
    12093                var result = ''; 
    12194 
     
    155128        this.auto_select = auto_select; 
    156129}; 
    157  
    158130ThumbCallback.prototype = { 
    159131        run: function() { 
    160132        if (photos.thumb_cancel === true) 
    161                return; 
     133            return; 
    162134                try { 
    163135                        if (conf.console.thumb) { 
     
    172144                         
    173145                         
    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); 
     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); 
    178150 
    179151                        // If successful, replace with the thumb and update the 
     
    184156                                var ii = thumb.length; 
    185157                                for (var i = 0; i < ii; ++i) { 
    186                                         thumb[i] = thumb[i]; //why?  
     158                                        thumb[i] = thumb[i]; 
    187159                                } 
    188160 
     
    225197                                photos.list[this.id].thumb_width = parseInt(thumb[4]); 
    226198                                photos.list[this.id].thumb_height = parseInt(thumb[5]); 
    227                                 //img.setAttribute('width', thumb[4]); 
    228                                 //img.setAttpribute('height', thumb[5]); 
     199                                img.setAttribute('width', thumb[4]); 
     200                                img.setAttribute('height', thumb[5]); 
    229201                                var thumbPath = thumb[6].replace(/^\s+|\s+$/g, '') 
    230                                                .replace(/\{---THREE---POUND---DELIM---\}/g, '###'); 
    231                                 //img.src = 'file:///' + encodeURIComponent(thumbPath); 
     202                                        .replace(/\{---THREE---POUND---DELIM---\}/g, '###'); 
     203                                img.src = 'file:///' + encodeURIComponent(thumbPath); 
    232204                                if (conf.console.thumb) { 
    233205                                    logStringMessage('GM THUMB: path ' + img.src + " " + thumbPath); 
    234                                    } 
     206                            } 
    235207                                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                                 } 
    243208 
    244209                                // Make video icons for videos 
    245210                                //   This will look funny for a portrait-oriented video 
    246                                 /* 
    247211                                if (photos.is_video(photos.list[this.id].path)) { 
    248212                                        var icon = document.createElementNS(NS_HTML, 'img'); 
     
    254218                                        img.parentNode.appendChild(icon); 
    255219                                } 
    256                                 */ 
    257220 
    258221                                // Title/tags/description 
     
    331294                                } 
    332295                                ui.bandwidth_updated(); 
    333                                  
     296 
    334297                        } 
    335298 
    336299                        // If unsuccessful, replace with the error image 
    337300                        else { 
    338                                 /* 
    339301                                img.setAttribute('src', 
    340302                                        'chrome://uploadr/skin/icon_alert.png'); 
     
    359321                                        } 
    360322                                }; 
    361                                 */ 
    362323                                Components.utils.reportError(new Date().toUTCString() +this.result); 
    363324                        } 
    364325 
    365326                        // After updating, make it visible again 
    366                         //img.style.visibility = 'visible'; 
     327                        img.style.visibility = 'visible'; 
    367328 
    368329                } catch (err) { 
    369330                        Components.utils.reportError(new Date().toUTCString() +err); 
    370331                } 
    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; 
     332        unblock_normalize(); 
    380333                // Tell extensions that we got a new thumbnail 
    381334                extension.after_thumb.exec(this.id); 
    382                 // and sync the view as well 
     335                // and synch the view as well 
    383336                photos.normalize(); 
    384337 
    385338                unblock_sort(); 
    386339                if(photos.sort && !_block_sort) { // hack hack :( 
    387                            threads.worker.dispatch(new Sort(), 
     340            threads.worker.dispatch(new Sort(), 
    388341                            threads.worker.DISPATCH_NORMAL); 
    389342                } 
     
    405358        this.path = path; 
    406359}; 
    407  
    408360Rotate.prototype = { 
    409361        run: function() { 
     
    464416var Sort = function() { 
    465417}; 
    466  
    467418Sort.prototype = { 
    468419        run: function() { 
     
    531482                //   This is far from being a bottleneck, so leave it alone 
    532483                //   until it is 
    533                 /* 
    534484                var list = document.getElementById('photos_list'); 
    535485                for (var i = p.length - 1; i >= 0; --i) { 
     
    538488                        } 
    539489                } 
    540                 */ 
    541                  
    542490                unblock_normalize(); 
    543491        if(conf.console.sort) { 
     
    567515        this.path = path; 
    568516}; 
    569  
    570517Resize.prototype = { 
    571518        run: function() { 
    572519                try { 
    573  
    574520                        // Resize the image and callback to the UI thread 
    575521            if(ui.cancel) 
     
    594540        this.result = result; 
    595541}; 
    596  
    597542ResizeCallback.prototype = { 
    598543        run: function() { 
     
    613558 
    614559                        if (null == resize) { 
    615                                 Components.utils.reportError(new Date().toUTCString() +' ' + this.result); 
     560                                Components.utils.reportError(new Date().toUTCString() +this.result); 
    616561                        } else { 
    617562                                list = photos.ready[photos.ready.length - 1]; 
     
    641586 
    642587// Job to enable uploads that can follow a bunch of jobs in the queue 
    643 var IndexDrive = function() { 
    644          
    645 }; 
    646 IndexDrive.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  
    802 var IndexDriveCallback = function(paths) { 
    803         this.paths = paths; 
    804 }; 
    805  
    806 IndexDriveCallback.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 
    827588var EnableUpload = function() { 
    828589}; 
     
    928689        } 
    929690}; 
    930  
    931 var Save = function() { 
    932 }; 
    933 Save.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 }; 
    946 var SaveCallback = function() { 
    947 }; 
    948 SaveCallback.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

    r590 r592  
    1 /* * Flickr Uploadr 
     1/* 
     2 * Flickr Uploadr 
    23 * 
    34 * Copyright (c) 2007-2009 Yahoo! Inc.  All rights reserved.  This library is 
    45 * 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  
    1412var ui = { 
    1513 
    1614    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.free'); 
     22                document.getElementById('photos_init_prompt').firstChild.nodeValue = 
     23                        locale.getString('photos.init.pro'); 
    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                 /* 
    3231                for each (var id in ['help_offline', 'help_drag']) { 
    3332                        var node = document.getElementById(id); 
     
    5150                node.appendChild(span); 
    5251                node.appendChild(document.createTextNode(parts[2])); 
    53                 */ 
    5452 
    5553        }, 
     
    6159 
    6260                // Notes in the empty photo pane 
    63                 /* 
    6461                var notes = document.getElementById('photos_init_notes'); 
    6562                while (notes.hasChildNodes()) { 
     
    8582                document.getElementById('photos_init_prompt') 
    8683                        .firstChild.nodeValue = locale.getString('photos.init.pro'); 
    87                         */ 
    8884        }, 
    8985 
     
    9187        bandwidth_updated: function() { 
    9288 
    93                 //short circuit 
    94                 return; 
    95                  
    9689                // Counter for remaining bandwidth 
    9790                if (users.bandwidth && !users.is_pro) { 
     
    153146                                display = 'none'; 
    154147                        } 
    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                         } 
     148                        document.getElementById('page_' + pages._list[i]) 
     149                                .style.display = display; 
    168150                } 
    169151 
    170152                // Only the photos page has the toolbar 
    171                 /* 
    172153                if ('photos' == id) { 
    173154                        document.getElementById('tools').style.display = '-moz-box'; 
     
    177158                        document.getElementById('bw_batch').style.display = 'none'; 
    178159                } 
    179                 */ 
    180160 
    181161        }, 
     
    222202 
    223203                about: function() { 
     204                    //photos.normalize(); 
    224205                        window.openDialog('chrome://uploadr/content/about.xul', 
    225206                                'about-dialog', 'chrome,modal,centerscreen', 
     
    391372var isNormalizing = false; 
    392373var block_normalize = function() { 
    393         /* 
    394374    while(isNormalizing) { 
    395375        logStringMessage('block_normalize while already normalizing'); 
     
    398378            .currentThread.processNextEvent(true); 
    399379    }     
    400     */ 
    401380        ++_block_normalize; 
    402381}; 
     
    404383var unblock_normalize = function() { 
    405384        --_block_normalize; 
    406         /* 
    407385        if(_block_normalize < 0) { 
    408386            logStringMessage("extra unblock_normalize :-("); 
    409387        } 
    410         */ 
    411 }; 
    412  
     388}; 
    413389var _block_exit = 0; 
    414390var block_exit = function() { 
     
    433409                return false; 
    434410        } 
    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          
    461411 
    462412        // Save state 
    463         try{ 
    464                 photos.save(); 
    465                 settings.save(); 
    466                 users.save(); 
    467         } 
    468         catch(e){ 
    469                 Components.utils.reportError(e); 
    470         } 
     413        photos.save(); 
     414        settings.save(); 
     415        users.save(); 
    471416 
    472417        // Remove the images and TEMP directories if there are no photos left 
    473         /* 
    474418        if (0 == photos.count) { 
    475419                try { 
     
    496440                } catch (err) {} 
    497441        } 
    498         */ 
    499  
    500          
    501         try{ 
    502                 threads.saver.shutdown(); 
    503         } 
    504         catch(e){ 
    505                 Components.utils.reportError(e); 
    506         } 
    507          
     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) {} 
    508453 
    509454        // Finally exit 
    510455        var e = Cc['@mozilla.org/toolkit/app-startup;1'] 
    511456                .getService(Ci.nsIAppStartup); 
    512          
    513457        e.quit(Ci.nsIAppStartup.eForceQuit); 
    514458 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js

    r590 r592  
    7777        // Upload a photo 
    7878        start: function(id) { 
    79              
    8079            //reset upload progress 
    8180            upload.progress_id = -1; 
    8281 
    8382                // Update the UI 
    84                 /* 
    8583                if (null == upload.progress_bar) { 
    8684                        document.getElementById('footer').style.display = '-moz-box'; 
     
    9088                        progress_text.value = ''; 
    9189                } 
    92                 */ 
    9390 
    9491                var photo = photos.uploading[id]; 
     
    157154                } 
    158155                upload.progress_zero = 0; 
    159                 photos.call_swf('update_upload_progress', [photos.uploading[id].id, 1]); 
    160  
    161156        // If no ticket came back, fail this photo 
    162157                if ('object' != typeof rsp || 'ok' != rsp.getAttribute('stat')) { 
     
    215210                // Otherwise, spin for a ticket 
    216211                if (null != photos.uploading[id]) { 
    217                         //photos.uploading[id].progress_bar.done(true); 
     212                        photos.uploading[id].progress_bar.done(true); 
    218213                        upload.tickets[rsp.getElementsByTagName('ticketid')[0] 
    219214                                .firstChild.nodeValue] = { 
     
    226221                                window.clearTimeout(upload.tickets_handle); 
    227222                                upload.tickets_handle = null; 
    228                                upload.tickets_delta = 1000; 
     223                        upload.tickets_delta = 1000; 
    229224                        } 
    230225                        upload.tickets_retry_count = 0; 
     
    247242        // Finish a synchronous upload 
    248243        _sync: function(rsp, id) { 
    249  
     244         
    250245                // Stop checking progress if we're in synchronous mode 
    251246                if ('sync' == conf.mode) { 
     
    256251                        upload.progress_zero = 0; 
    257252                } 
    258  
     253         
    259254                // How did the upload go? 
    260255                var photo_id; 
     
    270265                if ('ok' == stat) { 
    271266                        if (null != photos.uploading[id]) { 
    272                                 //photos.uploading[id].progress_bar.done(true); 
     267                                photos.uploading[id].progress_bar.done(true); 
    273268                                ++photos.ok; 
    274269                        } 
     
    414409                    status.set(locale.getString('status.uploading') + ' ' +  
    415410                        (1000 * photos.kb.sent / (currentTime-upload.startTime)).toFixed(1) + ' KB/s'); 
    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                          
     411                photos.uploading[id].progress_bar.update(1 - 
     412                                a / upload.progress_total); 
     413                } 
    422414                var percent = Math.max(0, Math.min(1, 
    423415                        photos.kb.sent / photos.kb.total)); 
    424                  
    425416                if (null != upload.progress_bar) { 
    426                         //upload.progress_bar.update(percent); 
    427                 } 
    428                  
     417                        upload.progress_bar.update(percent); 
     418                } 
    429419                if (100 == Math.round(100 * percent)) { 
    430                         //document.getElementById('progress_text').value = 
    431                                 //locale.getString('upload.waiting.status'); 
     420                        document.getElementById('progress_text').value = 
     421                                locale.getString('upload.waiting.status'); 
    432422                        upload.processing = true; 
    433423                } else { 
    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                                 //]); 
     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                                ]); 
    440430                } 
    441431 
     
    485475                        6 == parseInt(rsp.getElementsByTagName('err')[0] 
    486476                        .getAttribute('code'))) { 
    487                         //document.getElementById('progress').style.display = 'none'; 
     477                        document.getElementById('progress').style.display = 'none'; 
    488478                        var f = photos.failed; 
    489479                        for each (var p in photos.uploading) { 
     
    492482                        var ii = f.length; 
    493483                        if (0 != ii) { 
    494                                 //document.getElementById('photos_init') 
    495                                         //.style.display = 'none'; 
    496                                 //document.getElementById('photos_new') 
    497                                         //.style.display = 'none'; 
     484                                document.getElementById('photos_init') 
     485                                        .style.display = 'none'; 
     486                                document.getElementById('photos_new') 
     487                                        .style.display = 'none'; 
    498488                                if (photos.sort) { 
    499                                         //document.getElementById('photos_sort_default') 
    500                                                 //.style.display = 'block'; 
    501                                         //document.getElementById('photos_sort_revert') 
    502                                                 //.style.display = 'none'; 
     489                                        document.getElementById('photos_sort_default') 
     490                                                .style.display = 'block'; 
     491                                        document.getElementById('photos_sort_revert') 
     492                                                .style.display = 'none'; 
    503493                                } else { 
    504                                         //document.getElementById('photos_sort_default') 
    505                                                 //.style.display = 'none'; 
    506                                         //document.getElementById('photos_sort_revert') 
    507                                                 //.style.display = 'inline'; 
     494                                        document.getElementById('photos_sort_default') 
     495                                                .style.display = 'none'; 
     496                                        document.getElementById('photos_sort_revert') 
     497                                                .style.display = 'inline'; 
    508498                                } 
    509499                        } 
     
    523513                                } 
    524514                        } 
    525                        unblock_normalize(); 
     515            unblock_normalize(); 
    526516             
    527517                        photos.uploading = []; 
     
    560550                // Update the UI 
    561551                if (null != upload.progress_bar) { 
    562                     //upload.progress_bar.update(1); 
     552                    upload.progress_bar.update(1); 
    563553                } 
    564554                var text = document.getElementById('progress_text'); 
     
    571561                } 
    572562                mouse.show_photos(); 
    573                 //var queue = document.getElementById('queue_list'); 
    574                 //while (queue.hasChildNodes()) { 
    575                         //queue.removeChild(queue.firstChild); 
    576                 //
     563                var queue = document.getElementById('queue_list'); 
     564                while (queue.hasChildNodes()) { 
     565                        queue.removeChild(queue.firstChild); 
     566               
    577567                status.clear(); 
    578568 
     
    618608        // Finally give the user feedback on their upload 
    619609        finalize: function() { 
     610            if(conf.console.upload) { 
     611            logStringMessage('finalize'); 
     612                } 
    620613                status.clear(); 
    621614 
     
    707700         
    708701                // Hide the progress bar now that the user has realized we're done 
    709                 //document.getElementById('progress_bar').style.width = '0'; 
    710                 //document.getElementById('footer').style.display = 'none'; 
     702                document.getElementById('progress_bar').style.width = '0'; 
     703                document.getElementById('footer').style.display = 'none'; 
    711704 
    712705                // If requested, open the site 
    713706                if (go_to_flickr) { 
    714707                        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); 
    718708                } 
    719709 
  • trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js

    r590 r592  
    8787 
    8888                        // Update the UI 
    89                         /* 
    9089                        document.getElementById('username').firstChild.nodeValue = 
    9190                                locale.getFormattedString('username', [users.username]) + '  '; 
     
    9695                        status.set(locale.getString('status.ready')); 
    9796                        meta.login(); 
    98                         */ 
    9997 
    10098                        // Check the command line 
     
    127125 
    128126                // Update the UI 
    129                 /* 
    130127                document.getElementById('username').firstChild.nodeValue = 
    131128                        locale.getString('notloggedin') + '  '; 
     
    140137                        'http://flickr.com/images/buddyicon.jpg'; 
    141138                document.getElementById('photostream_pro').style.display = 'none'; 
    142                 */ 
    143                 photos.call_swf('logged_in', [null]); 
    144139 
    145140        }, 
     
    170165                                users.nbVids, users.videosize, users.sets); 
    171166                } 
    172                 photos.call_swf("logged_in", [users.list[users.nsid]]); 
    173167 
    174168        }, 
     
    199193        save: function() { 
    200194                file.write('users.json', users.list); 
    201         }, 
    202                
    203         current_user:function(){ 
    204                 if(!users.nsid) 
    205                         return null 
    206                 else 
    207                         return users.list[users.nsid]; 
    208         } 
     195        } 
    209196 
    210197};