src/widgets/KnowledgeConcierge.js
changeset 1013 392ddcd212d7
parent 1002 a86208b60c91
child 1072 ac1eacb3aa33
equal deleted inserted replaced
1012:7e18d953a1f8 1013:392ddcd212d7
    12     kc_api_root: "/kn-concierge/",
    12     kc_api_root: "/kn-concierge/",
    13     related_api_endpoint: "",
    13     related_api_endpoint: "",
    14     use_word_boundaries: false,
    14     use_word_boundaries: false,
    15     related_data_type: 'json', // SET TO "jsonp" FOR CROSS-DOMAIN OPERATION
    15     related_data_type: 'json', // SET TO "jsonp" FOR CROSS-DOMAIN OPERATION
    16     related_count: 8,
    16     related_count: 8,
    17 }
    17 };
    18 
    18 
    19 IriSP.Widgets.KnowledgeConcierge.prototype.messages = {
    19 IriSP.Widgets.KnowledgeConcierge.prototype.messages = {
    20     "fr": {
    20     "fr": {
    21         related_videos: "Vidéos liées",
    21         related_videos: "Vidéos liées",
    22         duration_: "Durée\u00a0:",
    22         duration_: "Durée\u00a0:",
    27         related_videos: "Related Videos",
    27         related_videos: "Related Videos",
    28         duration_: "Duration:",
    28         duration_: "Duration:",
    29         for_keywords_: "for keyword(s):",
    29         for_keywords_: "for keyword(s):",
    30         no_matching_videos: "No matching videos"
    30         no_matching_videos: "No matching videos"
    31     }
    31     }
    32 }
    32 };
    33 
    33 
    34 IriSP.Widgets.KnowledgeConcierge.prototype.template =
    34 IriSP.Widgets.KnowledgeConcierge.prototype.template =
    35     '<div class="Ldt-Kc-Slider"></div><canvas class="Ldt-Kc-Canvas" />'
    35     '<div class="Ldt-Kc-Slider"></div><canvas class="Ldt-Kc-Canvas" />'
    36     + '<div class="Ldt-Kc-Related"><h2>{{ l10n.related_videos }}</h2>'
    36     + '<div class="Ldt-Kc-Related"><h2>{{ l10n.related_videos }}</h2>'
    37     + '<h3 class="Ldt-Kc-For-Keywords">{{l10n.for_keywords_}} <span class="Ldt-Kc-Keywords"></span></h3>'
    37     + '<h3 class="Ldt-Kc-For-Keywords">{{l10n.for_keywords_}} <span class="Ldt-Kc-Keywords"></span></h3>'
    53     }).css({
    53     }).css({
    54         width: _canvasWidth,
    54         width: _canvasWidth,
    55         height: _canvasHeight
    55         height: _canvasHeight
    56     });
    56     });
    57     var _this = this,
    57     var _this = this,
    58         _pjsfiles = IriSP._(this.sketch_files).map(function(_f) { return _this.sketch_path + "/" + _f }),
    58         _pjsfiles = IriSP._(this.sketch_files).map(function(_f) { return _this.sketch_path + "/" + _f; }),
    59         _selectedText = "",
    59         _selectedText = "",
    60         currentNodesList = "",
    60         currentNodesList = "",
    61         relatedCache = {},
    61         relatedCache = {},
    62         relatedRequests = {},
    62         relatedRequests = {},
    63         relatedTemplate = '<div class="Ldt-Kc-Related-Item"><a href="{{ widget.video_url_base }}{{ media.iri_id }}#keyword={{ escaped_keyword }}"><img src="{{ media.image }}"></a>'
    63         relatedTemplate = '<div class="Ldt-Kc-Related-Item"><a href="{{ widget.video_url_base }}{{ media.iri_id }}#keyword={{ escaped_keyword }}"><img src="{{ media.image }}"></a>'
    81                     widget: _this,
    81                     widget: _this,
    82                     media: media,
    82                     media: media,
    83                     description: media.description.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1&hellip;'),
    83                     description: media.description.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1&hellip;'),
    84                     duration: new IriSP.Model.Time(media.duration).toString(),
    84                     duration: new IriSP.Model.Time(media.duration).toString(),
    85                     escaped_keyword: encodeURIComponent(keywords.split(",")[0])
    85                     escaped_keyword: encodeURIComponent(keywords.split(",")[0])
    86                 }
    86                 };
    87                 _html += Mustache.to_html(relatedTemplate, _tmpldata);
    87                 _html += Mustache.to_html(relatedTemplate, _tmpldata);
    88                 if (i % 2) {
    88                 if (i % 2) {
    89                     _html += '</div><div class="Ldt-Kc-Row">';
    89                     _html += '</div><div class="Ldt-Kc-Row">';
    90                 }
    90                 }
    91             });
    91             });
   162                         })
   162                         })
   163                         .first(_this.related_count)
   163                         .first(_this.related_count)
   164                         .value();
   164                         .value();
   165                     renderRelated();
   165                     renderRelated();
   166                 }
   166                 }
   167             })
   167             });
   168         } else {
   168         } else {
   169             renderRelated();
   169             renderRelated();
   170         }
   170         }
   171     }
   171     }
   172     
   172     
   289                 showRelated(selection.name);
   289                 showRelated(selection.name);
   290             } else {
   290             } else {
   291                 triggerSearch();
   291                 triggerSearch();
   292             }
   292             }
   293         }
   293         }
   294     }
   294     };
   295     var uselessfuncts = [
   295     var uselessfuncts = [
   296         "selectnode", "selectedge", "topicnode","group_shapes",
   296         "selectnode", "selectedge", "topicnode","group_shapes",
   297         "allbackup", "allretrieve", "new_topic", "pedia", "set_mode",
   297         "allbackup", "allretrieve", "new_topic", "pedia", "set_mode",
   298         "new_relation", "startexpand", "endexpand", "new_select" //, "mouseover" //, "username"
   298         "new_relation", "startexpand", "endexpand", "new_select" //, "mouseover" //, "username"
   299     ];
   299     ];
   323     
   323     
   324     var keywmatch = document.location.hash.match(/keyword=([^#?&]+)/);
   324     var keywmatch = document.location.hash.match(/keyword=([^#?&]+)/);
   325     if (keywmatch) {
   325     if (keywmatch) {
   326         this.player.on("widgets-loaded", function() {
   326         this.player.on("widgets-loaded", function() {
   327             triggerSearch(decodeURIComponent(keywmatch[1]));
   327             triggerSearch(decodeURIComponent(keywmatch[1]));
   328         })
   328         });
   329     }
   329     }
   330     
   330     
   331     bindJavascript();
   331     bindJavascript();
   332     
   332     
   333 }
   333 };