Changeset 681
- Timestamp:
- 10/21/09 17:21:14 (1 month ago)
- Files:
-
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/api.js (modified) (4 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/drag.js (modified) (2 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js (modified) (2 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/flickr.js (modified) (2 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js (modified) (2 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/keyboard.js (modified) (2 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js (modified) (15 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js (modified) (8 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js (modified) (12 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.xul (modified) (3 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/proxy.js (modified) (1 diff)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js (modified) (5 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/threads.js (modified) (10 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/ui.js (modified) (7 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js (modified) (7 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js (modified) (1 diff)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/skin/uploadr/main.css (modified) (6 diffs)
- branches/uploadr/3.2/MacUploadr.app/Contents/Resources/components/simpleAutoComplete.js (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/api.js
r667 r681 292 292 'title': photo.title, 293 293 'description': photo.description, 294 'tags': photo.tags ,294 'tags': photo.tags.join(' '), 295 295 'is_public': photo.is_public, 296 296 'is_friend': photo.is_friend, … … 485 485 // Translate photos in the batch to this list 486 486 block_normalize(); 487 for each (var p in photos.list) { 488 if(p != null) { 489 for (var i in p.sets) { 490 p.sets[i] = sets_map[p.sets[i]]; 491 } 492 } 487 try { 488 for each (var p in photos.list) { 489 if(p != null) { 490 for (var i in p.sets) { 491 p.sets[i] = sets_map[p.sets[i]]; 492 } 493 } 494 } 495 } catch(err) { 496 Components.utils.reportError(new Date().toUTCString() + " " + err); 493 497 } 494 498 unblock_normalize(); … … 524 528 // Update selected photos 525 529 block_normalize(); 526 if (photos.selected.length) { 527 var prefix = 1 == photos.selected.length ? 528 'single' : 'batch'; 529 var li = document.getElementById(prefix + '_sets_added') 530 .getElementsByTagName('li'); 531 var ii = li.length; 532 for (var i = 0; i < ii; ++i) { 533 if ('sets_none' == li[i].className) { continue; } 534 var id = sets_map[parseInt(li[i].id.replace( 535 /^(single|batch)_sets_added_/, ''))]; 536 li[i].id = prefix + '_sets_added_' + id; 537 document.getElementById(prefix + '_sets_add_' + id) 538 .className = 'sets_disabled'; 539 } 540 } 530 try { 531 if (photos.selected.length) { 532 var prefix = 1 == photos.selected.length ? 533 'single' : 'batch'; 534 var li = document.getElementById(prefix + '_sets_added') 535 .getElementsByTagName('li'); 536 var ii = li.length; 537 for (var i = 0; i < ii; ++i) { 538 if ('sets_none' == li[i].className) { continue; } 539 var id = sets_map[parseInt(li[i].id.replace( 540 /^(single|batch)_sets_added_/, ''))]; 541 li[i].id = prefix + '_sets_added_' + id; 542 document.getElementById(prefix + '_sets_add_' + id) 543 .className = 'sets_disabled'; 544 } 545 } 546 } catch(err) { 547 Components.utils.reportError(new Date().toUTCString() + " " + err); 548 } 541 549 unblock_normalize(); 542 550 } … … 620 628 } 621 629 622 } 630 }, 631 632 tags: { 633 getListUserRaw: function(token) { 634 flickr.tags.getListUserRaw(wrap.tags._getListUserRaw, token); 635 }, 636 _getListUserRaw: function(rsp) { 637 if('object' != typeof rsp || 'ok' != rsp.getAttribute('stat')) { 638 return; // too bad but we don't care 639 } 640 var serializer = new XMLSerializer(); 641 document.getElementById('tags_input').setAttribute('autocompletesearchparam', serializer.serializeToString(rsp)); 642 } 643 } 623 644 624 645 }; branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/drag.js
r680 r681 45 45 }); 46 46 } 47 else {47 //else { 48 48 // var types = e.dataTransfer.types; 49 // var i = 1; 50 // logStringMessage("type: " + types.item(i)); 51 // logStringMessage(e.dataTransfer.getData(types.item(i))); 52 // paths.push(e.dataTransfer.getData(types.item(i))); 53 } 49 // for(i=0;i<types.length;i++) 50 // { 51 // logStringMessage("type: " + types.item(i)); 52 // logStringMessage(e.dataTransfer.getData(types.item(i))); 53 // } 54 //paths.push(e.dataTransfer.getData(types.item(i))); 55 //} 54 56 55 57 photos.add(paths); … … 67 69 drag.flavors.appendFlavour('application/x-moz-file', 'nsIFile'); 68 70 } catch (err) { 69 Components.utils.reportError(new Date().toUTCString() + err);71 Components.utils.reportError(new Date().toUTCString() + " " + err); 70 72 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/file.js
r601 r681 89 89 return 1 + Math.round(file.fileSize >> 10); 90 90 } catch (err) { 91 Components.utils.reportError(new Date().toUTCString() + err);91 Components.utils.reportError(new Date().toUTCString() + " " + err); 92 92 return 0; 93 93 } … … 104 104 } 105 105 } catch (err) { 106 Components.utils.reportError(new Date().toUTCString() + err);106 Components.utils.reportError(new Date().toUTCString() + " " + err); 107 107 } 108 108 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/flickr.js
r661 r681 13 13 var key = Cc['@flickr.com/key;1'].createInstance(Ci.flIKey); 14 14 } catch (err) { 15 Components.utils.reportError(new Date().toUTCString() + err);15 Components.utils.reportError(new Date().toUTCString() + " " + err); 16 16 } 17 17 … … 189 189 } 190 190 191 }, 192 193 tags: { 194 getListUserRaw: function(callback, token) { 195 api.start({ 196 'method' : 'flickr.tags.getListUserRaw', 197 'auth_token': token 198 }, callback); 199 } 191 200 } 192 193 201 }; 194 202 branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/grid.js
r601 r681 20 20 width: function() { 21 21 block_normalize(); 22 var p = photos.list; 23 var top = -1; 24 var width = 0; 25 for (var i = p.length; i >= 0; --i) { 26 if (null != p[i]) { 27 var test = document.getElementById('photo' + i).offsetTop; 28 if (-1 != top && test > top) { 29 return width; 30 } 31 top = test; 32 ++width; 33 } 34 } 22 try { 23 var p = photos.list; 24 var top = -1; 25 var width = 0; 26 for (var i = p.length; i >= 0; --i) { 27 if (null != p[i]) { 28 var test = document.getElementById('photo' + i).offsetTop; 29 if (-1 != top && test > top) { 30 unblock_normalize(); 31 return width; 32 } 33 top = test; 34 ++width; 35 } 36 } 37 } catch(err) { 38 Components.utils.reportError(new Date().toUTCString() + " " + err); 39 } 35 40 unblock_normalize(); 36 41 return 0; … … 58 63 // Walk the photos and see which are in the box 59 64 block_normalize(); 60 var p = photos.list; 61 for (var i = p.length; i >= 0; --i) { 62 if (null != p[i]) { 63 var img = document.getElementById('photo' + i) 64 .getElementsByTagName('img')[0]; 65 if (-1 == img.className.indexOf('error') 66 && -1 == img.className.indexOf('loading')) { 67 if (img.offsetLeft + OFFSET_X + img.width >= x1 && 68 img.offsetLeft + OFFSET_X <= x2 && 69 img.offsetTop + OFFSET_Y + img.height >= y1 && 70 img.offsetTop + OFFSET_Y <= y2) { 71 img.className = 'selecting'; 72 } else { 73 img.className = ''; 74 } 75 } 76 } 77 } 65 try { 66 var p = photos.list; 67 for (var i = p.length; i >= 0; --i) { 68 if (null != p[i]) { 69 var img = document.getElementById('photo' + i) 70 .getElementsByTagName('img')[0]; 71 if (-1 == img.className.indexOf('error') 72 && -1 == img.className.indexOf('loading')) { 73 if (img.offsetLeft + OFFSET_X + img.width >= x1 && 74 img.offsetLeft + OFFSET_X <= x2 && 75 img.offsetTop + OFFSET_Y + img.height >= y1 && 76 img.offsetTop + OFFSET_Y <= y2) { 77 img.className = 'selecting'; 78 } else { 79 img.className = ''; 80 } 81 } 82 } 83 } 84 } catch(err) { 85 Components.utils.reportError(new Date().toUTCString() + " " + err); 86 } 78 87 unblock_normalize(); 79 88 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/keyboard.js
r553 r681 35 35 } 36 36 block_normalize(); 37 photos.selected = []; 38 var list = document.getElementById('photos_list').getElementsByTagName('li'); 39 var ii = list.length; 40 for (var i = 0; i < ii; ++i) { 41 var img = list[i].getElementsByTagName('img')[0]; 42 if ('error' != img.className && 'loading' != img.className) { 43 img.className = 'selected'; 44 photos.selected.push(parseInt(list[i].id.replace('photo', ''))); 45 } 46 } 37 try { 38 photos.selected = []; 39 var list = document.getElementById('photos_list').getElementsByTagName('li'); 40 var ii = list.length; 41 for (var i = 0; i < ii; ++i) { 42 var img = list[i].getElementsByTagName('img')[0]; 43 if ('error' != img.className && 'loading' != img.className) { 44 img.className = 'selected'; 45 photos.selected.push(parseInt(list[i].id.replace('photo', ''))); 46 } 47 } 48 } catch(err) { 49 Components.utils.reportError(new Date().toUTCString() + " " + err); 50 } 47 51 unblock_normalize(); 48 52 meta.batch(); … … 78 82 79 83 block_normalize(); 80 var i = photos.last + inc; 81 var next = photos.list[i]; 82 var ii = photos.list.length; 83 while (null == next && i >= 0 && i < ii) { 84 // I do not think we are supposed to be in this loop. 85 // but let's make sure we can get out of it. 86 i += inc; 87 next = photos.list[i]; 88 } 89 if (null != next) { 90 var img = document.getElementById('photo' + next.id).getElementsByTagName('img')[0]; 91 mouse.click({ 92 target: img, 93 shiftKey: e.shiftKey, 94 ctrlKey: e.ctrlKey, 95 metaKey: e.metaKey 96 }); 97 img.scrollIntoView(inc > 0); 98 } 84 try { 85 var i = photos.last + inc; 86 var next = photos.list[i]; 87 var ii = photos.list.length; 88 while (null == next && i >= 0 && i < ii) { 89 // I do not think we are supposed to be in this loop. 90 // but let's make sure we can get out of it. 91 i += inc; 92 next = photos.list[i]; 93 } 94 if (null != next) { 95 var img = document.getElementById('photo' + next.id).getElementsByTagName('img')[0]; 96 mouse.click({ 97 target: img, 98 shiftKey: e.shiftKey, 99 ctrlKey: e.ctrlKey, 100 metaKey: e.metaKey 101 }); 102 img.scrollIntoView(inc > 0); 103 } 104 } catch(err) { 105 Components.utils.reportError(new Date().toUTCString() + " " + err); 106 } 99 107 unblock_normalize(); 100 108 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/meta.js
r670 r681 14 14 sets: [], 15 15 created_sets: 0, 16 16 17 17 // Show a special status message for their first batch 18 18 first: true, … … 37 37 } 38 38 block_normalize(); 39 // Load the defaults for a partial batch 40 if (null == id) { 41 42 // Proper diction 43 var p_count = 0; 44 var v_count = 0; 45 for each (var id in photos.selected) { 46 if (null == photos.list[id]) { 47 continue; 48 } 49 if (photos.is_photo(photos.list[id].path)) { 50 ++p_count; 51 } else { 52 ++v_count; 53 } 54 } 55 if (p_count && v_count) { 56 document.getElementById('batch_who').firstChild.nodeValue = 57 locale.getString('meta.batch.who.items'); 58 } else if (v_count) { 59 document.getElementById('batch_who').firstChild.nodeValue = 60 locale.getString('meta.batch.who.videos'); 61 } else { 62 document.getElementById('batch_who').firstChild.nodeValue = 63 locale.getString('meta.batch.who.photos'); 64 } 65 66 // Prompt 67 if (meta.first) { 68 document.getElementById('batch_prompt').firstChild.nodeValue = 69 locale.getString('meta.first'); 70 } else { 71 if (p_count && v_count) { 72 document.getElementById('batch_prompt').firstChild.nodeValue = 73 locale.getFormattedString('meta.batch.prompt.items', 74 [photos.selected.length]); 75 } else if (v_count) { 76 document.getElementById('batch_prompt').firstChild.nodeValue = 77 locale.getFormattedString('meta.batch.prompt.videos', 78 [photos.selected.length]); 79 } else { 80 document.getElementById('batch_prompt').firstChild.nodeValue = 81 locale.getFormattedString('meta.batch.prompt.photos', 82 [photos.selected.length]); 83 } 84 } 85 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; 99 var safety_level = document.getElementById('batch_safety_level'); 100 safety_level.value = 0; 101 safety_level.selectedItem.label = ''; 102 103 // Clear the old sets list 104 ul = document.getElementById('batch_sets_added'); 105 while (ul.hasChildNodes()) { 106 ul.removeChild(ul.firstChild); 107 } 108 var li = document.createElementNS(NS_HTML, 'li') 109 li.className = 'sets_none'; 110 li.appendChild(document.createTextNode( 111 locale.getString('meta.sets.added.none'))); 112 ul.appendChild(li); 113 document.getElementById('batch_sets_create').style.display = 114 meta.created_sets == users.sets ? 'none' : 'block'; 115 116 } 117 118 // Load the values from a specific photo 119 else if(photos.list[id]){ 120 var p = photos.list[id]; 121 122 // Proper diction 123 if (photos.is_video(p.path)) { 124 document.getElementById('single_who').firstChild.nodeValue = 125 locale.getString('meta.single.who.video'); 126 } else { 127 document.getElementById('single_who').firstChild.nodeValue = 128 locale.getString('meta.single.who.photo'); 129 } 130 131 // Show a preview of the image with file size and dimensions 132 if (!meta.first) { 133 document.getElementById('single_prompt').style.display = 'none'; 134 document.getElementById('single_preview').style.display = '-moz-box'; 135 var img = document.getElementById('photo' + id).getElementsByTagName('img')[0]; 136 var meta_div = document.getElementById('meta_div'); 137 while (meta_div.hasChildNodes()) { 138 meta_div.removeChild(meta_div.firstChild); 139 } 140 var w = parseInt(img.getAttribute('width')); 141 var h = parseInt(img.getAttribute('height')); 142 meta_div.setAttribute('width', w + 4); 143 meta_div.setAttribute('height', h + 4); 144 var meta_img = document.createElementNS(NS_HTML, 'img'); 145 meta_img.setAttribute('width', w); 146 meta_img.setAttribute('height', h); 147 meta_img.src = img.src; 148 meta_div.appendChild(meta_img); 149 document.getElementById('meta_dim').value = 150 locale.getFormattedString('meta.dim', [p.width, p.height]); 151 if (1024 > p.size) { 152 document.getElementById('meta_size').value = 153 locale.getFormattedString('kb', [p.size]); 154 } else { 155 document.getElementById('meta_size').value = 156 locale.getFormattedString('mb', 157 [Math.round(p.size / 102.4) / 10]); 158 } 159 if (photos.is_video(p.path)) { 160 var min = 0, sec = p.duration; 161 if (60 <= sec) { 162 min = parseInt(sec / 60); 163 sec = sec % 60; 164 } 165 if (10 > sec) { sec = '0' + sec; } 166 document.getElementById('meta_duration').value = 167 locale.getFormattedString('meta.duration', [min, sec]); 168 } else { 169 document.getElementById('meta_duration').value = ''; 170 } 171 } 172 173 // Pre-populate metadata 174 document.getElementById('single_title').value = p.title; 175 document.getElementById('single_description').value = p.description; 176 document.getElementById('single_tags').value = p.tags; 177 document.getElementById('single_is_public').value = p.is_public; 178 document.getElementById('single_is_friend').checked = 1 == p.is_friend; 179 document.getElementById('single_is_family').checked = 1 == p.is_family; 180 document.getElementById('single_content_type').value = p.content_type; 181 document.getElementById('single_hidden').value = p.hidden; 182 document.getElementById('single_safety_level').value = p.safety_level; 183 184 // Sets list 185 var ul = document.getElementById('single_sets_added'); 186 while (ul.hasChildNodes()) { 187 ul.removeChild(ul.firstChild); 188 } 189 var ii = p.sets.length; 190 if (0 == ii) { 191 var li = document.createElementNS(NS_HTML, 'li'); 192 li.className = 'sets_none'; 193 li.appendChild(document.createTextNode( 194 locale.getString('meta.sets.added.none'))); 195 ul.appendChild(li); 196 } else { 197 for (var i = 0; i < ii; ++i) { 198 document.getElementById('single_sets_add_' + p.sets[i]) 199 .className = 'sets_disabled'; 200 var li = document.createElementNS(NS_HTML, 'li'); 201 li.id = 'single_sets_added_' + p.sets[i]; 202 li.className = 'sets_trash'; 203 li.appendChild(document.createTextNode( 204 meta.sets[p.sets[i]].title)); 205 ul.appendChild(li); 206 } 207 } 208 document.getElementById('single_sets_create').style.display = 209 meta.created_sets == users.sets ? 'none' : 'block'; 210 } 211 212 // Send the selected photos list to extensions 213 extension.after_select.exec(photos.selected); 39 try { 40 // Load the defaults for a partial batch 41 if (null == id) { 42 // Proper diction 43 var p_count = 0; 44 var v_count = 0; 45 for each (var id in photos.selected) { 46 if (null == photos.list[id]) { 47 continue; 48 } 49 if (photos.is_photo(photos.list[id].path)) { 50 ++p_count; 51 } else { 52 ++v_count; 53 } 54 } 55 if (p_count && v_count) { 56 document.getElementById('batch_who').firstChild.nodeValue = 57 locale.getString('meta.batch.who.items'); 58 } else if (v_count) { 59 document.getElementById('batch_who').firstChild.nodeValue = 60 locale.getString('meta.batch.who.videos'); 61 } else { 62 document.getElementById('batch_who').firstChild.nodeValue = 63 locale.getString('meta.batch.who.photos'); 64 } 65 66 // Prompt 67 if (meta.first) { 68 document.getElementById('batch_prompt').firstChild.nodeValue = 69 locale.getString('meta.first'); 70 } else { 71 if (p_count && v_count) { 72 document.getElementById('batch_prompt').firstChild.nodeValue = 73 locale.getFormattedString('meta.batch.prompt.items', 74 [photos.selected.length]); 75 } else if (v_count) { 76 document.getElementById('batch_prompt').firstChild.nodeValue = 77 locale.getFormattedString('meta.batch.prompt.videos', 78 [photos.selected.length]); 79 } else { 80 document.getElementById('batch_prompt').firstChild.nodeValue = 81 locale.getFormattedString('meta.batch.prompt.photos', 82 [photos.selected.length]); 83 } 84 } 85 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; 99 var safety_level = document.getElementById('batch_safety_level'); 100 safety_level.value = 0; 101 safety_level.selectedItem.label = ''; 102 103 // Clear the old sets list 104 ul = document.getElementById('batch_sets_added'); 105 while (ul.hasChildNodes()) { 106 ul.removeChild(ul.firstChild); 107 } 108 var li = document.createElementNS(NS_HTML, 'li') 109 li.className = 'sets_none'; 110 li.appendChild(document.createTextNode( 111 locale.getString('meta.sets.added.none'))); 112 ul.appendChild(li); 113 document.getElementById('batch_sets_create').style.display = 114 meta.created_sets == users.sets ? 'none' : 'block'; 115 116 } 117 118 // Load the values from a specific photo 119 else if(photos.list[id]){ 120 var p = photos.list[id]; 121 122 // Proper diction 123 if (photos.is_video(p.path)) { 124 document.getElementById('single_who').firstChild.nodeValue = 125 locale.getString('meta.single.who.video'); 126 } else { 127 document.getElementById('single_who').firstChild.nodeValue = 128 locale.getString('meta.single.who.photo'); 129 } 130 131 // Show a preview of the image with file size and dimensions 132 if (!meta.first) { 133 document.getElementById('single_prompt').style.display = 'none'; 134 document.getElementById('single_preview').style.display = '-moz-box'; 135 var img = document.getElementById('photo' + id).getElementsByTagName('img')[0]; 136 var meta_div = document.getElementById('meta_div'); 137 while (meta_div.hasChildNodes()) { 138 meta_div.removeChild(meta_div.firstChild); 139 } 140 var w = parseInt(img.getAttribute('width')); 141 var h = parseInt(img.getAttribute('height')); 142 meta_div.setAttribute('width', w + 4); 143 meta_div.setAttribute('height', h + 4); 144 var meta_img = document.createElementNS(NS_HTML, 'img'); 145 meta_img.setAttribute('width', w); 146 meta_img.setAttribute('height', h); 147 meta_img.src = img.src; 148 meta_div.appendChild(meta_img); 149 document.getElementById('meta_dim').value = 150 locale.getFormattedString('meta.dim', [p.width, p.height]); 151 if (1024 > p.size) { 152 document.getElementById('meta_size').value = 153 locale.getFormattedString('kb', [p.size]); 154 } else { 155 document.getElementById('meta_size').value = 156 locale.getFormattedString('mb', 157 [Math.round(p.size / 102.4) / 10]); 158 } 159 if (photos.is_video(p.path)) { 160 var min = 0, sec = p.duration; 161 if (60 <= sec) { 162 min = parseInt(sec / 60); 163 sec = sec % 60; 164 } 165 if (10 > sec) { sec = '0' + sec; } 166 document.getElementById('meta_duration').value = 167 locale.getFormattedString('meta.duration', [min, sec]); 168 } else { 169 document.getElementById('meta_duration').value = ''; 170 } 171 } 172 173 // Pre-populate metadata 174 document.getElementById('single_title').value = p.title; 175 document.getElementById('single_description').value = p.description; 176 var ul = document.getElementById('single_tags_added'); 177 while (ul.hasChildNodes()) { 178 ul.removeChild(ul.firstChild); 179 } 180 for (var i=0; i<p.tags.length; i++) { 181 var li = ul.appendItem(p.tags[i], p.tags[i]); 182 li.setAttribute('crop', 'center'); 183 li.className = 'tags_added'; 184 // ui feedback + assure the elment is actually added! Grr... 185 ul.ensureElementIsVisible(li); 186 } 187 ul.ensureIndexIsVisible(0); 188 document.getElementById('single_is_public').value = p.is_public; 189 document.getElementById('single_is_friend').checked = 1 == p.is_friend; 190 document.getElementById('single_is_family').checked = 1 == p.is_family; 191 document.getElementById('single_content_type').value = p.content_type; 192 document.getElementById('single_hidden').value = p.hidden; 193 document.getElementById('single_safety_level').value = p.safety_level; 194 195 // Sets list 196 var ul = document.getElementById('single_sets_added'); 197 while (ul.hasChildNodes()) { 198 ul.removeChild(ul.firstChild); 199 } 200 var ii = p.sets.length; 201 if (0 == ii) { 202 var li = document.createElementNS(NS_HTML, 'li'); 203 li.className = 'sets_none'; 204 li.appendChild(document.createTextNode( 205 locale.getString('meta.sets.added.none'))); 206 ul.appendChild(li); 207 } else { 208 for (var i = 0; i < ii; ++i) { 209 document.getElementById('single_sets_add_' + p.sets[i]) 210 .className = 'sets_disabled'; 211 var li = document.createElementNS(NS_HTML, 'li'); 212 li.id = 'single_sets_added_' + p.sets[i]; 213 li.className = 'sets_trash'; 214 li.appendChild(document.createTextNode( 215 meta.sets[p.sets[i]].title)); 216 ul.appendChild(li); 217 } 218 } 219 document.getElementById('single_sets_create').style.display = 220 meta.created_sets == users.sets ? 'none' : 'block'; 221 } 222 223 // Send the selected photos list to extensions 224 extension.after_select.exec(photos.selected); 225 } catch(err) { 226 Components.utils.reportError(new Date().toUTCString() + " " + err); 227 } 214 228 unblock_normalize(); 215 229 }, … … 217 231 // Save photo metadata from the DOM into JS 218 232 save: function(id) { 233 if(meta.saving) { 234 logStringMessage('saving while saving'); 235 window.setTimeout(function(id) { 236 meta.save(id); 237 }, 100, id); 238 } 239 meta.saving = true; 219 240 220 241 // Save a partial batch into the selected photos 221 242 block_normalize(); 222 if (null == id) { 223 var ii = photos.selected.length; 224 for (var i = 0; i < ii; ++i) { 225 var p = photos.list[photos.selected[i]]; 226 if (null == p) { 227 continue; 228 } 229 230 // Overwrite title if one is given 231 var title = document.getElementById('batch_title').value; 232 if ('' != title) { 233 p.title = title; 234 } 235 236 // Append description if one is given 237 var description = document.getElementById('batch_description').value; 238 if ('' != description) { 239 p.description += ('' == p.description ? '' : '\n\n') + description; 240 } 241 242 // Append tags, but then parse and remove duplicates 243 p.tags = meta.tags(p.tags, 244 document.getElementById('batch_tags').value); 245 246 // Overwrite privacy, content type, hidden and safety level 247 var is_public = parseInt(document.getElementById('batch_is_public').value); 248 if (2 != is_public) { 249 p.is_public = is_public; 250 p.is_friend = document.getElementById('batch_is_friend').checked ? 1 : 0; 251 p.is_family = document.getElementById('batch_is_family').checked ? 1 : 0; 252 } 253 var content_type = parseInt(document.getElementById('batch_content_type').value); 254 if (0 != content_type) { 255 p.content_type = content_type; 256 } 257 var hidden = parseInt(document.getElementById('batch_hidden').value); 258 if (0 != hidden) { 259 p.hidden = hidden; 260 } 261 var safety_level = parseInt(document.getElementById('batch_safety_level').value); 262 if (0 != safety_level) { 263 p.safety_level = safety_level; 264 } 265 } 266 } 267 268 // Save a single photo 269 else if(photos.list[id]){ 270 var p = photos.list[id]; 271 p.title = document.getElementById('single_title').value; 272 p.description = document.getElementById('single_description').value; 273 p.tags = document.getElementById('single_tags').value; 274 p.is_public = parseInt(document.getElementById('single_is_public').value); 275 p.is_friend = document.getElementById('single_is_friend').checked ? 1 : 0; 276 p.is_family = document.getElementById('single_is_family').checked ? 1 : 0; 277 p.content_type = parseInt(document.getElementById('single_content_type').value); 278 p.hidden = parseInt(document.getElementById('single_hidden').value); 279 p.safety_level = parseInt(document.getElementById('single_safety_level').value); 280 } 281 282 // Send the selected photos list to extensions 283 extension.after_edit.exec(photos.selected); 243 try { 244 if (null == id) { 245 var ii = photos.selected.length; 246 for (var i = 0; i < ii; ++i) { 247 var p = photos.list[photos.selected[i]]; 248 if (null == p) { 249 continue; 250 } 251 252 // Overwrite title if one is given 253 var title = document.getElementById('batch_title').value; 254 if ('' != title) { 255 p.title = title; 256 } 257 258 // Append description if one is given 259 var description = document.getElementById('batch_description').value; 260 if ('' != description) { 261 p.description += ('' == p.description ? '' : '\n\n') + description; 262 } 263 264 // Append tags, but then parse and remove duplicates 265 p.tags = meta.tagsStringToArray(meta.tags(p.tags.join(' '), 266 document.getElementById('batch_tags').value)); 267 268 // Overwrite privacy, content type, hidden and safety level 269 var is_public = parseInt(document.getElementById('batch_is_public').value); 270 if (2 != is_public) { 271 p.is_public = is_public; 272 p.is_friend = document.getElementById('batch_is_friend').checked ? 1 : 0; 273 p.is_family = document.getElementById('batch_is_family').checked ? 1 : 0; 274 } 275 var content_type = parseInt(document.getElementById('batch_content_type').value); 276 if (0 != content_type) { 277 p.content_type = content_type; 278 } 279 var hidden = parseInt(document.getElementById('batch_hidden').value); 280 if (0 != hidden) { 281 p.hidden = hidden; 282 } 283 var safety_level = parseInt(document.getElementById('batch_safety_level').value); 284 if (0 != safety_level) { 285 p.safety_level = safety_level; 286 } 287 } 288 } 289 290 // Save a single photo 291 else if(photos.list[id]){ 292 var p = photos.list[id]; 293 p.title = document.getElementById('single_title').value; 294 p.description = document.getElementById('single_description').value; 295 var ul = document.getElementById('single_tags_added'); 296 p.tags = new Array(ul.itemCount); 297 for (var i = 0; i<ul.itemCount; i++) { 298 p.tags[i] = ul.getItemAtIndex(i).value; 299 } 300 p.is_public = parseInt(document.getElementById('single_is_public').value); 301 p.is_friend = document.getElementById('single_is_friend').checked ? 1 : 0; 302 p.is_family = document.getElementById('single_is_family').checked ? 1 : 0; 303 p.content_type = parseInt(document.getElementById('single_content_type').value); 304 p.hidden = parseInt(document.getElementById('single_hidden').value); 305 p.safety_level = parseInt(document.getElementById('single_safety_level').value); 306 } 307 308 // Send the selected photos list to extensions 309 extension.after_edit.exec(photos.selected); 310 } catch(err) { 311 Components.utils.reportError(new Date().toUTCString() + " " + err); 312 } 284 313 unblock_normalize(); 314 meta.saving = false; 285 315 }, 286 316 … … 311 341 var have_photos = false; 312 342 block_normalize(); 313 for each (var i in photos.selected) { 314 if (null == photos.list[i]) { 315 continue; 316 } 317 have_photos = photos.is_photo(photos.list[i].path) ? true : have_photos; 318 } 343 try { 344 for each (var i in photos.selected) { 345 if (null == photos.list[i]) { 346 continue; 347 } 348 have_photos = photos.is_photo(photos.list[i].path) ? true : have_photos; 349 } 350 } catch(err) { 351 Components.utils.reportError(new Date().toUTCString() + " " + err); 352 } 319 353 unblock_normalize(); 320 354 if (have_photos) { … … 341 375 // Single photo or group of photos? 342 376 block_normalize(); 343 var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 377 var prefix = 'single'; // arbitrary default value 378 try { 379 prefix = 1 == photos.selected.length ? 'single' : 'batch'; 380 } catch(err) { 381 Components.utils.reportError(new Date().toUTCString() + " " + err); 382 } 344 383 unblock_normalize(); 345 384 … … 365 404 // If conf.confirm_save_batch is off, this will always save rather than abandon 366 405 abandon: function() { 406 var batchSelected = false; 367 407 block_normalize(); 368 var batchSelected = (1 < photos.selected.length); 408 try { 409 batchSelected = (1 < photos.selected.length); 410 } catch(err) { 411 Components.utils.reportError(new Date().toUTCString() + " " + err); 412 } 369 413 unblock_normalize(); 370 414 if ('-moz-box' == document.getElementById('batch_meta').style.display && … … 385 429 }, 386 430 431 tagsStringToArray: function(str) { 432 // builds an array with already quoted tags 433 var tagsArray = str.match(/"[^"]+"/g); 434 if(tagsArray === null) { 435 tagsArray=[]; 436 } 437 // treats the rest as being comma or space delimited 438 var remainingStringsArray = str.replace(/"[^"]+"/g, "").split(/\s+|\s?,\s?/); 439 for each(var st in remainingStringsArray) { 440 if(st != "") { 441 tagsArray.push(st); 442 } 443 } 444 return tagsArray; 445 }, 446 387 447 // Parse a string into an array of tags 388 448 tags: function() { 449 450 389 451 var out = []; 390 452 var out_delim = ' '; … … 480 542 ul.insertBefore(li, ul.firstChild); 481 543 } 544 var prefix = 'single'; 482 545 block_normalize(); 483 var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 546 try { 547 prefix = 1 == photos.selected.length ? 'single' : 'batch'; 548 } catch(err) { 549 Components.utils.reportError(new Date().toUTCString() + " " + err); 550 } 484 551 unblock_normalize(); 485 552 meta.add_to_set({target: … … 492 559 }, 493 560 561 add_tag: function(e){ 562 var ul = document.getElementById('single_tags_added'); 563 var newTagsArray = meta.tagsStringToArray(document.getElementById('tags_input').value); 564 for each (var tag in newTagsArray) { 565 var li = ul.appendItem(tag, tag); 566 li.setAttribute('crop', 'center'); 567 li.className = 'tags_added'; 568 // ui feedback + assure the elment is actually added! Grr... 569 ul.ensureElementIsVisible(li); 570 } 571 document.getElementById('tags_input').value = ""; 572 }, 573 574 remove_tag: function(e) { 575 e.target.removeItemAt(e.target.selectedIndex); 576 }, 577 494 578 // Add selected photos to the selected set 495 579 add_to_set: function(e) { … … 506 590 507 591 // Add each selected photo to this set 592 var prefix = 'single'; 508 593 block_normalize(); 509 var ii = photos.selected.length; 510 for (var i = 0; i < ii; ++i) { 511 var p = photos.list[photos.selected[i]]; 512 if (null != p && -1 == p.sets.indexOf(set_index)) { 513 p.sets.push(set_index); 514 } 515 } 516 517 // Update the UI 518 var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 594 try { 595 var ii = photos.selected.length; 596 for (var i = 0; i < ii; ++i) { 597 var p = photos.list[photos.selected[i]]; 598 if (null != p && -1 == p.sets.indexOf(set_index)) { 599 p.sets.push(set_index); 600 } 601 } 602 603 // Update the UI 604 prefix = 1 == photos.selected.length ? 'single' : 'batch'; 605 } catch(err) { 606 Components.utils.reportError(new Date().toUTCString() + " " + err); 607 } 519 608 unblock_normalize(); 520 609 var ul = document.getElementById(prefix + '_sets_added'); … … 543 632 // Remove each selected photo from this set 544 633 block_normalize(); 545 var ii = photos.selected.length; 546 for (var i = 0; i < ii; ++i) { 547 var p = photos.list[photos.selected[i]]; 548 if (null == p) { continue; } 549 var new_sets = []; 550 var jj = p.sets.length; 551 for (var j = 0; j < jj; ++j) { 552 if (set_index != p.sets[j]) { 553 new_sets.push(p.sets[j]); 554 } 555 } 556 p.sets = new_sets; 557 } 558 559 // Update the UI 560 li.parentNode.removeChild(li); 561 var prefix = 1 == photos.selected.length ? 'single' : 'batch'; 634 var prefix = 'single'; 635 try { 636 var ii = photos.selected.length; 637 for (var i = 0; i < ii; ++i) { 638 var p = photos.list[photos.selected[i]]; 639 if (null == p) { continue; } 640 var new_sets = []; 641 var jj = p.sets.length; 642 for (var j = 0; j < jj; ++j) { 643 if (set_index != p.sets[j]) { 644 new_sets.push(p.sets[j]); 645 } 646 } 647 p.sets = new_sets; 648 } 649 650 // Update the UI 651 li.parentNode.removeChild(li); 652 prefix = 1 == photos.selected.length ? 'single' : 'batch'; 653 } catch(err) { 654 Components.utils.reportError(new Date().toUTCString() + " " + err); 655 } 562 656 unblock_normalize(); 563 657 var ul = document.getElementById(prefix + '_sets_added'); … … 611 705 // Null/NaN shows up on photos added before a user was logged in 612 706 block_normalize(); 613 var ii = photos.list.length; 614 for (var i = 0; i < ii; ++i) { 615 var p = photos.list[i]; 616 if (null != p) { 617 for (var m in map) { 618 if (isNaN(p[m]) || null == p[m]) { 619 p[m] = map[m]; 620 } 621 } 622 } 623 } 707 try { 708 var ii = photos.list.length; 709 for (var i = 0; i < ii; ++i) { 710 var p = photos.list[i]; 711 if (null != p) { 712 for (var m in map) { 713 if (isNaN(p[m]) || null == p[m]) { 714 p[m] = map[m]; 715 } 716 } 717 } 718 } 719 } catch(err) { 720 Components.utils.reportError(new Date().toUTCString() + " " + err); 721 } 624 722 unblock_normalize(); 625 723 }, … … 647 745 var v_count = 0; 648 746 block_normalize(); 649 for each (var id in photos.selected) { 650 var p = photos.list[id]; 651 if (null == p) { 652 continue; 653 } 654 if (photos.is_photo(p.path)) { 655 ++p_count; 656 } else if (photos.is_video(p.path)) { 657 ++v_count; 658 } 659 } 747 try { 748 for each (var id in photos.selected) { 749 var p = photos.list[id]; 750 if (null == p) { 751 continue; 752 } 753 if (photos.is_photo(p.path)) { 754 ++p_count; 755 } else if (photos.is_video(p.path)) { 756 ++v_count; 757 } 758 } 759 } catch(err) { 760 Components.utils.reportError(new Date().toUTCString() + " " + err); 761 } 660 762 unblock_normalize(); 661 763 // If there are videos then bother them … … 691 793 var new_selected = []; 692 794 block_normalize(); 693 for each (var id in photos.selected) { 694 if (null == photos.list[id]) { continue; } 695 696 // Remove videos 697 if (photos.is_video(photos.list[id].path)) { 698 var li = document.getElementById('photo' + id); 699 li.parentNode.removeChild(li); 700 photos.batch_size -= photos.list[id].size; 701 photos.video_batch_size -= photos.list[id].size; 702 if (users.nsid && !users.is_pro && 703 users.bandwidth && 704 0 < users.bandwidth.remaining - 705 photos.batch_size + photos.video_batch_size) { 706 status.clear(); 707 } 708 photos.list[id] = null; 709 --photos.count; 710 --photos.videoCount; 711 } 712 713 // Restrict photos 714 else { 715 new_selected.push(id); 716 photos.list[id].safety_level = 3; 717 } 718 719 } 720 ui.bandwidth_updated(); 721 photos.selected = new_selected; 722 if (photos.selected.length) { 723 if (1 == photos.selected.length) { 724 meta.load(photos.selected[0]); 725 meta.enable(); 726 } else { 727 meta.load(); 728 meta.batch(); 729 } 730 } else { 731 meta.disable(); 732 photos._remove(); 733 } 795 try { 796 for each (var id in photos.selected) { 797 if (null == photos.list[id]) { continue; } 798 799 // Remove videos 800 if (photos.is_video(photos.list[id].path)) { 801 var li = document.getElementById('photo' + id); 802 li.parentNode.removeChild(li); 803 photos.batch_size -= photos.list[id].size; 804 photos.video_batch_size -= photos.list[id].size; 805 if (users.nsid && !users.is_pro && 806 users.bandwidth && 807 0 < users.bandwidth.remaining - 808 photos.batch_size + photos.video_batch_size) { 809 status.clear(); 810 } 811 photos.list[id] = null; 812 --photos.count; 813 --photos.videoCount; 814 } 815 816 // Restrict photos 817 else { 818 new_selected.push(id); 819 photos.list[id].safety_level = 3; 820 } 821 822 } 823 ui.bandwidth_updated(); 824 photos.selected = new_selected; 825 if (photos.selected.length) { 826 if (1 == photos.selected.length) { 827 meta.load(photos.selected[0]); 828 meta.enable(); 829 } else { 830 meta.load(); 831 meta.batch(); 832 } 833 } else { 834 meta.disable(); 835 photos._remove(); 836 } 837 } catch(err) { 838 Components.utils.reportError(new Date().toUTCString() + " " + err); 839 } 734 840 unblock_normalize(); 735 841 // If remove is blocked then we know photos.normalize … … 748 854 // Update the safety level of only the videos 749 855 block_normalize(); 750 for each (var id in photos.selected) { 751 if (null == photos.list[id]) { continue; } 752 if (photos.is_video(photos.list[id].path)) { 753 photos.list[id].safety_level = 754 result.safety_level; 755 } else { 756 photos.list[id].safety_level = 3; 757 } 758 } 759 // If just one video is selected adjust the safety level 760 if (1 == photos.selected.length) { 761 document.getElementById('single_safety_level') 762 .value = result.safety_level; 763 } 764 // If multiple photos are selected, indicate the safety 765 // level inconsistency in the display 766 else { 767 var safety_level = document.getElementById( 768 'batch_safety_level'); 769 safety_level.value = 0; 770 safety_level.selectedItem.label = 771 locale.getString('video.safety_level.mixed'); 772 } 856 try { 857 for each (var id in photos.selected) { 858 if (null == photos.list[id]) { continue; } 859 if (photos.is_video(photos.list[id].path)) { 860 photos.list[id].safety_level = 861 result.safety_level; 862 } else { 863 photos.list[id].safety_level = 3; 864 } 865 } 866 // If just one video is selected adjust the safety level 867 if (1 == photos.selected.length) { 868 document.getElementById('single_safety_level') 869 .value = result.safety_level; 870 } 871 // If multiple photos are selected, indicate the safety 872 // level inconsistency in the display 873 else { 874 var safety_level = document.getElementById( 875 'batch_safety_level'); 876 safety_level.value = 0; 877 safety_level.selectedItem.label = 878 locale.getString('video.safety_level.mixed'); 879 } 880 } catch(err) { 881 Components.utils.reportError(new Date().toUTCString() + " " + err); 882 } 773 883 unblock_normalize(); 774 884 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/mouse.js
r674 r681 24 24 // Save old metadata 25 25 block_normalize(); 26 if (1 == photos.selected.length) { 27 meta.save(photos.selected[0]); 28 } else if (1 < photos.selected.length) { 29 meta.abandon(); 30 } 26 try { 27 if (1 == photos.selected.length) { 28 meta.save(photos.selected[0]); 29 } else if (1 < photos.selected.length) { 30 meta.abandon(); 31 } 32 } catch(err) { 33 Components.utils.reportError(new Date().toUTCString() + " " + err); 34 } 31 35 unblock_normalize(); 32 36 … … 39 43 if (!(e.shiftKey || e.ctrlKey || e.metaKey)) { 40 44 block_normalize(); 41 var imgs = document.getElementById('photos_list') 42 .getElementsByTagName('img'); 43 var ii = imgs.length; 44 for (var i = 0; i < ii; ++i) { 45 if ('error' != imgs[i].className 46 && 'loading' != imgs[i].className) { 47 imgs[i].className = ''; 48 } 49 } 50 photos.selected = []; 51 unblock_normalize(); 45 try { 46 var imgs = document.getElementById('photos_list') 47 .getElementsByTagName('img'); 48 var ii = imgs.length; 49 for (var i = 0; i < ii; ++i) { 50 if ('error' != imgs[i].className 51 && 'loading' != imgs[i].className) { 52 imgs[i].className = ''; 53 } 54 } 55 photos.selected = []; 56 } catch(err) { 57 Components.utils.reportError(new Date().toUTCString() + " " + err); 58 } 59 unblock_normalize(); 52 60 } 53 61 … … 58 66 // clicked and the image last clicked 59 67 block_normalize(); 60 if (null != photos.last && e.shiftKey) { 61 var inc = id < photos.last ? 1 : -1; 62 for (var i = id; i != photos.last; i += inc) { 63 try { 64 var p = document.getElementById('photo' + i); 65 if ('' == p.firstChild.className) { 66 p.firstChild.className = 'selected'; 67 photos.selected.push(i); 68 } 69 } catch (err) {} 70 } 71 } 72 // If ctrl or command is held, select or deselect this without 73 // changing others 74 else if (e.ctrlKey || e.metaKey) { 75 if ('' == img.className) { 76 img.className = 'selected'; 77 photos.selected.push(id); 78 } else { 79 img.className = ''; 80 var tmp = photos.selected; 81 photos.selected = []; 82 var ii = tmp.length; 83 for (var i = 0; i < ii; ++i) { 84 if (tmp[i] != id) { 85 photos.selected.push(tmp[i]); 86 } 87 } 88 } 89 } 90 91 // If this was just plain clicked, select it 92 else { 93 img.className = 'selected'; 94 photos.selected = [id]; 95 } 96 // Save the image last clicked 97 photos.last = id; 98 99 // Update the metadata pane 100 if (1 == photos.selected.length) { 101 meta.load(photos.selected[0]); 102 meta.enable(); 103 } else { 104 meta.batch(); 105 } 68 try { 69 if (null != photos.last && e.shiftKey) { 70 var inc = id < photos.last ? 1 : -1; 71 for (var i = id; i != photos.last; i += inc) { 72 try { 73 var p = document.getElementById('photo' + i); 74 if ('' == p.firstChild.className) { 75 p.firstChild.className = 'selected'; 76 photos.selected.push(i); 77 } 78 } catch (err) { 79 Components.utils.reportError(new Date().toUTCString() + " " + err); 80 } 81 } 82 } 83 // If ctrl or command is held, select or deselect this without 84 // changing others 85 else if (e.ctrlKey || e.metaKey) { 86 if ('' == img.className) { 87 img.className = 'selected'; 88 photos.selected.push(id); 89 } else { 90 img.className = ''; 91 var tmp = photos.selected; 92 photos.selected = []; 93 var ii = tmp.length; 94 for (var i = 0; i < ii; ++i) { 95 if (tmp[i] != id) { 96 photos.selected.push(tmp[i]); 97 } 98 } 99 } 100 } 101 102 // If this was just plain clicked, select it 103 else { 104 img.className = 'selected'; 105 photos.selected = [id]; 106 } 107 // Save the image last clicked 108 photos.last = id; 109 110 // Update the metadata pane 111 if (1 == photos.selected.length) { 112 meta.load(photos.selected[0]); 113 meta.enable(); 114 } else { 115 meta.batch(); 116 } 117 } catch(err) { 118 Components.utils.reportError(new Date().toUTCString() + " " + err); 119 } 106 120 unblock_normalize(); 107 121 } … … 126 140 else { 127 141 block_normalize(); 128 photos.selected = []; 142 try { 143 photos.selected = []; 144 } catch(err) { 145 Components.utils.reportError(new Date().toUTCString() + " " + err); 146 } 129 147 unblock_normalize(); 130 148 var imgs = document.getElementsByTagName('img'); … … 284 302 // Make the selected photos look like they're being dragged 285 303 block_normalize(); 286 for each (var id in photos.selected) { 287 document.getElementById('photo' + id) 288 .getElementsByTagName('img')[0].className = 289 'selected dragging'; 290 } 304 try { 305 for each (var id in photos.selected) { 306 document.getElementById('photo' + id) 307 .getElementsByTagName('img')[0].className = 308 'selected dragging'; 309 } 310 } catch(err) { 311 Components.utils.reportError(new Date().toUTCString() + " " + err); 312 } 291 313 unblock_normalize(); 292 314 mouse.dragging = 2; … … 305 327 var follower = document.getElementById('drag_follower'); 306 328 block_normalize(); 307 follower.firstChild.nodeValue = photos.selected.length;308 follower.style.left = (e.clientX + pos.x.value +309 OFFSET_X + 10) + 'px';310 follower.style.top = (e.clientY + pos.y.value +311 OFFSET_Y + 7) + 'px';312 follower.style.display = 'block';313 314 // Get the list item we're hovering over315 329 var target; 316 if ('li' == e.target.nodeName) { 317 target = e.target; 318 } else if ('img' == e.target.nodeName) { 319 target = e.target.parentNode; 320 } else { 321 target = document.getElementById('photos_list') 322 .lastChild; 323 } 324 325 // Which side of the list item are we on? 326 var left = e.clientX < (target.offsetLeft + 327 target.getElementsByTagName('img')[0].width / 2); 328 329 // Don't place the target in the middle of a bunch of 330 // selected elements 331 var list = document.getElementById('photos_list'); 332 while (target != list[left ? 'firstChild' : 'lastChild']) { 333 var tmp = target[left ? 'previousSibling' : 334 'nextSibling']; 335 if (-1 == target.getElementsByTagName('img')[0] 336 .className.indexOf('selected') 337 || -1 != target.getElementsByTagName('img')[0] 338 .className.indexOf('selected') 339 && -1 == tmp.getElementsByTagName('img')[0] 340 .className.indexOf('selected')) { 341 break; 342 } 343 target = tmp; 344 } 330 var left; 331 var list; 332 try { 333 follower.firstChild.nodeValue = photos.selected.length; 334 follower.style.left = (e.clientX + pos.x.value + 335 OFFSET_X + 10) + 'px'; 336 follower.style.top = (e.clientY + pos.y.value + 337 OFFSET_Y + 7) + 'px'; 338 follower.style.display = 'block'; 339 340 // Get the list item we're hovering over 341 if ('li' == e.target.nodeName) { 342 target = e.target; 343 } else if ('img' == e.target.nodeName) { 344 target = e.target.parentNode; 345 } else { 346 target = document.getElementById('photos_list') 347 .lastChild; 348 } 349 350 // Which side of the list item are we on? 351 left = e.clientX < (target.offsetLeft + 352 target.getElementsByTagName('img')[0].width / 2); 353 354 // Don't place the target in the middle of a bunch of 355 // selected elements 356 list = document.getElementById('photos_list'); 357 while (target != list[left ? 'firstChild' : 'lastChild']) { 358 var tmp = target[left ? 'previousSibling' : 359 'nextSibling']; 360 if (-1 == target.getElementsByTagName('img')[0] 361 .className.indexOf('selected') 362 || -1 != target.getElementsByTagName('img')[0] 363 .className.indexOf('selected') 364 && -1 == tmp.getElementsByTagName('img')[0] 365 .className.indexOf('selected')) { 366 break; 367 } 368 target = tmp; 369 } 370 } catch(err) { 371 Components.utils.reportError(new Date().toUTCString() + " " + err); 372 } 345 373 unblock_normalize(); 346 374 … … 436 464 if (null == mouse.anchor) { 437 465 block_normalize(); 438 var list = document.getElementById('photos_list'); 439 if (3 == mouse.dragging) { 440 441 // Reorder the photo list 442 photos.selected.sort(function(a, b) { 443 return a < b; 444 }); 445 for each (var id in photos.selected) { 446 var p = document.getElementById('photo' + id); 447 448 // Stop giving drag feedback 449 p.getElementsByTagName('img')[0].className = 'selected'; 450 451 // Move this image to its new home 452 if (mouse.left) { 453 list.insertBefore(p, mouse.target); 454 } else { 455 if (mouse.target == list.lastChild) { 456 list.appendChild(p); 457 } else { 458 list.insertBefore(p, mouse.target.nextSibling); 459 } 460 } 461 462 } 463 photos.normalize(); 464 465 // Stop showing feedback on the cursor 466 document.getElementById('drag_follower') 467 .style.display = 'none'; 468 if (null != mouse.target) { 469 mouse.target.className = ''; 470 } 471 472 // Show the link to revert to default order 473 document.getElementById('photos_sort_default') 474 .style.display = 'none'; 475 document.getElementById('photos_sort_revert') 476 .style.display = 'inline'; 477 photos.sort = false; 478 479 // Let extensions know we reordered photos 480 extension.after_reorder.exec(true); 481 482 } 466 try { 467 var list = document.getElementById('photos_list'); 468 if (3 == mouse.dragging) { 469 470 // Reorder the photo list 471 photos.selected.sort(function(a, b) { 472 return a < b; 473 }); 474 for each (var id in photos.selected) { 475 var p = document.getElementById('photo' + id); 476 477 // Stop giving drag feedback 478 p.getElementsByTagName('img')[0].className = 'selected'; 479 480 // Move this image to its new home 481 if (mouse.left) { 482 list.insertBefore(p, mouse.target); 483 } else { 484 if (mouse.target == list.lastChild) { 485 list.appendChild(p); 486 } else { 487 list.insertBefore(p, mouse.target.nextSibling); 488 } 489 } 490 491 } 492 photos.normalize(); 493 494 // Stop showing feedback on the cursor 495 document.getElementById('drag_follower') 496 .style.display = 'none'; 497 if (null != mouse.target) { 498 mouse.target.className = ''; 499 } 500 501 // Show the link to revert to default order 502 document.getElementById('photos_sort_default') 503 .style.display = 'none'; 504 document.getElementById('photos_sort_revert') 505 .style.display = 'inline'; 506 photos.sort = false; 507 508 // Let extensions know we reordered photos 509 extension.after_reorder.exec(true); 510 511 } 512 } catch(err) { 513 Components.utils.reportError(new Date().toUTCString() + " " + err); 514 } 483 515 unblock_normalize(); 484 516 mouse.dragging = 0; … … 508 540 // Save old metadata 509 541 block_normalize(); 510 if (1 == photos.selected.length) { 511 meta.save(photos.selected[0]); 512 } else if (1 < photos.selected.length) { 513 meta.abandon(); 514 } 515 516 // Find new selection 517 var p = photos.list; 518 photos.selected = []; 519 for (var i = p.length; i >= 0; --i) { 520 if (null != p[i]) { 521 var img = document.getElementById('photo' + i) 522 .getElementsByTagName('img')[0]; 523 524 // Don't select things that are errors or are loading 525 if (-1 == img.className.indexOf('error') && 526 -1 == img.className.indexOf('loading')) { 527 if ('selecting' == img.className) { 528 img.className = 'selected'; 529 photos.selected.push(i); 530 } else { 531 img.className = ''; 532 } 533 } 534 } 535 } 536 if (0 == photos.selected.length) { 537 mouse.click(e); 538 } else { 539 if (1 == photos.selected.length) { 540 meta.load(photos.selected[0]); 541 meta.enable(); 542 } else { 543 meta.batch(); 544 } 545 } 542 try { 543 if (1 == photos.selected.length) { 544 meta.save(photos.selected[0]); 545 } else if (1 < photos.selected.length) { 546 meta.abandon(); 547 } 548 549 // Find new selection 550 var p = photos.list; 551 photos.selected = []; 552 for (var i = p.length; i >= 0; --i) { 553 if (null != p[i]) { 554 var img = document.getElementById('photo' + i) 555 .getElementsByTagName('img')[0]; 556 557 // Don't select things that are errors or are loading 558 if (-1 == img.className.indexOf('error') && 559 -1 == img.className.indexOf('loading')) { 560 if ('selecting' == img.className) { 561 img.className = 'selected'; 562 photos.selected.push(i); 563 } else { 564 img.className = ''; 565 } 566 } 567 } 568 } 569 if (0 == photos.selected.length) { 570 mouse.click(e); 571 } else { 572 if (1 == photos.selected.length) { 573 meta.load(photos.selected[0]); 574 meta.enable(); 575 } else { 576 meta.batch(); 577 } 578 } 579 } catch(err) { 580 Components.utils.reportError(new Date().toUTCString() + " " + err); 581 } 546 582 unblock_normalize(); 547 583 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.js
r671 r681 285 285 var ii = paths.length; 286 286 block_normalize(); 287 var ext_list = []; 288 var currentPathsLists = photos.list.map(function(x) {return (x ? x.path : "");}); 289 290 for (var i = 0; i < ii; ++i) { 291 var p = 'object' == typeof paths[i] ? paths[i].path : paths[i]; 292 293 // Resolve the path and add the photo 294 if (/^file:\/\//.test(p)) { 295 p = Cc['@mozilla.org/network/protocol;1?name=file'] 296 .getService(Ci.nsIFileProtocolHandler) 297 .getFileFromURLSpec(p).path; 298 // p = Cc["@mozilla.org/network/io-service;1"] 299 // .getService(Components.interfaces.nsIIOService).newURI(p).QueryInterface(Ci.nsIFileURL).file.path 300 } 301 if(currentPathsLists.indexOf(p) === -1) { 302 ext_list.push(photos._add(p)); 303 304 // Photos can be passed as an object which already has metadata 305 if ('object' == typeof paths[i]) { 306 for (var k in paths[i]) { 307 if ('id' == k) { continue; } 308 photos.list[photos.list.length - 1][k] = paths[i][k]; 309 } 287 try { 288 var ext_list = []; 289 var currentPathsLists = photos.list.map(function(x) {return (x ? x.path : "");}); 290 291 for (var i = 0; i < ii; ++i) { 292 var p = 'object' == typeof paths[i] ? paths[i].path : paths[i]; 293 294 // Resolve the path and add the photo 295 if (/^file:\/\//.test(p)) { 296 p = Cc['@mozilla.org/network/protocol;1?name=file'] 297 .getService(Ci.nsIFileProtocolHandler) 298 .getFileFromURLSpec(p).path; 299 // p = Cc["@mozilla.org/network/io-service;1"] 300 // .getService(Components.interfaces.nsIIOService).newURI(p).QueryInterface(Ci.nsIFileURL).file.path 310 301 } 311 } 312 } 313 314 // Do extension stuff after we've added all of the photos but 315 // before the list we've saved potentially becomes invalid 316 extension.after_add.exec(ext_list); 317 318 // Update the UI 319 if (photos.count + photos.errors) { 320 document.getElementById('t_clear').className = 'button'; 321 if (photos.sort) { 322 threads.worker.dispatch(new Sort(), 323 threads.worker.DISPATCH_NORMAL); 324 document.getElementById('photos_sort_default') 325 .style.display = 'block'; 326 document.getElementById('photos_sort_revert') 327 .style.display = 'none'; 328 } else { 329 threads.worker.dispatch(new EnableUpload(), 330 threads.worker.DISPATCH_NORMAL); 331 document.getElementById('photos_sort_default') 332 .style.display = 'none'; 333 document.getElementById('photos_sort_revert') 334 .style.display = 'inline'; 335 } 336 document.getElementById('photos_init') 337 .style.display = 'none'; 338 document.getElementById('photos_new') 339 .style.display = 'none'; 340 document.getElementById('no_meta_prompt') 341 .style.visibility = 'visible'; 342 mouse.show_photos(); 343 } else { 344 document.getElementById('t_clear').className = 'disabled_button'; 345 document.getElementById('photos_init').style.display = '-moz-box'; 346 document.getElementById('photos_new').style.display = 'none'; 347 } 302 if(currentPathsLists.indexOf(p) === -1) { 303 ext_list.push(photos._add(p)); 304 305 // Photos can be passed as an object which already has metadata 306 if ('object' == typeof paths[i]) { 307 for (var k in paths[i]) { 308 if ('id' == k) { continue; } 309 photos.list[photos.list.length - 1][k] = paths[i][k]; 310 } 311 } 312 } 313 } 314 315 // Do extension stuff after we've added all of the photos but 316 // before the list we've saved potentially becomes invalid 317 extension.after_add.exec(ext_list); 318 319 // Update the UI 320 if (photos.count + photos.errors) { 321 document.getElementById('t_clear').className = 'button'; 322 if (photos.sort) { 323 threads.worker.dispatch(new Sort(), 324 threads.worker.DISPATCH_NORMAL); 325 document.getElementById('photos_sort_default') 326 .style.display = 'block'; 327 document.getElementById('photos_sort_revert') 328 .style.display = 'none'; 329 } else { 330 threads.worker.dispatch(new EnableUpload(), 331 threads.worker.DISPATCH_NORMAL); 332 document.getElementById('photos_sort_default') 333 .style.display = 'none'; 334 document.getElementById('photos_sort_revert') 335 .style.display = 'inline'; 336 } 337 document.getElementById('photos_init') 338 .style.display = 'none'; 339 document.getElementById('photos_new') 340 .style.display = 'none'; 341 document.getElementById('no_meta_prompt') 342 .style.visibility = 'visible'; 343 mouse.show_photos(); 344 } else { 345 document.getElementById('t_clear').className = 'disabled_button'; 346 document.getElementById('photos_init').style.display = '-moz-box'; 347 document.getElementById('photos_new').style.display = 'none'; 348 } 349 } catch(err) { 350 Components.utils.reportError(new Date().toUTCString() + " " + err); 351 } 348 352 unblock_normalize(); 349 353 photos.normalize(); … … 356 360 // Add the original image to the list and set our status 357 361 block_normalize(); 358 var id = photos.list.length; 359 var p = new Photo(id, path); 360 photos.list.push(p); 362 var id; 363 var p; 364 try { 365 id = photos.list.length; 366 p = new Photo(id, path); 367 photos.list.push(p); 368 } catch(err) { 369 Components.utils.reportError(new Date().toUTCString() + " " + err); 370 } 361 371 unblock_normalize(); 362 372 ++photos.count; … … 379 389 li.appendChild(img); 380 390 block_normalize(); 381 var list = document.getElementById('photos_list'); 382 list.insertBefore(li, list.firstChild); 383 // Create and show the thumbnail 384 photos.thumb_cancel = false; 385 threads.workerPool.dispatch(new Thumb(id, conf.thumb_size, path), 386 threads.workerPool.DISPATCH_NORMAL); 391 try { 392 var list = document.getElementById('photos_list'); 393 list.insertBefore(li, list.firstChild); 394 // Create and show the thumbnail 395 photos.thumb_cancel = false; 396 threads.workerPool.dispatch(new Thumb(id, conf.thumb_size, path), 397 threads.workerPool.DISPATCH_NORMAL); 398 } catch(err) { 399 Components.utils.reportError(new Date().toUTCString() + " " + err); 400 // if an exception is thrown here, the Thumbcallback won't be called. 401 // So we manually unblock_normalize 402 unblock_normalize(); 403 } 387 404 388 405 return p; … … 397 414 // Nothing to do if somehow there are no selected photos 398 415 block_normalize(); 399 var ii = photos.selected.length; 400 if (0 == ii) { 401 unblock_normalize(); 402 return; 403 } 404 document.getElementById('photos').style.display = 'none'; 405 document.getElementById('normalizing').style.display = '-moz-box'; 406 // Tell extensions which photos we're removing 407 extension.before_remove.exec(photos.selected); 408 409 // Remove selected photos 410 for (var i = 0; i < ii; ++i) { 411 var id = photos.selected[i]; 412 var li = document.getElementById('photo' + id); 413 if(li) { 414 li.parentNode.removeChild(li); 415 } 416 417 // Free the size of this file 418 photos.batch_size -= photos.list[id].size; 419 if(photos.is_video(photos.list[id].path)) { 420 photos.video_batch_size -= photos.list[id].size; 421 } 422 if (users.nsid && !users.is_pro && users.bandwidth && 423 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 424 status.clear(); 425 } 426 if(photos.is_video(photos.list[id].path)) { 427 --photos.videoCount; 428 } 429 photos.list[id] = null; 430 --photos.count; 431 } 416 try { 417 var ii = photos.selected.length; 418 if (0 == ii) { 419 unblock_normalize(); 420 return; 421 } 422 document.getElementById('photos').style.display = 'none'; 423 document.getElementById('normalizing').style.display = '-moz-box'; 424 // Tell extensions which photos we're removing 425 extension.before_remove.exec(photos.selected); 426 427 // Remove selected photos 428 for (var i = 0; i < ii; ++i) { 429 var id = photos.selected[i]; 430 var li = document.getElementById('photo' + id); 431 if(li) { 432 li.parentNode.removeChild(li); 433 } 434 435 // Free the size of this file 436 photos.batch_size -= photos.list[id].size; 437 if(photos.is_video(photos.list[id].path)) { 438 photos.video_batch_size -= photos.list[id].size; 439 } 440 if (users.nsid && !users.is_pro && users.bandwidth && 441 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 442 status.clear(); 443 } 444 if(photos.is_video(photos.list[id].path)) { 445 --photos.videoCount; 446 } 447 photos.list[id] = null; 448 --photos.count; 449 } 450 } catch(err) { 451 Components.utils.reportError(new Date().toUTCString() + " " + err); 452 } 432 453 unblock_normalize(); 433 454 ui.bandwidth_updated(); … … 437 458 // Clear the selection 438 459 block_normalize(); 439 photos.selected = []; 460 try { 461 photos.selected = []; 462 } catch(err) { 463 Components.utils.reportError(new Date().toUTCString() + " " + err); 464 } 440 465 unblock_normalize(); 441 466 mouse.click({target: {}}); … … 472 497 // Prevent silliness 473 498 block_normalize(); 474 var s = photos.selected; 475 var ii = s.length; 476 if (0 == ii) { 477 unblock_normalize(); 478 return; 479 } 480 photos.selected = []; 481 mouse.click({target: {}}); 482 483 // For each selected image, show the loading spinner and dispatch 484 // the rotate job 485 buttons.upload.disable(); 486 for (var i = 0; i < ii; ++i) { 487 var p = photos.list[s[i]]; 488 if (photos.is_photo(p.path)) { 489 block_sort(); 490 photos.batch_size -= p.size; 491 var img = document.getElementById('photo' + p.id) 492 .getElementsByTagName('img')[0]; 493 img.className = 'loading'; 494 img.setAttribute('width', 16); 495 img.setAttribute('height', 8); 496 img.src = 'chrome://uploadr/skin/balls-16x8-trans.gif'; 497 block_normalize(); 498 threads.worker.dispatch(new Rotate(p.id, degrees, 499 conf.thumb_size, p.path), 500 threads.worker.DISPATCH_NORMAL); 501 } 502 } 499 try { 500 var s = photos.selected; 501 var ii = s.length; 502 if (0 == ii) { 503 unblock_normalize(); 504 return; 505 } 506 photos.selected = []; 507 mouse.click({target: {}}); 508 509 // For each selected image, show the loading spinner and dispatch 510 // the rotate job 511 buttons.upload.disable(); 512 for (var i = 0; i < ii; ++i) { 513 var p = photos.list[s[i]]; 514 if (photos.is_photo(p.path)) { 515 block_sort(); 516 photos.batch_size -= p.size; 517 var img = document.getElementById('photo' + p.id) 518 .getElementsByTagName('img')[0]; 519 img.className = 'loading'; 520 img.setAttribute('width', 16); 521 img.setAttribute('height', 8); 522 img.src = 'chrome://uploadr/skin/balls-16x8-trans.gif'; 523 block_normalize(); 524 try { 525 threads.worker.dispatch(new Rotate(p.id, degrees, 526 conf.thumb_size, p.path), 527 threads.worker.DISPATCH_NORMAL); 528 } catch(err) { 529 Components.utils.reportError(new Date().toUTCString() + " " + err); 530 unblock_normalize(); // in case of exception RotateCallBack calling Thumb and thumbcallback won't happen 531 } 532 } 533 } 534 } catch(err) { 535 Components.utils.reportError(new Date().toUTCString() + " " + err); 536 } 503 537 unblock_normalize(); 504 538 threads.worker.dispatch(new EnableUpload(), … … 527 561 // Remove error indicators 528 562 block_normalize(); 529 var li = document.getElementById('photos_list') 530 .getElementsByTagName('li'); 531 var ii = li.length; 532 for (var i = 0; i < ii; ++i) { 533 var img = li[i].getElementsByTagName('img')[0]; 534 if ('error' == img.className) { 535 img.onclick(); 536 } 537 } 563 try { 564 var li = document.getElementById('photos_list') 565 .getElementsByTagName('li'); 566 var ii = li.length; 567 for (var i = 0; i < ii; ++i) { 568 var img = li[i].getElementsByTagName('img')[0]; 569 if ('error' == img.className) { 570 img.onclick(); 571 } 572 } 573 } catch(err) { 574 Components.utils.reportError(new Date().toUTCString() + " " + err); 575 } 538 576 unblock_normalize(); 539 577 … … 637 675 photos.videoCount = 0; 638 676 block_normalize(); 639 photos.selected = []; 677 try { 678 photos.selected = []; 679 } catch(err) { 680 Components.utils.reportError(new Date().toUTCString() + " " + err); 681 } 640 682 unblock_normalize(); 641 683 photos.last = null; 642 684 block_normalize(); 643 var uilist = document.getElementById('photos_list'); 644 while (uilist.hasChildNodes()) { 645 uilist.removeChild(uilist.firstChild); 646 } 685 try { 686 var uilist = document.getElementById('photos_list'); 687 while (uilist.hasChildNodes()) { 688 uilist.removeChild(uilist.firstChild); 689 } 690 } catch(err) { 691 Components.utils.reportError(new Date().toUTCString() + " " + err); 692 } 647 693 unblock_normalize(); 648 694 threads.readyToResize = true; … … 766 812 photos.videoCount = 0; 767 813 block_normalize(); 768 photos.selected = []; 814 try { 815 photos.selected = []; 816 } catch(err) { 817 Components.utils.reportError(new Date().toUTCString() + " " + err); 818 } 769 819 unblock_normalize(); 770 820 photos.last = null; 771 821 block_normalize(); 772 var ul = document.getElementById('photos_list'); 773 while (ul.hasChildNodes()) { 774 ul.removeChild(ul.firstChild); 775 } 822 try { 823 var ul = document.getElementById('photos_list'); 824 while (ul.hasChildNodes()) { 825 ul.removeChild(ul.firstChild); 826 } 827 } catch(err) { 828 Components.utils.reportError(new Date().toUTCString() + " " + err); 829 } 776 830 unblock_normalize(); 777 831 ui.bandwidth_updated(); … … 892 946 // Remove photos from UI 893 947 block_normalize(); 894 var list = document.getElementById('photos_list'); 895 while (list.hasChildNodes()) { 896 list.removeChild(list.firstChild); 897 } 948 try { 949 var list = document.getElementById('photos_list'); 950 while (list.hasChildNodes()) { 951 list.removeChild(list.firstChild); 952 } 953 } catch(err) { 954 Components.utils.reportError(new Date().toUTCString() + " " + err); 955 } 898 956 unblock_normalize(); 899 957 document.getElementById('photos_init').style.display = '-moz-box'; … … 907 965 if (0 != _block_exit) { return; } 908 966 block_normalize(); 909 if (1 == photos.selected.length) { 910 meta.save(photos.selected[0]); 911 } 912 file.write('photos.json', { 913 sort: photos.sort, 914 sets: meta.sets, 915 list: photos.list, 916 thumbSize: document.getElementById('photo_slider').value 917 }); 967 try { 968 if (1 == photos.selected.length) { 969 meta.save(photos.selected[0]); 970 } 971 file.write('photos.json', { 972 sort: photos.sort, 973 sets: meta.sets, 974 list: photos.list, 975 thumbSize: document.getElementById('photo_slider').value 976 }); 977 } catch(err) { 978 Components.utils.reportError(new Date().toUTCString() + " " + err); 979 } 918 980 unblock_normalize(); 919 981 }, … … 952 1014 this.title = ''; 953 1015 this.description = ''; 954 this.tags = '';1016 this.tags = []; 955 1017 this.duration = 0; 956 1018 this.is_public = settings.is_public; branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/photos.xul
r674 r681 119 119 <vbox id="single_meta_column_top_left" class="column"> 120 120 <html:p>&meta.single.title;</html:p> 121 <textbox id="single_title" tabindex="1"121 <textbox class="textfield" id="single_title" tabindex="1" 122 122 onfocus="keyboard.select_all_text(this);" 123 123 onblur="keyboard.select_all_photos();" /> 124 124 <html:p>&meta.single.description;</html:p> 125 <textbox id="single_description" multiline="true" rows="3" tabindex="2"125 <textbox class="textfield" id="single_description" multiline="true" rows="3" tabindex="2" 126 126 onfocus="keyboard.select_all_text(this);" 127 127 onblur="keyboard.select_all_photos();" /> 128 128 <html:p title="&meta.tags.tooltip;">&meta.single.tags;</html:p> 129 <textbox id="single_tags" multiline="true" rows="2" tabindex="3" 130 onfocus="keyboard.select_all_text(this);" 131 onblur="keyboard.select_all_photos();" 132 tooltiptext="&meta.tags.tooltip;" /> 129 <listbox id="single_tags_added" rows="4" onselect="meta.remove_tag(event);"> 130 <listitem class="tags_none"></listitem> 131 </listbox> 132 <hbox> 133 <textbox id="tags_input" tabindex="3" 134 onfocus="keyboard.select_all_text(this);" onblur="keyboard.select_all_photos();" 135 tooltiptext="&meta.tags.tooltip;" type="autocomplete" autocompletesearch="tags-autocomplete" 136 onkeypress="ui.autoComplete.onKeyPressed(event);" /> 137 <html:div id="tags_add" class="small button" onclick="meta.add_tag();" > 138 <html:div>&tools.add;</html:div> 139 </html:div> 140 </hbox> 133 141 </vbox> 134 142 <vbox id="single_meta_column_top_right" class="column"> … … 150 158 </vbox> 151 159 </hbox> 152 <hbox>153 <vbox id="single_meta_column_bottom_left" class="column">154 <html:p>&meta.safety_level;</html:p>155 <menulist id="single_safety_level" tabindex="4"156 oncommand="meta.restricted(this.value);">157 <menupopup>158 <menuitem value="1" label="&settings.safety_level.safe;"159 selected="true" />160 <menuitem value="2"161 label="&settings.safety_level.moderate;" />162 <menuitem value="3"163 label="&settings.safety_level.restricted;" />164 </menupopup>165 </menulist>166 </vbox>167 <vbox id="single_meta_column_bottom_right" class="column">168 <html:p>&meta.content_type;</html:p>169 <menulist id="single_content_type" tabindex="9">170 <menupopup>171 <menuitem value="1" label="&settings.content_type.photo;"172 selected="true" />173 <menuitem value="2"174 label="&settings.content_type.screenshot;" />175 <menuitem value="3" label="&settings.content_type.other;" />176 </menupopup>177 </menulist>178 </vbox>179 </hbox>180 <hbox id="hide_single_explain" class="status" >181 <html:p>&meta.hidden;</html:p>182 </hbox>183 <hbox id="hide_single_sets">184 <vbox>185 <html:p>&meta.single.sets.add;</html:p>186 <html:ul id="single_sets_add" onclick="meta.add_to_set(event);"160 <hbox> 161 <vbox id="single_meta_column_bottom_left" class="column"> 162 <html:p>&meta.safety_level;</html:p> 163 <menulist id="single_safety_level" tabindex="4" 164 oncommand="meta.restricted(this.value);"> 165 <menupopup> 166 <menuitem value="1" label="&settings.safety_level.safe;" 167 selected="true" /> 168 <menuitem value="2" 169 label="&settings.safety_level.moderate;" /> 170 <menuitem value="3" 171 label="&settings.safety_level.restricted;" /> 172 </menupopup> 173 </menulist> 174 </vbox> 175 <vbox id="single_meta_column_bottom_right" class="column"> 176 <html:p>&meta.content_type;</html:p> 177 <menulist id="single_content_type" tabindex="9"> 178 <menupopup> 179 <menuitem value="1" label="&settings.content_type.photo;" 180 selected="true" /> 181 <menuitem value="2" 182 label="&settings.content_type.screenshot;" /> 183 <menuitem value="3" label="&settings.content_type.other;" /> 184 </menupopup> 185 </menulist> 186 </vbox> 187 </hbox> 188 <hbox id="hide_single_explain" class="status" > 189 <html:p>&meta.hidden;</html:p> 190 </hbox> 191 <hbox id="hide_single_sets"> 192 <vbox> 193 <html:p>&meta.single.sets.add;</html:p> 194 <html:ul id="single_sets_add" onclick="meta.add_to_set(event);" 187 195 ></html:ul> 188 <box> 189 <html:div id="single_sets_create" onclick="meta.create_set();" 190 class="button"> 191 <html:div>&meta.sets.create;</html:div> 192 </html:div> 193 </box> 194 </vbox> 195 <vbox> 196 <html:p>&meta.single.sets.added;</html:p> 197 <html:ul id="single_sets_added" onclick="meta.remove_from_set(event);"> 198 <html:li class="sets_none">&meta.sets.added.none;</html:li> 199 </html:ul> 200 </vbox> 201 </hbox> 202 </vbox> 203 <vbox id="batch_meta" flex="1"> 204 <vbox class="status thumb_height"> 205 <html:h3 id="batch_prompt"> </html:h3> 206 <html:p>&meta.batch.prompt;</html:p> 196 <box> 197 <html:div id="single_sets_create" onclick="meta.create_set();" 198 class="button"> 199 <html:div>&meta.sets.create;</html:div> 200 </html:div> 201 </box> 202 </vbox> 203 <vbox> 204 <html:p>&meta.single.sets.added;</html:p> 205 <html:ul id="single_sets_added" onclick="meta.remove_from_set(event);"> 206 <html:li class="sets_none">&meta.sets.added.none;</html:li> 207 </html:ul> 208 </vbox> 209 </hbox> 207 210 </vbox> 208 <hbox> 209 <vbox id="batch_meta_column_top_left" class="column"> 210 <html:p title="&meta.batch.title.tooltip;">&meta.batch.title;</html:p> 211 <textbox id="batch_title" tabindex="1" 212 onfocus="keyboard.select_all_text(this);" 213 onblur="keyboard.select_all_photos();" 214 tooltiptext="&meta.batch.title.tooltip;" /> 215 <html:p title="&meta.batch.description.tooltip;" 211 <vbox id="batch_meta" flex="1"> 212 <vbox class="status thumb_height"> 213 <html:h3 id="batch_prompt"> </html:h3> 214 <html:p>&meta.batch.prompt;</html:p> 215 </vbox> 216 <hbox> 217 <vbox id="batch_meta_column_top_left" class="column"> 218 <html:p title="&meta.batch.title.tooltip;">&meta.batch.title;</html:p> 219 <textbox class="textfield" id="batch_title" tabindex="1" 220 onfocus="keyboard.select_all_text(this);" 221 onblur="keyboard.select_all_photos();" 222 tooltiptext="&meta.batch.title.tooltip;" /> 223 <html:p title="&meta.batch.description.tooltip;" 216 224 >&meta.batch.description;</html:p> 217 <hbox>218 <vbox>219 <spacer flex="1"/>220 <description>[...] +</description>221 <spacer flex="1"/>222 </vbox>223 <textboxid="batch_description" multiline="true" rows="3" tabindex="2"224 onfocus="keyboard.select_all_text(this);"225 onblur="keyboard.select_all_photos();"226 tooltiptext="&meta.batch.description.tooltip;" />227 </hbox>228 <html:p title="&meta.tags.tooltip;">&meta.batch.tags;</html:p>229 <hbox>230 <vbox>231 <spacer flex="1"/>232 <description>[...] +</description>233 <spacer flex="1"/>234 </vbox>235 <textbox id="batch_tags" multiline="true" rows="2" tabindex="3"236 onfocus="keyboard.select_all_text(this);"237 onblur="keyboard.select_all_photos();"238 tooltiptext="&meta.tags.tooltip;" />239 </hbox>240 </vbox>241 <vbox id="batch_meta_column_top_right" class="column">242 <html:p id="batch_who"> </html:p>243 <radiogroup id="batch_is_public" value="2" tabindex="5"244 oncommand="meta.is_public(this.value);">245 <radio value="0" label="&settings.privacy.private;" />246 <checkbox id="batch_is_friend"247 label="&settings.privacy.friend;" tabindex="6" />248 <checkbox id="batch_is_family"249 label="&settings.privacy.family;" tabindex="7" />250 <radio value="1" label="&settings.privacy.public;" />251 <radio value="2" label="" style="display: none;" />252 </radiogroup>253 <html:p style="margin: 16px 0 0 0;"> </html:p>254 <html:p>&settings.hidden;</html:p>255 <menulist id="batch_hidden" tabindex="8">256 <menupopup>257 <menuitem value="0" label="" selected="true" />258 <menuitem value="1" label="&settings.hidden.no;" />259 <menuitem value="2" label="&settings.hidden.yes;" />260 </menupopup>261 </menulist>262 </vbox>263 </hbox>264 <hbox>265 <vbox id="batch_meta_column_bottom_left" class="column">266 <html:p>&meta.safety_level;</html:p>267 <menulist id="batch_safety_level" tabindex="4"268 oncommand="meta.restricted(this.value);">269 <menupopup>270 <menuitem value="0" label="" selected="true" />271 <menuitem value="1" label="&settings.safety_level.safe;" />272 <menuitem value="2"273 label="&settings.safety_level.moderate;" />274 <menuitem value="3"275 label="&settings.safety_level.restricted;" />276 </menupopup>277 </menulist>278 </vbox>279 <vbox id="batch_meta_column_bottom_right" class="column">280 <html:p>&meta.content_type;</html:p>281 <menulist id="batch_content_type" tabindex="9">282 <menupopup>283 <menuitem value="0" label="" selected="true" />284 <menuitem value="1" label="&settings.content_type.photo;" />285 <menuitem value="2"286 label="&settings.content_type.screenshot;" />287 <menuitem value="3" label="&settings.content_type.other;" />288 </menupopup>289 </menulist>290 </vbox>291 </hbox>292 <hbox id="hide_batch_explain" class="status" >293 <html:p>&meta.hidden;</html:p>294 </hbox>295 <hbox id="hide_batch_sets">296 <vbox>297 <html:p>&meta.batch.sets.add;</html:p>298 <html:ul id="batch_sets_add" onclick="meta.add_to_set(event);"225 <hbox> 226 <vbox> 227 <spacer flex="1"/> 228 <description>[...] +</description> 229 <spacer flex="1"/> 230 </vbox> 231 <textbox class="textfield" id="batch_description" multiline="true" rows="3" tabindex="2" 232 onfocus="keyboard.select_all_text(this);" 233 onblur="keyboard.select_all_photos();" 234 tooltiptext="&meta.batch.description.tooltip;" /> 235 </hbox> 236 <html:p title="&meta.tags.tooltip;">&meta.batch.tags;</html:p> 237 <hbox> 238 <vbox> 239 <spacer flex="1"/> 240 <description>[...] +</description> 241 <spacer flex="1"/> 242 </vbox> 243 <textbox id="batch_tags" multiline="true" rows="2" tabindex="3" 244 onfocus="keyboard.select_all_text(this);" 245 onblur="keyboard.select_all_photos();" 246 tooltiptext="&meta.tags.tooltip;" /> 247 </hbox> 248 </vbox> 249 <vbox id="batch_meta_column_top_right" class="column"> 250 <html:p id="batch_who"> </html:p> 251 <radiogroup id="batch_is_public" value="2" tabindex="5" 252 oncommand="meta.is_public(this.value);"> 253 <radio value="0" label="&settings.privacy.private;" /> 254 <checkbox id="batch_is_friend" 255 label="&settings.privacy.friend;" tabindex="6" /> 256 <checkbox id="batch_is_family" 257 label="&settings.privacy.family;" tabindex="7" /> 258 <radio value="1" label="&settings.privacy.public;" /> 259 <radio value="2" label="" style="display: none;" /> 260 </radiogroup> 261 <html:p style="margin: 16px 0 0 0;"> </html:p> 262 <html:p>&settings.hidden;</html:p> 263 <menulist id="batch_hidden" tabindex="8"> 264 <menupopup> 265 <menuitem value="0" label="" selected="true" /> 266 <menuitem value="1" label="&settings.hidden.no;" /> 267 <menuitem value="2" label="&settings.hidden.yes;" /> 268 </menupopup> 269 </menulist> 270 </vbox> 271 </hbox> 272 <hbox> 273 <vbox id="batch_meta_column_bottom_left" class="column"> 274 <html:p>&meta.safety_level;</html:p> 275 <menulist id="batch_safety_level" tabindex="4" 276 oncommand="meta.restricted(this.value);"> 277 <menupopup> 278 <menuitem value="0" label="" selected="true" /> 279 <menuitem value="1" label="&settings.safety_level.safe;" /> 280 <menuitem value="2" 281 label="&settings.safety_level.moderate;" /> 282 <menuitem value="3" 283 label="&settings.safety_level.restricted;" /> 284 </menupopup> 285 </menulist> 286 </vbox> 287 <vbox id="batch_meta_column_bottom_right" class="column"> 288 <html:p>&meta.content_type;</html:p> 289 <menulist id="batch_content_type" tabindex="9"> 290 <menupopup> 291 <menuitem value="0" label="" selected="true" /> 292 <menuitem value="1" label="&settings.content_type.photo;" /> 293 <menuitem value="2" 294 label="&settings.content_type.screenshot;" /> 295 <menuitem value="3" label="&settings.content_type.other;" /> 296 </menupopup> 297 </menulist> 298 </vbox> 299 </hbox> 300 <hbox id="hide_batch_explain" class="status" > 301 <html:p>&meta.hidden;</html:p> 302 </hbox> 303 <hbox id="hide_batch_sets"> 304 <vbox> 305 <html:p>&meta.batch.sets.add;</html:p> 306 <html:ul id="batch_sets_add" onclick="meta.add_to_set(event);" 299 307 ></html:ul> 300 <box>301 <html:div id="batch_sets_create" onclick="meta.create_set();"302 class="button">303 <html:div>&meta.sets.create;</html:div>304 </html:div>305 </box>306 </vbox>307 <vbox>308 <html:p>&meta.batch.sets.added;</html:p>309 <description>[...] +</description>308 <box> 309 <html:div id="batch_sets_create" onclick="meta.create_set();" 310 class="button"> 311 <html:div>&meta.sets.create;</html:div> 312 </html:div> 313 </box> 314 </vbox> 315 <vbox> 316 <html:p>&meta.batch.sets.added;</html:p> 317 <description>[...] +</description> 310 318 <html:ul id="batch_sets_added" onclick="meta.remove_from_set(event);"> 311 319 <html:li class="sets_none">&meta.sets.added.none;</html:li> 312 320 </html:ul> 313 </vbox> 314 </hbox> 315 </vbox> 316 <vbox id="no_meta" flex="1"> 317 <vbox id="no_meta_prompt" class="status thumb_height" > 318 <html:h3>&meta.no.prompt;</html:h3> 321 </vbox> 322 </hbox> 319 323 </vbox> 320 <hbox> 321 <vbox class="column"> 322 <html:p>&meta.single.title;</html:p> 323 <textbox disabled="true" /> 324 <html:p>&meta.single.description;</html:p> 325 <textbox multiline="true" rows="3" disabled="true" /> 326 <html:p>&meta.single.tags;</html:p> 327 <textbox multiline="true" rows="2" disabled="true" /> 328 </vbox> 329 <vbox class="column"> 330 <html:p id="no_who"> </html:p> 331 <radiogroup id="no_is_public" value="2" disabled="true"> 332 <radio value="0" label="&settings.privacy.private;" /> 333 <checkbox label="&settings.privacy.friend;" disabled="true" /> 334 <checkbox label="&settings.privacy.family;" disabled="true" /> 335 <radio value="1" label="&settings.privacy.public;" /> 336 <radio value="2" label="" style="display: none;" /> 337 </radiogroup> 338 <html:p style="margin: 16px 0 0 0;"> </html:p> 339 <html:p>&settings.hidden;</html:p> 340 <menulist disabled="true"> 341 <menupopup /> 342 </menulist> 343 </vbox> 344 </hbox> 324 <vbox id="no_meta" flex="1"> 325 <vbox id="no_meta_prompt" class="status thumb_height" > 326 <html:h3>&meta.no.prompt;</html:h3> 327 </vbox> 328 <hbox> 329 <vbox class="column"> 330 <html:p>&meta.single.title;</html:p> 331 <textbox class="textfield" disabled="true" /> 332 <html:p>&meta.single.description;</html:p> 333 <textbox class="textfield" multiline="true" rows="3" disabled="true" /> 334 <html:p>&meta.single.tags;</html:p> 335 <textbox multiline="true" rows="2" disabled="true" /> 336 </vbox> 337 <vbox class="column"> 338 <html:p id="no_who"> </html:p> 339 <radiogroup id="no_is_public" value="2" disabled="true"> 340 <radio value="0" label="&settings.privacy.private;" /> 341 <checkbox label="&settings.privacy.friend;" disabled="true" /> 342 <checkbox label="&settings.privacy.family;" disabled="true" /> 343 <radio value="1" label="&settings.privacy.public;" /> 344 <radio value="2" label="" style="display: none;" /> 345 </radiogroup> 346 <html:p style="margin: 16px 0 0 0;"> </html:p> 347 <html:p>&settings.hidden;</html:p> 348 <menulist disabled="true"> 349 <menupopup /> 350 </menulist> 351 </vbox> 352 </hbox> 345 353 <hbox> 346 354 <vbox class="column"> … … 387 395 </hbox> 388 396 </vbox> 389 </overlay>397 </overlay> branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/proxy.js
r514 r681 58 58 try { 59 59 autoURLPref.value = autoURL.value = URIFixup.createFixupURI(autoURL.value, 0).spec; 60 } catch(ex) {} 60 } catch(ex) { 61 Components.utils.reportError(new Date().toUTCString() + " " + ex); 62 } 61 63 } 62 64 branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/settings.js
r601 r681 189 189 // Save metadata 190 190 block_normalize(); 191 if (1 == photos.selected.length) { 192 meta.save(photos.selected[0]); 193 } else if (1 < photos.selected.length) { 194 meta.save(); 195 meta.load(); 196 } 197 198 // Update all photos 199 var ii = photos.list.length; 200 for (var i = 0; i < ii; ++i) { 201 var photo = photos.list[i]; 202 if (null != photo) { 203 for each (var k in ['is_public', 'is_friend', 'is_family']) { 204 photo[k] = settings[k]; 205 } 206 photo.content_type = settings.content_type; 207 photo.hidden = settings.hidden; 208 photo.safety_level = settings.safety_level; 209 } 210 } 191 try { 192 if (1 == photos.selected.length) { 193 meta.save(photos.selected[0]); 194 } else if (1 < photos.selected.length) { 195 meta.save(); 196 meta.load(); 197 } 198 199 // Update all photos 200 var ii = photos.list.length; 201 for (var i = 0; i < ii; ++i) { 202 var photo = photos.list[i]; 203 if (null != photo) { 204 for each (var k in ['is_public', 'is_friend', 'is_family']) { 205 photo[k] = settings[k]; 206 } 207 photo.content_type = settings.content_type; 208 photo.hidden = settings.hidden; 209 photo.safety_level = settings.safety_level; 210 } 211 } 212 } catch(err) { 213 Components.utils.reportError(new Date().toUTCString() + " " + err); 214 } 211 215 unblock_normalize(); 212 216 // Videos can't be restricted so either update them or delete them … … 217 221 var v_count = 0; 218 222 block_normalize(); 219 for each (var p in photos.list) { 220 if (null == p) { 221 continue; 222 } 223 if (photos.is_photo(p.path)) { 224 ++p_count; 225 } else if (photos.is_video(p.path)) { 226 ++v_count; 227 } 228 } 223 try { 224 for each (var p in photos.list) { 225 if (null == p) { 226 continue; 227 } 228 if (photos.is_photo(p.path)) { 229 ++p_count; 230 } else if (photos.is_video(p.path)) { 231 ++v_count; 232 } 233 } 234 } catch(err) { 235 Components.utils.reportError(new Date().toUTCString() + " " + err); 236 } 229 237 unblock_normalize(); 230 238 // If there are videos, bother them … … 259 267 if ('cancel' == result.result) { 260 268 block_normalize(); 261 var ii = photos.list.length; 262 for (var i = 0; i < ii; ++i) { 263 if (null == photos.list[i]) { 264 continue; 265 } 266 if (photos.is_video(photos.list[i].path)) { 267 var li = document.getElementById('photo' + i); 268 li.parentNode.removeChild(li); 269 photos.batch_size -= photos.list[i].size; 270 photos.video_batch_size -= photos.list[i].size; 271 if (users.nsid && !users.is_pro && 272 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 273 status.clear(); 274 } 275 if(photos.is_video(photos.list[i].path)) { 276 --photos.videoCount; 277 } 278 photos.list[i] = null; 279 --photos.count; 280 } 281 } 269 try { 270 var ii = photos.list.length; 271 for (var i = 0; i < ii; ++i) { 272 if (null == photos.list[i]) { 273 continue; 274 } 275 if (photos.is_video(photos.list[i].path)) { 276 var li = document.getElementById('photo' + i); 277 li.parentNode.removeChild(li); 278 photos.batch_size -= photos.list[i].size; 279 photos.video_batch_size -= photos.list[i].size; 280 if (users.nsid && !users.is_pro && 281 0 < users.bandwidth.remaining - photos.batch_size + photos.video_batch_size) { 282 status.clear(); 283 } 284 if(photos.is_video(photos.list[i].path)) { 285 --photos.videoCount; 286 } 287 photos.list[i] = null; 288 --photos.count; 289 } 290 } 291 } catch(err) { 292 Components.utils.reportError(new Date().toUTCString() + " " + err); 293 } 282 294 unblock_normalize(); 283 295 ui.bandwidth_updated(); … … 296 308 else if ('ok' == result.result && result.safety_level) { 297 309 block_normalize(); 298 var ii = photos.list.length; 299 for (var i = 0; i < ii; ++i) { 300 if (null != photos.list[i] && 301 photos.is_video(photos.list[i].path)) { 302 photos.list[i].safety_level = result.safety_level; 303 } 304 } 310 try { 311 var ii = photos.list.length; 312 for (var i = 0; i < ii; ++i) { 313 if (null != photos.list[i] && 314 photos.is_video(photos.list[i].path)) { 315 photos.list[i].safety_level = result.safety_level; 316 } 317 } 318 } catch(err) { 319 Components.utils.reportError(new Date().toUTCString() + " " + err); 320 } 305 321 unblock_normalize(); 306 322 } … … 312 328 // Refresh visible photo metadata if necessary 313 329 block_normalize(); 314 if (1 == photos.selected.length) { 315 meta.load(photos.selected[0]); 316 meta.enable(); 317 } else if (1 < photos.selected.length) { 318 meta.load(); 319 meta.batch(); 320 } 330 try { 331 if (1 == photos.selected.length) { 332 meta.load(photos.selected[0]); 333 meta.enable(); 334 } else if (1 < photos.selected.length) { 335 meta.load(); 336 meta.batch(); 337 } 338 } catch(err) { 339 Components.utils.reportError(new Date().toUTCString() + " " + err); 340 } 321 341 unblock_normalize(); 322 342 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/threads.js
r673 r681 59 59 threads.initialized = true; 60 60 } catch (err) { 61 Components.utils.reportError(new Date().toUTCString() + err);61 Components.utils.reportError(new Date().toUTCString() + " " + err); 62 62 var VSRedist = Components.classes["@mozilla.org/file/directory_service;1"] 63 63 .getService(Components.interfaces.nsIProperties) … … 72 72 installer.run(true,'',0); 73 73 } catch (err2) { 74 Components.utils.reportError(new Date().toUTCString() + err2);74 Components.utils.reportError(new Date().toUTCString() + " " + err2); 75 75 } 76 76 var e = Cc['@mozilla.org/toolkit/app-startup;1'] … … 152 152 } 153 153 mouse.box.ensureElementIsVisible(li); 154 }catch (e) 155 { 154 } catch (e) { 156 155 // we don't care if something went wrong here 156 logStringMessage(e); 157 157 } 158 158 … … 265 265 266 266 } 267 if ( '' == photos.list[this.id].tags) {268 photos.list[this.id].tags= thumb[9] ? thumb[9]267 if (0 == photos.list[this.id].tags.length) { 268 tmpTagsString = thumb[9] ? thumb[9] 269 269 .replace(/^\s+|\s+$/g, '') 270 270 .replace(/\{---THREE---POUND---DELIM---\}/g, '###') 271 271 : ''; 272 photos.list[this.id].tags = meta.tagsStringToArray(tmpTagsString); 272 273 } 273 274 … … 332 333 333 334 } catch (err) { 334 Components.utils.reportError(new Date().toUTCString() + err);335 Components.utils.reportError(new Date().toUTCString() + " " + err); 335 336 } 336 337 unblock_normalize(); … … 386 387 387 388 } catch (err) { 388 Components.utils.reportError(new Date().toUTCString() + err);389 Components.utils.reportError(new Date().toUTCString() + " " + err); 389 390 } 390 391 }, … … 429 430 430 431 } catch (err) { 431 Components.utils.reportError(new Date().toUTCString() + err);432 Components.utils.reportError(new Date().toUTCString() + " " + err); 432 433 } 433 434 }, … … 456 457 // Perform the sort 457 458 block_normalize(); 458 if(conf.console.sort) { 459 logStringMessage('sort [in] ' + _block_normalize); 460 } 461 if (1 >= photos.list.length) { 462 if (1 == photos.list.length) { 463 buttons.upload.enable(); 464 } 465 if(conf.console.sort) { 466 logStringMessage('sort [out]'); 459 try { 460 if(conf.console.sort) { 461 logStringMessage('sort [in] ' + _block_normalize); 467 462 } 468 unblock_normalize(); 469 return; 470 } 471 var p = []; 472 for each (var photo in photos.list) { 473 if (null != photo) { 474 p.push({ 475 id: photo.id, 476 date_taken: photo.date_taken 477 }); 478 } 479 } 480 p.sort(function(a, b) { 481 return a.date_taken > b.date_taken; 482 }); 483 484 // Lazily do the UI refresh by appendChild'ing everything in the 485 // right order 486 // This is far from being a bottleneck, so leave it alone 487 // until it is 488 // Remember appendChild removes the node from its parent. 489 // We are effectively doing an inplace replace! 490 var list = document.getElementById('photos_list'); 491 for (var i = p.length - 1; i >= 0; --i) { 492 if (null != p[i]) { 493 list.appendChild(document.getElementById('photo' + p[i].id)); 494 } 495 } 463 if (1 >= photos.list.length) { 464 if (1 == photos.list.length) { 465 buttons.upload.enable(); 466 } 467 if(conf.console.sort) { 468 logStringMessage('sort [out]'); 469 } 470 unblock_normalize(); 471 return; 472 } 473 var p = []; 474 for each (var photo in photos.list) { 475 if (null != photo) { 476 p.push({ 477 id: photo.id, 478 date_taken: photo.date_taken 479 }); 480 } 481 } 482 p.sort(function(a, b) { 483 return a.date_taken > b.date_taken; 484 }); 485 486 // Lazily do the UI refresh by appendChild'ing everything in the 487 // right order 488 // This is far from being a bottleneck, so leave it alone 489 // until it is 490 // Remember appendChild removes the node from its parent. 491 // We are effectively doing an inplace replace! 492 var list = document.getElementById('photos_list'); 493 for (var i = p.length - 1; i >= 0; --i) { 494 if (null != p[i]) { 495 list.appendChild(document.getElementById('photo' + p[i].id)); 496 } 497 } 498 } catch(err) { 499 Components.utils.reportError(new Date().toUTCString() + " " + err); 500 } 496 501 unblock_normalize(); 497 502 if(conf.console.sort) { … … 533 538 534 539 } catch (err) { 535 Components.utils.reportError(new Date().toUTCString() + err);540 Components.utils.reportError(new Date().toUTCString() + " " + err); 536 541 } 537 542 }, … … 585 590 } 586 591 } catch (err) { 587 Components.utils.reportError(new Date().toUTCString() + err);592 Components.utils.reportError(new Date().toUTCString() + " " + err); 588 593 } 589 594 }, branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/ui.js
r676 r681 50 50 node.appendChild(span); 51 51 node.appendChild(document.createTextNode(parts[2])); 52 52 53 53 }, 54 54 … … 68 68 changeThumbSize: function(size) { 69 69 block_normalize(); 70 for each (var p in photos.list) { 71 if(p==null) { 72 continue; 70 try { 71 for each (var p in photos.list) { 72 if(p==null) { 73 continue; 74 } 75 ui.resizeThumbImg(p.id); 73 76 } 74 ui.resizeThumbImg(p.id); 75 } 77 } catch(err) { 78 Components.utils.reportError(new Date().toUTCString() + " " + err); 79 } 76 80 unblock_normalize(); 77 81 }, … … 183 187 } 184 188 185 } 186 189 }, 190 autoComplete: { 191 baseValue:"", 192 193 onKeyPressed: function(e) { 194 if(e.keyCode === Components.interfaces.nsIDOMKeyEvent.DOM_VK_ENTER || 195 e.keyCode === Components.interfaces.nsIDOMKeyEvent.DOM_VK_RETURN) { 196 meta.add_tag(); 197 } 198 } 199 } 187 200 }; 188 201 … … 398 411 launcher.preferredAction = Ci.nsIHandlerInfo.useSystemDefault; 399 412 launcher.launchWithURI(uri, null); 400 } catch (err) {} 413 } catch (err) { 414 Components.utils.reportError(new Date().toUTCString() + " " + err); 415 } 401 416 return url; 402 417 }; … … 505 520 profile.append('images'); 506 521 profile.remove(true); 507 } catch (err) {} 522 } catch (err) { 523 Components.utils.reportError(new Date().toUTCString() + " " + err); 524 } 508 525 try { 509 526 var temp = Cc['@mozilla.org/file/local;1'] … … 517 534 try { 518 535 f.remove(false); 519 } catch (err2) {} 536 } catch (err2) { 537 Components.utils.reportError(new Date().toUTCString() + " " + err2); 538 } 520 539 } 521 540 } 522 541 } 523 } catch (err) {} 542 } catch (err) { 543 Components.utils.reportError(new Date().toUTCString() + " " + err); 544 } 524 545 } 525 546 … … 533 554 threads.uploadr.shutdown(); 534 555 } 535 catch (err) {} 556 catch (err) { 557 Components.utils.reportError(new Date().toUTCString() + " " + err); 558 } 536 559 537 560 // Finally exit branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/upload.js
r679 r681 111 111 'title': photo.title, 112 112 'description': photo.description, 113 'tags': photo.tags ,113 'tags': photo.tags.join(' '), 114 114 'is_public': photo.is_public, 115 115 'is_friend': photo.is_friend, … … 530 530 } 531 531 block_normalize(); 532 for (var i = 0; i < ii; ++i) { 533 photos._add(f[i].path); 534 photos.list[photos.list.length - 1] = f[i]; 535 } 536 537 // Add back any queued batches 538 while (photos.ready.length) { 539 var r = photos.ready.shift(); 540 ii = r.length; 541 for (var i = 0; i < ii; ++i) { 542 photos._add(r[i].path); 543 photos.list[photos.list.length - 1] = r[i]; 544 } 545 } 532 try { 533 for (var i = 0; i < ii; ++i) { 534 photos._add(f[i].path); 535 photos.list[photos.list.length - 1] = f[i]; 536 } 537 538 // Add back any queued batches 539 while (photos.ready.length) { 540 var r = photos.ready.shift(); 541 ii = r.length; 542 for (var i = 0; i < ii; ++i) { 543 photos._add(r[i].path); 544 photos.list[photos.list.length - 1] = r[i]; 545 } 546 } 547 } catch(err) { 548 Components.utils.reportError(new Date().toUTCString() + " " + err); 549 } 546 550 unblock_normalize(); 547 551 … … 684 688 wrap.photosets.getList(users.token, users.nsid); 685 689 wrap.people.getUploadStatus(users.token); 686 //wrap.tags.getListUserRaw(users.token);690 wrap.tags.getListUserRaw(users.token); 687 691 688 692 // Send stats to the site … … 758 762 threads.uploadr.shutdown(); 759 763 } 760 catch(ex){} 764 catch(ex){ 765 Components.utils.reportError(new Date().toUTCString() + " " + ex); 766 } 761 767 upload.progress_bar = null; 762 768 threads.uploadr = Cc['@mozilla.org/thread-manager;1'].getService().newThread(0); … … 1003 1009 }, null); 1004 1010 } catch (err) { 1005 Components.utils.reportError(new Date().toUTCString() + err);1011 Components.utils.reportError(new Date().toUTCString() + " " + err); 1006 1012 threads.main.dispatch(new UploadDoneCallback( 1007 1013 upload.genErrorString, this.id), threads.main.DISPATCH_NORMAL); … … 1044 1050 } catch (err) { 1045 1051 if(!upload.cancel) { 1046 Components.utils.reportError(new Date().toUTCString() + err);1052 Components.utils.reportError(new Date().toUTCString() + " " + err); 1047 1053 } 1048 1054 threads.main.dispatch(new UploadDoneCallback( … … 1090 1096 'text/xml').documentElement; 1091 1097 } catch (err) { 1092 Components.utils.reportError(new Date().toUTCString() + err);1098 Components.utils.reportError(new Date().toUTCString() + " " + err); 1093 1099 } 1094 1100 } branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/content/uploadr/users.js
r640 r681 85 85 wrap.people.getUploadStatus(users.token); 86 86 wrap.photosets.getList(users.token, users.nsid); 87 wrap.tags.getListUserRaw(users.token); 87 88 88 89 // Update the UI branches/uploadr/3.2/MacUploadr.app/Contents/Resources/chrome/skin/uploadr/main.css
r674 r681 517 517 /* Three states, depending on what's selected */ 518 518 #meta, #batch_meta, #no_meta, #meta_button { 519 width: 4 20px;520 padding: 5px;519 width: 410px; 520 padding: 2px; 521 521 background: #f8f8f8; 522 522 border-left: 1px solid #ddd; … … 558 558 display: block; 559 559 } 560 #meta textbox, #no_meta textbox { 560 #meta radiogroup, #batch_meta radiogroup, #no_meta radiogroup 561 { 562 margin: 4px 0 0 0; 563 } 564 #meta .textfield, #no_meta .textfield { 561 565 width: 180px; 562 566 } 563 567 564 #batch_meta textbox 568 #tags_input 569 { 570 width: 140px; 571 } 572 573 #batch_meta .textfield 565 574 { 566 575 width: 140px; … … 613 622 background: #f2f2f2; 614 623 } 615 #single_sets_added, #batch_sets_added {624 #single_sets_added, #batch_sets_added, #single_tags_added { 616 625 border-left: 1px solid #ddd; 617 626 } … … 623 632 background: transparent; 624 633 } 625 .sets_plus, .sets_disabled, .sets_trash {634 .sets_plus, .sets_disabled, .sets_trash, .tags_added { 626 635 margin: 2px; 627 636 padding: 0 0 0 16px; … … 635 644 cursor: auto; 636 645 } 637 .sets_trash {646 .sets_trash, .tags_added { 638 647 background: url(icon_trash.png) no-repeat center left; 639 648 cursor: pointer; … … 647 656 margin: 5px 0 0 0; 648 657 } 649 650 658 651 659 /*