Line 7: | Line 7: | ||
<style> | <style> | ||
ul.tag-type{ | ul.tag-type{ | ||
− | column-width: | + | column-width: 300px; |
list-style: none; | list-style: none; | ||
} | } | ||
</style> | </style> | ||
− | <script | + | <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.10/handlebars.min.js"></script> |
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script> | <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script> | ||
<script src='https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js'></script> | <script src='https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js'></script> | ||
<script src="http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script> | <script src="http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script> | ||
+ | <script src='outreach_db.js'></script> | ||
<script id="checkbox-area-template" type="text/x-handlebars-template"> | <script id="checkbox-area-template" type="text/x-handlebars-template"> | ||
{{#each this}} | {{#each this}} | ||
− | + | <fieldset id='{{@key}}' value='{{@key}}'> | |
− | + | <legend>{{@key}}</legend> | |
− | + | <ul class='tag-type'> | |
{{#each this}} | {{#each this}} | ||
<li class='tag'> | <li class='tag'> | ||
− | <input type='checkbox' name='{{@../key}}' value='{{this}}' class='tag-checkbox' style='float:left'/><label class='tag-label'> {{this}}</label> | + | <input type='checkbox' name='{{@../key}}' value='{{this}}' class='tag-checkbox' style='float:left'/><label class='tag-label'>{{this}}</label> |
</li> | </li> | ||
+ | <br> | ||
{{/each}} | {{/each}} | ||
− | + | </ul> | |
− | + | </fieldset> | |
{{/each}} | {{/each}} | ||
</script> | </script> | ||
Line 48: | Line 50: | ||
<script id="search-results-template" type="text/x-handlebars-template"> | <script id="search-results-template" type="text/x-handlebars-template"> | ||
− | < | + | <div class='search-result'> |
− | + | {{#each this}} | |
− | < | + | <h3>{{[Outreach Project]}}</h3> |
− | + | <span class='school-info'><a href='{{[Wiki hyperlink]}}'>{{[School]}}-{{[Year]}}-{{[School Level]}}</a></span> | |
− | </ | + | <br /> |
+ | <span class='outreach-category'>{{[Outreach Category]}}</span> | ||
+ | <p> | ||
+ | {{[Product Description]}} | ||
+ | </p> | ||
+ | <dl> | ||
+ | <dt> | ||
+ | Award | ||
+ | </dt> | ||
+ | <dd> | ||
+ | {{[Award]}} | ||
+ | </dd> | ||
+ | <dt> | ||
+ | Project Tag | ||
+ | </dt> | ||
+ | <dd> | ||
+ | {{[Project Tag]}} | ||
+ | </dd> | ||
+ | </dl> | ||
+ | {{/each}} | ||
+ | </div> | ||
+ | |||
</script> | </script> | ||
<script type='text/javascript' > | <script type='text/javascript' > | ||
$(document).ready(function(){ | $(document).ready(function(){ | ||
var OUTREACH_URL = 'https://docs.google.com/spreadsheets/d/1lkZSXS3HXTS_ZyPZytyIW0Keer_aKy8rr1_pxV2-fSs/pubhtml?gid=1097044156&single=true' | var OUTREACH_URL = 'https://docs.google.com/spreadsheets/d/1lkZSXS3HXTS_ZyPZytyIW0Keer_aKy8rr1_pxV2-fSs/pubhtml?gid=1097044156&single=true' | ||
− | + | outreach_db.init( | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
).then( // scrape all tags from data | ).then( // scrape all tags from data | ||
− | + | outreach_db.list_tags | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
).then( // initialize checkbox area using tag data | ).then( // initialize checkbox area using tag data | ||
init_checkbox_area | init_checkbox_area | ||
Line 106: | Line 105: | ||
} | } | ||
− | function | + | function generate_table(data) { |
var html = '<table>'; | var html = '<table>'; | ||
Line 131: | Line 130: | ||
} | } | ||
} | } | ||
− | + | 1 | |
if(data[0].constructor === Object) { | if(data[0].constructor === Object) { | ||
for(var row in data) { | for(var row in data) { | ||
Line 144: | Line 143: | ||
return html; | return html; | ||
} | } | ||
+ | |||
+ | |||
function search(){ | function search(){ | ||
− | + | ||
− | + | ||
// From light comes darkness, and from darkness, light. | // From light comes darkness, and from darkness, light. | ||
// i.e. Don't filter types of which no tags has been selected | // i.e. Don't filter types of which no tags has been selected | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
var ordburl = 'https://docs.google.com/spreadsheets/d/1lkZSXS3HXTS_ZyPZytyIW0Keer_aKy8rr1_pxV2-fSs/pubhtml?gid=1097044156&single=true'; | var ordburl = 'https://docs.google.com/spreadsheets/d/1lkZSXS3HXTS_ZyPZytyIW0Keer_aKy8rr1_pxV2-fSs/pubhtml?gid=1097044156&single=true'; | ||
− | + | selected_tags = read_checkbox_area() | |
− | qString = 'SELECT * FROM outreach ' + | + | |
+ | qString = 'SELECT * FROM outreach ' + outreach_db.compile_sql(selected_tags) | ||
console.time(qString); | console.time(qString); | ||
− | alasql(qString, [ | + | alasql(qString, [], callback= function(data){ |
show_results(search_result=data) | show_results(search_result=data) | ||
console.log(data); | console.log(data); | ||
Line 170: | Line 166: | ||
show_results.template = show_results.template || Handlebars.compile($('#search-results-template').html()) | show_results.template = show_results.template || Handlebars.compile($('#search-results-template').html()) | ||
//$('#search-results').html(show_results.template(search_result)); | //$('#search-results').html(show_results.template(search_result)); | ||
− | $('#search-results').html( | + | $('#search-results').html(show_results.template(search_result)); |
} | } | ||
Line 178: | Line 174: | ||
$('#checkbox-area').html(checkbox_area_html) | $('#checkbox-area').html(checkbox_area_html) | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
</script> | </script> | ||
</head> | </head> |
Revision as of 15:28, 16 August 2017