TwitterWidget within SilverStripe - javascript

I am trying to integrate TwitterWidget within SilverStripe.
That's the plugin I am trying to use:
https://twitter.com/about/resources/widgets/widget_profile
If I put this code in a simple *.html file the widget works. Unfortunately I get an error if I try to use it in a *.ss file.
I downloaded the source code to find out where the error occurs. After several hours I found something pretty confusing:
That's the piece of code where the error occurs:
document.write('<div class="twtr-widget" id="'+this.id+'"></div>')
FireBug:
uncaught exception: [Exception... "An attempt was made to use an object that is not, or is no longer, usable" code: "11" nsresult: "0x8053000b (NS_ERROR_DOM_INVALID_STATE_ERR)" location: "http://www.domain.com/mysite/javascript/widget.js?m=1321187964 Line: 257"]
LeftAn...8532904 (Zeile 883)
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
After a few refreshes sometimes FireBug reports:
An attempt was made to use an object that is not, or is no longer, usable
[Bei diesem Fehler anhalten] document.write('<div class="twtr-widget" id="'+this.id+'"></div>')
Google Chrome JavaScript Debugger:
Uncaught TypeError: Object #<Document> has no method 'write' //widget.js:257
TWTR.Widget.init //widget.js:257
TWTR.Widget //widget.js:211
(anonymous function) //?stage=Stage&flush=1:117
f.extend._Deferred.e.resolveWith //jquery-1.6.4.min.js:2
e.extend.ready //jquery-1.6.4.min.js:2
c.addEventListener.C //jquery-1.6.4.min.js:2

This is a little incomplete to debug, but why not use one of the readily available widgets? Like http://www.silverstripe.org/twitter-widget-pack-widget/

Related

How to trigger `undefined is not a function` in modern broswers?

I remember getting this error a lot a while before. Today I wanted to show it to a friend unfamiliar with Javascript. Chrome and Safari instead gave me something like:
> const o = {};
< undefined
> o.doge()
< TypeError: o.doge is not a function (In 'o.doge()',' 'o.doge' is undefined)
Chrome and Firefox seem to be user-friendly as well.
How can I get an original error, without this helpful message?
You will never get that error in a modern browser; the error comes from js engine itself not the browser; and if there are no others other than that Type Error, modern engines will return a more developer friendly error by applying a (similar) /(w+)/ regex on what ever typed before () and placing it in the error message check out:
v8 (chrome) message templates that will make the error string (line 51, 52):
T(CalledNonCallable, "% is not a function")
and SpiderMoneky (mozilla) message templates (at line 51, 54):
MSG_DEF(JSMSG_NOT_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a function")
non-callable test case in v8 and a SpiderMokney test case .
So the only way to a undefined is not a function error message in a modern browser is doing undefined() :)
undefined()
you can just try to find and download an older version of the browser which logged the original error. (if that version is still publicly available).

Issue with the AutoDesk Forge Viewer API

While getting the document to load, I am getting this error
wgs.js:21467 Uncaught TypeError: Cannot read property 'numGeoms' of undefined
at d.RenderModel.initialize (wgs.js:21467)
at a.onModelRootLoadDone (viewer3D.min.js:4484)
at Worker.p (viewer3D.min.js:4432)
RenderModel.initialize # wgs.js:21467
a.onModelRootLoadDone # viewer3D.min.js:4484
p # viewer3D.min.js:4432
viewer3D.min.js:4446 Uncaught TypeError: Cannot read property
'meshToGeometry' of undefined
at a.processReceivedMesh (viewer3D.min.js:4446)
at a.processReceivedMesh2D (viewer3D.min.js:4465)
at Worker.p (viewer3D.min.js:4432)
a.processReceivedMesh # viewer3D.min.js:4446
a.processReceivedMesh2D # viewer3D.min.js:4465
p # viewer3D.min.js:4432
validator.html:1 [.Offscreen-For-WebGL-0x55a2800ad520]GL ERROR:GL_INVALID_FRAMEBUFFER_OPERATION : glClear: framebuffer incomplete (check) 59 viewer3D.min.js:4446
Uncaught TypeError: Cannot read property 'meshToGeometry' of undefined
at a.processReceivedMesh (viewer3D.min.js:4446)
at a.processReceivedMesh2D (viewer3D.min.js:4465)
at Worker.p (viewer3D.min.js:4432)
Can anyone please help ?
This problem may be caused by the use of an outdated version of the viewer.
Currently the Viewer is on Version 3.3 I will suggest doing the migration to solve your problem and also take advantage of all the new functionality.
Here is a list of the changelogs
https://developer.autodesk.com/en/docs/viewer/v2/overview/changelog/
And here the blog post about the newer version
https://forge.autodesk.com/blog/viewer-release-notes-v33

From live site to a localhost Javascript Errors

I'm quite new to Javascript, I copied my live site to localhost so I could work on it without having to touch the live site. The local site looks just like the live site, but doesn't work like it at all.
The Fancybox box popups aren't working now, and these are the errors I'm getting on my console log:
index.php?option=com_users&view=custom&layout=default_step4:107 Uncaught TypeError: undefined is not a functionindex.php?option=com_users&view=custom&layout=default_step4:107 (anonymous function)jquery.min.js:2 p.Callbacks.kjquery.min.js:2 p.Callbacks.l.fireWithjquery.min.js:2 p.extend.readyjquery.min.js:2 D
index.php?option=com_users&view=custom&layout=default_step4:399 Uncaught TypeError: undefined is not a functionindex.php?option=com_users&view=custom&layout=default_step4:399 (anonymous function)jquery.min.js:2 v.Callbacks.ljquery.min.js:2 v.Callbacks.c.fireWithjquery.min.js:2 v.extend.readyjquery.min.js:2 A
all.js:61 Invalid App Id: Must be a number or numeric string representing the application id.
all.js:61 FB.getLoginStatus() called before calling FB.init().
kallyas_script.js:32 Uncaught TypeError: undefined is not a functionkallyas_script.js:32 (anonymous function)jquery.min.js:2 v.event.dispatchjquery.min.js:2 v.event.add.o.handle.u
index.php?option=com_users&view=custom&layout=default_step4:336 Uncaught TypeError: undefined is not a functionindex.php?option=com_users&view=custom&layout=default_step4:336 reportindex.php?option=com_users&view=custom&layout=default_step4:480 onchange

Vline.js is giving cryptic error message

I am trying the room example of vline and getting a cryptic error message which is am not able to figure out.
Please see the exception stack below.
vline.js?t=1231:732
Local stream: W91AhWvMK6ohUoNi meeting:108
User came online, starting mediasession with: bakbak:biplav.saraf#gmail.com meeting:123
[140623 12:31:36.22] [vline.person] Cannot read property 'log' of undefined
TypeError: Cannot read property 'log' of undefined
at Qh.f (https://static.vline.com/vline.js?t=1231:195:297)
at oh (https://static.vline.com/vline.js?t=1231:187:418)
at W.n.dispatchEvent (https://static.vline.com/vline.js?t=1231:186:432)
at W.n.vj (https://static.vline.com/vline.js?t=1231:194:348)
at W.n.dispatchEvent (https://static.vline.com/vline.js?t=1231:193:416)
at Kl (https://static.vline.com/vline.js?t=1231:366:162)
at W.n.start (https://static.vline.com/vline.js?t=1231:358:142)
at bm.n.Oe (https://static.vline.com/vline.js?t=1231:374:279)
at startPeerMediaSession (http://localhost:5000/schedule/meeting:93:26)
at bm.<anonymous> (http://localhost:5000/schedule/meeting:124:13)
vline.js?t=1231:132
Be vline.js?t=1231:132
ze.Vs vline.js?t=1231:132
n.log vline.js?t=1231:127
Qh.f vline.js?t=1231:195
oh vline.js?t=1231:187
n.dispatchEvent vline.js?t=1231:186
n.vj vline.js?t=1231:194
n.dispatchEvent vline.js?t=1231:193
Nh vline.js?t=1231:194
n.xn vline.js?t=1231:384
oh vline.js?t=1231:187
n.dispatchEvent vline.js?t=1231:186
n.vj vline.js?t=1231:194
n.vj vline.js?t=1231:201
n.dispatchEvent vline.js?t=1231:193
Nh vline.js?t=1231:194
S vline.js?t=1231:207
ci vline.js?t=1231:206
mi vline.js?t=1231:209
n.kr vline.js?t=1231:439
Fo vline.js?t=1231:471
Go.send vline.js?t=1231:471
(anonymous function) vline.js?t=1231:488
$a.forEach.d vline.js?t=1231:75
sp vline.js?t=1231:488
(anonymous function) vline.js?t=1231:500
xh vline.js?t=1231:189
Is it possible to get unminified version of this file?
On further debugging i figured out that i was using a global variable which was conflicting with vline.js.

Uncaught TypeError: Cannot read property 'ui' of undefined

There is a weird problem with my server. I have a web application (vtiger CRM) locally and it works fine, it loads the neccessary data as it should (in the Email Manager module). The exact same copy is hosted on the server, and it gives the following:
Uncaught TypeError: Cannot read property 'ui' of undefined
MailManager._mainui_callback
(anonymous function)
n
o.fireWith
w
d
Sometimes it just gives:
Uncaught TypeError: Cannot read property 'ui' of undefined
Has this ever happened to anyone? Could there be something different in the server php.ini file which causes this?
Your help is much appreciated, thanks!
EDIT: To give a more descriptive example I could copy and paste the actual code which is responsible for this but since the same code works locally, I am pretty sure this is a server issue. And that's the point of this question. However, this is the function which accepts a response parameter and sends it as an argument via MailManager._mainui_callback function:
function(response){
MailManager._mainui_callback(response);
progressIndicatorElement.progressIndicator({
'mode' : 'hide'
})
jQuery("#_folderprogress_").hide();
var timeOut = jQuery("#refresh_timeout").val();
if(timeOut != "" && timeOut !=0) {
setInterval(MailManager.updateMailFolders, timeOut);
}
// Update the seleted folders to highlight them.
var folderName = jQuery('#mm_selected_folder').val();
MailManager.updateSelectedFolder(folderName);
}
This is the callback function that does some stuff with the response:
_mainui_callback: function(responseJSON){
jQuery('#_mainfolderdiv_').html(responseJSON['result']['ui']);
if (!responseJSON['result']['mailbox']) {
MailManager.open_settings();
}
MailManager.triggerUI5Resize();
}
What makes me wonder is, why does this work locally and not in the server?

Categories