Assignment 5: History of the Best Picture

Google Sheet Link: https://docs.google.com/spreadsheets/d/1cIrfQPut2NCVt05dzByVR3yylxIJbgKaHXwbrSyuNWQ/edit#gid=0

Although the table will not actually appear, we are leading up to the 90th Academy Awards. As a large film enthusiast, the winner of Best Picture is always something I look forward to. To honor the 90th best picture, I looked back at all of the previous best picture winners and saw how many times they were nominated and how many Oscars they won.

var jqueryNoConflict = jQuery;

// begin main function
jqueryNoConflict(document).ready(function(){

initializeTabletopObject(“https://docs.google.com/spreadsheets/d/1cIrfQPut2NCVt05dzByVR3yylxIJbgKaHXwbrSyuNWQ/pubhtml”);

});

// pull data from google spreadsheet
function initializeTabletopObject(dataSpreadsheet){
Tabletop.init({
key: dataSpreadsheet,
callback: writeTableWith,
simpleSheet: true,
debug: false
});
}

// create table headers
function createTableColumns(){

/* swap out the properties of mDataProp & sTitle to reflect
the names of columns or keys you want to display.
Remember, tabletop.js strips out spaces from column titles, which
is what happens with the More Info column header */

var tableColumns = [
{“mDataProp”: “year”, “sTitle”: “YEAR”, “sClass”: “center”},
{“mDataProp”: “title”, “sTitle”: “TITLE”, “sClass”: “center”},
{“mDataProp”: “nominations”, “sTitle”: “NOMINATIONS”, “sClass”: “center”},
{“mDataProp”: “wins”, “sTitle”: “WINS”, “sClass”: “center”}
];
return tableColumns;
}

// create the table container and object
function writeTableWith(dataSource){

jqueryNoConflict(“#demo”).html(”

“);

var oTable = jqueryNoConflict(“#data-table-container”).dataTable({
“sPaginationType”: “bootstrap”,
“iDisplayLength”: 25,
“aaData”: dataSource,
“aoColumns”: createTableColumns(),
“fnRowCallback”: function(nRow, aData, iDisplayIndex) {
console.log(aData);
$(“td:eq(2)”, nRow).html(“Website“);
return nRow;
},
“oLanguage”: {
“sLengthMenu”: “_MENU_ records per page”
}
});

};

//define two custom functions (asc and desc) for string sorting
jQuery.fn.dataTableExt.oSort[“string-case-asc”] = function(x,y) {
return ((x < y) ? -1 : ((x > y) ? 0 : 0));
};

jQuery.fn.dataTableExt.oSort[“string-case-desc”] = function(x,y) {
return ((x < y) ? 1 : ((x > y) ? -1 : 0));