AppLab "readRecords()" is broken - javascript

I'm year 10 and my final project for APCS is to make a game/app and turn in the code, a video of it running, and a written response. My problem is that the entire class was taught using Code.org's AppLab and the readRecords() function is seemingly broken , I think its readRecords() because the concept version of the game doesn't use readRecords and works fine, but the current version does and nearly half of the buttons in the game don't work most of the time. Including the buttons to log in, sign up, etc.Meaning I can't even get past the welcome screen. My code isn't the issue and this is due in a few hours. s u g g e s t i o n s p l e a s e.

applab docs for readRecords
it looks like readRecords should probably still be supported
you should use your browser's javascript console/debugger to find your application's point of failure
here's some ideas for where that point of failure might be:
in your code which is using readRecords incorrectly
you have to find the bug and fix it yourself
in applab's readRecords code itself (less likely)
you have to submit a bug report to applab
find a workaround until you can implement a potential fix from applab

Because you are saying that your buttons do not work "most of the time", and the readRecords() command is asynchronous, I suspect you have a timing issue of some kind. To help determine if the problem is with the readRecords() command or with how you're using it in your project, you could put the share link to your project here, or in a message to code.org support.

Related

Is there a way to echo every line of JavaScript as it is executed?

I have two programs that should be running the same . They are not. I'd like to see where their execution diverges. Is there an option in Chrome or Firefox or Safari to log/echo every line of JavaScript as it is executed ? Or some other way to do this short of manually adding console.log every few lines? Note: the divergence is 10k or 20k maybe 100k lines deep and ideally I'd want it to print variables similar to the Chrome dev tools.
Then I can just dump the logs and find the divergence
Stepping through the code in the debugger is not a solution as it would take hours if not days to step that far.
One idea is to use a babel or uglify plugin to use the last to emit code for each line to print what it is about to do or just did.
Another idea is if there is a way to dump all of memory from js so I can compare all objects and all references. They should be the same so when I see two dumps that differ I'll have found my bug. note: JSON.stringify is not an option as I need to see all variables/objects/classes etc.
Note: I'm not looking for basic answers like "use console.log" or "step in the debugger". I appreciate the help and maybe I've overlooked something simple but I do have quite a bit of JavaScript experience.
Maybe an example would help. Imagine you got the source to an app as large as google docs. You run some processor over it that's not supposed to break anything or change anything. Except it does. You look at the changes and can't see anything wrong. All you know is when you run it it runs but a few things are subtly broken. So you put a breakpoint there and see the data is bad. But when did it go bad? You don't know the code (you just got it). It could have been 100s of thousands of lines before. You have no idea where to put breakpoints or console.logs. It could take weeks. But, given you know the code should run exactly the same if you could print all lines of execution you'd find the bug in minutes instead of days.
You can add debugger; at the begin of the function() or where you want and open the console.
When the debugger is reached it stop the execution. After that you can execute code step by step and add some watches.
It works fine with all recent browser.
Example :
function test()
{
var rand = Math.random();
debugger;
return rand;
}
test();
It is node js but it may be helpful for you. set the NODE_V8_COVERAGE environment variable to a directory, coverage data will be output to that directory when the program exits.
https://blog.npmjs.org/post/178487845610/rethinking-javascript-test-coverage

Using JS (In FF-Pentadactyl), how to get a handle to site content like media players?

Using the Firefox Web Console (which can be brought up with control shift k ) I can easily access things like flowplayers.
jwplayer().play(), for example
The console even offers autocompletion suggestions for it.
What does the console do to be in that kind of, for my lack of words and knowledge, namespace?
I tried things like
content.document.getElementsByName('flvplayer').item(0)
Using Pentadactyls JS intepreter (accessed with :js)
This does seem to give me the player handle, or at least it prints out a <html:object> which corresponds to it.
Appending a .play() to it doesn't work, though. It's not a function.
What do I need to do to emulate the Web-Consoles way of doing it?
I realize that this might be a very spoonfeedy question, so if that is not acceptable then I'd still appreciate to get pointed into directions where I could possibly discover the solution myself by reading.
I tried searching for it myself but the terms seem to be quite ambiguous and I usually get results with people talking about their own sites, with scripts running inside of that 'namespace', not from outside like I am trying to do.
(Unless I am wrong about the concepts of inside and outside here.)
Cheers~~
The following command works for me; it defines the command ypl which
plays the YouTube video on the page
command! ypl open javascript:(function()
{content.document.getElementById('movie_player').playVideo()})()
Another example: this defines the ytr command which takes an integer argument and moves the current time position of the video by that amount in seconds
command! -nargs=1 ytr open javascript:(function(){var vid =
content.document.getElementById('movie_player'); vid.seekTo(vid.getCurrentTime() +
(<args>), true)})()
I hope that helps a bit. When I wrote those a while ago I may have tried :js and if it didn't work used :open javascript:....

Eclipse is hanged on copy/paste in JavaScript files

I've been running Eclipse Helios 3.6 using the Java/CFEclipse IDEs, and finding some very strange and aggravating errors when trying to edit Javascript files. After the .js file reaches a certain size (~250 lines of code), Eclipse will randomly hang whenever I try to select, copy-paste selections, or save. Clicking after the hang starts will result in the "file edit source ... help" bar being whited out, and clicking again leads to the windows "(not responding)" message displayed in the program header. The hang then goes away after another 5-10 seconds of waiting. This is the case for all JavaScript files I try to edit, although shorter ones don't hang as long and don't bring up the "(not responding)" message.
I've thought it was a problem with the Javascript validation/autocomplete options, and have accordingly turned those off; however, the copy-paste hang problem still persists. I've also tried the Javascript IDE - same problem. Is this a problem with Eclipse Javascript handling, period? Has anyone else gotten errors like these? And if it's a fundamentally Eclipse problem, would anyone be able to suggest a better Javascript/Coldfusion editor?
EDIT: For more information, log output from the latest hang:
!ENTRY org.eclipse.wst.jsdt.ui 4 2 2010-08-18 11:25:54.699
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.wst.jsdt.ui".
!STACK 0
java.lang.NullPointerException
at org.eclipse.wst.jsdt.internal.compiler.lookup.ArrayBinding.getExactMethod(ArrayBinding.java:233)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:401)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1813)
at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:307)
at org.eclipse.wst.jsdt.internal.compiler.ast.Expression.resolve(Expression.java:477)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:191)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:337)
at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:291)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:362)
at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:859)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:527)
at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:862)
at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:647)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:581)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:574)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:509)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:150)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:135)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
!ENTRY org.eclipse.wst.jsdt.ui 4 0 2010-08-18 11:25:54.824
!MESSAGE Error in JSDT Core during AST creation
!STACK 0
java.lang.NullPointerException
at org.eclipse.wst.jsdt.internal.compiler.lookup.ArrayBinding.getExactMethod(ArrayBinding.java:233)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:401)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1813)
at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:307)
at org.eclipse.wst.jsdt.internal.compiler.ast.Expression.resolve(Expression.java:477)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.ForStatement.resolve(ForStatement.java:280)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement.resolve(IfStatement.java:191)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:337)
at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:291)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:362)
at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:859)
at org.eclipse.wst.jsdt.core.dom.JavaScriptUnitResolver.resolve(JavaScriptUnitResolver.java:527)
at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:862)
at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:647)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:581)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:574)
at org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:509)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:150)
at org.eclipse.wst.jsdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:135)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
For me the solution was disable this option...
Preferences/JavaScript/Editor/Typing{When pasting}/Update imports
Ok, I think I found a brute force solution to this. I went into windows>preferences>javascript>[all sub menus] and just unchecked as many things as I could stomach to uncheck. I did that a couple of weeks ago and it's only hung once since then (I think it was unrelated as I had to force quit after 5 minutes).
First time met as Eclipse hangs on copy/cut for JavaScript files, and https://github.com/Nodeclipse/nodeclipse-1/issues/159
Current summary:
size matters: big project can cause Eclipse JSDT to freeze (this is old issue as #andreialecu has collected https://github.com/Nodeclipse/nodeclipse-1/issues/159#issuecomment-68098716)
hammer 100% solution is to remove JsNature for that one project
more subtle is to disable only some JSDT features
Window>Preferences>JavaScript>Editor>Mark Occurrences
and maybe even Window->Preferences->General->Editors->Text Editors->Hyperlinking
recommended by JSDT maintainers (for further observation): (by #vrubezhny )
get latest JSDT version
increase available memory settings
use resource filters to hide more files in folders like build/dist/bower/vendor (by #ppartida )
And generally:
pay attention what step you have taken when working with any software.
experiment with little changes
Please add more answers here
(the first issue raised Aug 18 '10)

VS2008 javascript debugger IE8 "there is no source code available for the current location"

I have almost the same problem as this unanswered question. The only difference is I'm using VS2008, but I'm in an MVC project calling this javascript function:
function CompanyChange(compCtrl) {
alert(compCtrl.value);
debugger;
var test;
for (var i = 0; i < document.all.length; i++) {
test = document.all[i];
}
}
I hit the alert, then I get the message "there is no source code available for the current location." At which point the page becomes unresponsive and I have to manually stop the debugger just to shut it down.
I've logged into another machine and ran this exact code and it works fine, I hit the debugger and can step through. I've checked to make sure all settings in VS>Tools>Options>Debugging are identical as well as IE>Options>Advanced and they are. Both machines are Windows 7 Enterprise edition 32-bit, VS2008, IE8.
I've also tried attaching a process manually in VS, and using the 'Developer Tools' in IE which didn't work (said there already was a process attached).
I was hoping someone may have had this problem and found a work-around because I've already done a lot of searching and tried all the options I've read. Anyone else run into this?
Thank you,
Jeff
I recently answered the original question, so thought I'd post my answer here too:
The debugger cannot debug both Silverlight code and Script code at the same time, if the Silverlight debugger is selected JavaScript debugging is switched off.
To resolve this go to the Project's Properties and select "Start Options". Next check that the Silverlight checkbox is NOT ticked if you want to be able to debug JavaScript. (It is unfortunate that the UI here is not clear about this side effect.)
Even I had the same "Source code not available" msg for ie8. Actually I was having 2 different methods with same names having different parameters in 2 different pages and one of the method which I was invoking was not getting called due to the overloaded method which Ie8 doesn't detect. So I just renamed the function and it resolved the issue

What causes Google Maps javascript exceptions?

I pretty consistently get GMaps API javascript exceptions that look like the following:
Ve.k is null or not an object (FF & IE)
b.k is null or not an object (FF & IE)
a is null (FF)
a.$e is undefined (FF)
Uncaught TypeError: Cannot read property 'k' of undefined (chrome)
Often the exception occurs during an eval of some expression in javascript in the bowels of the GMaps API
Almost anything can cause one of these to pop up, displaying an overlay on the map or a mouse click event for example.
I've been scouring my code for some time looking for offending overlays, and event handlers, but so far no relationship found. I've had this happen on a naked map with no overlays or handlers active.
Certain versions of the API will not crash on certain browsers, but it's hit and miss and I still have this sinking susspicion that something in the environment is giving GMaps a hard time (eg. maybe Facebook Connect, Google Analytics, my code...)
Does anyone have a handle on what causes these?
After spending quite a bit of time rolling back operations that affected the map 1 by 1, I finally got to the line(s) that caused this problem.
First, if I removed the call to setUIToDefault() the problem went away, this was unacceptable to me both because I wanted the default UI and that's a lame way to solve the problem. So many more map operations later I came to the GWT calls:
mapWidget.setHeight()
mapWidget.setWidth().
For those not familiar with GWT these two calls will ultimately translate to the following javascript template call:
element.style['height'] = height;
where 'element' in this case is the div that contains the map and height on the RHS of the expression is something like "690px".
That was all it took to derail the maps API.
The fix? Setting the size of the map div prior to instantiating the map.
You tell me, bug in the maps api or just a major feature lack? I'm going to check w/ the maps folks.
Just the perils of using a minified, obfuscated Javascript library I am afraid. There is no discrete group of errors that result in the exceptions you are seeing, but you can be sure that they are a result of a bug in your own code. I use Google maps pretty extensively and have regularly seen these types of errors. In 100% of cases, the bug was mine.
If you post (either here or in new questions) specific examples of pages that generate these errors, we can check them out and hopefully fix them.
I would have to guess it would be your code (not to say your a bad programmer) or another library interfering. I've been using the Google MAPS API happily for about 1 year now* and never had the first exception. The only time I've ever gotten an error message was when I was adding the balloon thingy.
*The website looks like crap but it was a high school project for my county fair and I couldn't use any server side stuff.
Edit: After reading your comment I'm wondering if you included a proper DOCTYPE? Check and see if you have it.

Categories

Resources