updated by GasGit automation
This commit is contained in:
parent
3882d50bc6
commit
667fba9baf
1 changed files with 50 additions and 0 deletions
50
scripts/Server.js
Normal file
50
scripts/Server.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
|
||||
/**
|
||||
* called to return latest active sheet data
|
||||
* @param {number} checksum the checksum for the last data we got
|
||||
* @param {boolean} useSelection where to use acrive selection - default is use the whole page
|
||||
* @return {object} object with new checksum and potentially the data if anything has changed
|
||||
*/
|
||||
function getData (checksum,useSelection) {
|
||||
return Server.getData (checksum,useSelection);
|
||||
}
|
||||
|
||||
/**
|
||||
* called to display a dialog and save content
|
||||
* @param {string} content the content
|
||||
*/
|
||||
|
||||
function startPicker (content) {
|
||||
showPicker(content);
|
||||
}
|
||||
|
||||
// namespace set up
|
||||
|
||||
var Server = (function(server) {
|
||||
|
||||
/**
|
||||
* get the data from the active sheet
|
||||
* @param {number} previousChecksum if its the same then no point in returning any data
|
||||
* @param {boolean} useSelection where to use acrive selection - default is use the whole page
|
||||
* @return {[[]]} sheet data
|
||||
*/
|
||||
server.getData = function (previousChecksum,useSelection) {
|
||||
var sheet = SpreadsheetApp.getActiveSheet();
|
||||
var range = useSelection ? SpreadsheetApp.getActiveRange() : sheet.getDataRange();
|
||||
var data = range.getValues();
|
||||
var p = {id:sheet.getSheetId(), range:range.getA1Notation() , data:range.getValues() };
|
||||
var thisChecksum = Utils.checksum (p);
|
||||
|
||||
return {
|
||||
checksum :thisChecksum,
|
||||
data: (Utils.isUndefined(previousChecksum) || previousChecksum !== thisChecksum) ? data : null
|
||||
};
|
||||
|
||||
// not used - it's just to provoke getting the driveapp scope
|
||||
function dummy () {
|
||||
Drive.Files.list();
|
||||
}
|
||||
};
|
||||
|
||||
return server;
|
||||
})(Server || {});
|
Loading…
Add table
Add a link
Reference in a new issue