I'm trying to change the score from Patch editor, but when I use the Patches.Get(data)value, always get an error.
[Spark AR editor] (http://prntscr.com/p9b77g)
Still getting this error
JavaScript error: Exception in native code while calling a function: Trying to get signal to Script with name (text). Please make sure to define a ToScript patch with that name in the patch editor
My code script.js opened using Visual studio code.
// Load in the patches module
const Patches = require('Patches');
// Get the 'myText' string from the Patch Editor
const myString = Patches.getStringValue('text');
It should be fine since I've tried the exact name, but I'm still getting that error.
Please make sure to define a ToScript patch with that name in the patch editor
This makes it seem like you don't have a patch called 'text'. For this to work you'll need to select your script in assets, in the 'To Script'-section click the plus icon, select text, rename that from 'EditorToScriptVar(x)' to 'text' and then click the arrow to add it to your patch editor.
I ran into a similar problem once I added more definitions added. Even though the ToScript patch was already defined, the script failed to find it.
To solve this, I delete the producer patch and created a new one. The error should go away and the simulator should resume. Connect your wires and it should continue to work.
I will be following this thread for a few days.
Related
I have done a microsoft tutorial called Web API with Javascript
I now have a UI made with Javascript and HTML which looks like this:
How do I use the UI? I keep getting a Reference Error. Is there a specific syntax I am supposed to follow when I add and edit something via APIs?
In the future, please copy and paste error messages into your question. I would normally copy and paste the error message in my answer, but I don't want to type it all out :)
The errors (red) mean that you're trying to use JavaScript that is not defined yet. The warnings (yellow) are the reason why.
The second warning says that it could not load the JavaScript. That explains the errors. The first warning might be the reason why. It's saying that the MIME type is empty, when it should be application/javascript.
But you said in the comments that the site.js file is empty when you try to access it directly. Did you save all the JavaScript in step 4 of that tutorial to site.js?
And what are you using as a web server? IIS Express?
I created a drag able component that what it does, is to require a certain module using RequireJS, and then executing this module. When I try to drag and use this component on CQ5, it fails to load, but on CQ6 it works fine!
edit1: CQ5 refers to localhost:4502/cf#/content/somePage.html url whereas CQ6 refers to
localhost:4502/editor.html/content/somePage.html
edit2: I tried to use more simpler component the depends on jQuery,
Backbone and underscore. It failed to execute because of binding
issue. I am trying to find now where CQ5 client code corrupting it.
Any help with that will be helpful!
One thing I saw, is that if I am adding the forceChannel query param, it loads the component, but fails to load the parsys fields. It also show the following error multiple time in the console:
Uncaught TypeError: Cannot read property 'edit' of undefined
It happens when it try to execute the following expression:
CQ.WCM.edit
Does anyone familiar with that issue? Or maybe show me where specifically might be the problem.
Thanks :)
I have run into an issue that I believe is rooted in the implementation of anchor tags in Rhino. Although I am utilizing env.js, I suspect perhaps I am not configuring something correctly.
In particular, my issue occurs while I am attempting to write unit tests against code written for an angularjs application. When I include angular.js (versions 1.2.1 to present), I get the following error:
TypeError: Cannot call method "charAt" of undefined
I am convinced the error is the result of this call to urlParsingNode.pathname since a console.log call reveals that the pathname object is undefined.
I traced the instantiation of the urlParsingNode to this line where we see that it is the result of a call to document.createElement("a"); Further down, we see that they set the href attribute in this line in hopes that the created anchor tag will utilize the browser to correctly parse the URL.
I have to believe I'm not the first to attempt JS unit testing for angular via Rhino, but thus far I've not successfully Googled myself to a solution. Any tips will be greatly appreciated.
Found it and fixed it. The pathname getter/setter simply was undefined for HTMLAnchorElement in env.js.
I submitted a pull request, but unfortunately the project looks all but abandoned. I also couldn't figure out how to build it out to a single file. It appears perhaps someone has taken it upon themselves to break it apart into require.js modules. Not a battle worth fighting for my use case.
So for anyone else who hits this issue, I have the code you need below. It belongs in the HTMLAnchorElement.prototype. In my copy of env.js 1.2, this prototype begins on line 8075. I added the following at line 8118.
get pathname() {
var uri = Envjs.urlsplit(this.href);
return uri.path;
},
set pathname(val) {
var uri = Envjs.urlsplit(this.href);
uri.path = val
this.href(uri.urlunsplit(uri));
},
FYI, my particular issue is resolved with this pull request.
I'm trying to code an extension to Firefox for the first time and I have a problem with the prefmanager.
var prefManager = Components.classes["#mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var updateintervall = prefManager.getCharPref("extensions.traffic.updateintervall");
After the second line of Javascript code my extension seems to stop working. The following codelines won't be excecuted anymore... What am I doing wrong?
The nsIPref* API expects preferences to already exist when using the get*() functions. When trying to get a preference that does not and exception will be thrown.
Also, the API may throw if you try to read e.g. an existing numerical preference as a string.
You can try/catch exceptions of course.
You might want to add default preferences to your XUL-based add-on, to not having to try/catch for non-existing prefs.
SDK users should have a look at the simple-prefs and/or preferences/service APIs.
Aside: These days you'll want to use the cached Services.prefs to access nsIPref*.
I'm trying to get MonkeyTalk working with Javascript. I'm automating some tests with iOS. When I run the .MT version, the test runs fine. But, the Javascript version errors with this.
ERROR sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function uISearchBarTextField. (RADialerDirectory.js#8) in RADialerDirectory.js at line number 8
The export javascript code shows this:
this.app.uISearchBarTextField().tap();
Anyone know how to get around this error? I'm just trying to use the Javascript version of the script to loop and later grab external data to iterate through.
I had the same problem for "UIAleartView". There are three ways to get it work. this happen because MonkeyTalkAPI.js file doesn't contain an entry for "uISearchBarTextField"
Use more generic type(Input) like above answer.
Set accessibilityLabel property of that component and use it as a monkeyID like here: MonkeyTalk : Verify custom UITableViewCell Label text without select the cell
A little hack to MonkeyTalkAPI.js class. find the word for "Input" which is more generic to your "uISearchBarTextField" and get a copy of it paste it again in that file and edit replaceing "Input" with "uISearchBarTextField" save it and run. if you did it carefully it works.
Happy Testting