Google Apps Script: formPanel and doPost - google-apps-script

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.

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();

GTM Setup for tracking "click to display" text on wordpress

Code and GTM Setup Example
I have tried a few variations in how I set my triggers, but none of the ways I have tried have actually started to track test clicks. The client has click to display text to show their phone numbers, ideally so that we can track how many visitors are coming to the site to get the phone contact details. I will include some code below. I am not sure if it is my syntax or if I am forgetting something outside of this setup. GTM is installed correctly and tracking standard google analytic information. Thanks in advance.
Previously I have tried to limit the trigger based on the class, but I have instead added and moved to ID.
This is tricky part of GTM because when you have nested elements like this:
<div>
<span>
<h2>
It is sometimes difficult to say what exact element is clicked.
Your triggers are set for <div> (based on ID you have in your screenshot) but I suspect when you click the actual element that is picked up is one of the <span> ones. To fix it, firstly in GTM go to variables tab -> Configure Built-in variables and make sure "Click Classes" is enabled.
Then setup a trigger like this:
This one will listen to one of those spans you have there.
Usually my approach to click events is: before I setup the trigger I enable the preview mode with GTM so that I see GTM's debugger console. Then click on an element - this action will generate click event on left hand event log. Select it and you will be able to see exact element that is being clicked with it's IDs and classes. Then it's easy to setup the trigger.
Hope this helps.

Adding a interactive gui to my VB.net application

OK. So first, I will try my best to explain so good. My friend has gotten cursed out on this forum for not explaining, so I will explain. :)
Ok so I have my program built and all. But then it hit me! Wouldn't it be better to add a news feature? One teeny tiny problem? I cant? How would I implement a interactive code into an HTML page.
Like can i connect a button to a URL that will make the program do something. Almost like you can open cydia tweaks with there identifier and url EXAMPLE: http://handleopenurl.com/scheme/cydia And then i can add urls so i can update the program, without updating the files.
Or even just a featured news thing would be nice. But how would i implement this perfectly. I tryed a webrowser, but the page is too big for it. I am good at html, not much at css, i mostly use Adobe Muse http://www.adobe.com/Muse
Last question. Kinda defies the first thing i said about having my program finished.
Is there a way i can add a plus button and make it add more buttons and more labels and all?
This would help with allowing users to customize more then what the program can handle. By The Way, its a winter board Theme Maker. So I have a bunch of icons with there bundle identifiers and I create the folders with VB.net and all that stuff. But i want users to be able to click a plus button to add MORE text boxes and file browsers.
Any ideas? Maybe DIM 1 as NewFileBrowser? But i need to move all the buttons and i need it to be able to be clicked an infinity amount of times. I can do the coding for all of these buttons, but i jest need to know how to create them <1 Move them and the button so that the button goes further down each time, and more boxes will go further down. Much help apreciated. THANKS:)
EDIT:
Are you trying to say that you're wondering how to have a web browser control in a vb.net >app, which displays a web page, and when a button is clicked on the page, your app detects >it and does something? – Thraka
That sums up the top part. I am using windows forms, and it is coded in VB.net
If you get the object you want, like the button, you can hook the event and have it call code in your form.
Find the object using the Browser.Document.GetElementById method.
With that object, add an event handler to the Click event.
See http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelementeventhandler(v=vs.110).aspx for information about the event handler used

Selenium does not record Ajax Call. Need help on coding in html or selenese

I am recording a .Net application using Selenium IDE. Theres this scenario, that a textbox is presnt. I need to enter a name to search. As soon as i start typing, matching options come in a dropdown below. I have to select one of them, then the application goes to the next page.
The problem is, Selenium doesnt record this selection from the drop down. More over, when the script is typing in the name, the dropdown list is not being visible at all.. i.e. the ajax call is not occuring.
Please help. I need the solution code in Selenese or HTML, since I'm not much of a coder myself, and also, I am simply recording and playback, so I am not using Java or other scripts.
This question is great,
and so is the answer in this blog: http://blog.buberel.org/2010/07/howto-test-jquery-ajax-autocomplete-menus-with-selenium.html
other option to deal with this problem is to use a different way to insert your text into the text box, as described here: Can selenium handle autocomplete?

How do I add a button on other UI element to a Google spreadsheet?

I want to add a ToggleButton to a Google Spreadsheet. I would like to be able to control the positioning and the text on the button. Is this possible?
If so, does anyone know of a good tutorial that covers these topics?
You can not interact with the spreadsheet environment UI except by adding a menu.
You can insert a drawing or an image and assign a function to it but the positioning of that "button" is only manual and not accessible programatically.
So,... unless you try to entirely recreate the spreadsheet layout in a personalized UI (which would be quite hard I guess /-) you have no way to do what you want.
I would suggest (as someone famous once said) 'Think differently'