It looks like you're new here. If you want to get involved, click one of these buttons!
$(function () { $.getScript("http://link.to/js/file.js", function (data, textStatus, jqxhr) { console.log(data); // Data returned console.log(textStatus); // Success console.log(jqxhr.status); // 200 console.log("Typed was loaded."); }); });…but it doesn’t seem to work.
Comments
Cool.
Could you clarify what you mean by that, and provide an example?
Use the jQuery getScript() function to call the external JavaScript file from wherever it's located. Then, within the function itself write in any of the script-specific calls that are required. So...
I'm writing this from my head on a mobile device, do let me know if you need a more detailed example.
I’m currently working on a game in which I wanted the title to appear on the screen as if being typed. To do this, I chose to use the typed.js jQuery plugin (http://www.mattboldt.com/demos/typed-js/). In order to use typed.js, one must first import the jQuery library (which Twine already does). Then, typed.js must be imported as well… After that, the typed.js function must be called when the web page loads.
To accomplish this, typed.js must reside at an Internet location (lets say you have a web server at http://twinerocks.com). On that server, you add a folder named "js" (to store JavaScript files in) and you upload the typed.js file to that folder.
Then, in the Twine story’s JavaScript, you need to import typed.js and call the typed.js function, including any options that you would like to use:
As you can see, the HTML selector that typed.js is applying itself to in this case has the class "title." So, the HTML looks like this:
You don’t have to actually put content in the <h1>, as the typed.js strings" will go there.
Let me know if you need additional clarification.
into the other format.....
Lost after the first bit......
…this should work:
But it doesn’t.
There’s most likely a conflict with Twine’s own syntax.
I’ll try to experiment a little more later.
Caveat: I could only get this to work in SugarCube, not Harlowe, which is the default story format. SugarCube is fortunately what's used in the example file I've attached, so you can rename the story and keep importing.
SugarCube docs are here: http://www.motoslave.net/sugarcube/
I had to play some tricks to make it work, but Javascript is halfway about tricks...
I can go into more details.
Now if we could just figure out how to split the MathJax part of this discussion into its own Forum thread…
Thank you for that. I'll have a tinker.
....why could it not be simple........
@timsamoff @AvaJarvis
Thank you both for your input on this.
I want to use an external javascript file which is annyang.js, ehich is used for voice recognition ,but I don´t have the link to read it from the internet. I have just a file with the code.
Is there a way to instead of reading the file from the internet to read it from a file stored in your computer?
So when you get the script instead of writing that http link, read it from a folder in your computer.
Thank you!!
I found the link to read it from the internet:
But I am not sure if I am doing correctly:
If from the code I want to use this functions: What should I put in this part??
Thank you!
Thanks to the excellent code of AvaJarvis, I was able to get MathJax working in Snowman 1.3.0
I am new to Twine, and I am hoping to use it when teaching mathematics, making the blank background a plus. I have also adjusted the math-mode delimiters to match the standard LaTeX syntax.
I hope you find this useful.
here is the code I used:
I tested the same script from my own local web-server using the following code and it worked fine, I had to add a delay between the file being download and the tracery object being initialised. note: I removed the window.harlowe object related code because it would first require me to include a scope escalation hack to have a window.harlowe object.