summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2006-12-18 13:22:11 (UTC)
committer Michael Krelin <hacker@klever.net>2006-12-18 13:22:11 (UTC)
commit676ead33f615fbc2affb3cb979d1316f0676daef (patch) (side-by-side diff)
tree06e7afff01a0c1df631c7f635618403d7989572a
parentb609e9157c1587b11f177edfa7fe65f6851e9706 (diff)
downloadfireflix-676ead33f615fbc2affb3cb979d1316f0676daef.zip
fireflix-676ead33f615fbc2affb3cb979d1316f0676daef.tar.gz
fireflix-676ead33f615fbc2affb3cb979d1316f0676daef.tar.bz2
make file properties visible but readonly for non-pending downloads.
And while we're at it show failure reason for failed uploads. git-svn-id: http://svn.klever.net/kin/fireflix/trunk@238 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix-panel.xul57
-rw-r--r--content/fireflix.css8
-rw-r--r--content/fireflix.js25
3 files changed, 56 insertions, 34 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul
index 0e511c5..aa3dbd6 100644
--- a/content/fireflix-panel.xul
+++ b/content/fireflix-panel.xul
@@ -162,144 +162,147 @@
onselect="fireflix.foundphotos.on_select()"
ondblclick="fireflix.foundphotos.on_cmd_open(event)"
onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.foundphotos.on_cmd_open(event)">
<treecols>
<treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" />
</treecols>
<treechildren/>
</tree>
<groupbox id="searchresult_props" orient="horizontal" hidden="true">
<vbox width="100" pack="center">
<hbox pack="center">
<image id="search_photo"
ondblclick="fireflix.foundphotos.on_cmd_open(event)"/>
</hbox>
</vbox>
<vbox flex="1">
<label id="searchresult_title" crop="end"/>
<hbox flex="1" pack="center">
<div flex="1" id="searchresult_description" xmlns="http://www.w3.org/1999/xhtml"/>
</hbox>
<hbox pack="end">
<button command="cmd_search_open"/>
</hbox>
</vbox>
</groupbox>
</vbox>
</tabpanel>
<tabpanel id="tabpanel_sets" flex="1"
onkeypress="if(event.keyCode==event.DOM_VK_RETURN)
document.getElementById('setphotos').focus()">
<vbox flex="1">
<tree id="setslist" rows="2" onselect="fireflix.photosets.on_select()"
flex="1" context="sets_menu"
ondblclick="fireflix.photosets.on_cmd_open_in_flickr(event)"
>
<treecols>
<treecol id="sl_name" label="&panel.sets.name.label;" flex="4" crop="end" align="start" tooltiptext="&panel.sets.name.tip;"/>
<splitter class="tree-splitter" />
<treecol id="sl_photos" label="&panel.sets.photos.label;" flex="1" align="end" tooltiptext="&panel.sets.photos.tip;" />
</treecols>
<treechildren/>
</tree>
<hbox>
<button command="cmd_refresh_sets" />
<button command="cmd_set_props" />
</hbox>
<tree id="setphotos" rows="2" onselect="fireflix.photoset.on_select()"
flex="1" ondblclick="fireflix.photoset.on_cmd_open(event)"
onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.photoset.on_cmd_open(event)" context="setphotos_menu">
<treecols>
<treecol id="sp_title" label="&panel.setphotos.title.label;" flex="1" crop="end" align="start" tooltiptext="&panel.setphotos.title.tip;" />
<splitter class="tree-splitter" />
<treecol id="sp_taken" label="&panel.setphotos.taken.label;" crop="end" align="start" tooltiptext="&panel.setphotos.taken.tip;" hidden="true" />
<treecol id="sp_upload" label="&panel.setphotos.upload.label;" crop="end" align="start" tooltiptext="&panel.setphotos.upload.tip;" hidden="true" />
</treecols>
<treechildren/>
</tree>
<groupbox id="set_photo_props" orient="horizontal" hidden="true">
<vbox width="100" pack="center">
<hbox pack="center">
<image id="set_photo"
ondblclick="fireflix.photoset.on_cmd_open(event)" />
</hbox>
</vbox>
<spacer flex="1"/>
</groupbox>
</vbox>
</tabpanel>
<tabpanel id="tabpanel_tags">
<listbox id="tagslist" rows="8" flex="1">
<listhead>
<listheader label="&panel.tagslist.tag.label;"/>
</listhead>
<listcols>
<listcol flex="1"/>
</listcols>
</listbox>
</tabpanel>
<tabpanel id="tabpanel_upload">
<vbox flex="1">
<tree id="uploadlist" rows="2" flex="1"
onselect="fireflix.uploads.selectionChanged()"
context="uploads_menu">
<treecols>
<treecol id="up_file" label="&panel.uploadlist.file.label;" flex="4" crop="start" align="start"/>
<splitter class="tree-splitter" />
<treecol id="up_title" label="&panel.uploadlist.title.label;" flex="5" crop="end" align="start" />
<splitter class="tree-splitter" />
<treecol id="up_status" label="&panel.uploadlist.status.label;" flex="1" crop="end" align="start" />
</treecols>
<treechildren/>
</tree>
<progressmeter id="upload_progress" mode="undetermined" hidden="true" />
- <groupbox id="upload_file_props" orient="horizontal" hidden="true">
- <image id="upload_file_preview" width="100" height="100" />
- <grid flex="1">
- <columns>
- <column/>
- <column flex="1"/>
- </columns>
- <rows>
- <row>
- <label control="upload_filename"
- value="&panel.upload_props.filename.label;" />
- <textbox id="upload_filename"
- oninput="fireflix.uploads.propsToSel('filename')"/>
- </row>
- <row>
- <label control="upload_title" value="&panel.upload_props.title.label;" />
- <textbox id="upload_title"
- oninput="fireflix.uploads.propsToSel('title')"/>
- </row>
- <row>
- <label control="uplod_tags" value="&panel.upload_props.tags.label;" />
- <textbox id="upload_tags"
- oninput="fireflix.uploads.propsToSel('tags')"/>
- </row>
- <!-- TODO: description, public, friend, family -->
- </rows>
- </grid>
+ <groupbox id="upload_file_props" orient="vertical" hidden="true">
+ <hbox>
+ <image id="upload_file_preview" width="100" height="100" />
+ <grid flex="1">
+ <columns>
+ <column/>
+ <column flex="1"/>
+ </columns>
+ <rows>
+ <row>
+ <label control="upload_filename"
+ value="&panel.upload_props.filename.label;" />
+ <textbox id="upload_filename"
+ oninput="fireflix.uploads.propsToSel('filename')"/>
+ </row>
+ <row>
+ <label control="upload_title" value="&panel.upload_props.title.label;" />
+ <textbox id="upload_title"
+ oninput="fireflix.uploads.propsToSel('title')"/>
+ </row>
+ <row>
+ <label control="upload_tags" value="&panel.upload_props.tags.label;" />
+ <textbox id="upload_tags"
+ oninput="fireflix.uploads.propsToSel('tags')"/>
+ </row>
+ <!-- TODO: description, public, friend, family -->
+ </rows>
+ </grid>
+ </hbox>
+ <description id="upload_failure" hidden="true"/>
</groupbox>
<hbox>
<button class="lean" command="cmd_uploads_add" />
<spacer flex="1"/>
<button class="lean" command="cmd_uploads_remove" />
<spacer flex="1"/>
<button class="lean" command="cmd_uploads_clear" />
</hbox>
<hbox pack="center">
<button command="cmd_uploads_upload" flex="1"/>
</hbox>
</vbox>
</tabpanel>
</tabpanels>
</tabbox>
</vbox>
</page>
diff --git a/content/fireflix.css b/content/fireflix.css
index ab90c11..06ae28a 100644
--- a/content/fireflix.css
+++ b/content/fireflix.css
@@ -1,125 +1,133 @@
html#help,
.generated.wholething, .about.wholething /* XXX:,
tabbox, tabpanels, tabpanel */ {
background: url("background.jpeg");
}
tabpanels {
padding: 0px;
}
tree {
margin-top: 2px;
color: #2d354a;
font-size: 90%;
}
tree treechildren { /* for windows */
background: #c5ffc5;
}
tree#uploadlist treechildren::-moz-tree-cell-text(pending) {
}
tree#uploadlist treechildren::-moz-tree-cell-text(completed) {
color: black;
}
tree#uploadlist treechildren::-moz-tree-row(failed) {
background: yellow;
}
tree#uploadlist treechildren::-moz-tree-cell-text(failed) {
color: red;
}
tree#uploadlist treechildren::-moz-tree-cell-text(uploading) {
font-weight: bold;
}
groupbox#searchresult_props,
groupbox.search_params,
groupbox#upload_file_props,
groupbox#set_props,
groupbox#set_photo_props {
background: white;
}
groupbox#upload_file_props label {
text-align: right;
}
+description#upload_failure {
+ border-top: solid 1px red;
+ margin: 0px; padding: 2px;
+ text-align: left;
+ font-size: 85%;
+ line-height: 105%;
+}
+
image#search_photo, image#set_photo, image#set_primary {
border: black 1px solid;
}
.about .insides {
margin: 1ex;
}
.about .text {
border: yellow solid 1px;
background: green;
}
.about .title {
font-size: 300%;
font-weight: bold;
color: yellow;
}
.about .link {
text-decoration: underline;
color: white;
cursor: pointer;
}
menuitem.menuhead {
background: gray;
color: black;
font-weight: bold;
}
div#searchresult_description {
min-height: 5em; max-height: 8em;
overflow: auto;
font-size: 90%;
margin: 0.1ex 0.5ex;
}
#copying div {
margin: 1ex 1em;
font-family: courier, monospace;
font-size: 9pt;
padding: 2px;
border: dotted 1px gray;
background: white;
}
label#search_page {
font-weight: bold;
background: white; color: #404040;
border-color: #c0c0c0 #404040 #404040 #c0c0c0;
border-style: solid;
border-width: 1px;
-moz-border-radius: 1em;
padding: 0.5ex 1ex;
}
html body {
font-family: arial, sans-serif;
font-size: 11pt;
margin: 1em 4em;
padding: 1em 4em;
border: double 3px gray;
background: #ffffc0;
}
html h1 {
font-size: 130%; color: maroon;
}
html p {
text-align: justify;
}
html div.copyright {
font-size: 60%;
text-align: right;
}
html div.copyright a {
text-decoration: none;
}
button.lean {
min-width: 1ex;
}
diff --git a/content/fireflix.js b/content/fireflix.js
index 995ec5c..7291b68 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -239,402 +239,413 @@ var fireflix = {
if(this.selection.currentIndex<0) return;
var p = this.sets[this.selection.currentIndex];
if(!p.id) return;
this.fireflix.openTab(this.fireflix.flickr.make_photoset_url(p));
}
},
refresh_user_tags: function() {
var lb = document.getElementById('tagslist');
var _this = this;
this.flickr.api_call(
{
method: 'flickr.tags.getListUser',
auth_token: 'default',
}, function(xr) {
var x = xr.responseXML;
var xp = x.evaluate(
'/rsp/who/tags/tag', x, null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
// TODO: clear list
var n; while(n=xp.iterateNext()) {
lb.appendItem(n.firstChild.nodeValue);
}
}, function(x,s,c,m) {
_this.flickr_failure(x,s,c,m);
}
);
},
uploadObserver: {
fireflix: null,
init: function(f) {
this.fireflix = f;
},
getSupportedFlavours: function() {
var rv = new FlavourSet();
rv.appendFlavour('application/x-moz-file','nsIFile');
rv.appendFlavour('application/x-moz-url');
rv.appendFlavour('text/uri-list');
rv.appendFlavour('text/unicode');
return rv;
},
canHandleMultipleItems: true,
onDragOver: function(ev,fl,sess) {
return true;
},
onDrop: function(ev,dd,s) {
var ldf = null;
for(var i in dd.dataList) {
var di = dd.dataList[i];
var dif = di.first;
if(
ldf==null
|| ldf.flavour.contentType!=dif.flavour.contentType
|| ldf.contentLength!=dif.contentLength
|| ldf.data!=dif.data )
this.drop_item(ev,di,s);
ldf = dif;
}
},
drop_item: function(ev,di,s) {
var d = di.first;
switch(d.flavour.contentType) {
case 'text/unicode':
this.drop_urilist(ev,d.data,s);
break;
case 'application/x-moz-file':
this.fireflix.uploads.add(d.data.path);
document.getElementById('fireflix_tabs').selectedTab
= document.getElementById('tab_upload');
break;
case 'text/uri-list':
// is it ascii or could it be utf8?
this.drop_urilist(ev,splitascii(d.data),s);
break;
default: alert(d.flavour.contentType+':'+d.data); break;
};
},
drop_urilist: function(ev,ul,s) {
// TODO: check for being a file?
var us = decodeURIComponent(ul).split(/[\r\n]/);
for(var ui in us)
if(/\S/.test(us[ui]))
this.fireflix.uploads.add(us[ui]);
document.getElementById('fireflix_tabs').selectedTab
= document.getElementById('tab_upload');
}
},
uploads: {
fireflix: null,
init: function(f) {
this.fireflix=f;
pull_elements(this,document,[
'upload_filename','upload_title','upload_file_preview',
'upload_file_props','upload_progress','upload_tags',
- 'cmd_uploads_upload'
+ 'cmd_uploads_upload', 'upload_failure'
]);
document.getElementById('uploadlist').view = this;
},
files: new Array(),
rowCount: 0,
getCellText: function(r,c) {
var f = this.files[r];
if(c.id=='up_file') return f.file;
if(c.id=='up_title') return f.title;
if(c.id=='up_status') return f.state;
return c.id;
},
setTree: function(t) { this.tree = t },
isContainer: function(r) { return false; },
isSeparator: function(r) { return false; },
isSorted: function(r) { return false; },
getLevel: function(r) { return 0; },
getImageSrc: function(r,c) { return null },
getRowProperties: function(r,p) {
try {
if(!Components) return;
}catch(e) { return }
var f = this.files[r];
var as = Components.classes['@mozilla.org/atom-service;1'].
getService(Components.interfaces.nsIAtomService);
p.AppendElement(as.getAtom(f.state));
},
getCellProperties: function(r,c,p) { this.getRowProperties(r,p); },
getColumnProperties: function(c,p) { },
cycleHeader: function(cid,e) { },
getParentIndex: function(r) { return -1; },
drop: function(r,o) { },
canDropBeforeAfter: function(r,b) { return false },
add: function(f) {
if(f.indexOf('file:/')==0) {
f = f.substr(5);
while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-)
f = f.substr(1);
}
}
var t = f;
var ls = t.lastIndexOf('/');
if(ls>0) t = t.substr(ls+1);
ls = t.lastIndexOf('\\');
if(ls>0) t = t.substr(ls+1);
var ld = t.lastIndexOf('.');
if(ld>0) t = t.substr(0,ld);
this.files.push( {
file: f,
title: t,
tags: '',
state: 'pending'
} );
this.rowCount = this.files.length;
this.tree.rowCountChanged(this.rowCount-1,1);
},
upload_worker: function() {
for(var f in this.files) {
if(this.files[f].state=='pending') {
var ff = this.files[f];
this.on_file_upload(ff);
ff.state='uploading';
this.tree.invalidate();
var _this = this;
this.fireflix.flickr.upload_file(
ff.file, { title: ff.title, tags: ff.tags },
function(x,p) {
ff.photoid = p;
_this.batch_ids.push(p);
ff.state='completed';
_this.tree.invalidate();
window.setTimeout(_this.upload_to,0,_this);
}, function(x,s,c,m) {
ff.state='failed';
ff.flickr_errcode = c;
ff.flickr_errmsg = m;
_this.tree.invalidate();
window.setTimeout(_this.upload_to,0,_this);
}
);
return;
}
}
this.on_finish_upload();
},
upload_to: function(_this) { _this.upload_worker(); },
on_file_upload: function(f) {
this.cmd_uploads_upload.setAttribute('disabled','true');
for(var fi in this.files) {
if(this.files[fi].file==f.file) {
this.tree.ensureRowIsVisible(fi);
this.selection.rangedSelect(fi,fi,false);
this.selection.currentIndex = fi;
this.selToProps();
break;
}
}
},
on_finish_upload: function() {
if(this.batch_ids.length) {
var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset'));
if(psn!=null) {
var pids = this.batch_ids.join(',');
var ppid = this.batch_ids[0];
var _this = this;
this.fireflix.flickr.api_call(
{
method: 'flickr.photosets.create',
auth_token: 'default',
title: psn,
primary_photo_id: ppid
}, function(x) {
var npid =
x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id');
_this.fireflix.flickr.api_call(
{
method: 'flickr.photosets.editPhotos',
auth_token: 'default',
photoset_id: npid,
primary_photo_id: ppid,
photo_ids: pids
}, function(x) {
_this.fireflix.refresh_sets();
}, function(x,s,c,m) {
_this.fireflix.flickr_failure(x,s,c,m);
}
);
}, function(x,s,c,m) {
_this.fireflix.flickr_failure(x,s,c,m);
}
);
}
}
this.selection.clearSelection();
this.cmd_uploads_upload.setAttribute('disabled','false');
this.upload_progress.setAttribute('hidden','true');
},
clear_list: function() {
this.tree.beginUpdateBatch();
this.rowCount = 0;
this.files = new Array();
this.tree.endUpdateBatch();
this.selToProps();
},
selectionChanged: function() {
this.selToProps();
},
disableProps: function() {
this.upload_filename.value='';
this.upload_filename.disabled = true;
this.upload_title.value='';
this.upload_title.disabled = true;
this.upload_file_preview.src = null;
- this.upload_file_props.hidden = true;
this.upload_tags.value='';
this.upload_tags.disabled = true;
+ /* this.upload_file_props.hidden = true; */
},
selToProps: function() {
if(!this.selection.count) {
this.disableProps();
+ this.upload_file_props.hidden = true;
}else if(this.selection.count==1) {
var f=this.files[this.selection.currentIndex];
- if(f==null || f.state!='pending') {
+ if(f==null) {
this.disableProps();
+ this.upload_file_props.hidden = true;
}else{
+ var inactives = f.state!='pending';
this.upload_filename.value = f.file;
- this.upload_filename.disabled = false;
+ this.upload_filename.disabled = inactives;
this.upload_title.value = f.title;
- this.upload_title.disabled = false;
+ this.upload_title.disabled = inactives;
this.upload_file_preview.src = 'file:///'+f.file;
- this.upload_file_props.hidden = false;
this.upload_tags.value = f.tags;
- this.upload_tags.disabled = false;
+ this.upload_tags.disabled = inactives;
+ if(f.state=='failed') {
+ this.upload_failure.textContent=f.flickr_errcode+': '+f.flickr_errmsg;
+ this.upload_failure.hidden = false;
+ }else{
+ this.upload_failure.hidden = true;
+ }
+ this.upload_file_props.hidden = false;
}
}else{
var ftitle = null; var onetitle = true;
var ftags = null; var onetag = true;
var fs = 0;
for(var ff in this.files) {
if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) {
++fs;
if(ftitle==null) {
ftitle = this.files[ff].title;
}else if(ftitle!=this.files[ff].title) {
onetitle = false;
}
if(ftags==null) {
ftags = this.files[ff].tags;
}else if(ftags!=this.files[ff].tags) {
onetag = false;
}
}
}
if(fs) {
this.upload_filename.value='';
this.upload_filename.disabled = true;
if(onetitle)
this.upload_title.value = ftitle;
this.upload_title.disabled = false;
if(onetag)
this.upload_tags.value = ftags;
this.upload_tags.disabled = false;
this.upload_file_preview.src = null;
+ this.upload_failure.hidden = true;
this.upload_file_props.hidden = false;
}else
this.disableProps();
+ this.upload_file_props.hidden = true;
}
},
propsToSel: function(prop) {
if(this.selection.count<=0) return;
for(var ff in this.files) {
if(this.selection.isSelected(ff) && this.files[ff].state=='pending') {
if(prop=='filename')
this.files[ff].file = this.upload_filename.value;
if(prop=='title')
this.files[ff].title = this.upload_title.value;
if(prop=='tags')
this.files[ff].tags = this.upload_tags.value;
this.tree.invalidateRow(ff);
}
}
},
on_upload: function() {
this.selToProps();
this.batch_ids = new Array();
this.upload_progress.value=0;
this.upload_progress.setAttribute('hidden','false');
this.upload_worker();
},
on_clear: function() {
this.clear_list();
},
on_remove: function() {
if(this.selection.count) {
this.tree.beginUpdateBatch();
for(var i=this.files.length-1;i>=0;--i) {
if(this.selection.isSelected(i)) {
this.files.splice(i,1);
this.rowCount--;
}
}
this.tree.endUpdateBatch();
this.selection.clearSelection();
}
},
on_add: function() {
var ifp = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp);
fp.init(window, "Select a File", ifp.modeOpenMultiple);
fp.appendFilters(ifp.filterImages);
var rv = fp.show();
if(rv==ifp.returnOK) {
var ff = fp.files;
while(ff.hasMoreElements()) {
var f = ff.getNext();
f.QueryInterface(Components.interfaces.nsIFile);
this.add(f.path);
}
}
}
},
on_set_props: function() {
var pset = this.photosets.sets[this.photosets.selection.currentIndex];
window.openDialog(
"chrome://fireflix/content/photoset-props.xul",
null, "dependent,modal,dialog,chrome", this,
pset );
if(pset.dirty) {
var _this = this;
this.flickr.api_call(
{
method: 'flickr.photosets.editMeta',
auth_token: 'default',
photoset_id: pset.id,
title: pset.title,
description: pset.description
}, function(xr) {
pset.dirty = false;
_this.flickr.api_call(
{
method: 'flickr.photosets.getPhotos',
auth_token: 'default',
photoset_id: pset.id
}, function(xr) {
var x = xr.responseXML;
var xp = x.evaluate(
'/rsp/photoset/photo', x, null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
var phids = new Array();
var priph = null;
var n; while(n=xp.iterateNext()) {
var pid = n.getAttribute('id');
phids.push( pid );
if(pid==pset.primary && n.getAttribute('isprimary')!='1')
priph = pid;
}
if(priph) {
_this.flickr.api_call(
{
method: 'flickr.photosets.editPhotos',