Changeset 139
- Timestamp:
- 02/05/08 23:24:24 (1 year ago)
- Files:
-
- MediAnnotateXPI/trunk/ma.xpi (modified) (previous)
- MediAnnotateXPI/trunk/srcExtension/chrome/MediAnnotate/content/SMediAnnotate.jar (modified) (previous)
- MediAnnotateXPI/trunk/srcExtension/chrome/MediAnnotate/content/overlay.js (modified) (3 diffs)
- MediAnnotateXPI/trunk/srcExtension/chrome/MediAnnotate/content/overlay.xul (modified) (2 diffs)
- MediAnnotateXPI/trunk/srcExtension/chrome/MediAnnotate/content/webtoolkit.sprintf.js (added)
- MediAnnotateXPI/trunk/srcExtension/install.rdf (modified) (1 diff)
- MediAnnotateXPI/trunk/update_mediannotate.rdf (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
MediAnnotateXPI/trunk/srcExtension/chrome/MediAnnotate/content/overlay.js
r136 r139 3 3 // initialization code 4 4 this.initialized = true; 5 this.timecodeRegexp = new RegExp(/^(\d{2}):(\d{2}):(\d{2}).(\d{2})$/g); //'^(\d{2}):(\d{2}):(\d{2}).(\d{2})$'; 6 this.timecodeRegexpEval = '($1 * 1000 * 1000 * 60) + ($2 * 1000 * 60) + ($3 * 1000) + ($4 * 33.3);' 7 this.sprintfString = "%02d:%02d:%02d.%02d"; 5 8 }, 6 9 … … 90 93 //update the fields 91 94 document.getElementById('ma-description').value = this.xmlDoc.evaluate("//description", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; 92 document.getElementById('ma-start-time').value = this.xmlDoc.evaluate("//start", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; 93 document.getElementById('ma-end-time').value = this.xmlDoc.evaluate("//end", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; 95 var start = this.xmlDoc.evaluate("//start", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; 96 var end = this.xmlDoc.evaluate("//end", this.xmlDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; 97 document.getElementById('ma-start-time').value = sprintf(this.sprintfString, (start/1000/60/60), ((start%(1000*60*60))/1000/60), ((start%(1000*60))/1000), ((start%1000)/33.3)); 98 document.getElementById('ma-end-time').value = sprintf(this.sprintfString, (end/1000/60/60), ((end%(1000*60*60))/1000/60), ((end%(1000*60))/1000), ((end%1000)/33.3)); 99 //And here we place the actual value in storage for getting back if the change is flubbed. 100 101 document.getElementById('ma-old-start-time').value = start; 102 document.getElementById('ma-old-end-time').value = end; 94 103 document.getElementById('ma-itemRef').value = item.getID(); 95 104 … … 110 119 111 120 applyChange: function() { 121 122 var startTime = document.getElementById('ma-start-time').value; 123 var endTime = document.getElementById('ma-end-time').value; 124 var oldStartValue = document.getElementById('ma-old-start-time').value; 125 var oldEndValue = document.getElementById('ma-old-end-time').value; 126 112 127 if(document.getElementById('ma-itemRef').value && !this.isInMidChange) { 128 if(!this.timecodeRegexp.test(startTime) || this.timecodeRegexp.test(endTime)) { 129 alert("Your start and end times must follow proper timecode format."); 130 document.getElementById('ma-start-time').value = sprintf(this.sprintfString, (oldStartValue/1000/60/60), ((oldStartValue%(1000*60*60))/1000/60), ((oldStartValue%(1000*60))/1000), ((oldStartValue%1000)/33.3)); 131 document.getElementById('ma-end-time').value = sprintf(this.sprintfString, (oldEndValue/1000/60/60), ((oldEndValue%(1000*60*60))/1000/60), ((oldEndValue%(1000*60))/1000), ((oldEndValue%1000)/33.3)); 132 return; 133 } 134 113 135 this.isInMidChange = true; 136 137 oldStartValue = eval(startTime.replace(this.timecodeRegexp, this.timecodeRegexpEval)); 138 oldEndValue = eval(endTime.replace(this.timecodeRegexp, this.timecodeRegexpEval)); 139 document.getElementById('ma-old-start-time').value = oldStartValue; 140 document.getElementById('ma-old-end-time').value = oldEndValue; 141 114 142 var item = Zotero.Items.get(document.getElementById('ma-itemRef').value); 115 143 var newNote = "<mediannotate><description>" + document.getElementById('ma-description').value + "</description>\n" + 116 "<start>" + document.getElementById('ma-start-time').value + "</start>\n" + 117 "<end>" + document.getElementById('ma-end-time').value + "</end></mediannotate>"; 118 item.updateNote(newNote); 119 //Sometimes were applying a change because we've switched to another item and the change in item takes effect before 120 //the onchange takes effect. If that item is a Media Annotation, we'll want to switch back to the MAPanel because 121 //updating the note will have reset it to its normal view, annoyingly enough. 122 if(this.isMediaAnnotation) this.showMAPanel(); 123 var title = document.getElementById('ma-start-time').value + " - " + document.getElementById('ma-end-time').value + " " + Zotero.Notes.noteToTitle(document.getElementById('ma-description').value); 124 item.setField(110, title, false); 125 item.save(); 144 "<start>" + Math.round(oldStartValue-0.5) + "</start>\n" + 145 "<end>" + Math.round(oldEndValue-0.5) + "</end></mediannotate>"; 146 try { 147 item.updateNote(newNote); 148 //Sometimes were applying a change because we've switched to another item and the change in item takes effect before 149 //the onchange takes effect. If that item is a Media Annotation, we'll want to switch back to the MAPanel because 150 //updating the note will have reset it to its normal view, annoyingly enough. 151 if(this.isMediaAnnotation) this.showMAPanel(); 152 var title = document.getElementById('ma-start-time').value + " - " + document.getElementById('ma-end-time').value + " " + Zotero.Notes.noteToTitle(document.getElementById('ma-description').value); 153 item.setField(110, title, false); 154 item.save(); 155 } catch (someProblem) { 156 alert(someProblem); 157 } 158 126 159 if(this.isMediaAnnotation) this.showMAPanel(); 127 160 this.isInMidChange = false; MediAnnotateXPI/trunk/srcExtension/chrome/MediAnnotate/content/overlay.xul
r136 r139 2 2 <overlay id="mediannotate-overlay-z" 3 3 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 4 <script src="chrome://mediannotate/content/webtoolkit.sprintf.js"/> 4 5 <script src="chrome://mediannotate/content/overlay.js"/> 5 6 <script src="chrome://mediannotate/content/tags.js"/> … … 23 24 <button id="ma-view-button" label="View in MediAnnotate" oncommand="mediannotate.workItOut(event)"/> 24 25 <hbox id="ma-time-indicators" flex="0"> 25 <textbox id="ma-start-time" rows="1" cols="8" onchange="mediannotate.applyChange()"/> 26 <textbox id="ma-end-time" rows="1" cols="8" onchange="mediannotate.applyChange()"/> 26 <label hidden="true" id="ma-old-start-time"/> 27 <label hidden="true" id="ma-old-end-time"/> 28 <textbox id="ma-start-time" rows="1" cols="8" onchange="mediannotate.applyChange(event)"/> 29 <textbox id="ma-end-time" rows="1" cols="8" onchange="mediannotate.applyChange(event)"/> 27 30 </hbox> 28 31 <textbox id="ma-description" rows="8" cols="25" flex="1" multiline="true" onchange="mediannotate.applyChange()"/> MediAnnotateXPI/trunk/srcExtension/install.rdf
r136 r139 5 5 <em:id>videannotate@htmlweb.com</em:id> 6 6 <em:name>MediAnnotate</em:name> 7 <em:version>0.6.7. 5</em:version>7 <em:version>0.6.7.6</em:version> 8 8 <em:creator>Stuart Thiel Concordia University University</em:creator> 9 9 <em:developer>Stuart Thiel</em:developer> MediAnnotateXPI/trunk/update_mediannotate.rdf
r136 r139 8 8 <RDF:li> 9 9 <RDF:Description> 10 <version>0.6.7. 5</version>10 <version>0.6.7.6</version> 11 11 <targetApplication> 12 12 <RDF:Description>
