yaz/commit
bind apply buttons
author | Michiel Hildebrand |
---|---|
Fri Jul 8 18:20:19 2011 +0200 | |
committer | Michiel Hildebrand |
Fri Jul 8 18:20:19 2011 +0200 | |
commit | 054114b394f6ae68638496f1f35fb085e94175c1 |
tree | 08060fabd37ac95fe880644c02c2e9a5bda1ef38 |
parent | cb9bc07417fe60d466c3122fda47b3c19848e315 |
Diff style: patch stat
diff --git a/applications/yaz_garden.pl b/applications/yaz_garden.pl index 5f5ad0a..dba14e9 100644 --- a/applications/yaz_garden.pl +++ b/applications/yaz_garden.pl @@ -28,6 +28,8 @@ :- use_module(library(user_process)). :- http_handler(yaz(garden), http_yaz_garden, []). +:- http_handler(yaz(data/reconcileentries), http_data_reconcile_entries, []). + reconcile_source(cornetto, 'Cornetto', @@ -215,18 +217,22 @@ html_video_page_yui(Video, Annotations, Groups, ReconcileSources, Options) --> \js_yui3_on(tagPlayer, itemSelect, \js_tag_select), \js_yui3_on(videoFrames, frameHover, \js_frame_hover), \js_yui3_on(videoFrames, frameSelect, \js_frame_select), - \js_yui3_on(tagReconcile, reconcileReturn, \js_reconcile_return) + \js_yui3_on(tagReconcile, reconcileReturn, \js_reconcile_return), + \js_yui3_on(tagLinker, applySelect, \js_apply_select(Video)) ]). js_tag_select --> js_function([e], \[ ' var tag = e.tag, + uri = tag.tag.value, entry = tag.annotations[0], - time = (entry.startTime/1000)-3;\n', + time = (entry.startTime/1000)-3, + reconciled = Y.reconciled;\n', ' videoPlayer.setTime(time, true); - videoFrames.set("frames", tag.annotations); - tagLinker.set("tag", tag);\n' + videoFrames.set("frames", tag.annotations);\n', +' var items = (reconciled&&reconciled[uri]) ? reconciled[uri].result : []; + tagLinker.set("items", items);' ]). js_frame_select --> @@ -246,14 +252,66 @@ js_frame_hover --> js_reconcile_return --> js_function([o], \[ -' var reconciled = o.reconciled, +' Y.reconciled = o.reconciled, tags = tagPlayer.get("tags");\n', -' tagLinker.set("reconciled", reconciled);\n', ' tagPlayer.listNode.all("li").each(function(node, index) { var tag = tags[index].tag, - r = reconciled[tag.value]; + r = Y.reconciled[tag.value]; if(r&&r.result.length>0) {node.one(".score").setContent("?").removeClass("hidden")} else {node.addClass("hidden")}; })' ]). +js_apply_select(Video) --> + { http_location_by_id(http_data_reconcile_entries, Server) + }, + js_function([o], + \[ +' var frames = videoFrames.get("frames"), + selected = videoFrames.get("selected"), + entries = [];\n', +' if(o.applyToAll) { for(var i=0;i<frames.length;i++) {entries.push(frames[i].entry) }} + else if(selected) { entries[0] = selected.entry } + else { entries[0] = frames[0].entry }\n', +' Y.io("',Server,'", + { data: {video:"',Video,'", + uri:o.item.id, + entries:entries + }, + on: { success: function(e) {console.log(e)}}, + });\n' + ]). + + +%% http_data_reconcile_entries(+Request) +% +% + +http_data_reconcile_entries(Request) :- + http_parameters(Request, + [ video(Video, + [description('video we are updating entries of')]), + entries(Entries, + [zero_or_more, description('entries to update')]), + uri(URI, + [description('Link to a concept')]) + ]), + logged_on(User0, anonymous), + user_property(User0, url(User)), + ( current_user_process(Process), + rdf(Process, rdf:type, pprime:'TagGarden'), + rdf(Process, opmv:used, Video) + -> true + ; create_user_process(User, [rdf:type=pprime:'TagGarden', + opmv:used=Video + ], _GardenProcess) + ), + rdfh_transaction(reconcile_entries(Entries, URI, Updated)), + reply_json(Updated). + +reconcile_entries([], _, []). +reconcile_entries([Entry|Es], URI, [json([entry=Entry, tag=NewTag])|Rest]) :- + reconcile_entry(Entry, URI, NewTag), + reconcile_entries(Es, URI, Rest). + +reconcile_entry(_E, URI, URI). diff --git a/web/css/garden.css b/web/css/garden.css index 5761bd9..b1cc10c 100644 --- a/web/css/garden.css +++ b/web/css/garden.css @@ -100,7 +100,11 @@ float: left; overflow: hidden; list-style: none; - margin: 0 10px 10px 0; + margin: 0 1px 10px; + border: 4px solid transparent; +} +.yui3-video-frames li.selected { + border-color: #0033CC; } .yui3-video-frames img { width: 100%; diff --git a/web/js/tagplayer/tagLinker.js b/web/js/tagplayer/tagLinker.js index ae65a74..7243e7a 100644 --- a/web/js/tagplayer/tagLinker.js +++ b/web/js/tagplayer/tagLinker.js @@ -25,11 +25,8 @@ YUI.add('tag-linker', function(Y) { * as with any other class extending Base. */ TagLinker.ATTRS = { - reconciled: { - value: {} - }, - tag: { - value: null + items: { + value: [] } }; @@ -41,7 +38,6 @@ YUI.add('tag-linker', function(Y) { Y.extend(TagLinker, Widget, { initializer: function() { - this.reconciled = {}; }, destructor : function() { @@ -57,31 +53,33 @@ YUI.add('tag-linker', function(Y) { }, bindUI : function() { - this.after("tagChange", this.syncUI); - this.applyButton.on("click", this._applySelect, this); - this.applyAllButton.on("click", this._applySelect, this, true); + this.after("itemsChange", this.syncUI); + this.applyButton.on("click", this._applySelect, this, {"applyToAll":false}); + this.applyAllButton.on("click", this._applySelect, this, {"applyToAll":true}); }, syncUI : function() { this._renderItems(); }, - _applySelect : function() { - var selectedNode = this.listNode.one("li input:checked"); - if(selectedNode) { - var selected = selectedNode.get("value"); - console.log(selected); + _applySelect : function(e, args) { + var items = this.get("items"), + checked = this.listNode.one("li input:checked"); + if(checked) { + var index = this.listNode.all("li").indexOf(checked.get("parentNode")); + this.fire("applySelect", { + item:items[index], + applyToAll:args.applyToAll + }) } }, _renderItems : function() { - var tag = this.get("tag"), - reconciled = this.get("reconciled"), + var items = this.get("items"), list = this.listNode; list.setContent(""); - if(tag&&tag.tag.value&&reconciled[tag.tag.value]) { - var items = reconciled[tag.tag.value].result; + if(items.length>0) { for (var i=0; i < items.length; i++) { list.append("<li>"+this.formatItem(items[i])+"</li>"); } @@ -96,7 +94,7 @@ YUI.add('tag-linker', function(Y) { name = item.name, types = item.type||[]; - var html = "<input type=radio value="+id+">"; + var html = "<input type=radio name='reconcileItem'>"; html += "<span class='name'>"+name+"</span>"; html += "<div class='types'>"; for (var i=0; i < types.length; i++) { diff --git a/web/js/tagplayer/tagReconcile.js b/web/js/tagplayer/tagReconcile.js index 68969f2..236dd74 100644 --- a/web/js/tagplayer/tagReconcile.js +++ b/web/js/tagplayer/tagReconcile.js @@ -30,6 +30,9 @@ YUI.add('tag-reconcile', function(Y) { }, tags: { value: [] + }, + tagsPerRequest: { + value:5 } }; @@ -79,8 +82,9 @@ YUI.add('tag-reconcile', function(Y) { reconcile : function(url, index) { var oSelf = this, tags = this.get("tags"), + n = this.get("tagsPerRequest"), start = index, - last = Math.min(index+5,tags.length), + last = Math.min(index+n,tags.length), queries = {}; //build the query object diff --git a/web/js/videoframes/videoframes.js b/web/js/videoframes/videoframes.js index 9c2ec3f..b4269e7 100644 --- a/web/js/videoframes/videoframes.js +++ b/web/js/videoframes/videoframes.js @@ -57,6 +57,9 @@ YUI.add('video-frames', function(Y) { }, showTime : { value: false + }, + selected : { + value: null } }; @@ -117,6 +120,8 @@ YUI.add('video-frames', function(Y) { _renderFrames : function() { var frames = this.get("frames"); + this.listNode.all("li").removeClass("selected"); + this.set("selected", null); this._updateFrames(this.listNode, frames); }, _renderRelated : function() { @@ -195,7 +200,9 @@ YUI.add('video-frames', function(Y) { index = list.all("li").indexOf(node), frame = this._getFrame(list, index), arg = {li:node, index:index, frame:frame}; - + this.set("selected", frame); + list.all("li").removeClass("selected"); + node.addClass("selected"); Y.log('clicked frame '+frame+' at index '+index); this.fire("frameSelect", arg); },