js/startscreen.js
changeset 21 007254e97333
parent 19 685c406c7d8c
child 23 933b388521f6
equal deleted inserted replaced
20:8b0a464fb5ac 21:007254e97333
     1 var topicPoubelle = 13;
       
     2 
       
     3 function showData() {
     1 function showData() {
       
     2     
       
     3     var nmmso = data.segments.length;
     4 	
     4 	
       
     5     data.topics.forEach(function(topic) {
       
     6         topic.score = 0;
       
     7         topic.weights = [];
       
     8         for (var i = 0; i < nmmso; i++) {
       
     9             topic.weights.push(0);
       
    10         }
       
    11     });
       
    12     
       
    13     data.segments.forEach(function(mmso, i) {
       
    14         mmso.topics.forEach(function(t) {
       
    15             data.topics[t.topic].weights[i] = t.weight;
       
    16             data.topics[t.topic].score += t.weight;
       
    17         });
       
    18     });
       
    19     
       
    20     var topicPoubelle = removeBiggestTopic ? _(data.topics.slice()).sortBy(function(t) { return -t.score; })[0].index : -1;
       
    21     
     5 	data.topiclabels.forEach(function(v) {
    22 	data.topiclabels.forEach(function(v) {
     6 		var words = _(v.words).map(function(v, k) {
    23 		var words = _(v.words).map(function(v, k) {
     7 			return {
    24 			return {
     8 				word: k,
    25 				word: k,
     9 				weight: v
    26 				weight: v
    31         return (hours ? (hours + ":") : "") + pad(minutes) + ":" + pad(secs);
    48         return (hours ? (hours + ":") : "") + pad(minutes) + ":" + pad(secs);
    32     }
    49     }
    33     
    50     
    34     $(".duration").text(secsToString(data.duration));
    51     $(".duration").text(secsToString(data.duration));
    35   
    52   
    36     var nmmso = data.segments.length;
       
    37     
       
    38     data.topics.forEach(function(topic) {
       
    39         topic.score = 0;
       
    40         topic.weights = [];
       
    41         for (var i = 0; i < nmmso; i++) {
       
    42             topic.weights.push(0);
       
    43         }
       
    44     });
       
    45     
       
    46     data.segments.forEach(function(mmso, i) {
       
    47         mmso.topics.forEach(function(t) {
       
    48             data.topics[t.topic].weights[i] = t.weight;
       
    49             data.topics[t.topic].score += t.weight;
       
    50         });
       
    51         mmso.tweet_rate = mmso.tweet_count / mmso.duration; 
       
    52     });
       
    53     
    53     
    54     var sortedTopics = data.topics.filter(function(t) {
    54     var sortedTopics = data.topics.filter(function(t) {
    55         return t.index !== topicPoubelle;
    55         return t.index !== topicPoubelle;
    56     }).sort(function(a,b) {
    56     }).sort(function(a,b) {
    57         return b.score - a.score;
    57         return b.score - a.score;
   158     
   158     
   159     $(".keyword-search").autocomplete({
   159     $(".keyword-search").autocomplete({
   160         source: allwords,
   160         source: allwords,
   161         change: function() {
   161         change: function() {
   162         	window.setTimeout(wordFilter,0);
   162         	window.setTimeout(wordFilter,0);
       
   163         },
       
   164         select: function() {
       
   165         	window.setTimeout(wordFilter,0);
   163         }
   166         }
   164     }).on("keyup change paste", wordFilter);
   167     }).on("keyup change paste", wordFilter);
   165 // */
   168 // */
   166     
   169     
   167     function showTopicViz() {
   170     function showTopicViz() {
   343             checkIfLoaded();
   346             checkIfLoaded();
   344         });
   347         });
   345     }
   348     }
   346     
   349     
   347     function solrUrl(table, params) {
   350     function solrUrl(table, params) {
   348         return "http://159.217.144.101:8050/sia-solr/" + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?";
   351         return solrUrlBase + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?";
   349     }
   352     }
   350     
   353     
   351     function loadFromTopicsBean(method, propname, args, callback) {
   354     function loadFromTopicsBean(method, propname, args, callback) {
   352         stepsToFullyLoaded++;
   355         stepsToFullyLoaded++;
   353         var arg = args || [],
   356         var arg = args || [],
   387                     }
   390                     }
   388                 }
   391                 }
   389                 topics.sort(function(a,b) {
   392                 topics.sort(function(a,b) {
   390                     return b.weight - a.weight;
   393                     return b.weight - a.weight;
   391                 });
   394                 });
   392 /*                topics = topics.filter(function(t) {
       
   393                     return t.topic !== topicPoubelle
       
   394                 }).slice(0,1);
       
   395                 topics[0].weight = 1; */
       
   396                 return {
   395                 return {
   397                     id: mmso.MMSO_id,
   396                     id: mmso.MMSO_id,
   398                     start: start,
   397                     start: start,
   399                     end: end,
   398                     end: end,
   400                     duration: end - start,
   399                     duration: end - start,