forked from 18F/PriceHistoryGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.tpl
535 lines (410 loc) · 15.7 KB
/
MainPage.tpl
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PricesPaid v. 2.0 BETA </title>
<meta name="robots" content="NOINDEX, NOFOLLOW">
<link rel="stylesheet" type="text/css" href="theme/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
href="./theme/css/decoration_gui.css" >
<link href="./theme/css/shared.css" rel="stylesheet" type="text/css" media="screen, projection">
<link href="./theme/css/mainPage.css" rel="stylesheet" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../SlickGrid-master/slick.grid.css" type="text/css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="../js/jqPagination-master/css/jqpagination.css">
<link rel="stylesheet" type="text/css" href="../js/jquery.jqplot.css" >
{{!goog_anal_script}}
</head>
<body>
<div id="header">
<div class="col-md-3 col-xs-5 logo">
<span id="pricespaid_logo"><img src="theme/img/pp_logo_beta.png" alt="PricesPaid"></span>
</div>
<div class="col-md-9 col-xs-7">
<nav class="navbar" role="navigation">
<!-- Collect the nav links, forms, and other content for toggling -->
<div>
<ul class="nav navbar-nav">
<li id="return_to_search" class="active"><a href="#">Search</a></li>
<li id="upload" class="active"><a href="#">Upload</a></li>
<li id="logoutLink"><a href="#">Logout</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</div>
<div id="sidebar" class="col-xs-3">
<div id="sidebar_search">
<span id="smallSearch">
<input type="text" name="small_search_string" id="small_search_string" placeholder="Search ..." value="{{search_string}}" title=
"
Enter any number of search terms to get a list of results ranked by relevance to those terms. To limit a search to those only containing a certain terms, separate terms by the upper case AND, like "laptop AND rugged". To exclude results containing a term, put upper case NOT or - in front of it, like "laptop AND NOT rugged"
To get more detailed help on searching, click the "Help!" link in the upper right of this page.
"
>
<input id="searchButton" name="submit" value="Search" class="input_submit" title="Click here to search the database" type="submit" onclick="performSearch();">
</span>
</div>
<div id='sidebar-manage-results'>
<span>Limit results to: </span>
<input type="text" id="num_results_to_return" placeholder="100" title="Change number of results returned here. More results will slow your response time. If you find yourself paging through too many results, try adding terms to your search to increase the relevancy of your results, excluding terms by putting a minus sign (-) in front of a term you want to exclude.">
<div id="sidebarpaginator"> <span id="paginationHolder2"></span> </div>
{{!portfolio_panel}}
<a href="./theme/movies/PortfolioTutorial.mp4" target="_blank">Watch a tutorial on portfolios</a>
</div>
</div>
</div>
<div class="container">
<div class='row'>
<div class='col-12-xs'>
<img id="betastripe" src="theme/img/Beta2.0.png" alt="Beta 2.0">
</div>
</div>
<!-- Content ... below the header -->
<div id="content">
<div id="loading">
<h1> Searching, Please Wait... </h1>
</div>
<div id="results-header">
<span class="majorlabel" id="optionalPrefix">First </span>
<span class="majorlabel" id="placeForNumberReturned"></span>
<span class="majorlabel"> Results </span>
<span class="joininglabel">for </span>
<span class="majorlabel" id="search_string_render"></span>
</div>
<!-- Start results header -->
<div id="sortcontrols">
<span id="results-sortby">
<label>Sort:</label>
{{!column_dropdown}}
</span>
<span id="results-sortdir">
<label>Order:</label>
<span id="orderDropdownWrapper">
<select id="sortOrder" >
<option value="dsc">Descending</option>
<option value="asc">Ascending</option>
</select>
</span>
</span>
</div>
<div id="detail-header">
<span id="paginationHolder1">
</span>
</div>
<div style="clear:both;"></div>
<div id="detailArea"></div>
<!-- This should not be turned on until I can tie everything together better
with javascript
<span id="paginationHolder2">
</span>
-->
<div style="clear:both"></div>
<div class="hideShowToggle">
<button id="hideShowGrid">Hide/Show Grid</button>
</div>
<p>
Clicking on a column header will sort both the grid and the detail area by that column. Clicking on the header again will reverse the order of the sort.
</p>
<div id="myGrid" style="height:500px;"></div>
<p></p>
<div style="clear:both"></div>
<div class="hideShowToggle">
<button id="hideShowGraph" >Hide/Show Graph</button>
</div>
<div id="chartContainer">
<div id="chartdiv" ></div>
</div>
</div>
<!-- end of "content" -->
</div>
<form id="fakeform" method="post" action="PortfolioPage">
<input type="hidden" name="antiCSRF" value="{{acsrf}}" />
<input type="hidden" name="session_id" value="{{session_id}}" />
<input id="portfolioinput" type="hidden" name="portfolio" value="" />
</form>
<form id="fakeuploadform" method="post" action="UploadData">
<input type="hidden" name="antiCSRF" value="{{acsrf}}" />
<input type="hidden" name="session_id" value="{{session_id}}" />
</form>
<form method="get" id="fakeLogoutForm" action="./">
</form>
<form method="post" id="fakeReturnForm" action="./StartPageReturned">
<input type="hidden" name="antiCSRF" value="{{acsrf}}" />
<input type="hidden" name="session_id" value="{{session_id}}" />
</form>
<div id="dialog">
Transaction Added to Portfolio.
</div>
{{!footer_html}}
</div>
</body>
<script src="../js/jquery.min.js"></script>
<script src="../SlickGrid-master/lib/jquery.event.drag-2.2.js"></script>
<script src="../SlickGrid-master/slick.core.js"></script>
<script src="../SlickGrid-master/slick.editors.js"></script>
<script src="../SlickGrid-master/slick.grid.js"></script>
<!-- jqplot stuff -->
<!--[if lt IE 9]>
<![endif]-->
<script src="../js/excanvas/excanvas.js"></script>
<script src="../js/jquery.jqplot.min.js"></script>
<script src="../js/plugins/jqplot.canvasTextRenderer.min.js"></script>
<script src="../js/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script src="../js/plugins/jqplot.highlighter.min.js"></script>
<script src="../js/plugins/jqplot.cursor.min.js"></script>
<script src="../js/plugins/jqplot.bubbleRenderer.min.js"></script>
<script src="../js/plugins/jqplot.dateAxisRenderer.min.js"></script>
<!-- Trying to get a bloody paginator to work! -->
<script src="../js/jqPagination-master/js/jquery.jqpagination.js"></script>
<!-- I use Stuart Banerman's hashcode to map award names to colors reliably: https://github.com/stuartbannerman/hashcode -->
<script src="../js/hashcode-master/lib/hashcode.min.js"></script>
<link href="../js/feedback_me/css/jquery.feedback_me.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery-ui.min.js"></script>
<script src="../js/feedback_me/js/jquery.feedback_me.js"></script>
<script src="./js/StandardFunctions.js"></script>
<script src="./js/Utility.js"></script>
<script src="./js/result_rendering.js"></script>
<script src="./js/plot_rendering.js"></script>
<script src="./js/grid_rendering.js"></script>
<script src="./js/header.js"></script>
<script src="./js/GUISpecifics.js"></script>
<script src="./js/pagination.js"></script>
<script src="../gui/MorrisDataDecorator/js/handlers.js"></script>
<script>
HANDLER_NAMESPACE_OBJECT.decoration_add_dialog_id = "#dialog";
$(HANDLER_NAMESPACE_OBJECT.decoration_add_dialog_id).dialog({
autoOpen: false,
modal: false,
buttons: [],
open: function(event, ui){
setTimeout("$('#dialog').dialog('close')",1500);
}
});
// TODO: Update tooltip styles
$(function() {
$( document ).tooltip({
position: {
my: "center bottom-20",
at: "center top",
tooltipClass: "p3-tooltip",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
});
$(document).ready(function(){
$("#logoutLink").click(Logout);
$("#return_to_search").click(function() {
$('#fakeReturnForm').submit();
});
$("#upload").click(function() {
$('#fakeuploadform').submit();
});
$("#pricespaid_logo").click(function() {
$('#fakeReturnForm').submit();
});
$( document ).tooltip({
position: {
my: "center bottom-20",
at: "center top",
tooltipClass: "p3-tooltip",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
});
// These should probably be parametrized
var portfolio_url = "/gui/portfolio";
var portfolio_url_addendum = "?antiCSRF={{acsrf}}&session_id={{session_id}}";
var portfolio_post_data = {
antiCSRF: '{{acsrf}}',
session_id: '{{session_id}}',
};
var tag_url = "/gui/tag";
HANDLER_NAMESPACE_OBJECT.portfolio_url = portfolio_url;
HANDLER_NAMESPACE_OBJECT.portfolio_url_addendum = portfolio_url_addendum;
HANDLER_NAMESPACE_OBJECT.portfolio_post_data = portfolio_post_data;
HANDLER_NAMESPACE_OBJECT.tag_url = tag_url;
HANDLER_NAMESPACE_OBJECT.decoration_add_dialog_id = "#dialog";
PAGE_CONTEXT = {};
PAGE_CONTEXT.render_transaction_delete = false;
DEFAULT_NUM_RESULTS = 100;
// BEGIN set up click handlers
$('#next_button').click(next_handler);
$('#prev_button').click(prev_handler);
$('#like_button').click(like_handler);
$('#dislike_button').click(dislike_handler);
$('#add_portfolio_button').click(add_portfolio_handler);
// $('#add_tag_button').click(add_tag_handler);
// END set up click handlers
function Portfolio(click) {
var portfolio = $(this).attr('id').substring("draggable-id-".length);
$("#portfolioinput").val(portfolio);
$("#fakeform").submit();
}
function refreshDroppablesPortfolios() {
$(".droppableportfolio").click(Portfolio);
}
HANDLER_NAMESPACE_OBJECT.refresh_droppables = refreshDroppablesPortfolios;
$(document).ready(function(){
get_portfolio_list();
// get_tag_list(refreshDroppablesPortfolios);
//set up some minimal options for the feedback_me plugin
fm_options = {
custom_params: {
session_id: '{{session_id}}',
antiCSRF: '{{acsrf}}'
},
name_required : false,
name_label : "(Optional) tell us who you are",
message_label : "How can we do better?",
message_placeholder:"Go ahead, type your feedback here ...",
message_required : false,
show_asterisk_for_required : true,
close_on_click_outside: false,
feedback_url : '{{feedback_url}}',
show_radio_button_list : true,
position: 'right-bottom',
radio_button_list_required : false,
radio_button_list_title: "How likely are you to recommend Prices Paid to a colleague (1 means not likely, 5 means very likely)?"
};
//init feedback_me plugin
fm.init(fm_options);
$("#hideShowGrid").click(function() {
$("#myGrid").toggle();
});
$("#hideShowPortfolios").click(function() {
$("#portfolios").toggle();
});
$("#hideShowDetails").click(function() {
$("#detailArea").toggle();
});
$("#hideShowGraph").click(function() {
$("#chartContainer").toggle();
});
}
);
// This is an ugly global variable hack that seems to be
// needed to events properly bound to dynamically created elements!
var SCRATCH_NUMBER = 0;
var itemDetailAssociation = [];
// The current desire is that
var data = [];
var transactionData = [];
var internalFieldLabel = [];
internalFieldLabel["starred"] = "Favorite";
internalFieldLabel["color"] = "Color";
// Note: that search_string here is html-encoded by Bottle,
// So presumably this does not represent a XSS vulnerability...
$('#search_string_render').html('“'+htmlEscape('{{search_string}}')+'”');
$('#commodities li').first().addClass("selected");
var currentlySelectedCommodityElement = '{{commodity_id}}';
$('input[id=small_search_string]').on('keyup', function(e) {
if (e.which == 13) {
performSearch();
}
});
// This is my basic page math...
var PAGESIZE = 5;
var currentPage = 0;
var timeSearchBegan;
var grid;
var currentColumn = "score";
var currentCommodityId = '{{commodity_id}}';
var com = $("#commodityChoice").val(currentCommodityId);
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function get_max_results() {
var max_results = $('#num_results_to_return').val();
var max_results_num = parseFloat(max_results);
if (!isNumber(max_results_num)) {
max_results_num = DEFAULT_NUM_RESULTS;
}
return max_results_num;
}
function performSearch() {
$('#loading').show();
$('#results-header').hide();
timeSearchBegan = new Date();
var standard = standardCommodities[currentCommodityId];
var search = $('#small_search_string').val();
var max_results_num = get_max_results();
if (search.length == 0) {
processAjaxSearch([]);
} else {
$('#search_string_render').html('“'+htmlEscape(search)+'”');
$.post("search",
{ search_string: search,
antiCSRF: '{{acsrf}}',
session_id: '{{session_id}}',
psc_pattern: standard,
numRows: max_results_num
},
processAjaxSearch
).fail(function() { alert("The search failed in some way; please try something else."); });
}
};
var comclickcount = 0;
$("#comDropdownWrapper").click(function(){
if ((comclickcount % 2) == 1) {
var com = $("#commodityChoice").val();
currentCommodityId = com;
performSearch();
}
comclickcount++;
});
function processAjaxSearch(dataFromSearch) {
dataFromSearch = handleEmptyResults(dataFromSearch);
$('#loading').hide();
$('#results-header').show();
var timeSearchEnded = new Date();
transactionData = [];
data = [];
var totalNumber = 0;
for (var key in dataFromSearch) {
transactionData[totalNumber++] = dataFromSearch[key];
}
var numberDiv = document.getElementById('placeForNumberReturned');
numberDiv.innerHTML = totalNumber;
var max_results_num = get_max_results();
if (totalNumber >= max_results_num) {
$('#optionalPrefix').show();
} else {
$('#optionalPrefix').hide();
}
recreatePagination();
// Note: This counts the Page from 1, not zero!
// $(document).ready(function() {
$('.pagination').jqPagination({
// link_string : '/?page={page_number}',
link_string : '',
max_page : Math.ceil(totalNumber/PAGESIZE),
currentPage : 1,
paged : function(page) {
currentPage = page - 1;
redrawDetailArea(transactionData,currentPage);
}
});
// });
var secondsSpent = (timeSearchEnded-timeSearchBegan)/1000.0;
$('#timeSpentRender').text(secondsSpent.toFixed(2));
var medianUnitPrice = 0.0;
grid_rendering();
initialize_plot(data,medianUnitPrice);
}
performSearch();
</script>
</html>