Skip to content

Commit

Permalink
Revert "configuring script to run as an Add-On"
Browse files Browse the repository at this point in the history
This reverts commit a196b78.
  • Loading branch information
dogracer committed Jan 25, 2021
1 parent bfad72f commit 1cbe85b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 52 deletions.
19 changes: 7 additions & 12 deletions appsscript.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
{
"timeZone": "America/Mexico_City",
"dependencies": {
"libraries": [
{
"userSymbol": "QUnit",
"libraryId": "13agWuzcPH32W4JJvOqOEYqeNHGihS63P2V-a-Vxz-c9WPIzZYBvIhs3m",
"version": "4"
}
]
"libraries": [{
"userSymbol": "QUnit",
"libraryId": "13agWuzcPH32W4JJvOqOEYqeNHGihS63P2V-a-Vxz-c9WPIzZYBvIhs3m",
"version": "4"
}]
},
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets"
],
"webapp": {
"executeAs": "USER_ACCESSING",
"access": "DOMAIN"
"access": "MYSELF",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
Expand Down
41 changes: 13 additions & 28 deletions crypto_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,24 @@
*
*/

/**
* A special function that runs when the this is installed as an addon
*/
function onInstall(e) {
onOpen(e);
}

/**
* A special function that runs when the spreadsheet is open, used to add a
* custom menu to the spreadsheet.
*/
function onOpen(e) {
function onOpen() {
var ui = SpreadsheetApp.getUi();
var menu = ui.createAddonMenu(); // createsMenu('HODL Totals')

menu.addItem('New currency...', 'newCurrencySheet_')
.addSeparator()
.addItem('Apply formatting', 'formatSheet_')
.addItem('Calculate (FIFO method)', 'calculateFIFO_')
.addSeparator()
.addSubMenu(ui.createMenu('Examples')
.addItem('Cost basis', 'loadExample0_')
.addItem('Fair market value', 'loadExample1_'))
.addSeparator()
.addItem('About', 'showAboutDialog_');

//if (e && e.authMode != ScriptApp.AuthMode.NONE)
// https://ctrlq.org/google.apps.script/docs/add-ons/lifecycle.html
// Add a menu item based on properties (doesn't work in AuthMode.NONE).
// i.e. analytics UrlFetchApp.fetch('http://www.example.com/analytics?event=open');
// or add dynamic menu items based on stored *properties* [i.e. FIFO vs LIFO etc]

menu.addToUi();
ui.createMenu('HODL Totals')
.addItem('New currency...', 'newCurrencySheet_')
.addSeparator()
.addItem('Apply formatting', 'formatSheet_')
.addItem('Calculate (FIFO method)', 'calculateFIFO_')
.addSeparator()
.addSubMenu(ui.createMenu('Examples')
.addItem('Cost basis', 'loadExample0_')
.addItem('Fair market value', 'loadExample1_'))
.addSeparator()
.addItem('About', 'showAboutDialog_')
.addToUi();
}

function showNewCurrencyPrompt() {
Expand Down
12 changes: 0 additions & 12 deletions examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
*/

function loadExample0_() {

// if no Categories sheet previously exists, create one
if (SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Categories") == null) {
newCategorySheet();
}

var newSheet = newCurrencySheet_(true);
if (newSheet !== null) {
example0(newSheet);
Expand Down Expand Up @@ -45,12 +39,6 @@ function example0(sheet) {
}

function loadExample1_() {

// if no Categories sheet previously exists, create one
if (SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Categories") == null) {
newCategorySheet();
}

var newSheet = newCurrencySheet_(true);
if (newSheet !== null) {
example1(newSheet);
Expand Down

0 comments on commit 1cbe85b

Please sign in to comment.