# HG changeset patch # User veltr # Date 1348193937 -32400 # Node ID d7d56ea2d0a689bf5ca40e5732c7ae866e66232f # Parent d58d0dcdb640ff88b5f7c80c37e7185cfd5f1631 Adaptations for Knowledge Concierge diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/js/defaults.js --- a/src/js/defaults.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/js/defaults.js Fri Sep 21 11:18:57 2012 +0900 @@ -21,7 +21,8 @@ backboneRelational: "backbone-relational.js", paper: "paper.js", jqueryMousewheel: "jquery.mousewheel.min.js", - renkanPublish: "renkan-publish.js" + renkanPublish: "renkan-publish.js", + processing: "processing-1.3.6.min.js" }, locations : { // use to define locations outside default_dir @@ -77,6 +78,9 @@ }, Renkan: { requires: [ "backbone", "backboneRelational", "paper", "jqueryMousewheel", "renkanPublish" ] + }, + KnowledgeConcierge: { + requires: [ "processing" ] } } diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/js/model.js --- a/src/js/model.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/js/model.js Fri Sep 21 11:18:57 2012 +0900 @@ -520,6 +520,10 @@ this.elementType = 'annotation'; this.begin = new IriSP.Model.Time(); this.end = new IriSP.Model.Time(); + var _this = this; + this.on("click", function() { + _this.getMedia().setCurrentTime(_this.begin); + }) } IriSP.Model.Annotation.prototype = new IriSP.Model.Element(null); diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/Annotation.js --- a/src/widgets/Annotation.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/widgets/Annotation.js Fri Sep 21 11:18:57 2012 +0900 @@ -45,7 +45,8 @@ annotation_type : "chap", start_minimized: true, show_top_border : false, - site_name : "Lignes de Temps" + site_name : "Lignes de Temps", + search_on_tag_click: true } IriSP.Widgets.Annotation.prototype.draw = function() { @@ -87,27 +88,27 @@ this.lastAnnotation = _annotation.id; var _url = (typeof _annotation.url !== "undefined" ? _annotation.url - : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)); - var _text = this.l10n.watching + _annotation.title + (this.site_name ? this.l10n.on_site + this.site_name : ''); - var _tags = _annotation.getTagTexts(); + : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)), + _text = this.l10n.watching + _annotation.title + (this.site_name ? this.l10n.on_site + this.site_name : ''), + _tags = _annotation.getTags(), + _tagblock = this.$.find(".Ldt-Annotation-Tags"), + _this = this; + _tagblock.empty(); if (_tags.length) { - var _html = IriSP._(_tags).map(function(_tag) { - return '
  • ' + _tag + '
  • '; - }).join(""); - this.$.find(".Ldt-Annotation-Tags").html(_html); this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock"); - - /* Correct the empty tag bug */ - this.$.find('.Ldt-Annotation-TagLabel').each(function() { - var _el = IriSP.jQuery(this); - if (!_el.text().replace(/(^\s+|\s+$)/g,'')) { - _el.detach(); + _tags.forEach(function(_tag) { + var _trimmedTitle = _tag.title.replace(/(^\s+|\s+$)/g,''); + if (_trimmedTitle) { + var _el = IriSP.jQuery('
  • ').append(IriSP.jQuery('').text(_trimmedTitle)); + _el.click(function() { + if (_this.search_on_tag_click) { + _this.player.trigger("search.triggeredSearch",_trimmedTitle); + } + _tag.trigger("click"); + }); + _tagblock.append(_el); } }); - - this.$.find('.Ldt-Annotation-TagLabel').click(function() { - _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); - }); } else { this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); } @@ -132,7 +133,6 @@ if (typeof this.socialWidget !== "undefined") { this.socialWidget.updateUrls(_url, _text); } else { - var _this = this; setTimeout(function() { if (typeof _this.socialWidget !== "undefined") { _this.socialWidget.updateUrls(_url, _text); diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/JwpPlayer.js --- a/src/widgets/JwpPlayer.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/widgets/JwpPlayer.js Fri Sep 21 11:18:57 2012 +0900 @@ -23,7 +23,7 @@ this.streamer = this.streamer(this.video); } - if (typeof this.streamer === "string") { + if (typeof this.streamer === "string" && (this.provider === "http" || this.provider === "rtmp")) { this.video = this.video.replace(this.streamer,""); _opts.streamer = this.streamer; } diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/KnowledgeConcierge.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/KnowledgeConcierge.css Fri Sep 21 11:18:57 2012 +0900 @@ -0,0 +1,7 @@ +.Ldt-Kc-Slider { + width: 100%; height: 8px; margin: 3px 0; font-size: 8px; +} + +.Ldt-Kc-Canvas { + border: 1px solid #999999; +} diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/KnowledgeConcierge.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/KnowledgeConcierge.js Fri Sep 21 11:18:57 2012 +0900 @@ -0,0 +1,260 @@ +IriSP.Widgets.KnowledgeConcierge = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.KnowledgeConcierge.prototype = new IriSP.Widgets.Widget(); + +IriSP.Widgets.KnowledgeConcierge.prototype.defaults = { + width: 600, + height: 500, + sketch_path: "tmgraph", + sketch_files: [ "tmgraph.pde", "physics.pde", "model.pde", "javascript.pde", "menu.pde", "event.pde", "constants.pde", "initialdata.pde"], + api_root: "/kn-concierge/", + use_word_boundaries: false +} + +IriSP.Widgets.KnowledgeConcierge.prototype.messages = { + "fr": { + }, + "en": { + } +} + +IriSP.Widgets.KnowledgeConcierge.prototype.template = + '
    '; + +IriSP.Widgets.KnowledgeConcierge.prototype.draw = function() { + this.renderTemplate(); + var _canvasHeight = this.height - 16, + _canvasWidth = this.width - 2, + _canvas = this.$.find(".Ldt-Kc-Canvas"), + _tmpId = IriSP._.uniqueId("Processing-"), + _slider = this.$.find(".Ldt-Kc-Slider"); + _canvas.attr({ + width: _canvasWidth, + height: _canvasHeight, + id: _tmpId + }).css({ + width: _canvasWidth, + height: _canvasHeight + }); + var _this = this, + _pjsfiles = IriSP._(this.sketch_files).map(function(_f) { return _this.sketch_path + "/" + _f }), + _selectedText = ""; + Processing.loadSketchFromSources(_canvas[0],_pjsfiles); + + function triggerSearch(text) { + if (_selectedText !== text) { + //console.log("Trigger search for '" + text + "'"); + _selectedText = text; + _this.player.trigger("search.triggeredSearch", text); + } + } + + function searchNodes(tags) { + var _tlist = (_this.use_word_boundaries ? IriSP._(tags).map(function(t) { return "\\\\y" + t + "\\\\y" }) : tags), + _q = "(?i)(" + _tlist.join("|") + ")"; + jQuery.getJSON( + _this.api_root + "topics.jsp", + { + proj: _this.project_id, + q: _q + }, + function(data) { + if (data && data.items && data.items.length) { + for (var i=0, l=data.items.length; i 1) { + node.position(Math.floor(200*Math.sin(2 * Math.PI * i / l)),Math.floor(200*Math.cos(2 * Math.PI * i / l))); + } + } + } else { + console.log("No match found"); + } + } + ); + } + + function rootNode(id, proj) { + jQuery.getJSON( + _this.api_root + "topic.jsp", + { + id: id, + proj: proj + }, + function(response) { + if (response != null && response.items.length > 0){ + item = response.items[0]; + _pjs.initNode(item.id, item.name, item.grp, item.uid, item.proj); + _fns.countassoc(item.id, item.proj); + } else { + console.debug('No such topic.'); + } + }); + } + + function bindJavascript() { + _pjs = Processing.getInstanceById(_tmpId); + if (_pjs && typeof _pjs.bindJavascript === "function") { + setTimeout(function() { + _pjs.bindJavascript(_fns); + _pjs.setSize(_canvasWidth,_canvasHeight); + var _edit = false, + _teamMode = true; + _pjs.saveMode("en",false,_teamMode,false,"both",_edit); + rootNode(_this.topic_id, _this.project_id); + _canvas.click(function() { + triggerSearch("") + }); + _slider.slider({ + min: -20, + max: 20, + value: 0, + range: "min", + slide: function(event, ui) { + _pjs.zoom(Math.exp(ui.value / 10)); + } + }); + }, 1000); + } else { + setTimeout(bindJavascript, 1000); + } + } + + var _fns = { + adjacentnodes: function(id, proj, adj, both) { + //console.log("Function adjacentnodes called with", arguments); + jQuery.ajax({ + url: _this.api_root + "associations-bd.jsp", + cache: false, + data: { + id: id, + proj: proj, + both: both, + adj: adj + }, + success: function(response) { + if (response.items.length > 0){ + for(i = 0, end = response.items.length; i < end; i++) { + item = response.items[i]; + _pjs.addEdge(item.asc_id, item.id, item.from_proj, item.to_id, item.to_proj, + item.r_name, item.r_from, item.r_to, item.uid, item.proj); + _pjs.setNodeName( item.id, item.from_proj,item.name); + _pjs.setNodeValue(item.id, item.from_proj,item.name, item.grp, item.abst, item.from_uid); + if (item.from_assoc!=null) { + _pjs.setNodeAssoc(item.id, item.from_proj, item.from_assoc); + } + _pjs.setNodeName( item.to_id,item.to_proj, item.to_name); + _pjs.setNodeValue(item.to_id,item.to_proj, item.to_name,item.to_grp,item.to_abst,item.to_uid); + if (item.to_assoc!=null) { + _pjs.setNodeAssoc(item.to_id, item.to_proj, item.to_assoc); + } + } + return response; + } else { + console.debug('No such topic.'); + return null; + } + } + }); + }, + selectnode: function(id, proj) { + //console.log("Function selectnode called with", arguments); + /* Originally, open dialog with info from + * /kn-concierge/topic.jsp?id={{id}}&proj={{proj}} + * /kn-concierge/topicContent.jsp?id={{id}}&proj={{proj}} + */ + }, + selectedge: function(asc_id) { + //console.log("Function selectedge called with", arguments); + /* /kn-concierge/association.jsp?asc_id={{asc_id}}&proj={{proj}}" */ + }, + topicnode: function(id){ + //console.log("Function topicnode called with", arguments); + }, + setscale: function(scl){ + //console.log("Function setscale called with", arguments); + _slider.slider("value", 10*Math.log(scl)); + }, + group_shapes: function(){ + //console.log("Function group_shapes"); + }, + allbackup: function(){ + }, + allretrieve: function(){ + }, + new_topic: function(){ + }, + pedia: function() { + }, + set_mode: function(){ + }, + countassoc: function(id, proj) { + //console.log("Fonction countassoc called with", arguments); + jQuery.ajax({ + url: _this.api_root + "count-assoc.jsp", + data: { + id: id, + proj: proj + }, + success: function(response) { + if (response.items.length > 0){ + for(i = 0, end = response.items.length; i < end; i++) { + item = response.items[i]; + _pjs.setNodeValue(item.id, item.proj, item.name, item.grp, item.abst); + if (item.assoc!=null) _pjs.setNodeAssoc(item.id, item.proj, item.assoc); + if (item.mass!=null) _pjs.setNodeMass( item.id, item.proj, item.mass); + } + } else { + console.debug('No such topic.'); + } + } + }); + }, + new_relation: function() { + }, + new_select: function(id, proj) { + var node = _pjs.findNode(id, proj); + triggerSearch(node.name); + //console.log("Mouse over node named '" + node.name + "'"); + }, + startexpand: function() { + //console.log("Function startexpand()"); + }, + endexpand: function() { + //console.log("Function endexpand()"); + }, + username: function() { + //console.log("Function username()"); + } + } + + this.getWidgetAnnotations().forEach(function(annotation) { + annotation.on("click", function() { + var _tags = annotation.getTagTexts(); + if (_tags.length) { + searchNodes(_tags); + } + }); + }); + + this.source.getTags().forEach(function(tag) { + tag.on("click", function() { + if (tag.title) { + searchNodes([tag.title]); + } + }); + }); + + bindJavascript(); + +} diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/Mediafragment.js --- a/src/widgets/Mediafragment.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/widgets/Mediafragment.js Fri Sep 21 11:18:57 2012 +0900 @@ -20,6 +20,12 @@ this.onMediaEvent("pause","setHashToTime"); this.onMediaEvent("seeked","setHashToTime"); this.goToHash(); + var _this = this; + this.getWidgetAnnotations().forEach(function(_annotation) { + _annotation.on("click", function() { + _this.setHashToAnnotation(_annotation.id); + }) + }) } IriSP.Widgets.Mediafragment.prototype.setWindowHash = function(_hash) { diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/Polemic.js --- a/src/widgets/Polemic.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/widgets/Polemic.js Fri Sep 21 11:18:57 2012 +0900 @@ -168,8 +168,7 @@ }).mouseout(function() { _annotation.trigger("unselect"); }).click(function() { - _this.player.trigger("Mediafragment.setHashToAnnotation", _annotation.id); - _this.player.trigger("Tweet.show", _annotation.id); + _annotation.trigger("click"); }); _annotation.on("select", function() { _this.tooltip.show( diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/Segments.js --- a/src/widgets/Segments.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/widgets/Segments.js Fri Sep 21 11:18:57 2012 +0900 @@ -62,8 +62,7 @@ _annotation.trigger("unselect"); }) .click(function() { - _this.media.setCurrentTime(_annotation.begin); - _this.player.trigger("Mediafragment.setHashToAnnotation", _data.id); + _annotation.trigger("click"); }) .appendTo(_this.list_$) _annotation.on("select", function() { diff -r d58d0dcdb640 -r d7d56ea2d0a6 src/widgets/Tweet.js --- a/src/widgets/Tweet.js Wed Sep 19 14:59:35 2012 +0900 +++ b/src/widgets/Tweet.js Fri Sep 21 11:18:57 2012 +0900 @@ -25,6 +25,7 @@ "color" : "#05aae6" } ], + annotation_type: "tweet", pin_at_start: false } @@ -66,7 +67,6 @@ IriSP.Widgets.Tweet.prototype.draw = function() { this.renderTemplate(); - this.onMdpEvent("Tweet.show","show"); this.pinned = this.pin_at_start; var _this = this; this.$.find(".Ldt-Tweet-Pin").click(function() { @@ -84,10 +84,14 @@ _this.hide(); }); this.$.hide(); + this.getWidgetAnnotations().forEach(function(_annotation) { + _annotation.on("click", function() { + _this.show(_annotation); + }); + }); } -IriSP.Widgets.Tweet.prototype.show = function(_id) { - var _tweet = this.source.getElement(_id); +IriSP.Widgets.Tweet.prototype.show = function(_tweet) { if (typeof _tweet !== "undefined" && typeof _tweet.source !== "undefined") { var _entities = []; for (var _i = 0; _i < _tweet.source.entities.hashtags.length; _i++) {