Last active
May 5, 2016 15:08
-
-
Save brainysmurf/666c5bf422810f7d9d11adc18dc1426c to your computer and use it in GitHub Desktop.
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
// Step 1: Place this in your <script> area of your template | |
// Step 2: Change 'columns' variable to reflect on line 19 to your desires | |
// e.g. columns = {'b': 'Column B!', 'c': 'Column C!'} | |
// | |
// NOTE: Does NOT refer to the columns in the data source sheet | |
// Column A here is the first column that appears on the awesometable, | |
// B the second | |
var convertColToN = function(val) { | |
var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', i, j, result = 0; | |
val = val.toUpperCase(); | |
for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) { | |
result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1); | |
} | |
return result; | |
}; | |
function main() { | |
columns = { | |
'a': 'Change', | |
}; | |
$.each(columns, function (col, colName) { | |
var n = convertColToN(col); | |
$('.google-visualization-table-th:nth-child(' + n.toString() + ')').text(colName); | |
}); | |
} | |
(function() { | |
[ | |
'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js', | |
].forEach(function(src, index, arr) { | |
var tag = undefined; | |
if (src.endsWith('.js')) { | |
tag = document.createElement('script'); | |
tag.src = src; | |
tag.async = false; | |
} else if (src.endsWith('.css')) { | |
tag = document.createElement('link'); | |
tag.rel = "stylesheet"; | |
tag.href = src; | |
} | |
if (index === (arr.length-1)) { | |
tag.onload = function () { | |
$(function () { | |
main(); | |
}); | |
}; | |
} | |
document.head.appendChild(tag); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment