calljs updated to work with cocoonjs

Post your completed addons to share with the community

Post » Sun Sep 09, 2012 5:28 pm

for some reason search failed when I tried to find an original calljs plugin, so new thread.

if you can't get calljs to work on cocoonjs (and probably direct canvas also), open plugin's runtime.js file and edit it around line 49:

change this:
[code]this.nameOfExternalScript = this.properties[0];
          this.returnValue= "";
          var myScriptTag=document.createElement('script');
          myScriptTag.setAttribute("type","text/javascript");
          myScriptTag.setAttribute("src", this.nameOfExternalScript);
          
          if (typeof myScriptTag != "undefined")
               document.getElementsByTagName("head")[0].appendChild(myScriptTag);[/code]

to this:
[code]
if (typeof this.properties[0] != "undefined" && this.properties[0] != "") {
this.nameOfExternalScript = this.properties[0];
          this.returnValue= "";
          var myScriptTag=document.createElement('script');
          myScriptTag.setAttribute("type","text/javascript");
          myScriptTag.setAttribute("src", this.nameOfExternalScript);
          
          if (typeof myScriptTag != "undefined")
               document.getElementsByTagName("head")[0].appendChild(myScriptTag);
}
[/code]

and it should work, but remember to clear the plugin's Scriptfile property (it must be empty for it to work with cocoonjs). this change should be done in original plugin also to prevent creating empty <script> tag.

hope I helped anyone :)
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Sep 10, 2012 7:08 am

The original thread for Call Javascript

Maybe it's worth contacting Joe7 by PM to see if he could implement this in his plugin in some way.

Is it worth listing this "trick" in the plugins list ?
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Sep 10, 2012 9:55 am

Hey, thanks!

I just contacted Joe7, so if he implements this change in the original plugin, I don't think there's much sense in listing it in plugins list.

Cheers
B
81
S
50
G
10
Posts: 555
Reputation: 13,009


Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests