[Plugin] Call Javascript

Post your completed addons to share with the community

Post » Fri Nov 04, 2011 1:33 pm

hi,
a plugin for executing Javascripts in runtime.
(The plugin doesn't work in preview mode.)

[Update]
now the external javascriptfile-loading should work in all browsers
[/Update]


callJS - Demo, Plugin, example Scriptfile
another example: Call Google Maps

The Plugin executes scripts/functions
#) written in an external javascript file - ie myScripts.js

#) coming out from construct - ie: 2+3+4 or the example with the browser name in the demo - you can write any script in a textbox and then execute it



All suggestions are welcome.

Joe7 Joe72011-11-05 11:26:42
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Fri Nov 04, 2011 2:02 pm

Joe7,

I'm not exactly sure where to put the myscript.js, so the example keeps failing. I specified a the location in the capx before exporting, and I also put the myscript.js in the same folder as the index.html, but no go.

I think i am missing something obvious.
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Fri Nov 04, 2011 2:08 pm

hi Wastrel,

have you changed the initial value of the Plugin to: myscript.js
(the name is case sensitiv)
you should place your script file next to your index.html



hope that helps, Joe7
Joe72011-11-04 21:00:39
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Fri Nov 04, 2011 2:54 pm

[code]jQuery.getScript(this.nameOfExternalScript, function(){});[/code]
I like it!
This method is better then mine. I use AJAX to load js file, then save in plugin.rexrainbow2011-11-04 15:02:31
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Fri Nov 04, 2011 2:56 pm

Yes, that clears it up. I will test it out. Thanks!
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Fri Nov 04, 2011 9:04 pm

[QUOTE=rexrainbow] [code]jQuery.getScript(this.nameOfExternalScript, function(){});[/code]
[/QUOTE]
this line looks nice but was bad for other browsers as firefox
- i've changed it now and load the external file with pure javascript+dom
=> now the loading of the external-script should work
B
14
S
6
G
5
Posts: 173
Reputation: 4,742

Post » Mon Nov 07, 2011 11:17 am

I embarqued this morning on a project for a plugin to manipulate & change the URLs, and I remembered your nice plugin. It's way more quicker to use it to do things like that !
So, here's an example, which shows how to change the url you are currently browsing when clicking on a button inside C2's canvas. Beware, everything you were doing on your game can be lost !
I added a second button. When you click on the first one to go to google (for example), and go back with the 'back' button of your browser, you can use the second button to navigate forward in the history tree.

http://dl.dropbox.com/u/1412774/URLs_and_Timeouts.capxPode2011-11-07 11:17:57
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Tue Dec 13, 2011 4:10 pm

How can i use this :
Its in javascript but not working..

$.post("https://www.scoreoid.com/api/getNotification", { api_key: "Your API Key", game_id: "Your Game ID", response: "JSON"},
   function(data) {
     alert("Data Loaded: " + data);
   },
"json"
);

Obviously i changed the details with my API key ect..
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Thu Dec 22, 2011 10:57 am

Excellent! This makes the question of adding a stack to my "learning C2" game simple! Thank You!
B
27
S
5
G
5
Posts: 24
Reputation: 4,553

Post » Thu Dec 22, 2011 1:20 pm

[QUOTE=Joe7] [QUOTE=rexrainbow] [code]jQuery.getScript(this.nameOfExternalScript, function(){});[/code]
[/QUOTE]
this line looks nice but was bad for other browsers as firefox
- i've changed it now and load the external file with pure javascript+dom
=> now the loading of the external-script should work [/QUOTE]

Interesting... getScript is what I use in my plugin so it looks like I'll have to do a little more testing.

Quick question. What do you do to include the .js file when the project is exported? I wanted to load my script from an external location, but fall back to a local version if it's unavailable. But the only way I could find to include the script during export was to set dependency in edittime, but that also automatically adds the script to the html thus making the remote loading useless.wgfunstorm2011-12-22 13:20:36
B
22
S
9
G
5
Posts: 122
Reputation: 5,386

Next

Return to Completed Addons

Who is online

Users browsing this forum: gamecorpstudio, X3M and 0 guests