Last active
August 18, 2017 20:35
-
-
Save thealanberman/7dd856db4cefe363d2d3afc74a788850 to your computer and use it in GitHub Desktop.
BingoCardGenerator
This file contains 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
// the ID for the spreadsheet of quotes | |
var sheet_id = SpreadsheetApp.getActiveSpreadsheet().getId(); | |
var sheet = SpreadsheetApp.openById(sheet_id); | |
var range = sheet.getDataRange(); | |
var values = range.getValues(); | |
var rows = range.getNumRows(); | |
// Log some things for sanity check | |
Logger.log("sheet ID: " + sheet_id) | |
Logger.log("sheet: " + sheet) | |
Logger.log("range: " + range) | |
//Logger.log("values: " + values) | |
Logger.log("rows: " + rows) | |
// respond to HTTP POST requests | |
function doGet(e) { | |
var possibilities = [] | |
for (var i=1; i < rows; i++) { | |
possibilities.push(values[i][0]) | |
} | |
// Logger.log(possibilities) | |
var randomized = UnderscoreGS._shuffle(possibilities) | |
// Logger.log(randomized) | |
var bingoCard = "<div class='card'>\n" | |
for (j=0;j<5;j++) { | |
bingoCard += "<div class='row'>\n" | |
for (k=0;k<5;k++) { | |
bingoCard += "<div class='square'>" + randomized[k] + "</div>" | |
} | |
bingoCard += "\n</div>" | |
} | |
bingoCard += "\n</div>" | |
Logger.log(bingoCard) | |
var output = HtmlService.createHtmlOutput(bingoCard); | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment