diff --new-file --recursive --suppress-common-lines --exclude changes.txt --exclude diff.txt releases/unplug-2.042/source/chrome/content/common.js releases/unplug-2.043/source/chrome/content/common.js 142c142 < version : 2.042, --- > version : 2.043, 146c146 < revision : 201102282323, --- > revision : 201103010004, diff --new-file --recursive --suppress-common-lines --exclude changes.txt --exclude diff.txt releases/unplug-2.042/source/chrome/content/display/pop/pop.js releases/unplug-2.043/source/chrome/content/display/pop/pop.js 54,57c54,59 < this.download_to_uid = {}; // { result.download.toSource() : 1 } < this.results = []; // { 1 : result } ... or rather [ ..., result, ... ] < this.media_id_lookup = {}; // { "youtube-324121" : [1, ...] } < this.playlist_id_lookup = {}; // { "youtube-uploader-1213" : [1, ...] } --- > this.results_lookup = {}; // { download.toSource() : MediaResult } > this.results_lookup_length = 0; // equivalent to this.results_lookup.keys().length (which would need FF >= 4.0) > this.main_group = new UnPlug2SearchPage.MediaResultGroup([]); > window.addEventListener("load", (function () { > document.getElementById("results").appendChild(UnPlug2SearchPage.main_group.element); > }), true); 101c103 < var num_results = UnPlug2SearchPage.results.length; --- > var num_results = UnPlug2SearchPage.results_lookup_length; 139,179c141,148 < var download_tosource = result.download.toSource(); < var uid = UnPlug2SearchPage.download_to_uid[download_tosource]; // TODO -- also need to check this key is not a "native object" like "length", "toString", etc! < < if (uid === undefined) { < try { < // we need to add a new object < var uid = UnPlug2SearchPage.results.length; < UnPlug2SearchPage.download_to_uid[download_tosource] = uid; < UnPlug2SearchPage.results[uid] = result; < result.uid = uid; < < var reselem = UnPlug2SearchPage.result_e_create(); < reselem.setAttribute("id", "result_" + uid); < reselem.setAttribute("tooltiptext", "uid=" + uid + "\n\ndownload=" + result.download.toSource() + "\n\noriginal = " + result.details.toSource()); < < // sets download callbacks, etc < UnPlug2SearchPage.result_e_set_download(reselem, result); < < // this sets labels, icons, descripions, css, etc < // but wont ever move the element < UnPlug2SearchPage.result_e_set_description(reselem, result); < < // container for the group, eg the mediaid and/or playlistid < UnPlug2SearchPage.set_container(uid, reselem, result.details); < < } catch(e) { < UnPlug2.log("ERROR displaying result " + e.toSource()); < } < } else { < var reselem = document.getElementById("result_" + uid); < var old_result = UnPlug2SearchPage.results[uid]; < if (old_result.details.certainty < result.details.certainty) { < // Update < UnPlug2SearchPage.results[uid].details = result.details; < < // we need to update this.results and the widget displayed on the page with our better data < reselem.setAttribute("tooltiptext", reselem.getAttribute("tooltiptext") + "\n\nupdated = " + result.details.toSource()); < UnPlug2SearchPage.result_e_set_description(reselem, result); < < // it can attach/detach from the parent element as needed < UnPlug2SearchPage.update_container(uid, reselem, old_result.details, result.description); --- > try { > result.download_tosource = result.download.toSource(); > var existing_mediaresult = UnPlug2SearchPage.results_lookup[result.download_tosource]; > if (existing_mediaresult === undefined) { > var mediaresult = new UnPlug2SearchPage.MediaResult(result); > UnPlug2SearchPage.results_lookup_length += 1; > UnPlug2SearchPage.results_lookup[result.download_tosource] = mediaresult; > UnPlug2SearchPage.main_group.place_mediaresult(mediaresult); 181c150 < reselem.setAttribute("tooltiptext", reselem.getAttribute("tooltiptext") + "\n\nignored = " + result.details.toSource()); --- > existing_mediaresult.update(result); 182a152,153 > } catch(e) { > UnPlug2.log("ERROR displaying result " + e.toSource()); 186,190c157,191 < result_e_create : function () { < var orig = document.getElementById("unplug_result_template"); < var dupe = orig.cloneNode(true); < dupe.collapsed = false; < return dupe; --- > toString : function () { > return ''; > }, > > send_nothing_found_msg : function () { > if (!confirm(UnPlug2.str("nothing_found_send_data"))) > return; > try { > UnPlug2SearchPage.send_nothing_found_msg_noask(); > } catch (e) { > UnPlug2.log("Error sending nothing found msg " + e.toSource()); > } > }, > > send_nothing_found_msg_noask : function () { > var el = document.getElementById("notfound_button"); > if (!el) { > UnPlug2.log("No element in xul called notfound"); > return; > } > el.disabled = "true"; > el.label = UnPlug2.str("nothing_found_sending"); > > var dl = new UnPlug2Download( > null, // ref > "http://unplug.dbatley.com/popularity_contest/submit.cgi", > "problem=yes&useragent=" + escape(window.navigator.userAgent) + "&url=" + escape(UnPlug2SearchPage._win.location.href) + "&version=" + UnPlug2.version + "&revision=" + UnPlug2.revision + "&codename=" + UnPlug2.codename, > null, null, // callbacks > 10000); > dl.start() > }, > > done_nothing_found_msg : function () { > var el = document.getElementById("notfound_button"); > el.label = UnPlug2.str("nothing_found_done"); 193,194c194,354 < result_e_set_download : function (reselem, result) { < var popup = reselem.getElementsByTagName("menupopup")[0]; --- > failed_nothing_found_msg : function () { > var el = document.getElementById("notfound_button"); > el.label = UnPlug2.str("nothing_found_failed"); > el.disabled = "false"; > }, > > /* > * Stop downloading/searching pages! > */ > abort : function () { > UnPlug2Search._stopped = true; > UnPlug2Search.abort(); > }, > > /** > * When someone clicks the configure button on unplug_result > */ > configure : function (tabname) { > window.openDialog("chrome://unplug/content/config/config.xul", "", "", tabname); > }, > > endofobject : 1 } > > > > > UnPlug2SearchPage.MediaResultGroup = (function (keychain) { > this.keychain = keychain; > this.depth = keychain.length; > this.parent = null; > this.children = []; > this.lookup = {}; > this.element_create(); > }); > UnPlug2SearchPage.MediaResultGroup.prototype = { > element_create : (function () { > this.element = document.createElement("vbox"); > this.element.className = "container"; > }), > > > add_child : (function (child) { > var key = child.keychain[this.depth]; > this.children.push(child); > this.lookup[key] = child; > this.element.appendChild(child.element); > this.sort(); // could be more efficient by inserting in the correct place to begin with > child.parent = this; > }), > > remove_child : (function (child) { > var key = child.keychain[this.depth]; > delete this.lookup[key]; > this.children = this.children.splice(this.children.indexOf(this), 1); > this.element.removeChild(child.element); > child.parent = null; > }), > > root : (function () { > if (this.parent === null) { > return this; > } else { > return this.root(); > } > }), > > place_mediaresult : (function (mediaresult) { > var key = mediaresult.keychain[this.depth]; > if (this.depth+1 >= mediaresult.keychain.length) { > this.add_child(mediaresult); > this.update_sorting_keys(mediaresult); > } else { > // need to add to a sub group under this one > var child = this.lookup[key]; > if (!child) { > var new_keychain = this.keychain.concat([key]); > child = new UnPlug2SearchPage.MediaResultGroup(new_keychain); > this.add_child(child); // sets this.lookup[key] > } > // recurse > child.place_mediaresult(mediaresult); > } > }), > > cmp : (function (c1, c2) { > var r = (c2.certainty - c1.certainty); > if (r) { return r; } > r = (c2.quality - c1.quality); > if (r) { return r; } > return c2.download_tosource > c1.download_tosource; > }), > > is_sorted : (function () { > for (var i = 0; i < this.children.length - 1; ++i) { > if (this.cmp(this.children[i], this.children[i+1]) > 0) { > return false; > } > } > return true; > }), > > sort : (function () { > if (this.is_sorted()) { > // also catches case where this.children.length == 0 > return; > } > this.children.sort(this.cmp); > for (var i = 0; i < this.children.length; ++i) { > var c = this.element.removeChild(this.children[i].element); > this.element.appendChild(c); > } > }), > > update_sorting_keys : (function (child) { > var changed = false; > if (child.quality > this.quality || this.quality === undefined) { > this.quality = child.quality; > changed = true; > } > if (child.certainty > this.certainty || this.certainty === undefined) { > this.certainty = child.certainty; > changed = true; > } > if (changed && this.parent !== null) { > this.parent.update_sorting_keys(this); > } > this.sort(); > }) > } > > UnPlug2SearchPage.MediaResult = (function (result) { > this.parent = null; > this.result = result; > this.history = [result.details]; > > this.check_keychain_changed(); > > // initial setup: > this.element_create(); > this.update(result); > }); > UnPlug2SearchPage.MediaResult.prototype = { > element_create : (function () { > this._create_copy_of_template(); > this._create_download_buttons(); > }), > > _create_copy_of_template : (function () { > var orig = document.getElementById("unplug_result_template"); > this.element = orig.cloneNode(true); > this.element.collapsed = false; > }), > > /* > * Sets the download buttons based on the result.download value > * result.download should not change once the object is created > * (although the download methods read result.details.title, etc, when > * actually saving stuff) > */ > _create_download_buttons : (function () { > var popup = this.element.getElementsByTagName("menupopup")[0]; 206c366 < if (info.avail(result)) { --- > if (info.avail(this.result)) { 219c379 < elem.addEventListener("command", UnPlug2DownloadMethods.callback(name, result), false); --- > elem.addEventListener("command", UnPlug2DownloadMethods.callback(name, this.result), false); 224c384 < var copy_button = reselem.getElementsByTagName("toolbarbutton")[0]; --- > var copy_button = this.element.getElementsByTagName("toolbarbutton")[0]; 230,231c390,391 < if (copy_info && copy_info.avail(result)) { < copy_button.addEventListener("command", UnPlug2DownloadMethods.callback("copyurl", result), false); --- > if (copy_info && copy_info.avail(this.result)) { > copy_button.addEventListener("command", UnPlug2DownloadMethods.callback("copyurl", this.result), false); 237c397 < var main_button = reselem.getElementsByTagName("toolbarbutton")[1]; --- > var main_button = this.element.getElementsByTagName("toolbarbutton")[1]; 246c406 < main_button.addEventListener("command", UnPlug2DownloadMethods.callback(name, result), false); --- > main_button.addEventListener("command", UnPlug2DownloadMethods.callback(name, this.result), false); 251,254c411,414 < if (result.download.url) { // make draggable if simple url only < var image = reselem.getElementsByTagName("image")[0]; // ur-thumbnail < reselem.setAttribute("draggable", true); < reselem.addEventListener("dragstart", (function (url, image) { --- > if (this.result.download.url) { // make draggable if simple url only > var image = this.element.getElementsByTagName("image")[0]; // ur-thumbnail > this.element.setAttribute("draggable", true); > this.element.addEventListener("dragstart", (function (url, image) { 261c421 < })(result.download.url, image), true); --- > })(this.result.download.url, image), true); 263c423 < }, --- > }), 265,271c425,428 < result_e_set_description : function (reselem, result) { < // variables for use in the callbaks (closures) < var uid = result.uid; < var details = result.details; < var that = UnPlug2SearchPage; < < var name_label = reselem.getElementsByTagName("label")[0]; --- > _element_update : (function () { > var details = this.result.details; > > var name_label = this.element.getElementsByTagName("label")[0]; 273c430 < var desc_label = reselem.getElementsByTagName("label")[1]; --- > var desc_label = this.element.getElementsByTagName("label")[1]; 275c432 < var protocol_label = reselem.getElementsByTagName("label")[2]; --- > var protocol_label = this.element.getElementsByTagName("label")[2]; 277c434 < var host_label = reselem.getElementsByTagName("label")[3]; --- > var host_label = this.element.getElementsByTagName("label")[3]; 279c436 < var thumbnail = reselem.getElementsByTagName("image")[0]; --- > var thumbnail = this.element.getElementsByTagName("image")[0]; 282c439 < reselem.className = [ --- > this.element.className = [ 286,310c443,448 < }, < < set_container : function (uid, reselem, details) { < if (!details.mediaid) { < document.getElementById("results").appendChild(reselem); < return; < } < < var minfo = this.media_id_lookup[details.mediaid]; < // escape used here because could have all sorts of special characters in mediaid < var eid = "mediaid_" + escape(details.mediaid || "none"); < var container = document.getElementById(eid); < if (! container) { < container = document.createElement("vbox"); < container.className = "container"; < container.id = eid; < document.getElementById("results").appendChild(container); < } < if (minfo === undefined) { < this.media_id_lookup[details.mediaid] = { < certainty : details.certainty, < quality : details.quality, < best : uid }; < reselem.className += " mediaid-best"; < container.appendChild(reselem); --- > }), > > root : (function () { > if (this.parent === null) { > UnPlug2.log("MediaResult.root() returned a non-group item"); > return this; 312,325c450 < if (minfo.certainty < details.certainty || (minfo.certainty == details.certainty && minfo.quality < details.quality)) { < var old_best = document.getElementById("result_" + minfo["best"]); < old_best.className = old_best.className.replace("mediaid-best", "mediaid-collapse"); < // this media info is the main one < this.media_id_lookup[details.mediaid] = { < certainty : details.certainty, < quality : details.quality, < best : uid }; < reselem.className += " mediaid-best"; < container.insertBefore(reselem, container.firstChild); < } else { < reselem.className += " mediaid-collapse"; < container.appendChild(reselem); < } --- > return this.root(); 327,349c452,466 < container.appendChild(reselem); < }, < < update_container : function (uid, reselem, old_details, new_details) { < if ((old_details.mediaid || "none") != (new_descripton.mediaid || "none")) { < // remove from current container < reselem.parentNode.removeChild(reselem); < // and add to the new one < UnPlug2SearchPage.set_container(uid, reselem, new_details); < } < }, < < toString : function () { < return ''; < }, < < send_nothing_found_msg : function () { < if (!confirm(UnPlug2.str("nothing_found_send_data"))) < return; < try { < UnPlug2SearchPage.send_nothing_found_msg_noask(); < } catch (e) { < UnPlug2.log("Error sending nothing found msg " + e.toSource()); --- > }), > > check_keychain_changed : (function () { > var new_keychain = [ > this.result.details.mediaid, > this.result.download_tosource ]; > if (!this.keychain) { > this.keychain = new_keychain; > return true; > } > for (var i = 0; i < new_keychain.length; ++i) { > if (new_keychain[i] != this.keychain[i]) { > this.keychain = new_keychain; > return true; > } 351,357c468,498 < }, < < send_nothing_found_msg_noask : function () { < var el = document.getElementById("notfound_button"); < if (!el) { < UnPlug2.log("No element in xul called notfound"); < return; --- > return false; > }), > > update : (function (result) { > // should assert that result.download is the same > this.history.push(result.details); > if (this.certainty === undefined || result.details.certainty > this.certainty) { > // XXX TODO: can copy some fields (eg: default title) iff they are unset, even if less certain > > // update values we keep track of > this.result = result; > > // update dom nodes > this._element_update(); > > // keychain changed? > if (this.check_keychain_changed()) { > var root = this.root(); > this.parent.remove_child(this); > root.place_mediaresult(this); > return; > } > > // sort > if (this.quality != this.result.details.quality || this.certainty != this.result.details.certainty) { > this.quality = this.result.details.quality; > this.certainty = this.result.details.certainty; > if (this.parent !== null) { > this.parent.update_sorting_keys(this); > } > } 359,397c500,501 < el.disabled = "true"; < el.label = UnPlug2.str("nothing_found_sending"); < < var dl = new UnPlug2Download( < null, // ref < "http://unplug.dbatley.com/popularity_contest/submit.cgi", < "problem=yes&useragent=" + escape(window.navigator.userAgent) + "&url=" + escape(UnPlug2SearchPage._win.location.href) + "&version=" + UnPlug2.version + "&revision=" + UnPlug2.revision + "&codename=" + UnPlug2.codename, < null, null, // callbacks < 10000); < dl.start() < }, < < done_nothing_found_msg : function () { < var el = document.getElementById("notfound_button"); < el.label = UnPlug2.str("nothing_found_done"); < }, < < failed_nothing_found_msg : function () { < var el = document.getElementById("notfound_button"); < el.label = UnPlug2.str("nothing_found_failed"); < el.disabled = "false"; < }, < < /* < * Stop downloading/searching pages! < */ < abort : function () { < UnPlug2Search._stopped = true; < UnPlug2Search.abort(); < }, < < /** < * When someone clicks the configure button on unplug_result < */ < configure : function (tabname) { < window.openDialog("chrome://unplug/content/config/config.xul", "", "", tabname); < }, < < endofobject : 1 } --- > }) > } diff --new-file --recursive --suppress-common-lines --exclude changes.txt --exclude diff.txt releases/unplug-2.042/source/chrome/content/rules.xml releases/unplug-2.043/source/chrome/content/rules.xml 1097a1098,1104 > > > > > > > diff --new-file --recursive --suppress-common-lines --exclude changes.txt --exclude diff.txt releases/unplug-2.042/source/chrome/skin/searchpage.css releases/unplug-2.043/source/chrome/skin/searchpage.css 18c18 < font-size: smaller; --- > font-size: 80%; 22c22,23 < .unplug-result label.ur-protocol { --- > .unplug-result label.ur-description { > font-size: 80%; 25c26,50 < .unplug-result label.ur-description { --- > > .unplug-result label.ur-name { > display: none; > } > .unplug-result image.ur-thumbnail { > visibility: hidden; > } > > .unplug-result:first-child label.ur-name { > display: block; > } > .unplug-result:first-child image.ur-thumbnail { > visibility: visible; > } > > .unplug-result toolbarbutton { > visibility: hidden; > font-size: 80%; > } > .unplug-result:hover toolbarbutton, > .unplug-result:first-child toolbarbutton { > visibility: visible; > } > .unplug-result:first-child toolbarbutton { > font-size: 100%; 93d117 < border: 1px black solid; 94a119 > margin-bottom: 1.2em; 95a121 > border-bottom: 1px #cccccc solid; 97,116c123,125 < < vbox.container#mediaid_none { < /* TODO - not used */ < } < < .unplug-result.mediaid-best { < } < .unplug-result.mediaid-collapse { < } < < .unplug-result.mediaid-collapse label.ur-name { < opacity: 0.8; < display: none; < } < .unplug-result.mediaid-collapse image.ur-thumbnail { < visibility: hidden; < } < .unplug-result.mediaid-collapse label.ur-protocol, < .unplug-result.mediaid-collapse label.ur-host { < /* display: none; */ --- > vbox.container:last-child { > margin-bottom: 0; > border-bottom: 0; 118d126 < diff --new-file --recursive --suppress-common-lines --exclude changes.txt --exclude diff.txt releases/unplug-2.042/source/install.rdf releases/unplug-2.043/source/install.rdf 9c9 < em:version="2.042" --- > em:version="2.043" Binary files releases/unplug-2.042/unplug.xpi and releases/unplug-2.043/unplug.xpi differ