Google Sites Drawing Reload - google-apps-script

Total noob here with almost zero understanding of Google Apps Script or coding in general.
I was looking for a way to force a reload of a google sites page. This (reload page google apps script) makes it look like that can't be done, so I want to try and reload just the google drawing embedded in the site if possible.
I tried to use a javascript iFrame reload:
window.setInterval("reloadIFrame();", 30000); function reloadIFrame() { document.frames["frameNameHere"].location.reload(); }
But I don't think google sites supports this our I got it wrong somewhere.
I can't figure out what the correct Apps Script would be to force the page to reload(pull from the server) the drawing in question. The code for the drawing looks like this:
img
src="https://www.google.com/chart?chc=sites&cht=d&chdp=sites&chl=%5B%5BGoogle+drawing'%3D20'f%5Cv'a%5C%3D0'10'%3D999'0'dim'%5Cbox1'b%5CF6F6F6'fC%5CF6F6F6'eC%5C0'sk'%5C%5B%2211.30.15%22'%5D'a%5CV%5C%3D12'f%5C%5DV%5Cta%5C%3D10'%3D0'%3D1000'%3D347'dim'%5C%3D10'%3D10'%3D1000'%3D347'vdim'%5Cbox1'b%5Cva%5CF6F6F6'fC%5CC8C8C8'eC%5C'a%5C%5Do%5CLauto'f%5C&sig=0bBZl8MyZOx5b3ykHuUS35Gb8iE"
data-origsrc="1mUFhZeas0mFl52FpqC_EgflRn6P3TixsOxMAXI-_Fgo"
data-type="sketchy"
data-props="align:left;borderTitle:11.30.15;height:350;objectTitle:11.30.15;showBorder:false;showBorderTitle:false;width:1000;wrap:false;" width="1000" height="350"
style="display:block;text-align:left;margin-right:auto;">
It's located in my google drive and I just used the google sites tools to embed it, I didn't code it. The drawing is edited constantly throughout the day and I need the changes to appear while viewing with out requiring a page refresh.
Can anyone help me with where and what code could be used to reload the drawing? Even better would be if I could set an interval (say every 5 minutes) for the refresh. Any help is appreciated.
Thanks

Probably you can create an XML gadget that reloads the Google Sites Page.
Try this one (found quickly)
http://www.k8oms.net/refresh

Related

Properly embed Google Apps Script URL into Google Site

In Google Sites, it is possible to embed a Google Apps Script which has been published as a Web App. You just click "embed" and paste the URL of the Web App. It is possible to use the mouse to resize the iframe. However, I could not set the iframe to be of full width. Is that possible? Also, is it possible to make the whole page scrollable (instead of the iframe) when the Web App has some larger height as well? (I actually don't want to use any other functionalities of Google Sites except that it "hosts" my Google Apps Script with a custom URL and that it gets rid of the standard header warning that this Web App is not by Google).
Sorry
Unfortunately, AFAIK, this is not possible within Google sites.
I have experimented with various custom iframe HTML and CSS to try and find a workaround, but due to the way the site is rendered, it will always wrap your custom code in its own HTML and CSS. Any solution along these lines seems like it will be unreliable.
If you would like to see this specific functionality you can always submit a feature request.
My best workaround so far
Start a new site.
Delete all the elements, including the title.
Then add in your webapp embed.
It let me resize it vertically as far down as I wanted, it seems like full width since it is the only element on the page, and it doesn't present me with the warning.

How can I force google docs embedded in iframes to open their links in the same window?

I'm currently making an educational resource with google drive.
I've currently got the "Publish to web" version of the google documents embedded in an iframe in an html document using
<iframe src="https://docs.google.com/document/d/e/2PACX-1vSaUZ2XolOoqc0M12v-VNTTMcz3dIAnAOO9gaCyifoAXhlWiKz114M2QYoQ5d-dNBEsgWDcXahKNMSD/pub" frameborder="0"></iframe>
I've inserted hyperlinks (using the built in hyperlink function) in the google docs, to link to other (published) google docs eg:
https://docs.google.com/document/d/1XnTTbjedXkL3OfeELMwzabeeL4FjnOjarmmWbKb97EY/pub
At the moment, all clicked links are opened in a new tab. This happens whether I link to other google docs, or to external sites. Naturally, this is quite frustrating for navigating the site.
I'd like to have them open either...
in the same iframe
or to another webpage that appears in the same tab (which I could then embed the target document in). I don't really mind which, as long as a new tab isn't created every time someone clicks a link.
I see from similar questions posted that in the past people seem to have had the opposite problem - trying to force the links to open in new tabs, so perhaps something has changed with the way links are handled?
For onlookers, the reason for the varying behavior is due to the query parameter that either is or isn't present as the src value:
You can see that the OP does not have ?embedded=true at the end (after /pub).
<iframe src="https://docs.google.com/document/d/e/2PACX-1vSaUZ2XolOoqc0M12v-VNTTMcz3dIAnAOO9gaCyifoAXhlWiKz114M2QYoQ5d-dNBEsgWDcXahKNMSD/pub" frameborder="0"></iframe>
Google doesn't document the differing functionality very well, but a URL like
https://docs.google.com/document/d/e/2PACX-1vSaUZ2XolOoqc0M12v-VNTTMcz3dIAnAOO9gaCyifoAXhlWiKz114M2QYoQ5d-dNBEsgWDcXahKNMSD/pub?embedded=true
will provide the desired behavior of keeping links opening in-iframe.

Google Analytics - Multiple pages and single header

My webpage is compose from more "pages". For example:
www.webpage.com/home.php
www.webpage.com/registration.php
www.webpage.com/contacts.php
...etc
But all my pages have the same , because I include the same head in all of my pages.
My question so far:
1.) Is good to place the google analytics script in my head?
2.) If someone goes from www.webpage.com/home.php to www.webpage.com/registration.php it will count it as two visit of my page?
Thx
its okay to place google analytics script in your head. google analytics is java script and is run only after the page is loaded into your browser. So each page will be individually recognized.
Yes. Google actually recommends to put the code in the header
Paste your snippet (unaltered, in its entirety) into every web page
you want to track. Paste it immediately before the closing
tag.
One of the reasons is that GA has a report on page timings. The timer is started when the tracking code is loaded, so if you insert the code later in the page the timing reports might be off.
If you have the tracking code in all pages and GA can set cookies properly then the two calls to the pages will be tracked as two pageviews, but only one session/visit.

Google Script to replace image background color?

Looking to automate the tedious clicking to change the backround of my PNG images from white to transparent.
The images reside in Google Drive, and as new images are submitted I have to make it transparent, each time, again. There's got to be a better way!
I don't see any way to use that website with code. That website has what it calls an API, but it looks like it's nothing more than a link. You could use something like AutoIt, to reproduce the keystrokes that you manually do.
AutoIt website
If there was an online picture editor that had an API that would receive HTTP Requests, Apps Script can send and receive HTTP Requests.
Google Documentation urlFetch
But the online picture editor would also need to read your files from your Google Account.
HTML does have a canvas tag, that you can manipulate pictures with, but Apps Script currently doesn't work with the canvas HTML tag the last I knew.
You can access your Google Drive with Apps Script, and get files, but then you'd need to either send the file out somewhere, or process it yourself, just like that online picture editor does. If Caja would allow the HTML Canvas tag to work with HTML Service, there might be a way to automate what you want.
I created a way to re-size pictures with the Canvas tag, but it wouldn't work with Apps Script HTML Service.

Apps Scripts within Google Sites

So I might be doing this entirely wrong, but I am trying to create a slideshow based on images stored in a google drive folder that can be easily added (ie by a non-technical person) to a google site.
I created a script that outputs the slideshow using the HTMLService. You can view the working site at https://script.google.com/a/macros/needham.k12.ma.us/s/AKfycbyOyqTr_sEMWRVBn0e0r4NV5083_LwzZSMYwPU-25_xd2m6ZexS/exec?width=300&height=200&folderID=0B-6QUsY0bQG5ZmI4QTl4T1ZQZmc
When I try to insert this script into a google site using the Apps Script Gadget (Screenshot 1) using the link above it appears that the parameters are either lost or ignored (Screenshot 2). When I hard code the parameters into the script, the slideshow loads correctly (Screenshot 3).
Screenshot 1
Screenshot 2
Screenshot 3
You cannot add the parameters to the URL when inserting your script in a Google Site. However, you can pass the parameters to the Site URL utself and the script will pick it up.
For example,
http://sites.google.com/example.com/example-site/example-page?folderID=1235
As for the width and the height, you can adjust them when you insert the script into a Site using controls that Google Sites provides
Same happened to me. My solution was to write a google gadget that iframed my apps script and added fhe necesary parameters.