Changeset 592
- Timestamp:
- 04/07/09 02:17:46 (8 months ago)
- Files:
-
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/api.js (modified) (3 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/buttons.js (modified) (5 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/clh.js (modified) (1 diff)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/conf.js (modified) (8 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/embed.xul (deleted)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js (modified) (3 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/flash (deleted)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js (modified) (1 diff)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/main.xul (modified) (5 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js (modified) (6 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js (modified) (7 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js (modified) (49 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.dtd (deleted)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js (modified) (17 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.xul (modified) (3 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings_dialog.js (modified) (1 diff)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/threads.js (modified) (23 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/ui.js (modified) (15 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js (modified) (16 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js (modified) (6 diffs)
- trunk/uploadr/flash (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/api.js
r590 r592 69 69 }, null, 'http://' + SITE_HOST + '/services/auth/' + 70 70 (fresh ? 'fresh/' : ''), true); 71 //document.getElementById('auth_url').value = url;71 document.getElementById('auth_url').value = url; 72 72 pages.go('auth'); 73 73 } … … 369 369 370 370 // Update the lists of available sets 371 /*372 371 var ii = meta.sets.length; 373 372 var prefixes = ['single', 'batch']; … … 413 412 } 414 413 } 415 unblock_normalize(); 416 */ 417 414 unblock_normalize(); 418 415 } 419 416 status.clear(); trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/buttons.js
r590 r592 2 2 * Flickr Uploadr 3 3 * 4 * Copyright (c) 2007-200 8Yahoo! Inc. All rights reserved. This library is4 * Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. This library is 5 5 * free software; you can redistribute it and/or modify it under the terms of 6 6 * the GNU General Public License (GPL), version 2 only. This library is … … 13 13 login: { 14 14 click: function() { 15 //if ('small button' != document.getElementById('login').className) {16 //return;17 //}15 if ('small button' != document.getElementById('login').className) { 16 return; 17 } 18 18 if (users.nsid) { 19 19 settings.show(); … … 23 23 }, 24 24 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'; 27 27 }, 28 28 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'; 31 31 } 32 32 }, … … 41 41 remove: { 42 42 enable: function() { 43 //document.getElementById('t_remove').className = 'button';43 document.getElementById('t_remove').className = 'button'; 44 44 }, 45 45 disable: function() { 46 //document.getElementById('t_remove').className = 'disabled_button';46 document.getElementById('t_remove').className = 'disabled_button'; 47 47 } 48 48 }, … … 52 52 if (users.nsid && 'boolean' == typeof users.is_pro && 53 53 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; 57 57 } 58 58 }, 59 59 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; 63 63 }, 64 64 click: function() { trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/clh.js
r590 r592 20 20 queue = comp.getQueue(); 21 21 } 22 var Q = queue.split('|||||'); 23 if(Q.length > 0) 24 photos.add(Q, silent); 22 photos.add(queue.split('|||||'), silent); 25 23 }; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/conf.js
r590 r592 2 2 * Flickr Uploadr 3 3 * 4 * Copyright (c) 2007-200 8Yahoo! Inc. All rights reserved. This library is4 * Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. This library is 5 5 * free software; you can redistribute it and/or modify it under the terms of 6 6 * the GNU General Public License (GPL), version 2 only. This library is … … 30 30 // What version am I? 31 31 version: '3.x', 32 base_url:'',33 32 34 33 app_ini: {}, … … 48 47 }, 49 48 50 // Size of threads pool for thumbnailing 51 maxThreadsCount: 1, 49 // Size of threads pool for thumbnailing 50 maxThreadsCount: 5, 51 52 52 // Scrolling threshold for dragging (pixels); 53 53 scroll: 20, … … 80 80 tickets_retry_count: 10, 81 81 82 83 82 84 // 83 85 // Feature switches … … 88 90 socket_uploadr: true, 89 91 92 93 90 94 // 91 95 // Not advised to change below here … … 94 98 // Size of thumbnails 95 99 // Changing this will require CSS tweaks 96 thumb_size: 200,100 thumb_size: 100, 97 101 98 102 // Upload mode … … 105 109 106 110 // 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'); 108 113 109 conf.base_url = bu;110 111 114 var f = Components.classes["@mozilla.org/file/directory_service;1"] 112 115 .getService(Components.interfaces.nsIProperties) … … 150 153 } 151 154 152 155 153 156 // use some of the parsed options 154 157 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js
r590 r592 40 40 41 41 // 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); 51 46 var _stream = Cc['@mozilla.org/network/file-output-stream;1'] 52 47 .createInstance(Ci.nsIFileOutputStream); … … 85 80 _stream.close(); 86 81 }, 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 mac97 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 },108 82 109 83 // File size in kilobytes … … 120 94 }, 121 95 122 // Delete123 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'] 126 100 .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 127 101 file.append(name); 128 102 if (file.exists()) { 129 file.remove(false);103 file.remove(false); 130 104 } 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 } 232 109 }; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js
r590 r592 76 76 } 77 77 } 78 unblock_normalize();78 unblock_normalize(); 79 79 } 80 80 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/main.xul
r590 r592 4 4 Flickr Uploadr 5 5 6 Copyright (c) 2007-200 8Yahoo! Inc. All rights reserved. This library is6 Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. This library is 7 7 free software; you can redistribute it and/or modify it under the terms of 8 8 the GNU General Public License (GPL), version 2 only. This library is … … 11 11 12 12 --> 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 20 13 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 21 14 <?xml-stylesheet href="chrome://uploadr/skin/main.css" type="text/css"?> 22 15 <!--<?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"?> 25 18 <?xul-overlay href="chrome://hacks/content/keyboard.xul"?> 26 27 19 <!DOCTYPE window SYSTEM "chrome://uploadr/locale/main.dtd"> 28 20 <window id="main" title="&title;" width="960" height="700" windowtype="app" 29 21 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 30 22 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();" 32 24 onclose="return exit();" persist="screenX screenY width height sizemode" 33 > 34 <!-- removed photos.load(); ui.init(); from onload, flash calls them--> 35 25 > 36 26 <stringbundleset> 37 27 <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 38 <stringbundle id="locale" src="chrome://uploadr/content/main.prefs" />39 28 </stringbundleset> 40 <head>41 42 29 <script src="chrome://global/content/globalOverlay.js" /> 43 30 <script src="chrome://global/content/nsDragAndDrop.js" /> 44 31 <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" /> 67 51 <!--<script src="chrome://venkman/content/venkman-overlay.js"/>--> 68 52 <keyset id="key"> … … 94 78 <menuitem label="&menu.upload.add;" key="key_add" accesskey="A" oncommand="photos.add_dialog();" /> 95 79 <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()" />97 80 <menuitem id="menu_FileQuitItem" label="&menu.upload.exit;" key="key_quit" accesskey="Q" oncommand="exit();" /> 98 81 </menupopup> … … 129 112 <vbox flex="1"> 130 113 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" /> 139 163 140 164 <!-- Page to show during authorization --> … … 157 181 <!-- Placeholder for help page --> 158 182 <vbox id="page_help" flex="1" /> 159 </stack>160 183 161 184 <!-- Upload progress bar and (hidden) upload queue --> trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js
r590 r592 85 85 86 86 // 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; 142 99 var safety_level = document.getElementById('batch_safety_level'); 143 100 safety_level.value = 0; 144 //safety_level.selectedItem.label = '';101 safety_level.selectedItem.label = ''; 145 102 146 103 // Clear the old sets list … … 318 275 var p = photos.list[id]; 319 276 if (null == p) { 320 unblock_normalize();277 unblock_normalize(); 321 278 return; 322 279 } … … 392 349 393 350 // Single photo or group of photos? 394 block_normalize();351 block_normalize(); 395 352 var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 396 unblock_normalize();353 unblock_normalize(); 397 354 398 355 if (1 == parseInt(value)) { … … 674 631 } 675 632 } 676 unblock_normalize();633 unblock_normalize(); 677 634 }, 678 635 … … 710 667 } 711 668 } 712 unblock_normalize();669 unblock_normalize(); 713 670 // If there are videos then bother them 714 671 if (v_count) { … … 784 741 photos._remove(); 785 742 } 786 unblock_normalize();743 unblock_normalize(); 787 744 // If remove is blocked then we know photos.normalize 788 745 // will be called as it is unblocked trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js
r590 r592 29 29 meta.abandon(); 30 30 } 31 unblock_normalize();31 unblock_normalize(); 32 32 33 33 // If we clicked on an image that isn't an error and isn't loading … … 104 104 meta.batch(); 105 105 } 106 unblock_normalize();106 unblock_normalize(); 107 107 } 108 108 // If we clicked the revert to sorted button … … 287 287 'selected dragging'; 288 288 } 289 unblock_normalize();289 unblock_normalize(); 290 290 mouse.dragging = 2; 291 291 } … … 433 433 // If we're reordering 434 434 if (null == mouse.anchor) { 435 block_normalize();435 block_normalize(); 436 436 var list = document.getElementById('photos_list'); 437 437 if (3 == mouse.dragging) { … … 544 544 unblock_normalize(); 545 545 } 546 546 547 mouse.anchor = null; 547 548 }, … … 553 554 show_photos: function() { 554 555 mouse._photos_visible = true; 555 document.getElementById(' the_swf').style.visibility = 'visible';556 document.getElementById('page_photos').style.display = '-moz-box'; 556 557 document.getElementById('page_queue').style.display = 'none'; 557 558 document.getElementById('footer').className = 'photos'; … … 559 560 show_queue: function() { 560 561 mouse._photos_visible = false; 561 document.getElementById(' the_swf').style.visibility = 'hidden';562 document.getElementById('page_photos').style.display = 'none'; 562 563 document.getElementById('page_queue').style.display = '-moz-box'; 563 564 document.getElementById('footer').className = 'queue'; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js
r590 r592 9 9 */ 10 10 11 12 11 var photos = { 13 12 … … 16 15 count: 0, 17 16 videoCount: 0, 18 the_swf:null,19 file:null,20 17 errors: 0, 21 18 selected: [], … … 24 21 batch_size: 0, 25 22 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: {},40 23 thumb_cancel: false, 41 24 … … 46 29 failed: [], 47 30 sets: {}, 48 49 to_add: [],50 51 31 ok: 0, 52 32 fail: 0, … … 64 44 normalizeTimeoutId: null, 65 45 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 else78 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 98 46 // Let the user select some files, thumbnail them and track them 99 47 // Patch for saving our place in the directory structure from … … 140 88 while (files.hasMoreElements()) { 141 89 var arg = files.getNext().QueryInterface(Ci.nsILocalFile).path; 142 arg = arg.replace(/\\/g, '\/'); 143 paths.unshift(arg); 90 paths.push(arg); 144 91 } 145 92 photos.add(paths); … … 158 105 }, 159 106 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 165 107 // Add a list of photos 166 108 add: function(paths, silent) { 109 167 110 if (null == silent) { silent = false; } 168 //buttons.upload.disable();111 buttons.upload.disable(); 169 112 170 113 // Tally up photos and videos and remove large videos … … 175 118 var bad = []; 176 119 for each (var p in paths) { 177 var P = p;178 p = p[0];179 120 if (p === null) { 121 continue; 122 } 180 123 var path = 'object' == typeof p ? p.path : p; 181 124 … … 183 126 if (photos.is_photo(path)) { 184 127 ++p_count; 185 new_paths.push( P);128 new_paths.push(p); 186 129 } 187 130 … … 193 136 big_videos.push(null == filename ? path : filename[1]); 194 137 } else { 195 new_paths.push( P);196 } 197 } 198 138 new_paths.push(p); 139 } 140 } 141 199 142 // 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 } 204 147 205 148 } … … 288 231 while (paths.length) { 289 232 var p = paths.shift(); 290 P = p;291 p = p[0];292 293 233 var path = 'object' == typeof p ? p.path : p; 294 234 if (!photos.is_video(path)) { 295 new_paths.push( P);235 new_paths.push(p); 296 236 } 297 237 } … … 303 243 var ii = paths.length; 304 244 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]; 307 247 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; 311 251 } 312 252 } … … 343 283 // Now add whatever's left 344 284 var ii = paths.length; 345 var to_flash = [];346 285 block_normalize(); 347 286 var ext_list = []; 287 var currentPathsLists = photos.list.map(function(x) {return (x ? x.path : "");}); 348 288 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]; 351 291 352 292 // Resolve the path and add the photo … … 355 295 .getService(Ci.nsIFileProtocolHandler) 356 296 .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)); 365 302 366 303 // 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]) { 369 306 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]; 371 308 } 372 309 } 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 386 313 // Do extension stuff after we've added all of the photos but 387 314 // before the list we've saved potentially becomes invalid … … 389 316 390 317 // Update the UI 391 /*392 318 if (photos.count + photos.errors) { 393 319 document.getElementById('t_clear').className = 'button'; … … 419 345 document.getElementById('photos_new').style.display = 'none'; 420 346 } 421 */422 347 unblock_normalize(); 423 348 photos.normalize(); 424 349 425 350 }, 426 351 _add: function(path) { … … 432 357 var id = photos.list.length; 433 358 var p = new Photo(id, path); 434 //p.hash = file.compute_file_hash(path);435 359 photos.list.push(p); 436 360 unblock_normalize(); 437 361 ++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 442 366 // Create a spot for the image, leaving a spinning placeholder 443 367 // Add images to the start of the list because this is our best 444 368 // guess for ordering newest to oldest 445 /*446 369 var img = document.createElementNS(NS_HTML, 'img'); 447 370 img.className = 'loading'; … … 452 375 li.id = 'photo' + id; 453 376 li.appendChild(img); 377 block_normalize(); 454 378 var list = document.getElementById('photos_list'); 455 379 list.insertBefore(li, list.firstChild); 456 */457 458 380 // 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 478 385 return p; 479 480 },481 482 alert: function(s){483 Components.utils.reportError(String(s));484 386 }, 485 387 … … 491 393 492 394 // Nothing to do if somehow there are no selected photos 395 block_normalize(); 493 396 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'; 496 403 // Tell extensions which photos we're removing 497 404 extension.before_remove.exec(photos.selected); … … 500 407 for (var i = 0; i < ii; ++i) { 501 408 var id = photos.selected[i]; 502 /*503 409 var li = document.getElementById('photo' + id); 504 410 if(li) { 505 411 li.parentNode.removeChild(li); 506 412 } 507 */508 413 509 414 // Free the size of this file 510 415 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 } 511 419 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) { 513 421 status.clear(); 514 422 } 515 423 if(photos.is_video(photos.list[id].path)) { 424 --photos.videoCount; 425 } 516 426 photos.list[id] = null; 517 427 --photos.count; 518 428 } 429 unblock_normalize(); 519 430 ui.bandwidth_updated(); 520 431 photos.normalize(); … … 522 433 523 434 // Clear the selection 435 block_normalize(); 524 436 photos.selected = []; 437 unblock_normalize(); 525 438 mouse.click({target: {}}); 526 439 527 440 photos._remove(); 441 document.getElementById('photos').style.display = '-moz-box'; 442 document.getElementById('normalizing').style.display = 'none'; 528 443 }, 529 444 … … 535 450 photos.sort = true; 536 451 buttons.upload.disable(); 537 /*538 452 document.getElementById('photos_sort_default') 539 453 .style.display = 'none'; … … 547 461 document.getElementById('no_meta_prompt') 548 462 .style.visibility = 'hidden'; 549 */550 463 } 551 464 }, … … 555 468 556 469 // Prevent silliness 470 block_normalize(); 557 471 var s = photos.selected; 558 472 var ii = s.length; … … 572 486 block_sort(); 573 487 photos.batch_size -= p.size; 574 575 /*576 488 var img = document.getElementById('photo' + p.id) 577 489 .getElementsByTagName('img')[0]; … … 580 492 img.setAttribute('height', 8); 581 493 img.src = 'chrome://uploadr/skin/balls-16x8-trans.gif'; 582 */583 494 block_normalize(); 584 495 threads.worker.dispatch(new Rotate(p.id, degrees, … … 593 504 }, 594 505 595 // Upload photos506 // Upload photos 596 507 // The arguments will either both be null or both be set 597 508 // If they're both set, this is an automated call to upload by the … … 600 511 var from_user = null == list; 601 512 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;611 513 612 514 // Don't upload if this is a user action and the button is disabled 613 /*614 515 if (from_user && 'disabled_button' == document.getElementById( 615 516 'button_upload').className) { 616 517 return; 617 518 } 618 */ 519 if(ui.cancel) { 520 upload.cancel = true; 521 return upload.done(); 522 } 619 523 620 if(ui.cancel) {621 upload.cancel = true;622 return upload.done();623 }624 625 524 // Remove error indicators 626 /*627 525 block_normalize(); 628 526 var li = document.getElementById('photos_list') … … 635 533 } 636 534 } 637 unblock_normalize(); 638 */ 639 535 unblock_normalize(); 536 640 537 // Decide if we're already in the midst of an upload 641 538 var not_started = 0 == photos.uploading.length; … … 644 541 if (from_user) { 645 542 var new_list = []; 543 var nbVideosToUpload = 0; 646 544 for each (var p in list) { 647 545 if (null == p) { … … 693 591 694 592 // Resize because of user settings 695 /*696 593 if (null != settings.resize && 697 594 -1 != settings.resize && … … 715 612 ready_size += p.size; 716 613 } 717 */718 614 719 615 } … … 742 638 photos.last = null; 743 639 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 } 749 644 unblock_normalize(); 750 645 threads.readyToResize = true; … … 754 649 755 650 // Give some meaningful feedback 756 /*757 651 if (not_started) { 758 652 document.getElementById('footer').style.display = … … 779 673 photos.sets[users.nsid] = meta.sets; 780 674 } 781 */782 675 783 676 return; … … 787 680 // Update the UI 788 681 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; 804 697 } 805 698 806 699 // 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); 808 701 809 702 // Take the list of photos into upload mode and reset the UI … … 825 718 826 719 // Setup progress bar for this photo and show it in the queue 827 /*828 720 var img = document.createElementNS(NS_HTML, 'img'); 829 721 img.src = 'file:///' + encodeURIComponent(p.thumb); … … 840 732 li.appendChild(stack); 841 733 document.getElementById('queue_list').appendChild(li); 842 */843 734 844 735 } … … 855 746 } 856 747 } 857 858 748 if (from_user) { 859 749 photos.batch_size = 0; … … 866 756 unblock_normalize(); 867 757 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(); 880 769 881 770 // Kick off the first batch job if we haven't started … … 892 781 893 782 }, 894 783 895 784 // Normalize the photo list and selected list with the DOM 896 785 normalize: function() { … … 908 797 logStringMessage('normalize [in]'); 909 798 } 910 911 /*912 799 document.getElementById('photos').style.display = 'none'; 913 800 document.getElementById('normalizing').style.display = '-moz-box'; … … 938 825 } 939 826 isNormalizing = false; 940 */ 941 942 }, 943 827 }, 944 828 945 829 // Load saved metadata 946 load: function(){ 947 830 load: function() { 948 831 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 992 833 // Don't bother if there are no photos 993 //if ('undefined' == typeof obj.list) { return; }834 if ('undefined' == typeof obj.list) { return; } 994 835 995 836 // 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); 1005 846 1006 847 // 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 } 1011 851 }, 1012 852 … … 1014 854 // this is desperate move when the uploadr is in unusable state 1015 855 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'; 1019 859 photos.thumb_cancel = true; 1020 860 if (conf.console.thumb) { … … 1022 862 } 1023 863 photos.list = []; 1024 photos.indexed_paths = {},1025 864 photos.selected = []; 1026 865 photos.count = 0; … … 1031 870 _block_sort = _block_remove = _block_normalize = _block_exit = 0; 1032 871 file.remove('photos.json'); 1033 photos.call_swf('reset', []);1034 872 // Remove photos from UI 1035 /*1036 873 block_normalize(); 1037 874 var list = document.getElementById('photos_list'); … … 1041 878 unblock_normalize(); 1042 879 document.getElementById('photos_init').style.display = '-moz-box'; 1043 */1044 880 ui.bandwidth_updated(); 1045 //meta.disable();1046 //buttons.upload.disable();881 meta.disable(); 882 buttons.upload.disable(); 1047 883 }, 1048 884 1049 1050 885 // 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.flash1064 //waiting_on_thumb:waiting_on_thumb1065 });1066 1067 },1068 1069 886 save: function() { 1070 887 if (0 != _block_exit) { return; } 1071 888 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 } 1079 892 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 1087 896 }); 1088 897 unblock_normalize(); 1089 photos.saving = false;1090 photos.thumb_cancel = false;1091 898 }, 1092 899 1093 900 // Decide if a given path is a photo 1094 901 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); 1100 903 }, 1101 904 1102 905 // Similarly, is it a video 1103 906 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); 1108 908 } 1109 909 … … 1112 912 // Setup auto-saving of metadata in case of crashes 1113 913 // See photos.save for problems related to the auto-save interval 1114 /*1115 914 window.setInterval(function() { 1116 915 photos.save(); 1117 916 }, 1000 * conf.auto_save); 1118 */1119 917 1120 918 // Photo properties … … 1142 940 this.hidden = settings.hidden; 1143 941 this.sets = []; 1144 this.is_video = null;1145 942 this.progress_bar = null; 1146 943 this.nsid = null; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js
r590 r592 2 2 * Flickr Uploadr 3 3 * 4 * Copyright (c) 2007-200 8Yahoo! Inc. All rights reserved. This library is4 * Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. This library is 5 5 * free software; you can redistribute it and/or modify it under the terms of 6 6 * the GNU General Public License (GPL), version 2 only. This library is … … 95 95 u.safety_level = isNaN(settings.safety_level) ? 1 : settings.safety_level; 96 96 u.resize = null == settings.resize ? -1 : settings.resize; 97 98 97 } 99 98 100 99 }, 101 100 102 101 // Show the settings dialog 103 102 show: function() { … … 106 105 // the current NSID and the maximum file size string 107 106 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 114 114 // If we're adding a new user, auth// and re-open the dialog 115 115 if (result.add_user) { … … 120 120 // Otherwise, save changes to settings and users 121 121 else if (result.ok) { 122 123 122 124 123 // Replace old users object with new one … … 160 159 safety_level: s.safety_level 161 160 }); 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 }167 161 } else { 168 162 settings.is_public = 1; … … 183 177 } 184 178 185 // If they've changed to a free account and have videos, warn them186 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 200 179 // Get permission to overwrite any changes that were made 201 180 if (0 < photos.count && … … 209 188 210 189 // Save metadata 190 block_normalize(); 211 191 if (1 == photos.selected.length) { 212 192 meta.save(photos.selected[0]); … … 229 209 } 230 210 } 231 211 unblock_normalize(); 232 212 // Videos can't be restricted so either update them or delete them 233 213 if (3 == settings.safety_level) { … … 236 216 var p_count = 0; 237 217 var v_count = 0; 218 block_normalize(); 238 219 for each (var p in photos.list) { 239 220 if (null == p) { … … 246 227 } 247 228 } 248 229 unblock_normalize(); 249 230 // If there are videos, bother them 250 231 if (v_count) { … … 277 258 // Remove selected videos 278 259 if ('cancel' == result.result) { 260 block_normalize(); 279 261 var ii = photos.list.length; 280 262 for (var i = 0; i < ii; ++i) { … … 286 268 li.parentNode.removeChild(li); 287 269 photos.batch_size -= photos.list[i].size; 270 photos.video_batch_size -= photos.list[i].size; 288 271 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) { 290 273 status.clear(); 274 } 275 if(photos.is_video(photos.list[i].path)) { 276 --photos.videoCount; 291 277 } 292 278 photos.list[i] = null; … … 294 280 } 295 281 } 282 unblock_normalize(); 296 283 ui.bandwidth_updated(); 297 284 … … 308 295 // Set a different safety level for videos 309 296 else if ('ok' == result.result && result.safety_level) { 297 block_normalize(); 310 298 var ii = photos.list.length; 311 299 for (var i = 0; i < ii; ++i) { … … 315 303 } 316 304 } 305 unblock_normalize(); 317 306 } 318 307 … … 322 311 323 312 // Refresh visible photo metadata if necessary 313 block_normalize(); 324 314 if (1 == photos.selected.length) { 325 315 meta.load(photos.selected[0]); … … 329 319 meta.batch(); 330 320 } 331 321 unblock_normalize(); 332 322 } 333 323 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.xul
r590 r592 20 20 <!ENTITY % proxyDTD SYSTEM "chrome://uploadr/locale/proxy.dtd"> 21 21 %proxyDTD; 22 <!ENTITY % settingsDTD SYSTEM "chrome://uploadr/content/settings.dtd">23 %settingsDTD;24 22 ]> 25 23 <dialog id="dialog_settings" title="&settings;" buttons="accept,cancel" … … 29 27 xmlns:html="http://www.w3.org/1999/xhtml"> 30 28 <stringbundleset> 31 <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" />29 <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 32 30 </stringbundleset> 33 <script src=" &base.url;settings_dialog.js" />31 <script src="chrome://uploadr/content/settings_dialog.js" /> 34 32 <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;" 38 36 oncommand="settings.add_user();" /> 39 </box>37 </box> 40 38 </vbox> 41 39 <vbox flex="1" id="loggedin"> … … 121 119 </radiogroup> 122 120 </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> 128 122 </vbox> 129 123 </dialog> trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings_dialog.js
r590 r592 132 132 settings.list[settings.nsid].settings.resize = parseInt(value); 133 133 }, 134 base_url: function(value){135 settings.list[settings.nsid].settings.base_url = value;136 },137 134 config_proxy: function(){ 138 135 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 26 26 var threads = { 27 27 28 initialized: false,28 initialized: false, 29 29 // Hooks to threads 30 30 worker: null, 31 31 uploadr: null, 32 32 main: null, 33 indexer: null, 34 saver: null, 33 workerPool: null, 35 34 readyToResize: false, 36 //workers:[], 37 workerPool:null, 38 priorityPool:null, 39 40 // 35 41 36 // GraphicsMagick XPCOM object 42 37 gm: null, … … 44 39 // Create thread hooks and instantiate GraphicsMagick 45 40 init: function() { 46 try { 47 48 threads.misc_init(); 41 try { 49 42 // Threads themselves 50 43 var t = Cc['@mozilla.org/thread-manager;1'].getService(); … … 54 47 threads.uploadr = t.newThread(0); 55 48 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 62 50 // GraphicsMagick, for use on the worker thread 63 51 threads.gm = Cc['@flickr.com/gm;1'].createInstance(Ci.flIGM); … … 66 54 .get('resource:app', Ci.nsIFile).path, UploadProgressHandler); 67 55 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; 70 57 } catch (err) { 71 58 Components.utils.reportError(new Date().toUTCString() +err); … … 89 76 } 90 77 } 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);103 78 } 104 79 … … 107 82 // Thumbnail thread wrapper 108 83 var Thumb = function(id, thumb_size, path, auto_select) { 109 photos.thumb_thread_counter+=1;110 84 this.id = id; 111 85 this.thumb_size = thumb_size; … … 113 87 this.auto_select = null == auto_select ? false : auto_select; 114 88 }; 115 116 89 Thumb.prototype = { 117 90 run: function() { 118 if(photos.thumb_cancel === true)119 return;91 if(photos.thumb_cancel === true) 92 return; 120 93 var result = ''; 121 94 … … 155 128 this.auto_select = auto_select; 156 129 }; 157 158 130 ThumbCallback.prototype = { 159 131 run: function() { 160 132 if (photos.thumb_cancel === true) 161 return;133 return; 162 134 try { 163 135 if (conf.console.thumb) { … … 172 144 173 145 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); 178 150 179 151 // If successful, replace with the thumb and update the … … 184 156 var ii = thumb.length; 185 157 for (var i = 0; i < ii; ++i) { 186 thumb[i] = thumb[i]; //why?158 thumb[i] = thumb[i]; 187 159 } 188 160 … … 225 197 photos.list[this.id].thumb_width = parseInt(thumb[4]); 226 198 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]); 229 201 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); 232 204 if (conf.console.thumb) { 233 205 logStringMessage('GM THUMB: path ' + img.src + " " + thumbPath); 234 }206 } 235 207 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 }243 208 244 209 // Make video icons for videos 245 210 // This will look funny for a portrait-oriented video 246 /*247 211 if (photos.is_video(photos.list[this.id].path)) { 248 212 var icon = document.createElementNS(NS_HTML, 'img'); … … 254 218 img.parentNode.appendChild(icon); 255 219 } 256 */257 220 258 221 // Title/tags/description … … 331 294 } 332 295 ui.bandwidth_updated(); 333 296 334 297 } 335 298 336 299 // If unsuccessful, replace with the error image 337 300 else { 338 /*339 301 img.setAttribute('src', 340 302 'chrome://uploadr/skin/icon_alert.png'); … … 359 321 } 360 322 }; 361 */362 323 Components.utils.reportError(new Date().toUTCString() +this.result); 363 324 } 364 325 365 326 // After updating, make it visible again 366 //img.style.visibility = 'visible';327 img.style.visibility = 'visible'; 367 328 368 329 } catch (err) { 369 330 Components.utils.reportError(new Date().toUTCString() +err); 370 331 } 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(); 380 333 // Tell extensions that we got a new thumbnail 381 334 extension.after_thumb.exec(this.id); 382 // and sync the view as well335 // and synch the view as well 383 336 photos.normalize(); 384 337 385 338 unblock_sort(); 386 339 if(photos.sort && !_block_sort) { // hack hack :( 387 threads.worker.dispatch(new Sort(),340 threads.worker.dispatch(new Sort(), 388 341 threads.worker.DISPATCH_NORMAL); 389 342 } … … 405 358 this.path = path; 406 359 }; 407 408 360 Rotate.prototype = { 409 361 run: function() { … … 464 416 var Sort = function() { 465 417 }; 466 467 418 Sort.prototype = { 468 419 run: function() { … … 531 482 // This is far from being a bottleneck, so leave it alone 532 483 // until it is 533 /*534 484 var list = document.getElementById('photos_list'); 535 485 for (var i = p.length - 1; i >= 0; --i) { … … 538 488 } 539 489 } 540 */541 542 490 unblock_normalize(); 543 491 if(conf.console.sort) { … … 567 515 this.path = path; 568 516 }; 569 570 517 Resize.prototype = { 571 518 run: function() { 572 519 try { 573 574 520 // Resize the image and callback to the UI thread 575 521 if(ui.cancel) … … 594 540 this.result = result; 595 541 }; 596 597 542 ResizeCallback.prototype = { 598 543 run: function() { … … 613 558 614 559 if (null == resize) { 615 Components.utils.reportError(new Date().toUTCString() + ' ' +this.result);560 Components.utils.reportError(new Date().toUTCString() +this.result); 616 561 } else { 617 562 list = photos.ready[photos.ready.length - 1]; … … 641 586 642 587 // 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 slower684 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.leafName732 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 * photos738 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 directory777 //has been exhausted, so mark it778 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 to783 //num_each_time*multiplier784 //directories785 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); // silent811 //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 queue827 588 var EnableUpload = function() { 828 589 }; … … 928 689 } 929 690 }; 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 2 3 * 3 4 * Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. This library is 4 5 * free software; you can redistribute it and/or modify it under the terms of 5 6 6 * the GNU General Public License (GPL), version 2 only. This library is 7 7 * distributed WITHOUT ANY WARRANTY, whether express or implied. See the GNU … … 10 10 11 11 // A bit of a catch-all, but better than it was before 12 //var the_swf = {};13 14 12 var ui = { 15 13 16 14 cancel: false, 15 confirmUp: false, 16 promptUp: false, 17 17 18 18 // Called at app startup … … 20 20 21 21 // 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'); 24 24 25 25 26 26 // 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'); 29 29 30 30 // Sneaky reformatting of help text 31 /*32 31 for each (var id in ['help_offline', 'help_drag']) { 33 32 var node = document.getElementById(id); … … 51 50 node.appendChild(span); 52 51 node.appendChild(document.createTextNode(parts[2])); 53 */54 52 55 53 }, … … 61 59 62 60 // Notes in the empty photo pane 63 /*64 61 var notes = document.getElementById('photos_init_notes'); 65 62 while (notes.hasChildNodes()) { … … 85 82 document.getElementById('photos_init_prompt') 86 83 .firstChild.nodeValue = locale.getString('photos.init.pro'); 87 */88 84 }, 89 85 … … 91 87 bandwidth_updated: function() { 92 88 93 //short circuit94 return;95 96 89 // Counter for remaining bandwidth 97 90 if (users.bandwidth && !users.is_pro) { … … 153 146 display = 'none'; 154 147 } 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; 168 150 } 169 151 170 152 // Only the photos page has the toolbar 171 /*172 153 if ('photos' == id) { 173 154 document.getElementById('tools').style.display = '-moz-box'; … … 177 158 document.getElementById('bw_batch').style.display = 'none'; 178 159 } 179 */180 160 181 161 }, … … 222 202 223 203 about: function() { 204 //photos.normalize(); 224 205 window.openDialog('chrome://uploadr/content/about.xul', 225 206 'about-dialog', 'chrome,modal,centerscreen', … … 391 372 var isNormalizing = false; 392 373 var block_normalize = function() { 393 /*394 374 while(isNormalizing) { 395 375 logStringMessage('block_normalize while already normalizing'); … … 398 378 .currentThread.processNextEvent(true); 399 379 } 400 */401 380 ++_block_normalize; 402 381 }; … … 404 383 var unblock_normalize = function() { 405 384 --_block_normalize; 406 /*407 385 if(_block_normalize < 0) { 408 386 logStringMessage("extra unblock_normalize :-("); 409 387 } 410 */ 411 }; 412 388 }; 413 389 var _block_exit = 0; 414 390 var block_exit = function() { … … 433 409 return false; 434 410 } 435 436 // Shutdown threads437 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 swf458 //the_swf = document.getElementById('the_swf');459 photos.flash = photos.call_swf('get_flash_obj', []);460 461 411 462 412 // 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(); 471 416 472 417 // Remove the images and TEMP directories if there are no photos left 473 /*474 418 if (0 == photos.count) { 475 419 try { … … 496 440 } catch (err) {} 497 441 } 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) {} 508 453 509 454 // Finally exit 510 455 var e = Cc['@mozilla.org/toolkit/app-startup;1'] 511 456 .getService(Ci.nsIAppStartup); 512 513 457 e.quit(Ci.nsIAppStartup.eForceQuit); 514 458 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js
r590 r592 77 77 // Upload a photo 78 78 start: function(id) { 79 80 79 //reset upload progress 81 80 upload.progress_id = -1; 82 81 83 82 // Update the UI 84 /*85 83 if (null == upload.progress_bar) { 86 84 document.getElementById('footer').style.display = '-moz-box'; … … 90 88 progress_text.value = ''; 91 89 } 92 */93 90 94 91 var photo = photos.uploading[id]; … … 157 154 } 158 155 upload.progress_zero = 0; 159 photos.call_swf('update_upload_progress', [photos.uploading[id].id, 1]);160 161 156 // If no ticket came back, fail this photo 162 157 if ('object' != typeof rsp || 'ok' != rsp.getAttribute('stat')) { … … 215 210 // Otherwise, spin for a ticket 216 211 if (null != photos.uploading[id]) { 217 //photos.uploading[id].progress_bar.done(true);212 photos.uploading[id].progress_bar.done(true); 218 213 upload.tickets[rsp.getElementsByTagName('ticketid')[0] 219 214 .firstChild.nodeValue] = { … … 226 221 window.clearTimeout(upload.tickets_handle); 227 222 upload.tickets_handle = null; 228 upload.tickets_delta = 1000;223 upload.tickets_delta = 1000; 229 224 } 230 225 upload.tickets_retry_count = 0; … … 247 242 // Finish a synchronous upload 248 243 _sync: function(rsp, id) { 249 244 250 245 // Stop checking progress if we're in synchronous mode 251 246 if ('sync' == conf.mode) { … … 256 251 upload.progress_zero = 0; 257 252 } 258 253 259 254 // How did the upload go? 260 255 var photo_id; … … 270 265 if ('ok' == stat) { 271 266 if (null != photos.uploading[id]) { 272 //photos.uploading[id].progress_bar.done(true);267 photos.uploading[id].progress_bar.done(true); 273 268 ++photos.ok; 274 269 } … … 414 409 status.set(locale.getString('status.uploading') + ' ' + 415 410 (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 } 422 414 var percent = Math.max(0, Math.min(1, 423 415 photos.kb.sent / photos.kb.total)); 424 425 416 if (null != upload.progress_bar) { 426 //upload.progress_bar.update(percent); 427 } 428 417 upload.progress_bar.update(percent); 418 } 429 419 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'); 432 422 upload.processing = true; 433 423 } 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 ]); 440 430 } 441 431 … … 485 475 6 == parseInt(rsp.getElementsByTagName('err')[0] 486 476 .getAttribute('code'))) { 487 //document.getElementById('progress').style.display = 'none';477 document.getElementById('progress').style.display = 'none'; 488 478 var f = photos.failed; 489 479 for each (var p in photos.uploading) { … … 492 482 var ii = f.length; 493 483 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'; 498 488 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'; 503 493 } 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'; 508 498 } 509 499 } … … 523 513 } 524 514 } 525 unblock_normalize();515 unblock_normalize(); 526 516 527 517 photos.uploading = []; … … 560 550 // Update the UI 561 551 if (null != upload.progress_bar) { 562 //upload.progress_bar.update(1);552 upload.progress_bar.update(1); 563 553 } 564 554 var text = document.getElementById('progress_text'); … … 571 561 } 572 562 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 } 577 567 status.clear(); 578 568 … … 618 608 // Finally give the user feedback on their upload 619 609 finalize: function() { 610 if(conf.console.upload) { 611 logStringMessage('finalize'); 612 } 620 613 status.clear(); 621 614 … … 707 700 708 701 // 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'; 711 704 712 705 // If requested, open the site 713 706 if (go_to_flickr) { 714 707 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);718 708 } 719 709 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js
r590 r592 87 87 88 88 // Update the UI 89 /*90 89 document.getElementById('username').firstChild.nodeValue = 91 90 locale.getFormattedString('username', [users.username]) + ' '; … … 96 95 status.set(locale.getString('status.ready')); 97 96 meta.login(); 98 */99 97 100 98 // Check the command line … … 127 125 128 126 // Update the UI 129 /*130 127 document.getElementById('username').firstChild.nodeValue = 131 128 locale.getString('notloggedin') + ' '; … … 140 137 'http://flickr.com/images/buddyicon.jpg'; 141 138 document.getElementById('photostream_pro').style.display = 'none'; 142 */143 photos.call_swf('logged_in', [null]);144 139 145 140 }, … … 170 165 users.nbVids, users.videosize, users.sets); 171 166 } 172 photos.call_swf("logged_in", [users.list[users.nsid]]);173 167 174 168 }, … … 199 193 save: function() { 200 194 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 } 209 196 210 197 };