Debugging caja issues in google apps script [Google issue 2325] - google-apps-script

I have a script that worked fine last week, but no longer works today.
I have tried to reproduce the problem in a simple example to share here but can't reproduce my problem in smaller scripts.
The script creates a html interface (using HtmlService.createTemplateFromFile) and contains an OL to which the li items are added using javascript on the client side (from an array.)
The li items are made selecteable using jquery's $("olid").selectable() ;
When I run this script the chrome console says
Domado: HTMLOListElement is not tamed; its specific properties/methods will not be available on <ol>. es53-taming-frame.opt.js:409
Domado: HTMLLIElement is not tamed; its specific properties/methods will not be available on <li>.
When I try to click the li items they are not selected. Instead I get the following error in the javascript console:
Cannot read property nodeType_v___ of undefined 2462517803-maestro_htmlapp_bin_maestro_htmlapp.js:39
lk 2462517803-maestro_htmlapp_bin_maestro_htmlapp.js:39
applyFunction es53-taming-frame.opt.js:1696
(anonymous function) es53-taming-frame.opt.js:1522
fn.i___ es53-taming-frame.opt.js:96
applyFeralFunction es53-taming-frame.opt.js:1507
applyFeralFunction es53-taming-frame.opt.js:1535
fn.i___ es53-taming-frame.opt.js:96
t$_var es53-taming-frame.opt.js:1571
Object.m___ es53-taming-frame.opt.js:404
plugin_dispatchEvent es53-taming-frame.opt.js:1472
fn.i___ es53-taming-frame.opt.js:96
wrapper
How can I start debugging this? Can I provide the project id to someone from google to see what's going on?

Hopefully someone will come along and explain this issue. Until then you could go at google caja playground (http://caja.appspot.com/) and see if your code works with the latest version of caja. I beleive that the gas version of caja is about 3 weeks behind from the latest.

The problem can now be worked around by using setSandboxMode(HtmlService.SandboxMode.IFRAME);
and as such disabling caja on your project.

Related

Selenium (Chrome webdriver.exe 105) confusing By.NAME, By.CLASS_NAME with By.CSS_SELECTOR

I am trying to authenticate with my Google account using Selenium. It's frustrating because I've done this before with Selenium, but none of the selectable elements are working properly.
The driver.page_source is slightly different from what Chrome renders in the dev tools' element inspector
The versions of the webdriver.exe and Chrome are the same
I'm running Python 3.8 on Windows 10
I used pip install selenium as the installation method.
Error when I run my script: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"#password > div.aCsJod.oJeWuf"}. In another case, I include the name="password" element in tripe quotes; yet, I still get the error, which states the method is "css selector", and it should be "name".
Attempts that result in the same error:
web_driver.find_element(By.NAME, value='''password''').send_keys('''sklksdflsjdf''')
web_driver.find_element(By.CLASS_NAME, value='''whsOnd zHQkBf''').send_keys('''sklksdflsjdf''')
web_driver.find_element(By.CSS_SELECTOR, value='''#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input''').send_keys('''sklksdflsjdf''')
web_driver.find_element(By.XPATH, value='''//*[#id="password"]/div[1]/div/div[1]/input''').send_keys('''sklksdflsjdf''') (note: the error is the same but this does say "xpath" instead of "css selector", but the xpath is copied and pasted from Chrome dev tools)
Replaced the By object with by="class" or by="name", etc., which all result in the same error
If you have any questions, do not hesitate to ask in a comment. Otherwise, please help me with your ideas on how to get selenium to cooperate with the elements which I can clearly see in the driver.page_source.
Thank you!

SitesApp.getActivePage() always return landing page

I use the following function:
function doGet(e) {
Logger.log( SitesApp.getActivePage().getName())
}
It always returns the name of the home page
This seems to be an issue with Google currently. All Google Sites are facing this issue. Please submit a bug report, and cross your fingers it'll be solved soon.
Here is an existent bug report of this issue. Please +1 it to give it more attention.
There is an older discussion about this issue here Apps Script .getActivePage() only returning "home" page
which suggests the problem can be related to using setHtmlContent() when the embedded html gets modified. There has been a recent problem with htmlbox on Google Sites for which a fix is in the process of rolling out which may have some bearing on this issue
Hi I have the same issue. My script worked on Old Google Site, but it doesn't work anymore on a new Google Site.
And the issue in this code:
var pageUrl = SitesApp.getActivePage().getUrl();
My question is almost the same: How to get URL of the current page on the New Google Site with GAS?
google.script.url.getLocation
google.script.url.getLocation(function(location) {
console.log("locations:----------------------------------------");
console.log(location);
console.log(location.parameters);
console.log(location.hash);
console.log("----------------------------------------");
});
The code above gives the next output:

Why Twitter Feed isn't loading into my Website?

I am creating a Website using HTML5 and CSS3 myself. I am using jquery.tweet.js javascript file for showing my twitter feed into my website. And, I added below jQuery code into my body element:
<script>
jQuery(document).ready(function($) {
$('#latest-tweets').tweet({
username: 'sumonbdinfo',
count:1,
loading_text: "loading tweets..."
});
});
</script>
But, in my website is only now showing "loading tweets..." text, not showing my Twitter Feeds anymore.
Also, I added the jquery.tweet.js file into my head element and added jquery into my head element. But, still it's not showing on my website.
Should I put the above code into my head element of my website or I just added it in right place?
I pasted below the jquery.tweet.js file what I'm using for showing tweets on my website.
(function(a){a.fn.tweet=function(c){var n=a.extend({username:null,list:null,favorites:false,query:null,avatar_size:null,count:3,fetch:null,page:1,retweets:true,intro_text:null,outro_text:null,join_text:null,auto_join_text_default:"i said,",auto_join_text_ed:"i",auto_join_text_ing:"i am",auto_join_text_reply:"i replied to",auto_join_text_url:"i was looking at",loading_text:null,refresh_interval:null,twitter_url:"twitter.com",twitter_api_url:"api.twitter.com",twitter_search_url:"search.twitter.com",template:"{avatar}{time}{join}{text}",comparator:function(p,o){return o.tweet_time-p.tweet_time},filter:function(o){return true}},c);var b=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi;function l(q,r){if(typeof q==="string"){var o=q;for(var p in r){var s=r[p];o=o.replace(new RegExp("{"+p+"}","g"),s===null?"":s)}return o}else{return q(r)}}a.extend({tweet:{t:l}});function f(p,o){return function(){var q=[];this.each(function(){q.push(this.replace(p,o))});return a(q)}}function k(o){return o.replace(/</g,"<").replace(/>/g,"^>")}a.fn.extend({linkUser:f(/(^|[\W])#(\w+)/gi,'$1#$2'),linkHash:f(/(?:^| )[\#]+([\w\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0600-\u06ff]+)/gi,' #$1'),capAwesome:f(/\b(awesome)\b/gi,'<span class="awesome">$1</span>'),capEpic:f(/\b(epic)\b/gi,'<span class="epic">$1</span>'),makeHeart:f(/(<)+[3]/gi,"<tt class='heart'>♥</tt>")});function e(p,o){return p.replace(b,function(s){var r=(/^[a-z]+:/i).test(s)?s:"http://"+s;var u=s;for(var t=0;t<o.length;++t){var q=o[t];if(q.url==r&&q.expanded_url){r=q.expanded_url;u=q.display_url;break}}return''+k(u)+""})}function j(o){return Date.parse(o.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i,"$1,$2$4$3"))}function h(o){var q=(arguments.length>1)?arguments[1]:new Date();var s=parseInt((q.getTime()-o)/1000,10);var p="";if(s<1){p="just now"}else{if(s<60){p=s+" seconds ago"}else{if(s<120){p="a minute ago"}else{if(s<(45*60)){p=(parseInt(s/60,10)).toString()+" minutes ago"}else{if(s<(2*60*60)){p="an hour ago"}else{if(s<(24*60*60)){p=""+(parseInt(s/3600,10)).toString()+" hours ago"}else{if(s<(48*60*60)){p="a day ago"}else{p=(parseInt(s/86400,10)).toString()+" days ago"}}}}}}}return"about "+p}function g(o){if(o.match(/^(#([A-Za-z0-9-_]+)) .*/i)){return n.auto_join_text_reply}else{if(o.match(b)){return n.auto_join_text_url}else{if(o.match(/^((\w+ed)|just) .*/im)){return n.auto_join_text_ed}else{if(o.match(/^(\w*ing) .*/i)){return n.auto_join_text_ing}else{return n.auto_join_text_default}}}}}function d(){var p=("https:"==document.location.protocol?"https:":"http:");var o=(n.fetch===null)?n.count:n.fetch;var r="&include_entities=1&callback=?";if(n.list){return p+"//"+n.twitter_api_url+"/1/"+n.username[0]+"/lists/"+n.list+"/statuses.json?page="+n.page+"&per_page="+o+r}else{if(n.favorites){return p+"//"+n.twitter_api_url+"/favorites/"+n.username[0]+".json?page="+n.page+"&count="+o+r}else{if(n.query===null&&n.username.length==1){return p+"//"+n.twitter_api_url+"/1/statuses/user_timeline.json?screen_name="+n.username[0]+"&count="+o+(n.retweets?"&include_rts=1":"")+"&page="+n.page+r}else{var q=(n.query||"from:"+n.username.join(" OR from:"));return p+"//"+n.twitter_search_url+"/search.json?&q="+encodeURIComponent(q)+"&rpp="+o+"&page="+n.page+r}}}}function m(o,p){if(p){return("user" in o)?o.user.profile_image_url_https:m(o,false).replace(/^http:\/\/[a-z0-9]{1,3}\.twimg\.com\//,"https://s3.amazonaws.com/twitter_production/")}else{return o.profile_image_url||o.user.profile_image_url}}function i(p){var q={};q.item=p;q.source=p.source;q.screen_name=p.from_user||p.user.screen_name;q.avatar_size=n.avatar_size;q.avatar_url=m(p,(document.location.protocol==="https:"));q.retweet=typeof(p.retweeted_status)!="undefined";q.tweet_time=j(p.created_at);q.join_text=n.join_text=="auto"?g(p.text):n.join_text;q.tweet_id=p.id_str;q.twitter_base="http://"+n.twitter_url+"/";q.user_url=q.twitter_base+q.screen_name;q.tweet_url=q.user_url+"/status/"+q.tweet_id;q.reply_url=q.twitter_base+"intent/tweet?in_reply_to="+q.tweet_id;q.retweet_url=q.twitter_base+"intent/retweet?tweet_id="+q.tweet_id;q.favorite_url=q.twitter_base+"intent/favorite?tweet_id="+q.tweet_id;q.retweeted_screen_name=q.retweet&&p.retweeted_status.user.screen_name;q.tweet_relative_time=h(q.tweet_time);q.entities=p.entities?(p.entities.urls||[]).concat(p.entities.media||[]):[];q.tweet_raw_text=q.retweet?("RT #"+q.retweeted_screen_name+" "+p.retweeted_status.text):p.text;q.tweet_text=a([e(q.tweet_raw_text,q.entities)]).linkUser().linkHash()[0];q.tweet_text_fancy=a([q.tweet_text]).makeHeart().capAwesome().capEpic()[0];q.user=l('<a class="tweet_user" href="{user_url}">{screen_name}</a>',q);q.join=n.join_text?l(' <span class="tweet_join">{join_text}</span> ',q):" ";q.avatar=q.avatar_size?l('<a class="tweet_avatar" href="{user_url}"><img src="{avatar_url}" height="{avatar_size}" width="{avatar_size}" alt="{screen_name}\'s avatar" title="{screen_name}\'s avatar" border="0"/></a>',q):"";q.time=l('<span class="tweet_time">{tweet_relative_time}</span>',q);q.text=l('<span class="tweet_text">{tweet_text_fancy}</span>',q);q.reply_action=l('<a class="tweet_action tweet_reply" href="{reply_url}">reply</a>',q);q.retweet_action=l('<a class="tweet_action tweet_retweet" href="{retweet_url}">retweet</a>',q);q.favorite_action=l('<a class="tweet_action tweet_favorite" href="{favorite_url}">favorite</a>',q);return q}return this.each(function(p,s){var r=a('<ul class="tweet_list">');var q='<p class="tweet_intro">'+n.intro_text+"</p>";var o='<p class="tweet_outro">'+n.outro_text+"</p>";var t=a('<p class="loading">'+n.loading_text+"</p>");if(n.username&&typeof(n.username)=="string"){n.username=[n.username]}a(s).bind("tweet:load",function(){if(n.loading_text){a(s).empty().append(t)}a.getJSON(d(),function(u){a(s).empty().append(r);if(n.intro_text){r.before(q)}r.empty();var v=a.map(u.results||u,i);v=a.grep(v,n.filter).sort(n.comparator).slice(0,n.count);r.append(a.map(v,function(w){return"<li>"+l(n.template,w)+"</li>"}).join("")).children("li:first").addClass("tweet_first").end().children("li:odd").addClass("tweet_even").end().children("li:even").addClass("tweet_odd");if(n.outro_text){r.after(o)}a(s).trigger("loaded").trigger((v.length===0?"empty":"full"));if(n.refresh_interval){window.setTimeout(function(){a(s).trigger("tweet:load")},1000*n.refresh_interval)}})}).trigger("tweet:load")})}})(jQuery);
So, please help me anyone how may I fix this issue? It would be really very helpful for me man. Waiting for anyone answers here!
You cannot continue using the seaofclouds tweet.js and expect to pull tweets like you used to last month. The cause of this was that twitter 1.0 api was recently replaced with 1.1 - https://dev.twitter.com/blog/api-v1-is-retired. The author of jquery.tweet.js talks about the API changes and the state of his plugin here: https://github.com/seaofclouds/tweet/#important-note-about-twitters-api-changes-in-2013 and a separate discussion can be found here: https://github.com/seaofclouds/tweet/issues/264 with an alternative (which works) - https://github.com/StanScates/Tweet.js-Mod.
Tweet.js-Mod is a modified version of the original jquery.tweet.js and uses a php script to access twitter's API version 1.1.
Installation instructions can be found here: https://github.com/StanScates/Tweet.js-Mod#how-to-use
Looks like this is a major change to how Twitter is handling requests, version 1.0 of their API allowed unauthenticated requests, but now that has changed where Twitter is pushing developers to use their embedded timelines, which requires authentication.
Discussion of Twitter transition from v1.0 to v1.1
Let me warn you about using the https://github.com/StanScates/Tweet.js-Mod#how-to-use
It works perfectly but some of your clients where the website runs may have this ERROR
ERROR:
XMLHttpRequest cannot load http://api.getmytweets.co.uk/?screenname=philipbeel&limit=5&undefined=undefined. Origin http://plugins.theodin.co.uk is not allowed by Access-Control-Allow-Origin.
Also this method does not use the Oauth method and your security can be compromised. Twitter highly discourages the uses of client side authentication.
Your solution has 2 parts
Use a php based Oauth Script to retrieve you tweets in JSON format
Using Jquery format the JSON and show it into your website
SIMPLE AND SECURE.
HERE IS A COMPLETE TUTORIAL
http://www.webdevdoor.com/javascript-ajax/custom-twitter-feed-integration-jquery/

Why always getting Nullpointer when doubleclicking link on XPage?

I have a difficult problem: I always get a Nullpointer exception on my webpace, when I
rapidly click on the same link. Or when I reload the page rapidly.
This is the error I get:
java.lang.NullPointerException
com.ibm.xsp.webapp.FacesServlet.acquireSyncToken(FacesServlet.java:285)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:161)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:653)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:476)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Question: Can someone explain in detail what this acquireSyncToken does? Maybe then I can find the bug...
In my XPages I use
sessionScope.get(key) // same with applicationScope
sessionScope.put(key, value) // same with applicationScope
a LOT ;)
I tried very much, e.g. to wrap my lookups within
synchronize(applicationScope){
// lookups and so on...
}
and stuff like that, but that only made it worse, so I removed the synchronize-stuff...
Environment:
Domino Server 8.5.3 FP1
XPages
testing on modern Browsers like FF, Chrome
MacOS / Win7
Architecture:
I have one BIG xPage, where I basically add some CustomControls and due to the current URL embed another XPage.
Inside the CustomControls and XPages I have more Custom Controls and I added some Views as Datasources and did the wildest things with "repeat controls" and SSJS inside Computed Fields.
The heavy-weight DB-Lookups are cached in the applicationScope.
For more Info, please ask!
Thanks in advance!
This is a known issue. IBM advises to downgrade from FP1 or FP2 to 8.5.3 or UP1.
See Dojo xhrGet with sync:false issue with xe:viewJsonLegacyService and Domino 8.5.3 SP1 or http://www-01.ibm.com/support/docview.wss?uid=swg1LO71603

Widget object is undefined in Dashcode

I'm using Dashcode for a mobile Safari web application and from the documentation (https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Dashcode_UserGuide/Contents/Resources/en.lproj/MakingaWidgetwithDashcode/MakingaWidgetwithDashcode.html), it appears that I should be able to access an object called "widget".
However, when I tried, I get the error message saying that widget is undefined. I've also tried "window.widget" and it gives me the same error.
What's going on?
I'd like to make a text in my application a clickable link to open a URL using openURL (like the example given at the URL above).
You use widget.xxx to access things inside and outside you widget.
So to access curl and the Mac and get some data from Yahoo you do as follows
var yahoorate = widget.system("/usr/bin/curl 'http://download.finance.yahoo.com/d/quotes.csv?s=EUR" + interim0 + "=X&f=l1'", null).outputString;
to get a preference key value, stored in the widgets plist when you install on a mac
globalPreferenceValue = widget.preferenceForKey(null, "your-key");
i think in the question ask (below) we are checking to see if we are in a widget and then preparing a transition to the back of the widget.
if (window.widget) {
widget.prepareForTransition("ToBack");
}
this is how i set a preference so it is stored between system reboots (you use a get preference to retrieve them)
widget.setPreferenceForKey(2,"ratePrecision");
and this is how you create a link to open in a browser not the widget
<a onclick=" + "widget.openURL('http://www.wf.com/private/?ID=636');" + "><span id=company-info>click here</span></a>
These are all rel working examples from widgets i have built. Hope it helps. I found it useful to download widgets that performed similar functions to ones i wanted and then as well as installing them opening them as projects, you can import, and then you can see all the code.
Ok, this worked...hope it will help someone else...
window.location = "http://www.apple.com";