/examples won't run 404 error on GET /skeleton/javascript/gamejs.js

130 views
Skip to first unread message

Joel Schaubert

unread,
Apr 13, 2013, 2:24:29 PM4/13/13
to gam...@googlegroups.com

On a Mac
Get gamejs by github clone
./bin/build.sh       works fine

Using python's simple web server
cd ./examples
python -m SimpleHTTPServer 8080

Using a browser (firefox for me)

http://localhost:8080/

Shows a directory listing of the example subdirectories.

Click on skeleton  subdir / link

* URL shows http://localhost:8080/skeleton/
* browser window is stuck on    Loading..... with blue pacman background gif
* python console shows something was requesting /skeleton/javascript/gamejs.js   but got a 404

Console output here

JoelS$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/ HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/public/yabble.js HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/public/gamejs.min.js HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/javascript/main.js HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/public/ajax-loader.gif HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] code 404, message File not found
1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/javascript/gamejs.js HTTP/1.1" 404 -


It makes me wonder if this line in main.js
var gamejs = require('gamejs');

is confused about using the game.min.js file and is unable to use that properly?


------HACK---------------
This problem can be resolved by copying the lib/gamejs* structure down into the javascript subdir of each example.
cd /examples/sprite/javascript
cp -r ../../../lib/* .

Now it will work.  But this can't be the right way to run it ;)

Joel

si...@nekapuzer.at

unread,
Apr 14, 2013, 2:33:20 AM4/14/13
to gam...@googlegroups.com
you have to serve the whole gamejs directory, not just examples/. checkout where `gamejs.min.js` is loaded from in
index.html.

gamejs.min.js is in the top-level folder and your webserver wasn't serving it.

simon
> --
> You received this message because you are subscribed to the Google Groups "GameJs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gamejs+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

si...@nekapuzer.at

unread,
Apr 14, 2013, 3:14:44 AM4/14/13
to gam...@googlegroups.com

i just checked the folders and i was wrong :) it's sufficient to serve /examples. i'll take another shot:

> > Console output here
> >
> > JoelS$ python -m SimpleHTTPServer 8080
> > Serving HTTP on 0.0.0.0 port 8080 ...
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET /skeleton/ HTTP/1.1"
> > 200 -
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET
> > /skeleton/public/yabble.js HTTP/1.1" 200 -
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET
> > /skeleton/public/gamejs.min.js HTTP/1.1" 200 -
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET
> > /skeleton/javascript/main.js HTTP/1.1" 200 -
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET
> > /skeleton/public/ajax-loader.gif HTTP/1.1" 200 -
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] code 404, message File
> > not found
> > 1.0.0.127.in-addr.arpa - - [13/Apr/2013 13:16:04] "GET
> > /skeleton/javascript/gamejs.js HTTP/1.1" 404 -


it's very weird that it will try to load `gamejs.js` after you already successfully loaded `gamejs.min.js`, which
should contain all of gamejs. are you sure the file is not empty or something else going wrong?

simon

Joel Schaubert

unread,
Apr 15, 2013, 4:25:35 PM4/15/13
to gam...@googlegroups.com
The generated file is not zero

-rw-r--r--   1 JoelS  staff  148653 Apr  8 13:41 gamejs.min.js

and it also  copies to

JoelS$ ls -l examples/skeleton/public/

total 336
-rw-r--r--  1 JoelS  staff    1928 Apr  6 23:26 ajax-loader.gif
-rw-r--r--  1 JoelS  staff  148653 Apr  8 13:41 gamejs.min.js
-rw-r--r--  1 JoelS  staff   15287 Apr  6 23:26 yabble.js


I do not know what should be inside the gamejs.min.js.
I can attach it.
Here is the first 20 lines

JoelS$ head -20 gamejs.min.js
/* This file has been generated by yabbler.js */\r\nrequire.define({\r\n"gamejs/display": function(require, exports, module) {\r\nvar Surface = require('../gamejs').Surface;

/**
 * @fileoverview Methods to create, access and manipulate the display Surface.
 *
 * @example
 * var display = gamejs.display.setMode([800, 600]);
 * // blit sunflower picture in top left corner of display
 * var sunflower = gamejs.image.load("images/sunflower");
 * display.blit(sunflower);
 *
 */

var CANVAS_ID = "gjs-canvas";
var LOADER_ID = "gjs-loader";
var SURFACE = null;

/**
 * Pass this flag to `gamejs.display.setMode(resolution, flags)` to disable
 * pixel smoothing; this is, for example, useful for retro-style, low resolution graphics







--
You received this message because you are subscribed to a topic in the Google Groups "GameJs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamejs/XUJhqaAu9jA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamejs+un...@googlegroups.com.
gamejs.min.js

Joel Schaubert

unread,
Apr 15, 2013, 4:38:32 PM4/15/13
to gam...@googlegroups.com
Simon,
Are there environment variables or other such things to turn up the debugging log level?



On Sun, Apr 14, 2013 at 2:14 AM, <si...@nekapuzer.at> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "GameJs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamejs/XUJhqaAu9jA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamejs+un...@googlegroups.com.

Joel Schaubert

unread,
Apr 15, 2013, 4:42:01 PM4/15/13
to gam...@googlegroups.com
Simon,
I loaded in chrome with javascript console on.

I think maybe there is a problem with gamejs.min.js   ?
Look at what chrome says about gamejs.min.js   line 1


Uncaught SyntaxError: Unexpected token ILLEGAL gamejs.min.js:1
  1. Uncaught Error loading module yabble.js:195





On Sun, Apr 14, 2013 at 2:14 AM, <si...@nekapuzer.at> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "GameJs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamejs/XUJhqaAu9jA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamejs+un...@googlegroups.com.

Joel Schaubert

unread,
Apr 15, 2013, 4:57:39 PM4/15/13
to gam...@googlegroups.com
Problem pinned down to Yabbler.js  lines 38-41


As I suspect you have already discovered from the earlier emails,
something in the build.sh process is including literal    \r\n   characters in the output.

I deleted all those by hand and IT WORKS !!!!

It works  from /examples 
and it works from /


It looks like yabbler.js might be hardcoded for DOS style carriage returns.

starting at line 37

    var newModuleCode = '/* This file has been generated by yabbler.js */';
    newModuleCode += '\r\nrequire.define({';
    newModuleCode += '\r\n"' + moduleId + '": function(require, exports, module) {';
    newModuleCode += '\r\n'+moduleCode;
    newModuleCode += '\r\n}}, [' + deps.join(', ') + ']);';
   
    writeFile(outFileObj, newModuleCode);
};
   
I think yabbler.js should not be outputting \r\n unless it knows the machine filesystem is DOS.


Joel


On Sun, Apr 14, 2013 at 2:14 AM, <si...@nekapuzer.at> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "GameJs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamejs/XUJhqaAu9jA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gamejs+un...@googlegroups.com.

si...@nekapuzer.at

unread,
Apr 16, 2013, 6:55:24 AM4/16/13
to gam...@googlegroups.com
the linefeed \r\n are okay, and mac understands that. but the issue seems to be a missing semicolon (such
problems only become visible once you compress the javascript with bin/build.sh). i'll have to run the
gamejs code through jslint and fix all missing semicolons, that should fix it.

you are using safari, i assume? thanks for digging so deep :)

simon
> You received this message because you are subscribed to the Google Groups "GameJs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gamejs+un...@googlegroups.com.

Joel Schaubert

unread,
Apr 16, 2013, 9:55:31 AM4/16/13
to gam...@googlegroups.com
Great,
glad I could help out.

I don't like Safari, I use firefox with firebug (sometimes it works for javascript)
and google chrome (always works for debugging javascript)


My debugging skills are good from other languages, but my javascript knowledge is still very minimal as its new to me.

si...@nekapuzer.at

unread,
Apr 16, 2013, 3:20:29 PM4/16/13
to gam...@googlegroups.com
I used to run gamejs through jslint to fix semicolons but i haven't done this for a while...

So I just pushed the linted code to git HEAD. if that doesn't fix your issue i'll *really* have to dig
out a mac :)

thanks again for debugging. i think debugging gamejs is valuable for your general JS know-how level...
we are pretty best practice so you have learnt a lot already :) if you are curious about JS, I hope you
have seen all the links to MDN on gamejs.org

simon

Joel Schaubert

unread,
Apr 17, 2013, 5:15:40 PM4/17/13
to gam...@googlegroups.com
I agree completely,
Debugging is a really great way to make a developer stronger.


>  ) if you are curious about JS, I hope you have seen all the links to MDN on gamejs.org
No, I have not found them, what is MDN ?
I am planning on learning a lot more of javascript a few hours a week when I'm not working on our company website.


Ok
git clone from head
./bin/build.sh
verify file gamejs.min.js  in nonzero in both locations
start python webserver at gamejs top
browse to examples/skeleton

firefox - Fail
chrome - Fail



Chrome debugger
Uncaught SyntaxError: Unexpected token ILLEGAL :8080/examples/skeleton/public/gamejs.min.js:1



Open up /gamejs.min.js  in  a text editor
search and replace      "\r\n"   to ""
save /gamejs.min.js
cp gamejs.min.js examples/skeleton/public/


Refresh chrome browser window still at /examples/skeleton

WORKS !
Spot check all other examples
ALL WORK!

I will delete the hacked gamejs.min.js so I can attach the one generated.
Either some syntax is still wrong or else it is the  "\r\n" problem.

JoelS$  rm gamejs.min.js examples/skeleton/public/gamejs.min.js
JoelS$ ./bin/build.sh
Wrote /Users/JoelS/code/moo/gamejs/gamejs.min.js


Do you mean this js lint here ?
http://www.javascriptlint.com/download.htm

I grabbed that and ran it on all source code files
3 files have unexpected end of file warnings.
JoelS$ find . -name "*.js" -exec ../../jsl-0.3.0-mac/jsl -process {} \;  >gamejs.lint

grep end gamejs.lint
/Users/JoelS/code/moo/gamejs/lib/gamejs/draw.js(139): lint warning: unexpected end of line; it is ambiguous whether these lines are part of the same statement
/Users/JoelS/code/moo/gamejs/lib/gamejs/sprite.js(145): lint warning: unexpected end of line; it is ambiguous whether these lines are part of the same statement
/Users/JoelS/code/moo/gamejs/lib/gamejs.js(514): lint warning: unexpected end of line; it is ambiguous whether these lines are part of the same statement

I will attach the lint output file gamejs.lint in case it is working differently on a mac




gamejs.min.js
gamejs.lint
Reply all
Reply to author
Forward
0 new messages