3 var adjust = 54; |
3 var adjust = 54; |
4 |
4 |
5 var deltaT = new Date("Wed, 02 May 2012 19:00:00 +0000") / 1000 + adjust; |
5 var deltaT = new Date("Wed, 02 May 2012 19:00:00 +0000") / 1000 + adjust; |
6 |
6 |
7 function solrUrl(table, params) { |
7 function solrUrl(table, params) { |
8 return "http://159.217.144.101:8050/sia-solr/" + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?"; |
8 var u = "http://159.217.144.101:8050/sia-solr/" + table + "/select?" + $.param(params) + "&wt=json&json.wrf=?"; |
|
9 console.log(u); |
|
10 return u; |
9 } |
11 } |
10 |
12 |
11 function showData() { |
13 function showData() { |
12 |
14 |
13 var topicHash = document.location.hash || "#selectedtopics=5,15&visibletopics=5,10,15"; |
15 var topicHash = document.location.hash || "#selectedtopics=5,15&visibletopics=5,10,15"; |
539 |
541 |
540 tweetstoshow.sort(function(a, b) { |
542 tweetstoshow.sort(function(a, b) { |
541 return b.topic.weight - a.topic.weight; |
543 return b.topic.weight - a.topic.weight; |
542 }); |
544 }); |
543 |
545 |
|
546 if (tweetstoshow.length < 8) { |
|
547 var randtweets = data.randomtweets.filter(function(tw) { |
|
548 return (tw.timestamp > (localpos - localduration / 2)) && (tw.timestamp < (localpos + localduration / 2)) |
|
549 }); |
|
550 var mod = Math.ceil(randtweets.length / 8); |
|
551 randtweets = randtweets.filter(function(v,k) { |
|
552 return !(k % mod); |
|
553 }); |
|
554 tweetstoshow = tweetstoshow.concat(randtweets); |
|
555 } |
|
556 |
544 tweetstoshow = tweetstoshow.slice(0,10); |
557 tweetstoshow = tweetstoshow.slice(0,10); |
545 |
558 |
546 if (selectedWord) { |
559 if (selectedWord) { |
547 var rx = new RegExp( '(' + selectedWord.replace(/(\W)/gm,'\\$1') + ')', 'gim' ); |
560 var rx = new RegExp( '(' + selectedWord.replace(/(\W)/gm,'\\$1') + ')', 'gim' ); |
548 tweetstoshow.forEach(function(tw) { |
561 tweetstoshow.forEach(function(tw) { |
900 TopicsBean[method].apply(TopicsBean,arg); |
913 TopicsBean[method].apply(TopicsBean,arg); |
901 } |
914 } |
902 |
915 |
903 loadJson("data/minutes.json", "minutes"); |
916 loadJson("data/minutes.json", "minutes"); |
904 loadJson("data/5secs.json", "fiveseconds"); |
917 loadJson("data/5secs.json", "fiveseconds"); |
|
918 |
|
919 var t = Math.floor(30*Math.random()); |
|
920 |
|
921 function pad(n) { |
|
922 var r = n.toString(); |
|
923 while (r.length < 2) { |
|
924 r = "0" + r; |
|
925 } |
|
926 return r; |
|
927 } |
|
928 |
|
929 loadJson( |
|
930 solrUrl( |
|
931 "twitter", |
|
932 { |
|
933 q: "created_at:(*\\:*\\:" |
|
934 + pad(t) |
|
935 + "* OR *\\:*\\:" |
|
936 + (30+t) |
|
937 + "*)", |
|
938 group: "true", |
|
939 "group.field": "created_at", |
|
940 "fl": "id_str,created_at,from_user_name,text,profile_image_url", |
|
941 "rows": 800 |
|
942 } |
|
943 ), |
|
944 "randomtweets", |
|
945 function(d) { |
|
946 var randtweets = d.grouped.created_at.groups.map(function(g) { |
|
947 var tweet = g.doclist.docs[0]; |
|
948 return { |
|
949 topic: { topic: -1, weight: 0 }, |
|
950 timestamp: (new Date(tweet.created_at).valueOf() / 1000 - deltaT), |
|
951 data: tweet |
|
952 } |
|
953 }); |
|
954 randtweets.sort(function(a,b) { |
|
955 return a.timestamp - b.timestamp; |
|
956 }); |
|
957 return randtweets; |
|
958 } |
|
959 ) |
905 |
960 |
906 loadJson( |
961 loadJson( |
907 solrUrl("MMSO", {q: "*:*", fl: "topic*,MMSO_id,multimediaSegment,keywordsFromSocial", rows: 250 }), |
962 solrUrl("MMSO", {q: "*:*", fl: "topic*,MMSO_id,multimediaSegment,keywordsFromSocial", rows: 250 }), |
908 "segments", |
963 "segments", |
909 function(d) { |
964 function(d) { |