Last active
February 28, 2018 17:31
-
-
Save nacengineer/5678ca6f8997bc288cfa4e080b803d20 to your computer and use it in GitHub Desktop.
Reformat Schedule on http://el-una.org/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2017-2018, Dave Southard | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// The above copyright notice and this permission notice shall be included in all | |
// copies or substantial portions of the Software. | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
// SOFTWARE. | |
var jq = document.createElement('script'); | |
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
jQuery.noConflict(); | |
function drawTable(rowdata) { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('string', 'Title'); | |
data.addColumn('string', 'Date');; | |
data.addColumn('string', 'Track'); | |
data.addColumn('string', 'Presenters'); | |
data.addRows(rowdata); | |
var table = new google.visualization.Table(document.getElementById('table_div')); | |
table.draw(data, {showRowNumber: true, width: '100%', height: '100%', 'allowHtml': true}); | |
} | |
function redrawIt() { | |
loadContentFromPage(); | |
drawTable(data); | |
} | |
function loadContentFromPage() { | |
jQuery('.sessionholder').each(function(i) { | |
var element, datetime, presenters, track, title, link; | |
track = ''; | |
link = rootUrl + jQuery(this).children(".titleholder").children('a').attr("href"); | |
title = "<a href=' + link + '>" + jQuery(this).children(".titleholder").children('a').text() + "</a>"; | |
datetime = jQuery(this).children(".datetimeholder").text(); | |
jQuery(this).children(".fieldtextholder").find("p").each(function(i){ | |
if (i>0) {track += "<br/>";} | |
track += jQuery(this).text(); | |
}); | |
presenters = ''; | |
jQuery(this).children(".roleholder").find(".roleuserholder").each(function(i) { | |
if (i>0) {presenters += "<br/>";} | |
presenters += jQuery(this).children(".rolenameholder").text(); | |
}) | |
element = [title, datetime, track, presenters]; | |
data.push(element); | |
}); | |
} | |
jQuery.getScript( "https://www.gstatic.com/charts/loader.js"); | |
jQuery('body').prepend("<div id='table_div'></div>"); | |
var rootUrl = "https://el-una.org/meetings/eluna-2018-meeting/eluna-2018-program/" | |
var data = []; | |
loadContentFromPage(); | |
setTimeout(function(){google.charts.load('current', {'packages':['table']})}, 500); | |
setTimeout(function(){ | |
drawTable(data); | |
window.scrollTo(0,0); | |
}, 1000 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tested it in OS X Chrome, Firefox, and Safari JavaScript developer consoles and it works fine. Note you may have to turn on Safari's developer console, I believe Chrome and Firefox developer consoles are on by default.
This script hasn't been extensively tested and YMMV but it should get one most of the way. Afterwards, if you want to go further you can use an extension such as Table Capture to export the generated table to a spreadsheet or Google Doc.
This script only scrapes the loaded information contained within the browser via JavaScript so it doesn't affect ELUNAs website itself. If you want to undo its changes, just reload the page.
NOTE: ELUNA's jQuery load is bugged and there is some code that will reload it in noConflict mode for this script.
If anyone is really ambitious this could probably be moved into a Chrome Extension or even ELUNA could do something similar as their data is already nicely formatted for it. Regardless feel free to use the code as you see fit.
How to use: