Changeset 590
- Timestamp:
- 04/07/09 02:00:40 (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 (added)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js (modified) (3 diffs)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/flash (added)
- trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/flash/Desktop.swf (added)
- 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 (added)
- 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 (added)
- trunk/uploadr/flash/dev (added)
- trunk/uploadr/flash/dev/compile.bat (added)
- trunk/uploadr/flash/dev/run.bat (added)
- trunk/uploadr/flash/src (added)
- trunk/uploadr/flash/src/AbstractView.as (added)
- trunk/uploadr/flash/src/Debug.as (added)
- trunk/uploadr/flash/src/Desktop.as (added)
- trunk/uploadr/flash/src/Desktop_324609.cache (added)
- trunk/uploadr/flash/src/Globals.as (added)
- trunk/uploadr/flash/src/ItemLoader.as (added)
- trunk/uploadr/flash/src/JavaScriptInterface.as (added)
- trunk/uploadr/flash/src/KeyboardControls.as (added)
- trunk/uploadr/flash/src/LS.as (added)
- trunk/uploadr/flash/src/Layout.as (added)
- trunk/uploadr/flash/src/LayoutObject.as (added)
- trunk/uploadr/flash/src/LayoutWrapper.as (added)
- trunk/uploadr/flash/src/Library.as (added)
- trunk/uploadr/flash/src/Model.as (added)
- trunk/uploadr/flash/src/Output.as (added)
- trunk/uploadr/flash/src/S.as (added)
- trunk/uploadr/flash/src/caurina (added)
- trunk/uploadr/flash/src/caurina/transitions (added)
- trunk/uploadr/flash/src/caurina/transitions/AuxFunctions.as (added)
- trunk/uploadr/flash/src/caurina/transitions/Equations.as (added)
- trunk/uploadr/flash/src/caurina/transitions/PropertyInfoObj.as (added)
- trunk/uploadr/flash/src/caurina/transitions/SpecialProperty.as (added)
- trunk/uploadr/flash/src/caurina/transitions/SpecialPropertyModifier.as (added)
- trunk/uploadr/flash/src/caurina/transitions/SpecialPropertySplitter.as (added)
- trunk/uploadr/flash/src/caurina/transitions/TweenListObj.as (added)
- trunk/uploadr/flash/src/caurina/transitions/Tweener.as (added)
- trunk/uploadr/flash/src/caurina/transitions/properties (added)
- trunk/uploadr/flash/src/caurina/transitions/properties/ColorShortcuts.as (added)
- trunk/uploadr/flash/src/caurina/transitions/properties/CurveModifiers.as (added)
- trunk/uploadr/flash/src/caurina/transitions/properties/DisplayShortcuts.as (added)
- trunk/uploadr/flash/src/caurina/transitions/properties/FilterShortcuts.as (added)
- trunk/uploadr/flash/src/caurina/transitions/properties/SoundShortcuts.as (added)
- trunk/uploadr/flash/src/caurina/transitions/properties/TextShortcuts.as (added)
- trunk/uploadr/flash/src/com (added)
- trunk/uploadr/flash/src/com/adobe (added)
- trunk/uploadr/flash/src/com/adobe/crypto (added)
- trunk/uploadr/flash/src/com/adobe/crypto/MD5.as (added)
- trunk/uploadr/flash/src/com/adobe/crypto/SHA1.as (added)
- trunk/uploadr/flash/src/com/adobe/crypto/SHA224.as (added)
- trunk/uploadr/flash/src/com/adobe/crypto/SHA256.as (added)
- trunk/uploadr/flash/src/com/adobe/crypto/WSSEUsernameToken.as (added)
- trunk/uploadr/flash/src/com/adobe/errors (added)
- trunk/uploadr/flash/src/com/adobe/errors/IllegalStateError.as (added)
- trunk/uploadr/flash/src/com/adobe/images (added)
- trunk/uploadr/flash/src/com/adobe/images/BitString.as (added)
- trunk/uploadr/flash/src/com/adobe/images/JPGEncoder.as (added)
- trunk/uploadr/flash/src/com/adobe/images/PNGEncoder.as (added)
- trunk/uploadr/flash/src/com/adobe/net (added)
- trunk/uploadr/flash/src/com/adobe/net/DynamicURLLoader.as (added)
- trunk/uploadr/flash/src/com/adobe/net/IURIResolver.as (added)
- trunk/uploadr/flash/src/com/adobe/net/URI.as (added)
- trunk/uploadr/flash/src/com/adobe/net/URIEncodingBitmap.as (added)
- trunk/uploadr/flash/src/com/adobe/net/proxies (added)
- trunk/uploadr/flash/src/com/adobe/net/proxies/RFC2817Socket.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSON.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSONDecoder.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSONEncoder.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSONParseError.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSONToken.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSONTokenType.as (added)
- trunk/uploadr/flash/src/com/adobe/serialization/json/JSONTokenizer.as (added)
- trunk/uploadr/flash/src/com/adobe/utils (added)
- trunk/uploadr/flash/src/com/adobe/utils/ArrayUtil.as (added)
- trunk/uploadr/flash/src/com/adobe/utils/DateUtil.as (added)
- trunk/uploadr/flash/src/com/adobe/utils/DictionaryUtil.as (added)
- trunk/uploadr/flash/src/com/adobe/utils/IntUtil.as (added)
- trunk/uploadr/flash/src/com/adobe/utils/NumberFormatter.as (added)
- trunk/uploadr/flash/src/com/adobe/utils/StringUtil.as (added)
- trunk/uploadr/flash/src/com/adobe/utils/XMLUtil.as (added)
- trunk/uploadr/flash/src/com/adobe/webapis (added)
- trunk/uploadr/flash/src/com/adobe/webapis/ServiceBase.as (added)
- trunk/uploadr/flash/src/com/adobe/webapis/URLLoaderBase.as (added)
- trunk/uploadr/flash/src/com/adobe/webapis/events (added)
- trunk/uploadr/flash/src/com/adobe/webapis/events/ServiceEvent.as (added)
- trunk/uploadr/flash/src/com/deviant (added)
- trunk/uploadr/flash/src/com/deviant/HueColorMatrixFilter.as (added)
- trunk/uploadr/flash/src/data (added)
- trunk/uploadr/flash/src/data/FlickrAPI.as (added)
- trunk/uploadr/flash/src/data/FlickrAPI.as.old (added)
- trunk/uploadr/flash/src/data/Info.as (added)
- trunk/uploadr/flash/src/data/Photo.as (added)
- trunk/uploadr/flash/src/data/Request.as (added)
- trunk/uploadr/flash/src/data/Show.as (added)
- trunk/uploadr/flash/src/library.fla (added)
- trunk/uploadr/flash/src/library.swf (added)
- trunk/uploadr/flash/src/widget (added)
- trunk/uploadr/flash/src/widget/ActionBar.as (added)
- trunk/uploadr/flash/src/widget/CloseButton.as (added)
- trunk/uploadr/flash/src/widget/Grid.as (added)
- trunk/uploadr/flash/src/widget/HorizontalScrollBar.as (added)
- trunk/uploadr/flash/src/widget/Link.as (added)
- trunk/uploadr/flash/src/widget/List.as (added)
- trunk/uploadr/flash/src/widget/ListItem.as (added)
- trunk/uploadr/flash/src/widget/Option.as (added)
- trunk/uploadr/flash/src/widget/PhotoGrid.as (added)
- trunk/uploadr/flash/src/widget/PhotoItem.as (added)
- trunk/uploadr/flash/src/widget/Preview.as (added)
- trunk/uploadr/flash/src/widget/ScrollBar.as (added)
- trunk/uploadr/flash/src/widget/SelectableText.as (added)
- trunk/uploadr/flash/src/widget/SetList.as (added)
- trunk/uploadr/flash/src/widget/Text.as (added)
- trunk/uploadr/flash/src/widget/Title.as (added)
- trunk/uploadr/flash/src/widget/TopBar.as (added)
- trunk/uploadr/flash/src/widget/TopButton.as (added)
- trunk/uploadr/flash/src/widget/Transparent.as (added)
- trunk/uploadr/flash/src/widget/UploadLink.as (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/api.js
r544 r590 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 /* 371 372 var ii = meta.sets.length; 372 373 var prefixes = ['single', 'batch']; … … 412 413 } 413 414 } 414 unblock_normalize(); 415 unblock_normalize(); 416 */ 417 415 418 } 416 419 status.clear(); trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/buttons.js
r540 r590 2 2 * Flickr Uploadr 3 3 * 4 * Copyright (c) 2007-200 9Yahoo! Inc. All rights reserved. This library is4 * Copyright (c) 2007-2008 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('button_upload').style.display = 'block';56 document.getElementById('menu_upload').disabled = false;54 //document.getElementById('button_upload').className = 'button'; 55 //document.getElementById('menu_upload').disabled = false; 56 //document.getElementById('menu_upload').disabled = false; 57 57 } 58 58 }, 59 59 disable: function() { 60 document.getElementById('button_upload').className = 'disabled_button';61 document.getElementById('button_upload').style.display = 'none';62 document.getElementById('menu_upload').disabled = true;60 //document.getElementById('button_upload').className = 'disabled_button'; 61 //document.getElementById('menu_upload').disabled = true; 62 //document.getElementById('menu_upload').disabled = true; 63 63 }, 64 64 click: function() { trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/clh.js
r501 r590 20 20 queue = comp.getQueue(); 21 21 } 22 photos.add(queue.split('|||||'), silent); 22 var Q = queue.split('|||||'); 23 if(Q.length > 0) 24 photos.add(Q, silent); 23 25 }; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/conf.js
r583 r590 2 2 * Flickr Uploadr 3 3 * 4 * Copyright (c) 2007-200 9Yahoo! Inc. All rights reserved. This library is4 * Copyright (c) 2007-2008 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:'', 32 33 33 34 app_ini: {}, … … 47 48 }, 48 49 49 // Size of threads pool for thumbnailing 50 maxThreadsCount: 5, 51 50 // Size of threads pool for thumbnailing 51 maxThreadsCount: 1, 52 52 // Scrolling threshold for dragging (pixels); 53 53 scroll: 20, … … 80 80 tickets_retry_count: 10, 81 81 82 83 84 82 // 85 83 // Feature switches … … 90 88 socket_uploadr: true, 91 89 92 93 94 90 // 95 91 // Not advised to change below here … … 98 94 // Size of thumbnails 99 95 // Changing this will require CSS tweaks 100 thumb_size: 100,96 thumb_size: 200, 101 97 102 98 // Upload mode … … 109 105 110 106 // Load are parse the application.ini file 111 load_ini: function(){ 112 // window.openDialog('http://beta2.flickr.com','_blank','modal'); 107 load_ini: function(bu){ 113 108 109 conf.base_url = bu; 110 114 111 var f = Components.classes["@mozilla.org/file/directory_service;1"] 115 112 .getService(Components.interfaces.nsIProperties) … … 153 150 } 154 151 155 152 156 153 // use some of the parsed options 157 154 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js
r510 r590 40 40 41 41 // Write an object into a file as JSON 42 write: function(name, data) { 43 var profile = Cc['@mozilla.org/file/directory_service;1'] 44 .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 45 profile.append(name); 42 write: function(name, data, f) { 43 if(!f){ 44 var profile = Cc['@mozilla.org/file/directory_service;1'] 45 .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 46 profile.append(name); 47 } 48 else{ 49 profile = f; 50 } 46 51 var _stream = Cc['@mozilla.org/network/file-output-stream;1'] 47 52 .createInstance(Ci.nsIFileOutputStream); … … 80 85 _stream.close(); 81 86 }, 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 }, 82 108 83 109 // File size in kilobytes … … 94 120 }, 95 121 96 // Delete97 remove: function(name) {98 try {99 var file = Cc['@mozilla.org/file/directory_service;1']122 // Delete 123 remove: function(name) { 124 try { 125 var file = Cc['@mozilla.org/file/directory_service;1'] 100 126 .getService(Ci.nsIProperties).get('ProfD', Ci.nsIFile); 101 127 file.append(name); 102 128 if (file.exists()) { 103 file.remove(false);129 file.remove(false); 104 130 } 105 } catch (err) { 106 Components.utils.reportError(new Date().toUTCString() +err); 107 } 108 } 131 } catch (err) { 132 Components.utils.reportError(new Date().toUTCString() +err); 133 } 134 }, 135 136 save_from_url: function(url, file_name){ 137 var ioserv = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); 138 var channel = ioserv.newChannel(url+'?'+Math.random(), 0, null); 139 var stream = channel.open(); 140 141 if (channel instanceof Components.interfaces.nsIHttpChannel && channel.responseStatus != 200) { 142 return false; 143 } 144 145 var bstream = Components.classes["@mozilla.org/binaryinputstream;1"] 146 .createInstance(Components.interfaces.nsIBinaryInputStream); 147 bstream.setInputStream(stream); 148 149 150 var size = 0; 151 var file_data = ""; 152 while(size = bstream.available()) { 153 file_data += bstream.readBytes(size); 154 } 155 file.save_to_chrome(file_data, file_name) 156 return true; 157 }, 158 159 save_to_chrome: function(data, file_name){ 160 var profile = Cc['@mozilla.org/file/directory_service;1'] 161 .getService(Ci.nsIProperties).get('AChrom', Ci.nsILocalFile); 162 163 profile.append('content'); 164 profile.append('uploadr'); 165 try{ 166 for(var i=0;i<file_name.length;i++) 167 profile.append(file_name[i]); 168 } 169 catch(err){ 170 profile.initWithPath(profile.path + file_name); 171 } 172 173 var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); 174 stream.init(profile, 0x02 | 0x08 | 0x20, 0600, 0); // write, create, truncate 175 176 stream.write(data, data.length); 177 178 if (stream instanceof Ci.nsISafeOutputStream) { 179 stream.finish(); 180 } else { 181 stream.close(); 182 } 183 184 185 }, 186 187 compute_file_hash: function(path){ 188 var f = Components.classes["@mozilla.org/file/local;1"] 189 .createInstance(Components.interfaces.nsILocalFile); 190 f.initWithPath(path); 191 var istream = Components.classes["@mozilla.org/network/file-input-stream;1"] 192 .createInstance(Components.interfaces.nsIFileInputStream); 193 // open for reading 194 istream.init(f, 0x01, 0444, 0); 195 var ch = Components.classes["@mozilla.org/security/hash;1"] 196 .createInstance(Components.interfaces.nsICryptoHash); 197 // we want to use the MD5 algorithm 198 ch.init(ch.MD5); 199 // this tells updateFromStream to read the entire file 200 const PR_UINT32_MAX = 0xffffffff; 201 ch.updateFromStream(istream, PR_UINT32_MAX); 202 // pass false here to get binary data back 203 var hash = ch.finish(false); 204 205 // return the two-digit hexadecimal code for a byte 206 function toHexString(charCode) 207 { 208 return ("0" + charCode.toString(16)).slice(-2); 209 } 210 211 // convert the binary hash data to a hex string. 212 var s = [toHexString(hash.charCodeAt(i)) for (i in hash)].join(""); 213 // s now contains your hash in hex 214 return s; 215 }, 216 217 get_standard_path: function(s){ 218 try{ 219 var f = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get(s, Ci.nsIFile) 220 }catch(e){ 221 Components.utils.reportError(String(s)); 222 Components.utils.reportError(e); 223 return ''; 224 } 225 return f.path; 226 }, 227 228 get_excluded_directories: function(){ 229 return [file.get_standard_path('AChrom'), file.get_standard_path('TmpD'), file.get_standard_path('ProfLD')] 230 } 231 109 232 }; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js
r544 r590 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
r508 r590 4 4 Flickr Uploadr 5 5 6 Copyright (c) 2007-200 9Yahoo! Inc. All rights reserved. This library is6 Copyright (c) 2007-2008 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 13 20 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 14 21 <?xml-stylesheet href="chrome://uploadr/skin/main.css" type="text/css"?> 15 22 <!--<?xml-stylesheet href="chrome://hacks/skin/hacks.css" type="text/css"?>--> 16 < ?xul-overlay href="chrome://uploadr/content/photos.xul"?>17 <?xul-overlay href=" chrome://uploadr/content/help.xul"?>23 <!--<?xul-overlay href="chrome://uploadr/content/photos.xul"?>--> 24 <?xul-overlay href="&base.url;help.xul"?> 18 25 <?xul-overlay href="chrome://hacks/content/keyboard.xul"?> 19 <!DOCTYPE window SYSTEM "chrome://uploadr/locale/main.dtd"> 26 27 20 28 <window id="main" title="&title;" width="960" height="700" windowtype="app" 21 29 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 22 30 xmlns:html="http://www.w3.org/1999/xhtml" 23 onload="conf.load_ini( ); threads.init(); users.load(); photos.load(); ui.init();ui.users_updated();"31 onload="conf.load_ini('&base.url;'); threads.init(); users.load(); ui.users_updated();" 24 32 onclose="return exit();" persist="screenX screenY width height sizemode" 25 > 33 > 34 <!-- removed photos.load(); ui.init(); from onload, flash calls them--> 35 26 36 <stringbundleset> 27 37 <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 38 <stringbundle id="locale" src="chrome://uploadr/content/main.prefs" /> 28 39 </stringbundleset> 40 <head> 41 29 42 <script src="chrome://global/content/globalOverlay.js" /> 30 43 <script src="chrome://global/content/nsDragAndDrop.js" /> 31 44 <script src="chrome://global/content/nsUserSettings.js" /> 32 <script src="chrome://uploadr/content/ui.js" /> 33 <script src="chrome://uploadr/content/conf.js" /> 34 <script src="chrome://uploadr/content/clh.js" /> 35 <script src="chrome://uploadr/content/upgrade.js" /> 36 <script src="chrome://uploadr/content/file.js" /> 37 <script src="chrome://uploadr/content/threads.js" /> 38 <script src="chrome://uploadr/content/flickr.js" /> 39 <script src="chrome://uploadr/content/api.js" /> 40 <script src="chrome://uploadr/content/upload.js" /> 41 <script src="chrome://uploadr/content/photos.js" /> 42 <script src="chrome://uploadr/content/meta.js" /> 43 <script src="chrome://uploadr/content/settings.js" /> 44 <script src="chrome://uploadr/content/users.js" /> 45 <script src="chrome://uploadr/content/drag.js" /> 46 <script src="chrome://uploadr/content/grid.js" /> 47 <script src="chrome://uploadr/content/mouse.js" /> 48 <script src="chrome://uploadr/content/keyboard.js" /> 49 <script src="chrome://uploadr/content/buttons.js" /> 50 <script src="chrome://uploadr/content/extension.js" /> 45 46 <script src="&base.url;conf.js" /> 47 <script src="&base.url;clh.js" /> 48 <script src="&base.url;threads.js" /> 49 <script src="&base.url;upgrade.js" /> 50 <script src="&base.url;file.js" /> 51 <script src="&base.url;flickr.js" /> 52 <script src="&base.url;api.js" /> 53 <script src="&base.url;upload.js" /> 54 <script src="&base.url;photos.js" /> 55 <script src="&base.url;meta.js" /> 56 <script src="&base.url;settings.js" /> 57 <script src="&base.url;users.js" /> 58 <script src="&base.url;ui.js" /> 59 <script src="&base.url;drag.js" /> 60 <script src="&base.url;grid.js" /> 61 <script src="&base.url;mouse.js" /> 62 <script src="&base.url;keyboard.js" /> 63 <script src="&base.url;buttons.js" /> 64 <script src="&base.url;extension.js" /> 65 66 </head> 51 67 <!--<script src="chrome://venkman/content/venkman-overlay.js"/>--> 52 68 <keyset id="key"> … … 78 94 <menuitem label="&menu.upload.add;" key="key_add" accesskey="A" oncommand="photos.add_dialog();" /> 79 95 <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()" /> 80 97 <menuitem id="menu_FileQuitItem" label="&menu.upload.exit;" key="key_quit" accesskey="Q" oncommand="exit();" /> 81 98 </menupopup> … … 112 129 <vbox flex="1"> 113 130 114 <!-- Header --> 115 <hbox id="head"> 116 <hbox id="tools"> 117 <vbox> 118 <spacer flex="1" /> 119 <html:div id="t_add" class="button" onclick="photos.add_dialog();"> 120 <html:div>&tools.add;</html:div> 121 </html:div> 122 <spacer flex="1" /> 123 </vbox> 124 <vbox> 125 <spacer flex="1" /> 126 <html:div id="t_remove" class="disabled_button" onclick="photos.remove();"> 127 <html:div>&tools.remove;</html:div> 128 </html:div> 129 <spacer flex="1" /> 130 </vbox> 131 <vbox> 132 <spacer flex="1" /> 133 <html:div id="t_clear" class="disabled_button" onclick="photos.removeAll();"> 134 <html:div>&tools.clear;</html:div> 135 </html:div> 136 <spacer flex="1" /> 137 </vbox> 138 <html:div class="toolbarseparator" /> 139 <vbox> 140 <html:div id="t_rotate_l" class="disabled" onclick="photos.rotate(-90);" /> 141 </vbox> 142 <vbox> 143 <html:div id="t_rotate_r" class="disabled" onclick="photos.rotate(90);" /> 144 </vbox> 145 </hbox> 146 <box> 147 <html:p id="free"> </html:p> 148 </box> 149 <box flex="1" /> 150 <vbox id="bw_remaining"> 151 <html:p>&bandwidth.remaining;</html:p> 152 <html:h3 id="bw_remaining_mb"> </html:h3> 153 </vbox> 154 <vbox id="bw_batch"> 155 <html:p>&bandwidth.batch;</html:p> 156 <html:h3 id="bw_batch_mb"> </html:h3> 157 </vbox> 158 <box id="logo" /> 159 </hbox> 131 132 133 <stack flex="1"> 134 <vbox id="page_photos" flex="1"> 135 <html:embed id="the_swf" flex="1"/> 136 </vbox> 137 160 138 161 <!-- Placeholder for photos and metadata overlay -->162 <vbox id="page_photos" flex="1" />163 139 164 140 <!-- Page to show during authorization --> … … 181 157 <!-- Placeholder for help page --> 182 158 <vbox id="page_help" flex="1" /> 159 </stack> 183 160 184 161 <!-- Upload progress bar and (hidden) upload queue --> trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js
r546 r590 85 85 86 86 // Blank slate metadata 87 document.getElementById('batch_title').value = ''; 88 document.getElementById('batch_description').value = ''; 89 document.getElementById('batch_tags').value = ''; 90 document.getElementById('batch_is_public').value = 2; 91 var is_friend = document.getElementById('batch_is_friend'); 92 is_friend.checked = false; 93 is_friend.disabled = true; 94 var is_family = document.getElementById('batch_is_family'); 95 is_family.checked = false; 96 is_family.disabled = true; 97 document.getElementById('batch_content_type').value = 0; 98 document.getElementById('batch_hidden').value = 0; 87 var s = photos.selected; 88 var title = photos.list[s[0]].title; 89 var description = photos.list[s[0]].description; 90 var tags = photos.list[s[0]].tags; 91 var is_public = photos.list[s[0]].is_public; 92 var is_friend = photos.list[s[0]].is_friend; 93 var is_family = photos.list[s[0]].is_family; 94 var content_type = photos.list[s[0]].content_type; 95 var hidden = photos.list[s[0]].hidden; 96 var safety_level = photos.list[s[0]].safety_level; 97 for(var j in s){ 98 if(title != photos.list[s[j]].title) 99 title = ''; 100 if(description != photos.list[s[j]].description) 101 description = ''; 102 if(tags != photos.list[s[j]].tags) 103 tags = ''; 104 if(is_public != photos.list[s[j]].is_public) 105 is_public = 2; 106 if(is_friend != photos.list[s[j]].is_friend) 107 is_friend = 0; 108 if(is_family != photos.list[s[j]].is_family) 109 is_family = 0; 110 if(content_type != photos.list[s[j]].content_type) 111 content_type = 0; 112 if(hidden != photos.list[s[j]].hidden) 113 hidden = 0; 114 if(safety_level != photos.list[s[j]].safety_level) 115 safety_level = 0; 116 } 117 118 document.getElementById('batch_title').value = title; 119 document.getElementById('batch_description').value = description; 120 document.getElementById('batch_tags').value = tags; 121 document.getElementById('batch_is_public').value = is_public; 122 123 if(is_public!=0){ 124 var is_friend = document.getElementById('batch_is_friend'); 125 is_friend.checked = false; 126 is_friend.disabled = true; 127 var is_family = document.getElementById('batch_is_family'); 128 is_family.checked = false; 129 is_family.disabled = true; 130 } 131 else{ 132 var is_friend = document.getElementById('batch_is_friend'); 133 is_friend.checked = is_friend; 134 is_friend.disabled = !is_friend; 135 var is_family = document.getElementById('batch_is_family'); 136 is_family.checked = is_family; 137 is_family.disabled = !is_family; 138 } 139 140 document.getElementById('batch_content_type').value = content_type; 141 document.getElementById('batch_hidden').value = hidden; 99 142 var safety_level = document.getElementById('batch_safety_level'); 100 143 safety_level.value = 0; 101 safety_level.selectedItem.label = '';144 //safety_level.selectedItem.label = ''; 102 145 103 146 // Clear the old sets list … … 275 318 var p = photos.list[id]; 276 319 if (null == p) { 277 unblock_normalize();320 unblock_normalize(); 278 321 return; 279 322 } … … 349 392 350 393 // Single photo or group of photos? 351 block_normalize();394 block_normalize(); 352 395 var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 353 unblock_normalize();396 unblock_normalize(); 354 397 355 398 if (1 == parseInt(value)) { … … 631 674 } 632 675 } 633 unblock_normalize();676 unblock_normalize(); 634 677 }, 635 678 … … 667 710 } 668 711 } 669 unblock_normalize();712 unblock_normalize(); 670 713 // If there are videos then bother them 671 714 if (v_count) { … … 741 784 photos._remove(); 742 785 } 743 unblock_normalize();786 unblock_normalize(); 744 787 // If remove is blocked then we know photos.normalize 745 788 // will be called as it is unblocked trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js
r559 r590 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 547 546 mouse.anchor = null; 548 547 }, … … 554 553 show_photos: function() { 555 554 mouse._photos_visible = true; 556 document.getElementById(' page_photos').style.display = '-moz-box';555 document.getElementById('the_swf').style.visibility = 'visible'; 557 556 document.getElementById('page_queue').style.display = 'none'; 558 557 document.getElementById('footer').className = 'photos'; … … 560 559 show_queue: function() { 561 560 mouse._photos_visible = false; 562 document.getElementById(' page_photos').style.display = 'none';561 document.getElementById('the_swf').style.visibility = 'hidden'; 563 562 document.getElementById('page_queue').style.display = '-moz-box'; 564 563 document.getElementById('footer').className = 'queue'; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js
r583 r590 9 9 */ 10 10 11 11 12 var photos = { 12 13 … … 15 16 count: 0, 16 17 videoCount: 0, 18 the_swf:null, 19 file:null, 17 20 errors: 0, 18 21 selected: [], … … 21 24 batch_size: 0, 22 25 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: {}, 23 40 thumb_cancel: false, 24 41 … … 29 46 failed: [], 30 47 sets: {}, 48 49 to_add: [], 50 31 51 ok: 0, 32 52 fail: 0, … … 44 64 normalizeTimeoutId: null, 45 65 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 46 98 // Let the user select some files, thumbnail them and track them 47 99 // Patch for saving our place in the directory structure from … … 88 140 while (files.hasMoreElements()) { 89 141 var arg = files.getNext().QueryInterface(Ci.nsILocalFile).path; 90 paths.push(arg); 142 arg = arg.replace(/\\/g, '\/'); 143 paths.unshift(arg); 91 144 } 92 145 photos.add(paths); … … 105 158 }, 106 159 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 107 165 // Add a list of photos 108 166 add: function(paths, silent) { 109 110 167 if (null == silent) { silent = false; } 111 buttons.upload.disable();168 //buttons.upload.disable(); 112 169 113 170 // Tally up photos and videos and remove large videos … … 118 175 var bad = []; 119 176 for each (var p in paths) { 120 if (p === null) {121 continue;122 } 177 var P = p; 178 p = p[0]; 179 123 180 var path = 'object' == typeof p ? p.path : p; 124 181 … … 126 183 if (photos.is_photo(path)) { 127 184 ++p_count; 128 new_paths.push( p);185 new_paths.push(P); 129 186 } 130 187 … … 136 193 big_videos.push(null == filename ? path : filename[1]); 137 194 } else { 138 new_paths.push( p);195 new_paths.push(P); 139 196 } 140 197 } 141 198 142 199 // Warn about files that are being dropped 143 else if (path.length) {144 var filename = path.match(/([^\/\\]*)$/);145 bad.push(null == filename ? path : filename[1]);146 }200 //else if (path.length) { 201 //var filename = path.match(/([^\/\\]*)$/); 202 //bad.push(null == filename ? path : filename[1]); 203 //} 147 204 148 205 } … … 231 288 while (paths.length) { 232 289 var p = paths.shift(); 290 P = p; 291 p = p[0]; 292 233 293 var path = 'object' == typeof p ? p.path : p; 234 294 if (!photos.is_video(path)) { 235 new_paths.push( p);295 new_paths.push(P); 236 296 } 237 297 } … … 243 303 var ii = paths.length; 244 304 for (var i = 0; i < ii; ++i) { 245 var p = 'object' == typeof paths[i] ?246 paths[i] .path : paths[i];305 var p = 'object' == typeof paths[i][0] ? 306 paths[i][0].path : paths[i][0]; 247 307 if (photos.is_video(p)) { 248 paths[i] = 'object' == typeof paths[i] ?249 paths[i] : {'path': p};250 paths[i] .safety_level = result.safety_level;308 paths[i][0] = 'object' == typeof paths[i][0] ? 309 paths[i][0] : {'path': p}; 310 paths[i][0].safety_level = result.safety_level; 251 311 } 252 312 } … … 283 343 // Now add whatever's left 284 344 var ii = paths.length; 345 var to_flash = []; 285 346 block_normalize(); 286 347 var ext_list = []; 287 var currentPathsLists = photos.list.map(function(x) {return (x ? x.path : "");}); 288 289 for (var i = 0; i < ii; ++i) { 290 var p = 'object' == typeof paths[i] ? paths[i].path : paths[i]; 348 349 for (var i = ii-1; i >= 0; --i) { 350 var p = 'object' == typeof paths[i][0] ? paths[i][0].path : paths[i][0]; 291 351 292 352 // Resolve the path and add the photo … … 295 355 .getService(Ci.nsIFileProtocolHandler) 296 356 .getFileFromURLSpec(p).path; 297 // p = Cc["@mozilla.org/network/io-service;1"] 298 // .getService(Components.interfaces.nsIIOService).newURI(p).QueryInterface(Ci.nsIFileURL).file.path 299 } 300 if(currentPathsLists.indexOf(p) === -1) { 301 ext_list.push(photos._add(p)); 357 358 } 359 360 if(!photos.added_paths[p]) { 361 photos.added_paths[p] = true; 362 var P = photos._add(p, paths[i][1]); 363 ext_list.push(P); 364 to_flash.push([P,paths[i][1]]); 302 365 303 366 // Photos can be passed as an object which already has metadata 304 if ('object' == typeof paths[i] ) {305 for (var k in paths[i] ) {367 if ('object' == typeof paths[i][0]) { 368 for (var k in paths[i][0]) { 306 369 if ('id' == k) { continue; } 307 photos.list[photos.list.length - 1][k] = paths[i][ k];370 photos.list[photos.list.length - 1][k] = paths[i][0][k]; 308 371 } 309 372 } 310 } 311 } 312 373 } 374 } 375 376 377 if(to_flash.length > 0) 378 photos.call_swf('add_files', [to_flash]); 379 380 for(var i=0;i<to_flash.length;i++){ 381 photos.waiting_to_thumb++; 382 threads.workerPool.dispatch(new Thumb(to_flash[i][0].id, conf.thumb_size, to_flash[i][0].path), 383 threads.workerPool.DISPATCH_NORMAL); 384 } 385 313 386 // Do extension stuff after we've added all of the photos but 314 387 // before the list we've saved potentially becomes invalid … … 316 389 317 390 // Update the UI 391 /* 318 392 if (photos.count + photos.errors) { 319 393 document.getElementById('t_clear').className = 'button'; … … 345 419 document.getElementById('photos_new').style.display = 'none'; 346 420 } 421 */ 347 422 unblock_normalize(); 348 423 photos.normalize(); 349 424 350 425 }, 351 426 _add: function(path) { … … 357 432 var id = photos.list.length; 358 433 var p = new Photo(id, path); 434 //p.hash = file.compute_file_hash(path); 359 435 photos.list.push(p); 360 436 unblock_normalize(); 361 437 ++photos.count; 362 if(photos.is_video(path)) {363 ++photos.videoCount;364 }365 438 if(photos.is_video(path)){ 439 ++photos.videoCount; 440 p.is_video = true; 441 } 366 442 // Create a spot for the image, leaving a spinning placeholder 367 443 // Add images to the start of the list because this is our best 368 444 // guess for ordering newest to oldest 445 /* 369 446 var img = document.createElementNS(NS_HTML, 'img'); 370 447 img.className = 'loading'; … … 375 452 li.id = 'photo' + id; 376 453 li.appendChild(img); 377 block_normalize();378 454 var list = document.getElementById('photos_list'); 379 455 list.insertBefore(li, list.firstChild); 456 */ 457 380 458 // Create and show the thumbnail 381 photos.thumb_cancel = false; 382 threads.workerPool.dispatch(new Thumb(id, conf.thumb_size, path), 383 threads.workerPool.DISPATCH_NORMAL); 384 459 photos.thumb_cancel = false; 460 photos.waiting_on_thumb[p.id] = true; 461 //if(!threads.workers[0]) 462 //threads.workers[0] = Cc['@mozilla.org/thread-manager;1'].getService().newThread(0); 463 //threads.workers[0].dispatch(new Thumb(id, conf.thumb_size, path), 464 //threads.worker.DISPATCH_NORMAL); 465 // 466 467 468 469 470 471 //threads.worker.dispatch(new Thumb(id, conf.thumb_size, path), 472 //threads.worker.DISPATCH_NORMAL); 473 474 475 // Add the original image to the list and set our status 476 //var id = photos.list.length; 477 //var p = new Photo(id, path); 385 478 return p; 479 480 }, 481 482 alert: function(s){ 483 Components.utils.reportError(String(s)); 386 484 }, 387 485 … … 393 491 394 492 // Nothing to do if somehow there are no selected photos 395 block_normalize();396 493 var ii = photos.selected.length; 397 if (0 == ii) { 398 unblock_normalize(); 399 return; 400 } 401 document.getElementById('photos').style.display = 'none'; 402 document.getElementById('normalizing').style.display = '-moz-box'; 494 if (0 == ii) { return; } 495 403 496 // Tell extensions which photos we're removing 404 497 extension.before_remove.exec(photos.selected); … … 407 500 for (var i = 0; i < ii; ++i) { 408 501 var id = photos.selected[i]; 502 /* 409 503 var li = document.getElementById('photo' + id); 410 504 if(li) { 411 505 li.parentNode.removeChild(li); 412 506 } 507 */ 413 508 414 509 // Free the size of this file 415 510 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 }419 511 if (users.nsid && !users.is_pro && users.bandwidth && 420 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) {512 0 < users.bandwidth.remaining - photos.batch_size) { 421 513 status.clear(); 422 514 } 423 if(photos.is_video(photos.list[id].path)) { 424 --photos.videoCount; 425 } 515 426 516 photos.list[id] = null; 427 517 --photos.count; 428 518 } 429 unblock_normalize();430 519 ui.bandwidth_updated(); 431 520 photos.normalize(); … … 433 522 434 523 // Clear the selection 435 block_normalize();436 524 photos.selected = []; 437 unblock_normalize();438 525 mouse.click({target: {}}); 439 526 440 527 photos._remove(); 441 document.getElementById('photos').style.display = '-moz-box';442 document.getElementById('normalizing').style.display = 'none';443 528 }, 444 529 … … 450 535 photos.sort = true; 451 536 buttons.upload.disable(); 537 /* 452 538 document.getElementById('photos_sort_default') 453 539 .style.display = 'none'; … … 461 547 document.getElementById('no_meta_prompt') 462 548 .style.visibility = 'hidden'; 549 */ 463 550 } 464 551 }, … … 468 555 469 556 // Prevent silliness 470 block_normalize();471 557 var s = photos.selected; 472 558 var ii = s.length; … … 486 572 block_sort(); 487 573 photos.batch_size -= p.size; 574 575 /* 488 576 var img = document.getElementById('photo' + p.id) 489 577 .getElementsByTagName('img')[0]; … … 492 580 img.setAttribute('height', 8); 493 581 img.src = 'chrome://uploadr/skin/balls-16x8-trans.gif'; 582 */ 494 583 block_normalize(); 495 584 threads.worker.dispatch(new Rotate(p.id, degrees, … … 504 593 }, 505 594 506 // Upload photos595 // Upload photos 507 596 // The arguments will either both be null or both be set 508 597 // If they're both set, this is an automated call to upload by the … … 511 600 var from_user = null == list; 512 601 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; 513 611 514 612 // Don't upload if this is a user action and the button is disabled 613 /* 515 614 if (from_user && 'disabled_button' == document.getElementById( 516 615 'button_upload').className) { 517 616 return; 518 617 } 618 */ 619 519 620 if(ui.cancel) { 520 upload.cancel = true;621 upload.cancel = true; 521 622 return upload.done(); 522 623 } 523 624 524 625 // Remove error indicators 626 /* 525 627 block_normalize(); 526 628 var li = document.getElementById('photos_list') … … 533 635 } 534 636 } 535 unblock_normalize(); 536 637 unblock_normalize(); 638 */ 639 537 640 // Decide if we're already in the midst of an upload 538 641 var not_started = 0 == photos.uploading.length; … … 541 644 if (from_user) { 542 645 var new_list = []; 543 var nbVideosToUpload = 0;544 646 for each (var p in list) { 545 647 if (null == p) { … … 591 693 592 694 // Resize because of user settings 695 /* 593 696 if (null != settings.resize && 594 697 -1 != settings.resize && … … 612 715 ready_size += p.size; 613 716 } 717 */ 614 718 615 719 } … … 638 742 photos.last = null; 639 743 block_normalize(); 640 var list = document.getElementById('photos_list'); 641 while (list.hasChildNodes()) { 642 list.removeChild(list.firstChild); 643 } 744 //var list = document.getElementById('photos_list'); 745 //while (list.hasChildNodes()) { 746 //list.removeChild(list.firstChild); 747 //} 748 // 644 749 unblock_normalize(); 645 750 threads.readyToResize = true; … … 649 754 650 755 // Give some meaningful feedback 756 /* 651 757 if (not_started) { 652 758 document.getElementById('footer').style.display = … … 673 779 photos.sets[users.nsid] = meta.sets; 674 780 } 781 */ 675 782 676 783 return; … … 680 787 // Update the UI 681 788 if (from_user) { 682 status.set(locale.getString('status.uploading'));683 document.getElementById('t_clear').className = 'disabled_button';684 buttons.upload.disable();685 document.getElementById('photos_sort_default')686 .style.display = 'none';687 document.getElementById('photos_sort_revert')688 .style.display = 'none';689 document.getElementById('photos_init')690 .style.display = 'none';691 document.getElementById('photos_new')692 .style.display = '-moz-box';693 document.getElementById('no_meta_prompt')694 .style.visibility = 'hidden';695 meta.disable();696 photos.sets[users.nsid] = meta.sets;789 //status.set(locale.getString('status.uploading')); 790 //buttons.upload.disable(); 791 //document.getElementById('photos_sort_default') 792 //.style.display = 'none'; 793 //document.getElementById('photos_sort_revert') 794 //.style.display = 'none'; 795 //document.getElementById('photos_init') 796 //.style.display = 'none'; 797 //document.getElementById('photos_new') 798 //.style.display = '-moz-box'; 799 //document.getElementById('no_meta_prompt') 800 //.style.visibility = 'hidden'; 801 802 //meta.disable(); 803 //photos.sets[users.nsid] = meta.sets; 697 804 } 698 805 699 806 // We're really going to start or queue a batch, so do extension stuff 700 extension.before_upload.exec(list);807 //extension.before_upload.exec(list); 701 808 702 809 // Take the list of photos into upload mode and reset the UI … … 718 825 719 826 // Setup progress bar for this photo and show it in the queue 827 /* 720 828 var img = document.createElementNS(NS_HTML, 'img'); 721 829 img.src = 'file:///' + encodeURIComponent(p.thumb); … … 732 840 li.appendChild(stack); 733 841 document.getElementById('queue_list').appendChild(li); 842 */ 734 843 735 844 } … … 746 855 } 747 856 } 857 748 858 if (from_user) { 749 859 photos.batch_size = 0; … … 756 866 unblock_normalize(); 757 867 photos.last = null; 758 block_normalize(); 759 var ul = document.getElementById('photos_list'); 760 while (ul.hasChildNodes()) { 761 ul.removeChild(ul.firstChild); 762 } 763 unblock_normalize(); 764 ui.bandwidth_updated(); 765 } 766 767 mouse.toggle(); 768 upload.startTime = new Date().getTime(); 868 //block_normalize(); 869 //var ul = document.getElementById('photos_list'); 870 //while (ul.hasChildNodes()) { 871 //ul.removeChild(ul.firstChild); 872 //} 873 //unblock_normalize(); 874 //ui.bandwidth_updated(); 875 } 876 877 //mouse.toggle(); 878 879 upload.startTime = new Date().getTime(); 769 880 770 881 // Kick off the first batch job if we haven't started … … 781 892 782 893 }, 783 894 784 895 // Normalize the photo list and selected list with the DOM 785 896 normalize: function() { … … 797 908 logStringMessage('normalize [in]'); 798 909 } 910 911 /* 799 912 document.getElementById('photos').style.display = 'none'; 800 913 document.getElementById('normalizing').style.display = '-moz-box'; … … 825 938 } 826 939 isNormalizing = false; 827 }, 940 */ 941 942 }, 943 828 944 829 945 // Load saved metadata 830 load: function() { 946 load: function(){ 947 831 948 var obj = file.read('photos.json'); 832 949 950 if(obj.indexed_paths) 951 photos.indexed_paths = obj.indexed_paths; 952 953 if(obj.list) 954 photos.list = obj.list 955 956 for(var i=0;i<photos.list.length;i++) 957 photos.added_paths[photos.list[i].path] = true; 958 959 960 961 962 /* 963 photos.the_swf = document.getElementById('the_swf'); 964 var sets = obj.flash['sets']; 965 for(var i=0;i<sets.length;i++){ 966 var sl = {'sets':sets.slice(i,i+1)}; 967 photos.the_swf.load(sl); 968 nsWaitForDelay(150); 969 } 970 */ 971 972 photos.call_swf('load', [obj.flash]); 973 974 photos.index_some_photos(); 975 976 977 //thumbnail photos not thumbnailed last time 978 for(var i=0; i<photos.list.length; i++){ 979 if(!photos.list[i].thumb){ 980 photos.waiting_to_thumb++; 981 threads.workerPool.dispatch( 982 new Thumb(photos.list[i].id, 983 conf.thumb_size, 984 photos.list[i].path), 985 threads.worker.DISPATCH_NORMAL); 986 } 987 } 988 989 //alert('still'+obj.flash); 990 991 833 992 // Don't bother if there are no photos 834 if ('undefined' == typeof obj.list) { return; }993 //if ('undefined' == typeof obj.list) { return; } 835 994 836 995 // Add the previous batch of photos 837 var list = obj.list;838 if (list.length) {839 photos.sort = obj.sort;840 document.getElementById('photos_init').style.display = 'none';841 document.getElementById('photos_new').style.display = 'none';842 document.getElementById('no_meta_prompt')843 .style.visibility = 'visible';844 }845 photos.add(list, true);996 //var list = obj.list; 997 //if (list.length) { 998 //photos.sort = obj.sort; 999 //document.getElementById('photos_init').style.display = 'none'; 1000 //document.getElementById('photos_new').style.display = 'none'; 1001 //document.getElementById('no_meta_prompt') 1002 //.style.visibility = 'visible'; 1003 //} 1004 //photos.add(list, true); 846 1005 847 1006 // Bring in last known sets configuration 848 if(obj.sets) { 849 meta.sets = obj.sets; 850 } 1007 //if(obj.sets){ 1008 //meta.sets = obj.sets; 1009 //} 1010 851 1011 }, 852 1012 … … 854 1014 // this is desperate move when the uploadr is in unusable state 855 1015 removeAll: function() { 856 if (document.getElementById('t_clear').className == 'disabled_button')857 return;858 document.getElementById('t_clear').className = 'disabled_button';1016 //if (document.getElementById('t_clear').className == 'disabled_button') 1017 //return; 1018 //document.getElementById('t_clear').className = 'disabled_button'; 859 1019 photos.thumb_cancel = true; 860 1020 if (conf.console.thumb) { … … 862 1022 } 863 1023 photos.list = []; 1024 photos.indexed_paths = {}, 864 1025 photos.selected = []; 865 1026 photos.count = 0; … … 870 1031 _block_sort = _block_remove = _block_normalize = _block_exit = 0; 871 1032 file.remove('photos.json'); 1033 photos.call_swf('reset', []); 872 1034 // Remove photos from UI 1035 /* 873 1036 block_normalize(); 874 1037 var list = document.getElementById('photos_list'); … … 878 1041 unblock_normalize(); 879 1042 document.getElementById('photos_init').style.display = '-moz-box'; 1043 */ 880 1044 ui.bandwidth_updated(); 881 meta.disable();882 buttons.upload.disable();1045 //meta.disable(); 1046 //buttons.upload.disable(); 883 1047 }, 884 1048 1049 885 1050 // 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 886 1069 save: function() { 887 1070 if (0 != _block_exit) { return; } 888 1071 block_normalize(); 889 if (1 == photos.selected.length) { 890 meta.save(photos.selected[0]); 891 } 1072 //if (1 == photos.selected.length) { 1073 //meta.save(photos.selected[0]); 1074 //} 1075 1076 photos.saving = true; 1077 photos.thumb_cancel = true; 1078 Components.utils.reportError('saving'); 892 1079 file.write('photos.json', { 893 sort: photos.sort, 894 sets: meta.sets, 895 list: photos.list 1080 //sort: photos.sort, 1081 //sets: meta.sets, 1082 list: photos.list, 1083 indexed_paths:photos.indexed_paths, 1084 //flash:photos.the_swf.get_flash_obj()//photos.flash 1085 flash:photos.call_swf('get_flash_obj', [])//photos.flash 1086 //waiting_on_thumb:waiting_on_thumb 896 1087 }); 897 1088 unblock_normalize(); 1089 photos.saving = false; 1090 photos.thumb_cancel = false; 898 1091 }, 899 1092 900 1093 // Decide if a given path is a photo 901 1094 is_photo: function(path) { 902 return /\.(jpe?g|tiff?|gif|png|bmp)$/i.test(path); 1095 if(!path) return false; 1096 var ext = path.substring(path.lastIndexOf('.')+1, path.length).toLowerCase(); 1097 return ext == "jpeg" || ext == "jpg" || ext == "gif" || ext == "bmp" || ext == "tiff" || ext == "tif" || ext == "png"; 1098 1099 //return /\.(jpe?g|tiff?|gif|png|bmp)$/i.test(path); 903 1100 }, 904 1101 905 1102 // Similarly, is it a video 906 1103 is_video: function(path) { 907 return /\.(mp4|mpe?g|avi|wmv|mov|dv|3gp|3g2|m4v)$/i.test(path); 1104 if(!path) return false; 1105 var ext = path.substring(path.lastIndexOf('.')+1, path.length).toLowerCase(); 1106 return ext == 'mp4' || ext == 'mpg' || ext == 'mpeg' || ext == 'avi' || ext == 'dv' || ext == 'm4v' || ext == '3gp' || ext == 'mov' ||ext == 'wmv'; 1107 //return /\.(mp4|mpe?g|avi|wmv|mov|dv|3gp|m4v)$/i.test(path); 908 1108 } 909 1109 … … 912 1112 // Setup auto-saving of metadata in case of crashes 913 1113 // See photos.save for problems related to the auto-save interval 1114 /* 914 1115 window.setInterval(function() { 915 1116 photos.save(); 916 1117 }, 1000 * conf.auto_save); 1118 */ 917 1119 918 1120 // Photo properties … … 940 1142 this.hidden = settings.hidden; 941 1143 this.sets = []; 1144 this.is_video = null; 942 1145 this.progress_bar = null; 943 1146 this.nsid = null; trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js
r544 r590 2 2 * Flickr Uploadr 3 3 * 4 * Copyright (c) 2007-200 9Yahoo! Inc. All rights reserved. This library is4 * Copyright (c) 2007-2008 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 97 98 } 98 99 99 100 }, 100 101 101 102 // Show the settings dialog 102 103 show: function() { … … 105 106 // the current NSID and the maximum file size string 106 107 var u = eval(users.list.toSource()); 107 var result = {add_user:null, ok:null}; 108 109 window.openDialog('chrome://uploadr/content/settings.xul', 'dialog_settings', 110 'chrome,modal', users.nsid, u, locale.getFormattedString( 111 'settings.resize.prompt.' + (users.is_pro ? 'pro' : 'free'), 112 [users.filesize >> 10]), result); 113 108 var result = {}; 109 window.openDialog('chrome://uploadr/content/settings.xul', 'dialog_settings', 110 'chrome,modal', users.nsid, u, locale.getFormattedString( 111 'settings.resize.prompt.' + (users.is_pro ? 'pro' : 'free'), 112 [users.filesize >> 10]), result); 113 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 122 123 123 124 // Replace old users object with new one … … 159 160 safety_level: s.safety_level 160 161 }); 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 } 161 167 } else { 162 168 settings.is_public = 1; … … 177 183 } 178 184 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 179 200 // Get permission to overwrite any changes that were made 180 201 if (0 < photos.count && … … 188 209 189 210 // Save metadata 190 block_normalize();191 211 if (1 == photos.selected.length) { 192 212 meta.save(photos.selected[0]); … … 209 229 } 210 230 } 211 unblock_normalize(); 231 212 232 // Videos can't be restricted so either update them or delete them 213 233 if (3 == settings.safety_level) { … … 216 236 var p_count = 0; 217 237 var v_count = 0; 218 block_normalize();219 238 for each (var p in photos.list) { 220 239 if (null == p) { … … 227 246 } 228 247 } 229 unblock_normalize(); 248 230 249 // If there are videos, bother them 231 250 if (v_count) { … … 258 277 // Remove selected videos 259 278 if ('cancel' == result.result) { 260 block_normalize();261 279 var ii = photos.list.length; 262 280 for (var i = 0; i < ii; ++i) { … … 268 286 li.parentNode.removeChild(li); 269 287 photos.batch_size -= photos.list[i].size; 270 photos.video_batch_size -= photos.list[i].size;271 288 if (users.nsid && !users.is_pro && 272 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) {289 0 < users.bandwidth.remaining - photos.batch_size) { 273 290 status.clear(); 274 }275 if(photos.is_video(photos.list[i].path)) {276 --photos.videoCount;277 291 } 278 292 photos.list[i] = null; … … 280 294 } 281 295 } 282 unblock_normalize();283 296 ui.bandwidth_updated(); 284 297 … … 295 308 // Set a different safety level for videos 296 309 else if ('ok' == result.result && result.safety_level) { 297 block_normalize();298 310 var ii = photos.list.length; 299 311 for (var i = 0; i < ii; ++i) { … … 303 315 } 304 316 } 305 unblock_normalize();306 317 } 307 318 … … 311 322 312 323 // Refresh visible photo metadata if necessary 313 block_normalize();314 324 if (1 == photos.selected.length) { 315 325 meta.load(photos.selected[0]); … … 319 329 meta.batch(); 320 330 } 321 unblock_normalize(); 331 322 332 } 323 333 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.xul
r501 r590 20 20 <!ENTITY % proxyDTD SYSTEM "chrome://uploadr/locale/proxy.dtd"> 21 21 %proxyDTD; 22 <!ENTITY % settingsDTD SYSTEM "chrome://uploadr/content/settings.dtd"> 23 %settingsDTD; 22 24 ]> 23 25 <dialog id="dialog_settings" title="&settings;" buttons="accept,cancel" … … 27 29 xmlns:html="http://www.w3.org/1999/xhtml"> 28 30 <stringbundleset> 29 <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" />31 <stringbundle id="locale" src="chrome://uploadr/locale/main.properties" /> 30 32 </stringbundleset> 31 <script src=" chrome://uploadr/content/settings_dialog.js" />33 <script src="&base.url;settings_dialog.js" /> 32 34 <vbox flex="1" id="notloggedin"> 33 <html:h3>&settings.notloggedin;</html:h3>34 <box align="center">35 <button label="&login;"35 <html:h3>&settings.notloggedin;</html:h3> 36 <box align="center"> 37 <button label="&login;" 36 38 oncommand="settings.add_user();" /> 37 </box>39 </box> 38 40 </vbox> 39 41 <vbox flex="1" id="loggedin"> … … 119 121 </radiogroup> 120 122 </groupbox> 121 </hbox> 123 </hbox> 124 <groupbox id="base_url" flex="1"> 125 <caption label="Get uploader from" /> 126 <html:input onchange="settings.base_url(value);" value="&base.url;" id="base_url"></html:input> 127 </groupbox> 122 128 </vbox> 123 129 </dialog> trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings_dialog.js
r501 r590 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 }, 134 137 config_proxy: function(){ 135 138 window.openDialog('chrome://uploadr/content/proxy.xul', 'dialog_proxy', 'chrome,titlebar,toolbar,centerscreen,modal'); trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/threads.js
r583 r590 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 workerPool: null, 33 indexer: null, 34 saver: null, 34 35 readyToResize: false, 35 36 //workers:[], 37 workerPool:null, 38 priorityPool:null, 39 40 // 36 41 // GraphicsMagick XPCOM object 37 42 gm: null, … … 39 44 // Create thread hooks and instantiate GraphicsMagick 40 45 init: function() { 41 try { 46 try { 47 48 threads.misc_init(); 42 49 // Threads themselves 43 50 var t = Cc['@mozilla.org/thread-manager;1'].getService(); … … 47 54 threads.uploadr = t.newThread(0); 48 55 threads.main = t.mainThread; 49 56 threads.priorityPool = Cc['@mozilla.org/thread-pool;1'].createInstance(Ci.nsIThreadPool); 57 threads.priorityPool.threadLimit = conf.maxThreadsCount; 58 threads.indexer = t.newThread(0); 59 threads.saver = t.newThread(0); 60 61 50 62 // GraphicsMagick, for use on the worker thread 51 63 threads.gm = Cc['@flickr.com/gm;1'].createInstance(Ci.flIGM); … … 54 66 .get('resource:app', Ci.nsIFile).path, UploadProgressHandler); 55 67 new Date(); // hack so that new Date() works on worker threads. It must initialised some stuff and needs to be called on the main thread first!? 56 threads.initialized = true; 68 threads.initialized = true; 69 57 70 } catch (err) { 58 71 Components.utils.reportError(new Date().toUTCString() +err); … … 76 89 } 77 90 } 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); 78 103 } 79 104 … … 82 107 // Thumbnail thread wrapper 83 108 var Thumb = function(id, thumb_size, path, auto_select) { 109 photos.thumb_thread_counter+=1; 84 110 this.id = id; 85 111 this.thumb_size = thumb_size; … … 87 113 this.auto_select = null == auto_select ? false : auto_select; 88 114 }; 115 89 116 Thumb.prototype = { 90 117 run: function() { 91 if(photos.thumb_cancel === true)92 return;118 if(photos.thumb_cancel === true) 119 return; 93 120 var result = ''; 94 121 … … 128 155 this.auto_select = auto_select; 129 156 }; 157 130 158 ThumbCallback.prototype = { 131 159 run: function() { 132 160 if (photos.thumb_cancel === true) 133 return;161 return; 134 162 try { 135 163 if (conf.console.thumb) { … … 144 172 145 173 146 var li = document.getElementById('photo' + this.id);147 var oldImg = li.getElementsByTagName('img')[0];148 var img = document.createElementNS(NS_HTML, 'img');149 li.replaceChild(img, oldImg);174 //var li = document.getElementById('photo' + this.id); 175 //var oldImg = li.getElementsByTagName('img')[0]; 176 //var img = document.createElementNS(NS_HTML, 'img'); 177 //li.replaceChild(img, oldImg); 150 178 151 179 // If successful, replace with the thumb and update the … … 156 184 var ii = thumb.length; 157 185 for (var i = 0; i < ii; ++i) { 158 thumb[i] = thumb[i]; 186 thumb[i] = thumb[i]; //why? 159 187 } 160 188 … … 197 225 photos.list[this.id].thumb_width = parseInt(thumb[4]); 198 226 photos.list[this.id].thumb_height = parseInt(thumb[5]); 199 img.setAttribute('width', thumb[4]);200 img.setAttribute('height', thumb[5]);227 //img.setAttribute('width', thumb[4]); 228 //img.setAttpribute('height', thumb[5]); 201 229 var thumbPath = thumb[6].replace(/^\s+|\s+$/g, '') 202 .replace(/\{---THREE---POUND---DELIM---\}/g, '###');203 img.src = 'file:///' + encodeURIComponent(thumbPath);230 .replace(/\{---THREE---POUND---DELIM---\}/g, '###'); 231 //img.src = 'file:///' + encodeURIComponent(thumbPath); 204 232 if (conf.console.thumb) { 205 233 logStringMessage('GM THUMB: path ' + img.src + " " + thumbPath); 206 }234 } 207 235 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 } 208 243 209 244 // Make video icons for videos 210 245 // This will look funny for a portrait-oriented video 246 /* 211 247 if (photos.is_video(photos.list[this.id].path)) { 212 248 var icon = document.createElementNS(NS_HTML, 'img'); … … 218 254 img.parentNode.appendChild(icon); 219 255 } 256 */ 220 257 221 258 // Title/tags/description … … 294 331 } 295 332 ui.bandwidth_updated(); 296 333 297 334 } 298 335 299 336 // If unsuccessful, replace with the error image 300 337 else { 338 /* 301 339 img.setAttribute('src', 302 340 'chrome://uploadr/skin/icon_alert.png'); … … 321 359 } 322 360 }; 361 */ 323 362 Components.utils.reportError(new Date().toUTCString() +this.result); 324 363 } 325 364 326 365 // After updating, make it visible again 327 img.style.visibility = 'visible';366 //img.style.visibility = 'visible'; 328 367 329 368 } catch (err) { 330 369 Components.utils.reportError(new Date().toUTCString() +err); 331 370 } 332 unblock_normalize(); 371 unblock_normalize(); 372 373 photos.waiting_to_thumb--; 374 if(photos.waiting_to_thumb == 0) 375 status.set('finished generating thumbnails'); 376 else 377 status.set('generating thumbnails ('+String(photos.list.length - photos.waiting_to_thumb)+'/'+String(photos.list.length)+')'); 378 379 photos.waiting_on_thumb[this.id] = null; 333 380 // Tell extensions that we got a new thumbnail 334 381 extension.after_thumb.exec(this.id); 335 // and sync hthe view as well382 // and sync the view as well 336 383 photos.normalize(); 337 384 338 385 unblock_sort(); 339 386 if(photos.sort && !_block_sort) { // hack hack :( 340 threads.worker.dispatch(new Sort(),387 threads.worker.dispatch(new Sort(), 341 388 threads.worker.DISPATCH_NORMAL); 342 389 } … … 358 405 this.path = path; 359 406 }; 407 360 408 Rotate.prototype = { 361 409 run: function() { … … 416 464 var Sort = function() { 417 465 }; 466 418 467 Sort.prototype = { 419 468 run: function() { … … 482 531 // This is far from being a bottleneck, so leave it alone 483 532 // until it is 533 /* 484 534 var list = document.getElementById('photos_list'); 485 535 for (var i = p.length - 1; i >= 0; --i) { … … 488 538 } 489 539 } 540 */ 541 490 542 unblock_normalize(); 491 543 if(conf.console.sort) { … … 515 567 this.path = path; 516 568 }; 569 517 570 Resize.prototype = { 518 571 run: function() { 519 572 try { 573 520 574 // Resize the image and callback to the UI thread 521 575 if(ui.cancel) … … 540 594 this.result = result; 541 595 }; 596 542 597 ResizeCallback.prototype = { 543 598 run: function() { … … 558 613 559 614 if (null == resize) { 560 Components.utils.reportError(new Date().toUTCString() + this.result);615 Components.utils.reportError(new Date().toUTCString() +' ' + this.result); 561 616 } else { 562 617 list = photos.ready[photos.ready.length - 1]; … … 586 641 587 642 // 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 588 827 var EnableUpload = function() { 589 828 }; … … 689 928 } 690 929 }; 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
r583 r590 1 /* 2 * Flickr Uploadr 1 /* * Flickr Uploadr 3 2 * 4 3 * Copyright (c) 2007-2009 Yahoo! Inc. All rights reserved. This library is 5 4 * 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 12 14 var ui = { 13 15 14 16 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.pro');22 //document.getElementById('photos_init_prompt').firstChild.nodeValue = 23 //locale.getString('photos.init.free'); 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 /* 31 32 for each (var id in ['help_offline', 'help_drag']) { 32 33 var node = document.getElementById(id); … … 50 51 node.appendChild(span); 51 52 node.appendChild(document.createTextNode(parts[2])); 53 */ 52 54 53 55 }, … … 59 61 60 62 // Notes in the empty photo pane 63 /* 61 64 var notes = document.getElementById('photos_init_notes'); 62 65 while (notes.hasChildNodes()) { … … 82 85 document.getElementById('photos_init_prompt') 83 86 .firstChild.nodeValue = locale.getString('photos.init.pro'); 87 */ 84 88 }, 85 89 … … 87 91 bandwidth_updated: function() { 88 92 93 //short circuit 94 return; 95 89 96 // Counter for remaining bandwidth 90 97 if (users.bandwidth && !users.is_pro) { … … 146 153 display = 'none'; 147 154 } 148 document.getElementById('page_' + pages._list[i]) 149 .style.display = display; 155 //this is different so that flash hiding/showing will work without reseting the swf 156 var p = document.getElementById('page_' + pages._list[i]) 157 if(display == 'none'){ 158 p.style.visibility = 'hidden'; 159 if(pages._list[i]!='photos') 160 p.style.display = display 161 } 162 else{ 163 p.style.visibility = 'visible' 164 p.style.display = display; 165 //document.getElementById('page_' + pages._list[i]) 166 //.style.display = display; 167 } 150 168 } 151 169 152 170 // Only the photos page has the toolbar 171 /* 153 172 if ('photos' == id) { 154 173 document.getElementById('tools').style.display = '-moz-box'; … … 158 177 document.getElementById('bw_batch').style.display = 'none'; 159 178 } 179 */ 160 180 161 181 }, … … 202 222 203 223 about: function() { 204 //photos.normalize();205 224 window.openDialog('chrome://uploadr/content/about.xul', 206 225 'about-dialog', 'chrome,modal,centerscreen', … … 372 391 var isNormalizing = false; 373 392 var block_normalize = function() { 393 /* 374 394 while(isNormalizing) { 375 395 logStringMessage('block_normalize while already normalizing'); … … 378 398 .currentThread.processNextEvent(true); 379 399 } 400 */ 380 401 ++_block_normalize; 381 402 }; … … 383 404 var unblock_normalize = function() { 384 405 --_block_normalize; 406 /* 385 407 if(_block_normalize < 0) { 386 408 logStringMessage("extra unblock_normalize :-("); 387 409 } 388 }; 410 */ 411 }; 412 389 413 var _block_exit = 0; 390 414 var block_exit = function() { … … 409 433 return false; 410 434 } 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 411 461 412 462 // Save state 413 photos.save(); 414 settings.save(); 415 users.save(); 463 try{ 464 photos.save(); 465 settings.save(); 466 users.save(); 467 } 468 catch(e){ 469 Components.utils.reportError(e); 470 } 416 471 417 472 // Remove the images and TEMP directories if there are no photos left 473 /* 418 474 if (0 == photos.count) { 419 475 try { … … 440 496 } catch (err) {} 441 497 } 442 443 // Shutdown threads 444 photos.thumb_cancel = true; 445 ui.cancel = true; 446 upload.cancel = true; 447 try { 448 threads.worker.shutdown(); 449 threads.workerPool.shutdown(); 450 threads.uploadr.shutdown(); 451 } 452 catch (err) {} 498 */ 499 500 501 try{ 502 threads.saver.shutdown(); 503 } 504 catch(e){ 505 Components.utils.reportError(e); 506 } 507 453 508 454 509 // Finally exit 455 510 var e = Cc['@mozilla.org/toolkit/app-startup;1'] 456 511 .getService(Ci.nsIAppStartup); 512 457 513 e.quit(Ci.nsIAppStartup.eForceQuit); 458 514 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js
r559 r590 77 77 // Upload a photo 78 78 start: function(id) { 79 79 80 //reset upload progress 80 81 upload.progress_id = -1; 81 82 82 83 // Update the UI 84 /* 83 85 if (null == upload.progress_bar) { 84 86 document.getElementById('footer').style.display = '-moz-box'; … … 88 90 progress_text.value = ''; 89 91 } 92 */ 90 93 91 94 var photo = photos.uploading[id]; … … 154 157 } 155 158 upload.progress_zero = 0; 159 photos.call_swf('update_upload_progress', [photos.uploading[id].id, 1]); 160 156 161 // If no ticket came back, fail this photo 157 162 if ('object' != typeof rsp || 'ok' != rsp.getAttribute('stat')) { … … 210 215 // Otherwise, spin for a ticket 211 216 if (null != photos.uploading[id]) { 212 photos.uploading[id].progress_bar.done(true);217 //photos.uploading[id].progress_bar.done(true); 213 218 upload.tickets[rsp.getElementsByTagName('ticketid')[0] 214 219 .firstChild.nodeValue] = { … … 221 226 window.clearTimeout(upload.tickets_handle); 222 227 upload.tickets_handle = null; 223 upload.tickets_delta = 1000;228 upload.tickets_delta = 1000; 224 229 } 225 230 upload.tickets_retry_count = 0; … … 242 247 // Finish a synchronous upload 243 248 _sync: function(rsp, id) { 244 249 245 250 // Stop checking progress if we're in synchronous mode 246 251 if ('sync' == conf.mode) { … … 251 256 upload.progress_zero = 0; 252 257 } 253 258 254 259 // How did the upload go? 255 260 var photo_id; … … 265 270 if ('ok' == stat) { 266 271 if (null != photos.uploading[id]) { 267 photos.uploading[id].progress_bar.done(true);272 //photos.uploading[id].progress_bar.done(true); 268 273 ++photos.ok; 269 274 } … … 409 414 status.set(locale.getString('status.uploading') + ' ' + 410 415 (1000 * photos.kb.sent / (currentTime-upload.startTime)).toFixed(1) + ' KB/s'); 411 photos.uploading[id].progress_bar.update(1 - 412 a / upload.progress_total); 413 } 416 //photos.uploading[id].progress_bar.update(1 - 417 //a / upload.progress_total); 418 } 419 420 photos.call_swf('update_upload_progress', [photos.uploading[id].id, 1-a/upload.progress_total]); 421 414 422 var percent = Math.max(0, Math.min(1, 415 423 photos.kb.sent / photos.kb.total)); 424 416 425 if (null != upload.progress_bar) { 417 upload.progress_bar.update(percent); 418 } 426 //upload.progress_bar.update(percent); 427 } 428 419 429 if (100 == Math.round(100 * percent)) { 420 document.getElementById('progress_text').value =421 locale.getString('upload.waiting.status');430 //document.getElementById('progress_text').value = 431 //locale.getString('upload.waiting.status'); 422 432 upload.processing = true; 423 433 } else { 424 document.getElementById('progress_text').value =425 locale.getFormattedString('upload.progress.status', [426 id + 1,427 photos.uploading.length,428 Math.round(100 * percent)429 ]);434 //document.getElementById('progress_text').value = 435 //locale.getFormattedString('upload.progress.status', [ 436 //id + 1, 437 //photos.uploading.length, 438 //Math.round(100 * percent) 439 //]); 430 440 } 431 441 … … 475 485 6 == parseInt(rsp.getElementsByTagName('err')[0] 476 486 .getAttribute('code'))) { 477 document.getElementById('progress').style.display = 'none';487 //document.getElementById('progress').style.display = 'none'; 478 488 var f = photos.failed; 479 489 for each (var p in photos.uploading) { … … 482 492 var ii = f.length; 483 493 if (0 != ii) { 484 document.getElementById('photos_init')485 .style.display = 'none';486 document.getElementById('photos_new')487 .style.display = 'none';494 //document.getElementById('photos_init') 495 //.style.display = 'none'; 496 //document.getElementById('photos_new') 497 //.style.display = 'none'; 488 498 if (photos.sort) { 489 document.getElementById('photos_sort_default')490 .style.display = 'block';491 document.getElementById('photos_sort_revert')492 .style.display = 'none';499 //document.getElementById('photos_sort_default') 500 //.style.display = 'block'; 501 //document.getElementById('photos_sort_revert') 502 //.style.display = 'none'; 493 503 } else { 494 document.getElementById('photos_sort_default')495 .style.display = 'none';496 document.getElementById('photos_sort_revert')497 .style.display = 'inline';504 //document.getElementById('photos_sort_default') 505 //.style.display = 'none'; 506 //document.getElementById('photos_sort_revert') 507 //.style.display = 'inline'; 498 508 } 499 509 } … … 513 523 } 514 524 } 515 unblock_normalize();525 unblock_normalize(); 516 526 517 527 photos.uploading = []; … … 550 560 // Update the UI 551 561 if (null != upload.progress_bar) { 552 upload.progress_bar.update(1);562 //upload.progress_bar.update(1); 553 563 } 554 564 var text = document.getElementById('progress_text'); … … 561 571 } 562 572 mouse.show_photos(); 563 var queue = document.getElementById('queue_list');564 while (queue.hasChildNodes()) {565 queue.removeChild(queue.firstChild);566 }573 //var queue = document.getElementById('queue_list'); 574 //while (queue.hasChildNodes()) { 575 //queue.removeChild(queue.firstChild); 576 //} 567 577 status.clear(); 568 578 … … 608 618 // Finally give the user feedback on their upload 609 619 finalize: function() { 610 if(conf.console.upload) {611 logStringMessage('finalize');612 }613 620 status.clear(); 614 621 … … 700 707 701 708 // Hide the progress bar now that the user has realized we're done 702 document.getElementById('progress_bar').style.width = '0';703 document.getElementById('footer').style.display = 'none';709 //document.getElementById('progress_bar').style.width = '0'; 710 //document.getElementById('footer').style.display = 'none'; 704 711 705 712 // If requested, open the site 706 713 if (go_to_flickr) { 707 714 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); 708 718 } 709 719 trunk/uploadr/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js
r541 r590 87 87 88 88 // Update the UI 89 /* 89 90 document.getElementById('username').firstChild.nodeValue = 90 91 locale.getFormattedString('username', [users.username]) + ' '; … … 95 96 status.set(locale.getString('status.ready')); 96 97 meta.login(); 98 */ 97 99 98 100 // Check the command line … … 125 127 126 128 // Update the UI 129 /* 127 130 document.getElementById('username').firstChild.nodeValue = 128 131 locale.getString('notloggedin') + ' '; … … 137 140 'http://flickr.com/images/buddyicon.jpg'; 138 141 document.getElementById('photostream_pro').style.display = 'none'; 142 */ 143 photos.call_swf('logged_in', [null]); 139 144 140 145 }, … … 165 170 users.nbVids, users.videosize, users.sets); 166 171 } 172 photos.call_swf("logged_in", [users.list[users.nsid]]); 167 173 168 174 }, … … 193 199 save: function() { 194 200 file.write('users.json', users.list); 195 } 201 }, 202 203 current_user:function(){ 204 if(!users.nsid) 205 return null 206 else 207 return users.list[users.nsid]; 208 } 196 209 197 210 };