updated by GasGit automation
This commit is contained in:
parent
a5f2b8d56f
commit
5a20cc0053
1 changed files with 15 additions and 43 deletions
|
@ -1,45 +1,17 @@
|
||||||
/**
|
var Server = (function (ns) {
|
||||||
* used to expose memebers of a namespace
|
|
||||||
* @param {string} namespace name
|
ns.generateTestData = function () {
|
||||||
* @param {method} method name
|
var ss = SpreadsheetApp.getActiveSpreadsheet();
|
||||||
*/
|
var sh = ss.insertSheet();
|
||||||
function exposeRun (namespace, method , argArray ) {
|
var data = getTestData ();
|
||||||
var func = (namespace ? this[namespace][method] : this[method])
|
sh.getRange(1, 1, data.length, data[0].length).setValues(data);
|
||||||
if (argArray && argArray.length) {
|
ss.setActiveSheet(sh);
|
||||||
return func.apply(this,argArray);
|
return data;
|
||||||
}
|
|
||||||
else {
|
|
||||||
return func();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// namespace set up
|
|
||||||
var Server = (function(server) {
|
|
||||||
/**
|
|
||||||
* get the data from the active sheet
|
|
||||||
* @param {string} 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.keyDigest (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;
|
function getTestData () {
|
||||||
})(Server || {});
|
return [["Source","Target","Volume"],["CHP","Electricity",58],["CHP","Losses",60],["Electricity","Domestic",71],["Electricity","Industry",87],["Electricity","Other final",77],["Electricity","Losses",42],["Electricity","Non-energy",13],["Natural gas","CHP",62],["Natural gas","Industry",90],["Natural gas","Losses",22],["Natural gas","Non-energy",13],["Natural gas","Power",53],["Coal","CHP",61],["Coal","Other",64],["Coal","Power",153],["Crude oil","Export",58],["Crude oil","Refineries",573],["Nuclear","Power",228],["Petroleum products","Refineries",324],["Power","Electricity",222],["Power","Losses",285],["Refineries","Domestic",38],["Refineries","Export",370],["Refineries","Industry",30],["Refineries","Non-energy",84],["Refineries","Other final",33],["Refineries","Transport",329],["Renewables","CHP",75],["Renewables","Domestic",41],["Renewables","Other final",5],["Renewables","Power",74],["Renewables","Transport",15],["CHP","Industry",80]]
|
||||||
|
|
||||||
|
}
|
||||||
|
return ns;
|
||||||
|
})(Server || {});
|
Loading…
Add table
Add a link
Reference in a new issue