When you create an HTML widget, it is an isolated HTML document placed within your Tumult Hype document - an iframe. The URL above doesn't work -- what exactly is Codepress and what are you trying to do?
<script language=“javascript” type=“text/javascript”>
editAreaLoader.init({
id : “txtdef” // Hype Scene Textarea id
});
</script>
I would like now using codepress (http://codepress.sourceforge.net/) or codemirror (http://codemirror.net/index.html)
It seems they work the same way : give an Id, a little JS code + CSS.
However it doesn’t work and my Firefox Console tells me "textarea.value is null"
But if i create a TextArea Directly into my main webPage with Teh same Id, that’ok: i can highlight Syntax.
So here is the situation:
If i try calling from my Main Web Page codemirror.js for styling a textarea inside my web page: ok, no problem.
if i do the same thing for my Hype Scene TextArea, value is null.
It seems getElementById does not see my Hype TextArea. Or something like that i do not understand. All my tries were done inside the Main Web Page: can i do something inside Hype Script Editor ?
'On Scene Load' on the scene where you have an element with that ID. The issue is probably that the 'editAreaLoad' function is being fired before the element with that ID has been created, so it cannot find it.
thank you for being so patient.
I feel a little bit confused: i did not succeed.
I thought you asked me to run a JavaScript function onLoad Scene, so i wrote a function:
So i tried to listen to test document.changeState to check if document was complete and Bingo !
So here is the code you have to insert into the webMainPage calling codeMirror or whatever you want to apply AFTER it's ready:
document.onreadystatechange = function () {
if(document.readyState === "complete"){
/* your code /
var editor = CodeMirror.fromTextArea(document.getElementById("txtdef"), {
/ start codemirror */
});
}
}
For i had problems first with JS scripting (i'm new to that) i just would like to explain that the first line is very important: document.onreadystatechange = function ()
That's a kind of "while" listening every changes of the page.
I did not write it at first and nothing happened because it was checking "complete" state while page was "loading". So, nothing could happen....
I had to add the ressources to my Scene Head AND into my Main Web Page Head too and all the problems of CSS conflicting disappeared (it’s magic…).
Once done, i had to delay the codemirror fire up: