-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
576 lines (451 loc) · 19.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="bootstrap-3.3.7/bootstrap-3.3.7/docs/favicon.ico">
<title>Summary Jack</title>
<style>
img {
width: 150px;
height: 150px;
border-radius: 50%;
}
div.container {
display:inline-block;
}
p {
text-align:center;
}
.tweetImage{
width: 10% !important;
height: 10% !important;
border-radius: 0%;
}
.mainImage{
width:600px !important;
height:250px !important;
border-radius: 0%;
}
</style>
<!-- Bootstrap core CSS -->
<link href="bootstrap-3.3.7/bootstrap-3.3.7/docs/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap theme -->
<link href="bootstrap-3.3.7/bootstrap-3.3.7/docs/dist/css/bootstrap-theme.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="Summary Jack.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<script id = pie type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
</script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Page Header -->
<!-- Set your background image for this header on the line below. -->
<header class="intro-header" style="">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-3 col-md-10 col-md-offset-1">
<div class="site-heading textcolor">
<h1>
<center>
<img id="mainimage" class="mainImage" src="https://lh5.googleusercontent.com/KFVIE2d95xiDVqfH5C1BeVSCbcSjIAhYs--slay92ddoEe3xwdG7IVwofV7jzZr_w6kwNgmuYMspRe8=w2560-h1478" ><br><br>
Summary Jack
<hr class="large">
<div id="custom-search-input">
<div class="input-group col-lg-10">
<input type="text" class="form-control input-lg queryInput" placeholder="Query" onkeypress="Javascript: if (event.keyCode==13) QuerySolr();">
<span class="input-group-btn">
<button class="btn btn-info btn-lg searchQuery" type="button" onclick="QuerySolr();">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
</center>
<!-- <input type="text" class="form-control" placeholder="Search" id="name" required="" data-validation-required-message="Please search your Query" aria-invalid="false">
-->
</h1>
<!--<span class="subheading">A Clean Blog Theme by Start Bootstrap</span>-->
</div>
</div>
</div>
</div>
</header>
<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top" style="background-image: url('http://tbsila.cdn.turner.com/toonla/images/cnapac/content/1349/showpage/samurai-jack/au/background.jpg')">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Summary Jack</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container theme-showcase" role="main" >
<div class="col-lg-10 col-lg-offset-3 col-md-10 col-md-offset-1">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div id="Topics" style="display: none;">
<p>
</p>
</div>
</div>
</div>
<!-- Main Content -->
<div class="container">
<div id="try" <div id="london" >
<div class="row">
<input type='hidden' id='current_page' />
<input type='hidden' id='show_per_page' />
<div class="col-lg-4 ScrollSection" style="position:absolute; right:-5%; top:55%; height:100px; "></div>
<div class="col-lg-6 col-lg-offset 1 tweetSection" style="position:absolute;left:10%;top:55%">
<div class="post-preview">
<a href="post.html">
<h3 class="post-title">
</h3>
</a>
<hr>
</div>
<!-- Pager -->
</div>
</div>
<div id="page_navigation"></div>
</div>
</div>
<hr>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--script>window.jQuery || document.write('<script src="bootstrap-3.3.7/bootstrap-3.3.7/docs/assets/js/vendor/jquery.min.js"><\/script>')</script-->
<!--script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script-->
<script id = pie type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
</script>
<script type="text/javascript">
var j$ = jQuery.noConflict();
google.charts.load("current", {packages:["corechart"]});
function drawChart(topic_count) {
console.log(topic_count+"COUNT")
var data = google.visualization.arrayToDataTable([
['Topic', 'Frequency'],
['Christmas Day 1', topic_count[1]],
['Gift', topic_count[2]],
['New Year', topic_count[3]],
['Decorations', topic_count[4]],
['GiveAways',topic_count[5]]
]);
var options = {
title: 'Topic Distribution',
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
chart.draw(data, options);
}
function paginateTweets(){
console.log("In Pagination");
//how much items per page to show
var show_per_page = 10;
//getting the amount of elements inside content div
var number_of_items = j$('.tweetList').children().size();
//calculate the number of pages we are going to have
var number_of_pages = Math.ceil(number_of_items/show_per_page);
console.log("number_of_items " + number_of_items);
console.log("number_of_pages " + number_of_pages);
//set the value of our hidden input fields
j$('#current_page').val(0);
j$('#show_per_page').val(show_per_page);
//now when we got all we need for the navigation let's make it '
/*
what are we going to have in the navigation?
- link to previous page
- links to specific pages
- link to next page
*/
var navigation_html = '<a class="previous_link" href="javascript:previous();">Prev</a>';
var current_link = 0;
while(number_of_pages > current_link){
navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
current_link++;
}
navigation_html += '<a class="next_link" href="javascript:next();">Next</a>';
j$('#page_navigation').html("<div style=\"position:absolute;right:-100px;top:0px;width: 500px; height: 50px;>"+navigation_html+"</div>");
//add active_page class to the first page link
j$('#page_navigation .page_link:first').addClass('active_page');
//hide all the elements inside content div
j$('.tweetList').children().css('display', 'none');
//and show the first n (show_per_page) elements
j$('.tweetList').children().slice(0, show_per_page).css('display', 'block');
console.log("XXnumber_of_pages " + number_of_pages);
}
function previous(){
new_page = parseInt(j$('#current_page').val()) - 1;
//if there is an item before the current active link run the function
if(j$('.active_page').prev('.page_link').length==true){
go_to_page(new_page);
}
}
function next(){
new_page = parseInt(j$('#current_page').val()) + 1;
//if there is an item after the current active link run the function
if(j$('.active_page').next('.page_link').length==true){
go_to_page(new_page);
}
}
function go_to_page(page_num){
//get the number of items shown per page
var show_per_page = parseInt(j$('#show_per_page').val());
//get the element number where to start the slice from
start_from = page_num * show_per_page;
//get the element number where to end the slice
end_on = start_from + show_per_page;
//hide all children elements of content div, get specific items and show them
j$('.tweetList').children().css('display', 'none').slice(start_from, end_on).css('display', 'block');
/*get the page link that has longdesc attribute of the current page and add active_page class to it
and remove that class from previously active page link*/
j$('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page');
//update the current page input field
j$('#current_page').val(page_num);
}
function QuerySolr(){
document.getElementById("mainimage").style.display = "none";
var userInput = j$(".queryInput").val();
console.log(userInput)
if(userInput == "" || userInput == undefined){
alert("Please input a search query");
}else{
var solrInstance = "http://****/solr/gettingstarted/";
var url = solrInstance + "select?fl=id,score,tweet_topic,text_en,text,created_at,user.screen_name,user.profile_image_url_https&indent=on&q="+userInput+"&rows=50&start=0&wt=json&json.wrf=callback=getJSON";
console.log(url);
populateTweetDOM(url,userInput);
}
}
var topicMax=0;
function dispaly_subtopics(topic_number){
console.log(topic_number + "topic_number");
document.getElementById("Topics").style.display = "block";
var sub_topics = [
["Christmas","Day","Movie","Music","Christmas time","Party"],
["Christmas","Light","Love","Tree","Video","Break"],
["Christmas","New Year","Shop","Joy","Card","Present"],
["Gift","Thanks","Holiday","Wine","Decorations","Games"],
["Xmas","Cookie","Crush","Merry","Sweepstakes","Santa"]
];
var buttons="", i, tlen;
var junk="dsfsdf";
buttons+="<button type=\"button\" class=\"btn btn-lg btn-primary\" id=\"button1\" onclick=\"onclick=populateSummaryImagesDOM('"+sub_topics[topic_number][0]+"');\";>"+sub_topics[topic_number][0]+"</button>";
buttons+="<button type=\"button\" class=\"btn btn-lg btn-danger\" id=\"button2\" onclick=\"onclick=populateSummaryImagesDOM('"+sub_topics[topic_number][1]+"');\"; >"+sub_topics[topic_number][1]+"</button>";
buttons+="<button type=\"button\" class=\"btn btn-lg btn-success\" id=\"button3\" onclick=\"onclick=populateSummaryImagesDOM('"+sub_topics[topic_number][2]+"');\";>"+sub_topics[topic_number][2]+"</button>";
buttons+="<button type=\"button\" class=\"btn btn-lg btn-info\" id=\"button4\" onclick=\"onclick=populateSummaryImagesDOM('"+sub_topics[topic_number][3]+"');\";>"+sub_topics[topic_number][3]+"</button>";
buttons+="<button type=\"button\" class=\"btn btn-lg btn-warning\" id=\"button5\" onclick=\"onclick=populateSummaryImagesDOM('"+sub_topics[topic_number][4]+"');\";>"+sub_topics[topic_number][4]+"</button>";
buttons+="<button type=\"button\" class=\"btn btn-lg btn-warning\" id=\"button5\" onclick=\"onclick=populateSummaryImagesDOM('"+sub_topics[topic_number][5]+"');\";>"+sub_topics[topic_number][5]+"</button>";
j$("#Topics").html(buttons);
j$("#Topics").fadeIn();
console.log(sub_topics[topic_number][5]+" chartTopic");
}
function populateTweetDOM(url,userInput){
console.log(userInput);
j$.when(
j$.ajax({
url: url,
jsonpCallback : 'getJSON',
jsonp: "$jsonp",
dataType: "jsonp",
type: "GET",
crossDomain: true,
error: function (xhr, error) {
alert("error " + error);
}
})).done(function(data) {
var htmlString = "";
var topic_count = [0,0,0,0,0,0]
for(i = 0; i < data.response.docs.length; i++){
topic_count[data.response.docs[i]["tweet_topic"]]++;
if(data.response.docs[i]["id"])
var dateCreated=new Date(data.response.docs[i]["created_at"]);
var month=dateCreated.getMonth()+1;
htmlString = htmlString + "<div class='panel panel-default'>"
+"<div class='panel panel-heading'>"
+ "<a href='https://twitter.com/"+data.response.docs[i]["user.screen_name"]+"'>"
+ "@"+data.response.docs[i]["user.screen_name"]
+ "</a>"
+ " tweets:"
+"</div>"
+"<div class='panel panel-body'>"
+ "<div class='tweetDisplay' align=\"left\">"
+"<img class='tweetImage' src='"+data.response.docs[i]["user.profile_image_url_https"]+"' align='left' vertical-align='center' alt='"+data.response.docs[i]["user.profile_image_url_https"]+" width: 10px height: 10px'>"
+ "<a href='https://twitter.com/"+data.response.docs[i]["user.screen_name"]+"/status/"+data.response.docs[i]["id"]+"'>"
+ "<h4>"
+ "<div class='tweetText'>"
+ data.response.docs[i]["text"]
+ "</div>"
+ "</h4>"
+ "</a>"
+ "<p class='post-meta'> </p>"
//+ "<p class='post-meta'> <a href='#'>Tweet Link</a> </p>"
+" </div>"
+" <div>"
+ month+"-"+dateCreated.getDate()+"-"+dateCreated.getFullYear()+" "+dateCreated.getHours()+":"+dateCreated.getMinutes()+":"+dateCreated.getSeconds()
+ "<p class='post-meta'> </p>"
+ "</div>"
+ "</div>"
+ "</div>";
}
var biggest_topic_count_index = 1;
var biggest_topic_count_value = 0;
for(i = 1; i <= 5; i++){
if(topic_count[i] > biggest_topic_count_value)
{
biggest_topic_count_value = topic_count[i];
biggest_topic_count_index= i;
}
}
biggest_topic_count_index=biggest_topic_count_index-1;
topicMax=biggest_topic_count_index;
dispaly_subtopics(biggest_topic_count_index);
console.log(topic_count+" topic topic_count")
drawChart(topic_count);
if(htmlString != ""){
//console.log(htmlString);
htmlString = "<div class='tweetList'>" + htmlString + "</div>";
//console.log(htmlString);
j$(".tweetSection").html("<h3><br><br><br>Search Results</h3><hr/>" + htmlString);
}else{
j$(".tweetSection").html("<h4>No Tweets Available</h4><hr/>");
}
paginateTweets();
});
}
function populateTweetSummaryDOM(url){
console.log(url);
j$.when(
j$.ajax({
url: url,
jsonpCallback : 'getJSON',
jsonp: "$jsonp",
dataType: "jsonp",
type: "GET",
crossDomain: true,
error: function (xhr, error) {
alert("error " + error);
}
})).done(function(data) {
var htmlString="";
for(i = 0; i < data.response.docs.length; i++){
//topic_count[data.response.docs[i]["tweet_topic"]]++;
if(data.response.docs[i]["id"])
{
htmlString = htmlString+ data.response.docs[i]["text_en"]+"<br>";
}
//+ "<p class='post-meta'> <a href='#'>Tweet Link</a> </p>"
if(htmlString != ""){
console.log("DYNAMIC"+htmlString);
//console.log(htmlString);
//htmlString = htmlString ;
//console.log(htmlString);
j$(".ScrollSection").html("<h3>Tweet Summary</h3><hr/>" + htmlString );
}else{
j$(".tweetSection").html("");
}
};
})};
function populateSummaryImagesDOM(subtopic)
{
console.log(topicMax+"in Summaryy")
var solrInstance = "http://****/solr/gettingstarted/";
var urld = solrInstance + "select?fq=tweet_topic="+topicMax+"AND retweet_count:[100 TO *]fl=id,tweet_topic,text_en,text,user.screen_name&indent=on&q="+subtopic+"&rows=20&start=0&wt=json&json.wrf=callback=getJSON";
populateTweetSummaryDOM(urld)
var userInput = j$(".queryInput").val();
console.log(subtopic);
var url1 = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles="+ subtopic;
var content="";
console.log(url1);
j$.ajax({
type: "GET",
url: url1,
contentType: "application/json; charset=utf-8",
async: false,
crossDomain: true,
dataType: "jsonp",
success: function (data, textStatus, jqXHR) {
var obj = data.query.pages;
var ob = Object.keys(obj)[0];
//console.log(obj[ob]["extract"]);
//console.log(obj[ob]["property"]);
content = obj[ob]["extract"];
j$("#tweetSection").html("");
j$("#piechart_3d").html("");
j$("#page_navigation").html("");
//j$('.tweetSection').html("<p>"+obj[ob]["extract"]+"</p>");
image(subtopic);
j$('.tweetSection').html("<br><br><h3><i>Wikipedia says:</i></h3><br><p>"+content+"</p>");
},
error: function (errorMessage) {
console.log(errorMessage);
}
});
}
function image(subtopic)
{
console.log("Inside Images");
//var url = "https://pixabay.com/api/?key=****&q=Christmas+"+subtopic+"&image_type=photo&pretty=true";
//console.log(url);
var API_KEY = '****';
var URL = "https://pixabay.com/api/?key="+API_KEY+"&q="+encodeURIComponent(subtopic)+"&pretty=true";
//console.log(URL);
j$.ajax({
url: URL,
dataType: 'json',
type:"GET",
//data: data,
success: callback
}).done(function(data){
//console.log(data.hits[1]);
if (parseInt(data.totalHits) > 0)
{
var first_image=0;
var htmlDOMSummary="";
j$.each(data.hits, function(i, hit){
if(i==11)
{
return false;
}
imgurl=hit.webformatURL;
console.log(imgurl);
if(first_image==0)
{
//j$('.tweetSection').html(j$('<img>', {src: imgurl}));
first_image=1;
}
else{
htmlDOMSummary = htmlDOMSummary + " <img src="+imgurl+">";
}
});
j$('.tweetSection').html("<br><br><br><h3><i>Some Related images:</i></h3><br>"+htmlDOMSummary + j$('.tweetSection').html());
}
});
}
</script>
<div style="position:relative;width:100%">
<div id="piechart_3d" style="position:absolute;right:-100px;top:50px;width: 500px; height: 500px;"></div>
</body>
</html>