MSG Google Calendar adding a Feed - html

I know I must be brain-dead, and I had a solution about a month ago, but accidentally deleted it (oops)!
From the this page you can create a small widget calendar. With the date picker AND agenda (yes both are needed)
It produces some code like so:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/calendar3.xml&up_calendarFeeds=&up_calendarColors=&up_firstDay=0&up_dateFormat=0&up_timeFormat=1%3A00pm&up_showDatepicker=1&up_hideAgenda=0&up_showEmptyDays=0&up_showExpiredEvents=1&synd=open&w=320&h=165&title=__MSG_Google_Calendar__&lang=en&country=ALL&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>
However it doesn't specify the calendar, and always loads the local calendar. I see there is the variable up_calendarFeeds in there, and that got me thinking I should try to add a feed. I searched and found google's page on feeds. The says the feed url is in the format of:
https://www.google.com/calendar/feeds/userID/private-magicCookie/full
full over basic is for machine readable, of which I assume the gadget uses. However when I set the up_calenderFeeds variable with my data, It loads nothing. What am I missing? This being my final code:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/calendar3.xml&up_calendarFeeds=https://www.google.com/calendar/feeds/ohmusama#gmail.com/private-0b7544f4b5f2198fc76c96e59f285dad/full&up_calendarColors=&up_firstDay=0&up_dateFormat=0&up_timeFormat=1%3A00pm&up_showDatepicker=1&up_hideAgenda=0&up_showEmptyDays=0&up_showExpiredEvents=1&synd=open&w=195&h=500&title=Portland+IPA+Calendar&lang=en&country=ALL&border=%23ffffff%7C3px%2C0px+solid+%23999999&output=js"></script>

Alright, since no one was able to help me. I searched and searched and found some answers.
There are a variety of different variables in the get string with many characters that need escaping. First for what ever reason, up_calendarFeeds must be set to ({}) which url encoded ends up being up_calendarFeeds=%28%7B%7D%29
Then you need to set 2 variables for your calendar to work properly (I think you need both), up_c0u and up_c0c both to your feed path. Note that It seems this can be in an array form, so you can add many feeds by incrementing 0, so up_c1u up_c2u up_c3u etc

Related

Scan an area of a web page's source code for changes while reporting it?

this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}

Sequentialising Google Sheets Macro

I'm looking for a way to recursively generate links to next pages on a website with canonical structure. In essence, I'm trying to generate a link to each next page and then feed that result back in to the process to find the following page ad infinitum. However, I'm having problems automating this as the macro seems to be trying to generate the result for cells that are empty (i.e. the results for an earlier cell hasn't been created/copied yet).
So I'd like to sequentialise the macro to start from A20, generate the result for that cell, copy that result to A21, then begin the macro again for A21, et cetera, without requiring constant human input.
The Google spreadsheet with the error can be seen here in cell C27 and the macro itself can be seen here.
I realise this may be quite a roundabout way to perform this task and am open to any suggestions that may be easier, more intuitive, or faster.
So two suggestions: one is that with stuff that is a continuous scroll, its very easy to find the json of the source, and either grab all the data you want in one go, or by easily picking out the "next page" or pagination...
I personally use importdata() and importxml() more than any other functions, and when in google sheets I also use regexextract() and regexreplace() when needed.
for example the json your looking for is here: http://iconosquare.com/controller_nl.php?action=nlGetMethod&method=mediasTag&value=cricket&max_id=1145408330912313787
if you look at the top row, it tell you what the next min and max is so technically you could just extract that piece to generate your url.
Second option is to just build the query such that it autoincrements the urls. I can give you an example, but I would like to understand a little more about what you really want in the end result...
Are you just looking for the pagination urls, or are you wanting to extract the actual data from them?

Checking if a file has been edited

I want to know if there is a way to check if a file has been edited. I looked for methods that can make it for me on Google Apps library, but I have found nothing about it. I don't know if I searched wrong.
Basically, I need to take a file, take a measurable data (something like size) of this file and store on a variable. Then, I need to take that measurable data again, store on another variable, and compare if there was a change. I need a boolean return.
Anyone?
You could do the following (pseudo with links to documentation):
Get the file you want to check using the DocList Class.
Get the ID of that File once you have it using File.getID()
Get the last edit timestamp using File.getLastUpdated()
Store this value in a Spreadsheet, or maybe Script or User Properties.
When you want to check to see if the File was updated, simply File.getFileById()
Repeat step 3.
Then compare the two last-edited timestamps with an operator like !=, or do more complex comparisons on the Dates if you want.
Depending on the result of step 7, return true or false.
Google's documentation is great, for all their services. You just need to read it a bit to understand what kind of power you have through scripting. Hopefully my pseudo-method helps in solving your problem!
Look at the file update date: https://developers.google.com/apps-script/reference/drive/file#getLastUpdated() and for storing data look up the storing data section in the apps script help page.
You could also use the GAT General Audit Tool http://goo.gl/hzZ2yf... which reports when files were edited , viewed and much more.

Why does my code produce a different result on occasion in apps-script?

I have a very strange problem. I load my app, switch to the correct tab and then press the button I need to press. This runs a function and when I first load the page it may only provide part of the correct result. However if I wait a few seconds it produces the correct result in full. Any ideas why this might be happening?
Additional Information
The button simply checks through a list of objects returned via ScriptDB. Objects that are valid are displayed and objects that are in-valid are not. If the object appears again in updates the text to display how many have been found in the list (eg: the label would change from "Object A" to "Object A (2)").
It seems to me like it doesn't have the rest of the list somehow as it doesn't always stop at the same object. It's Very strange and not something I've experienced before. The other features of my app using ScriptDB work completely regardless of how quickly I use them.
I've figured it out now. I somehow had some erroneous data in the database which was returning a null field. I can only assume that this was from a import that I did last week from a spreadsheet.
This was copied from my comment to show that it has been resolved.

Google script DocsList service query string not working

I'm making a little script to automatically organize some autogenerated spreadsheets. The goal is to archive the spreadsheets in a directory based on their name (all of them start with the same name but end in a pattern I'm using to organize them). The problem I have is with the function:
lstFile = DocsList.find('type:spreadsheet title:"PROG_GRAL_CENTRE"');
The function doesn't have the query options specified in the docs, but I'm using it on another script and is working fine! I've also tried putting only:
lstFile = DocsList.find('PROG_GRAL_CENTRE');
which should find 200 documents, but none is found! Actually, if I type PROG_GRAL_CENTRE into the search box of my google Drive, all the documents are found, so I don't know what's wrong with my search filter.
Any thoughts?
The method find(query) looks for a string in file content, not only on file name... so even it it worked normally (meaning without the issue you mentioned) I'm not sure it would be a good solution for your use case since there would be a risk that some filename could be found inside another doc with another name (as a reference for example...).
Why don't you try getting all filenames in an array and search into this array instead ?
This can be done very easily and would bring an elegant solution to your problem wouldn't it ?
I'm working on this very same type of script right now ;-) here is the part that gets my files (just an example if ever you are interested):
var doclist=DocsList.getRootFolder().getFilesByType("document",0,2000);
var names = new Array();
for (nn=0;nn<doclist.length;++nn){
if(doclist[nn].getName().match("IMPRESSION_")=="IMPRESSION_"){
names.push([doclist[nn].getName(),doclist[nn].getId()]);
}
}
after that I sort the array the way I want and show the result in a list UI.