Google Apps Script; Sidebar OnClose - html

Is there a way to hook into the CLOSE event of the Ui Sidebar ?
I read up on the docs but could not find one.
Use-Case: User choices on the Sidebar updates the spreadsheet visually like coloring cells for easy visual responses. However, then the user abruptly closes the Sidebar - leaving the physical changes already made to the spreadsheet (such as coloring). To undo those changes, need to hook into close event of Sidebar.
Any ideas / other ways ?

Related

Clear certain cells on Window Close AppScript

I wanted an appscript mechanism, where I want to clear certain cells (A2:B8) if the spreadsheet window is closed. I have one way of doing it and that is:
onOpen()
{
sheet.getRange("A2:B8").setValues("");
}
But this seems like a hack but I wanted to know if there's a definite way to do so... like for example:
Browser.onWindowClose()=>{clearCells()}
You maybe able to do this if you have a modal dialog or sidebar open. If sidebar or dialog close is attempted, you may be able to catch the event with beforeunload, if catched, clear all cells using google.script.run(). This assumes user is closing the sidebar before/along with the Google sheets main web app.
There isn't onClose() or onExit() built in trigger as of yet.
Here is the list with all the currently available triggers.
The lack of this feature has already been reported in the IssueTracker.
You can go there and click on the star button to the top left of the page to "increase" the chances for this feature to be implemented by google.
As a side note, clearContent() would be more appropriate:
sheet.getRange("A2:B8").clearContent();

Modify a Google Slides presentation while presenting?

I'm afraid I already know the answer, but maybe someone else has found a way to do this.
I've been perusing the Slide Apps Script reference, and I'm excited about the possibilities. One thing I would like to do is alter a slide mid-presentation. Specifically, I would like to somehow indicate a link has been clicked.
If links in a presentation turned purple like web links I would settle for that, but I would like to use a trigger when a certain link is clicked or when a certain slide is shown. This trigger could run a script that alters the slide with the link appropriately to show the link has been clicked or even remove the link altogether.
I know the Slides API is behind the others, but Forms have installable triggers that can run onFormSubmit and Spreadsheets have triggers that run onChange and onEdit. I would love to see Slides have an onPresent trigger that ran a script that could detect slide changes with methods like onSlideChange that could report currentSlide. That way we could run scripts while the presentation is showing and take action based on current slides or links.
Aside from Slide specific triggers being added to the API, is there any way to modify slides during a presentation? Or at least show that a link has been clicked?

How to create a secondary slide-out in Google Doc add on side bar in Google Apps Script

I have a Google Doc add-on that utilizes the sidebar: no problem there. When one uses the Google research add-on, there is an secondary slide out from the sidebar that shows a preview of a search result (see picture below) when clicked. I am hoping to replicate this behaviour, but I see nothing about it in the api regarding size and limits. I tried having a tooltip pop up on my links in the sidebar, but they appear cut off or under the main Google Doc palette. I have tried a bunch of other Google Doc add-ons to see if any of them replicate this functionality, but they don't. Before I spend hours on this, I want to first ask is anyone know if this is specific permission for Google's sidebar only, or can developers replicate this functionality?
The Research Tool is a direct integration with Docs and Presentations, it's not a Google Apps Script add-on. The freedom to "slide out" within the document is not available to add-ons today.
As one alternative, you could use an accordion affect to collapse your "first page" and overlay the result page, still within the bounds of the sidebar.
A second alternative would be to use a non-modal window, where you'd have more freedom. (resizing there requires client-server exchanges, but is doable)

disable dismiss hyperlink and message on google spreadsheet

When we run any method of Google App Script,a message appears on Google Spreadsheet with dismiss hyperlink.
For Example:
Running Script methodname Dismiss hyperlink
I would like to know if there is any option to disable the message and dismiss hyperlink that appears on Google Spreadsheet when any function is executed at the back ground. In not , please share what alternates are available to hide this out.
It is within a div of class docs-butterbar-container so on your own machine, you could add
.docs-butterbar-container {
display:none;
}
to a user stylesheet.
But if you are hoping to hide it from other others of your sheets/scripts then your likely out of luck, unless you have means of rolling out user stylesheets.
I also wouldn't recommend hiding this. It's useful.

Google Apps Script: formPanel and doPost

I have a quick question concerning GAS efficiency and best practices. I have a script that is embedded into a site. In an effort to try and make it quicker I changed from using a doGet() with a serverclickhandler attached to a submit button and another submit() function to using doGet() with submit and doPost. The initial version used a vertical panel, while the second version requires a form panel. My vertical panel has a grid setup on it, and I would like to keep as much existing code as possible. My question is:
Can I put a grid directly into a formPanel without it slowing down the loading process? I tried it and it seemed slower, but maybe Google's server was having a bad day.
Can I add the verticalPanel to the formPanel without slowing things down? What would be the best practice in this situation?
The reason I want to switch to doPost is that it shows another panel when you click the submit button, so the user knows that there submission went through. Previously I was clearing the GUI elements, which seems like a lot of extra code that could slow things down.
Thanks in advance!
concerning the last point of your post, you don't have to clear everything, you can mask the whole panel with another empty (or not) one on top of it... quick and efficient ;-)
Depending on the way you created your Ui different approaches are possible : one of the easiest it to setVisible(false) the parent panel that holds all the widgets while you setVisible(true) a big label saying 'thanks for you answer... bla bla bla' (this one can be there from the beginning but invisible ;-) and set to visible by a handler on the 'submit' button (client or server... both are able to do the job))
Having panels inside other panels shouldn't slow down the loading of the UI.