Jump to content

L8V2L thoughts on JavaScript...


L8V2L

Recommended Posts

The term "node" refers to an element in a data structure that all programming languages can implement. It's called a tree, a node is any part of the tree that contains data. Here's the Wikipedia article about trees: http://en.wikipedia.org/wiki/Tree_(data_structure)

Thanks for the link, I read the introduction, and pass it toward the end, but not finish, wanted to get back to finishing the JavaScript tutorial.Is this a joke? The main competitor to SVG is Flash <-- Is this a joke?! If not WHY!?!?!
Link to comment
Share on other sites

did you look it up first?

I came a cross it before a few days back, but to have someone to explain it in their own words as not trying to be high tech about it, can help to get the bottom line of it... clarity...Is this a joke? The main competitor to SVG is Flash <-- Is this a joke?! If not WHY!?!?!Unless it's my internet connection, svg animation isn't smooth, choppy. Edited by L8V2L
Link to comment
Share on other sites

The setTimeout() function executes a function after a certain amount of time. If that function contains the setTimeout call then it will continue calling itself.

Link to comment
Share on other sites

/*How is window.setTimeout() method acting as setInterval() method?*///Is window.onload causing it to act as a setInterval() window method?

You really need to get to the point where you can figure things out on your own.

 

1. Did you look up setTimeout() to see how it works and what it does?

 

http://www.w3schools.com/jsref/met_win_settimeout.asp

 

2. Did you try using console.log or some other output method to watch the code run? You can always insert alert('x') into your code as a rough way to see what is executing. You can also add a div for your debugging and keep appending to it with innerHTML statements.

 

 

Link to comment
Share on other sites

[quote name="Ingolme" post="278362" timestamp="1400950645"

 

 

/*How is window.setTimeout() method acting as setInterval() method?*///Is window.onload causing it to act as a setInterval() window method?
You really need to get to the point where you can figure things out on your own. 1. Did you look up setTimeout() to see how it works and what it does? http://www.w3schools.com/jsref/met_win_settimeout.asp 2. Did you try using console.log or some other output method to watch the code run? You can always insert alert('x') into your code as a rough way to see what is executing. You can also add a div for your debugging and keep appending to it with innerHTML statements.

 

 

The setTimeout() function executes a function after a certain amount of time. If that function contains the setTimeout call then it will continue calling itself.

 

 

/*How is window.setTimeout() method acting as setInterval() method?*///Is window.onload causing it to act as a setInterval() window method?
You really need to get to the point where you can figure things out on your own. 1. Did you look up setTimeout() to see how it works and what it does? http://www.w3schools.com/jsref/met_win_settimeout.asp 2. Did you try using console.log or some other output method to watch the code run? You can always insert alert('x') into your code as a rough way to see what is executing. You can also add a div for your debugging and keep appending to it with innerHTML statements.

 

What do you mean by; "You can also add a div for your debugging and keep appending to it with innerHTML statements."

 

]The setTimeout() function executes a function after a certain amount of time. If that function contains the setTimeout call then it will continue calling itself.Oh, cause it in a function, ones the function is call, then it will be call again, and again.
Link to comment
Share on other sites

<!DOCTYPE html><html><body><h1 id="intro">My First Page</h1><p id="demo">Hello World!</p><script>var myText = document.getElementById("intro").childNodes[0].nodeValue;var innerhtml = childNodes[0].nodeValue;//<--How to make thisdocument.getElementById("demo").innerhtml = myText;//<--work?</script></body></html>
Link to comment
Share on other sites

Why don't you simply insert...

alert('['+ elem.childNodes[0].nodeValue +']');

...to see if it is what you expect? I think it is very unusual to try to use childNode in this situation where using innerHTML is the obvious choice.

 

 

What do you mean by; "You can also add a div for your debugging and keep appending to it with innerHTML statements."

 

I mean you can create a div such as...

<div id="debug1"></div>

...and then write to it with debugging statements inserted into your code...

function myFunction(){var debug1 = document.getElementById('debug1');debug1.innerHTML = '<hr/>';for (var i=4; i<=6; i++){debug1.innerHTML += 'i= '+ i +'<br/>';}}
Link to comment
Share on other sites

Why don't you simply insert...

alert('['+ elem.childNodes[0].nodeValue +']');
...to see if it is what you expect? I think it is very unusual to try to use childNode in this situation where using innerHTML is the obvious choice. I mean you can create a div such as...
<div id="debug1"></div>
...and then write to it with debugging statements inserted into your code...
function myFunction(){var debug1 = document.getElementById('debug1');debug1.innerHTML = '<hr/>';for (var i=4; i<=6; i++){debug1.innerHTML += 'i= '+ i +'<br/>';}}

 

<!DOCTYPE html><html><body><h1 id="intro">My First Page</h1><p id="demo">Hello World!</p><script>var myText = document.getElementById("intro").childNodes[0].nodeValue;var innerhtml = childNodes[0].nodeValue;/*<--I want to put it in the variable, so I can use the variable as innerHTML. It doesn't matter why, it's something I want to see possible. Can you help me?*/ document.getElementById("demo").innerhtml = myText;//<--work?</script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

just start using the console, that's what it's for.

https://developer.chrome.com/devtools/docs/console

var x = 5;var person = {  name: "Joe Smith",  age: 30}; console.log('ENTER some function');console.log('the value of x is => ' + x);console.log(person); //etc

most developers would already have it open and using it anyway to check for Javascript errors

  • Like 1
Link to comment
Share on other sites

just start using the console, that's what it's for.https://developer.chrome.com/devtools/docs/console

var x = 5;var person = {  name: "Joe Smith",  age: 30}; console.log('ENTER some function');console.log('the value of x is => ' + x);console.log(person); //etc
most developers would already have it open and using it anyway to check for Javascript errors

 

It don't seem possible, I want to try to reference childnodes[0].nodeValue in variable innerhtml. Do you know where I went wrong by looking at the code? Edited by L8V2L
Link to comment
Share on other sites

You can't do that. You can't make a reference to element properties that way. A variable does not point to generic things, just to specific things.

Link to comment
Share on other sites

<!DOCTYPE html><html><body><h1 id="intro">My First Page</h1><p id="demo">Hello World!</p><script>var myText = document.getElementById("intro").childNodes[0].nodeValue;var innerhtml = childNodes[0].nodeValue;/*<--I want to put it in the variable, so I can use the variable as innerHTML. It doesn't matter why, it's something I want to see possible. Can you help me?*/ document.getElementById("demo").innerhtml = myText;//<--work?</script></body></html>

I think you mean something like...

<!DOCTYPE html><html><body><h1 id="intro">My First Page</h1><p id="demo">Hello World!</p><script>var childnodes = document.getElementById("intro").childNodes;var str = '';for (var i=0,len=childnodes.length ; i<len ; i++){str += 'i:'+ i +' '+ childnodes[i].nodeType +' '+ childnodes[i].nodeName +' ['+ childnodes[i].nodeValue +']';}document.getElementById("demo").innerHTML = str;</script></body></html>
Link to comment
Share on other sites

Why can't you read documentation? http://www.inkscape.org/en/learn/tutorials/

Thanks for the link, I went there before you post that, but not to that section. I would love to go through it, but not now, now I just want to concentrate on learning JavaScript, and making sure I understand everything. So if you could simply tell me how to do it, I even search Google(first msn, cause that is the browser that my browser to go).Do anyone know how to save SVG to where it can be edited and put into html or as a html format so one can edited it.
Link to comment
Share on other sites

Your question doesn't even make any sense.

HAHAHA I'm lose in translation. And they said "please refer to picture" is not an disorder, or my favorite one that it can be cure with medicine.I wish to save an InkScape file, and be able to open it up in a text editor, and easily be able to edit the code as an html SVG inline code, and also be able to insert it into w3school to render out as the example display with their SVG inline code.Also, I was wonder if there is away to put SVG inline code into canvas? I don't care much it want be an sVG format file, I just desire to have the capability to use it as so, cause of the greater control and feature SVG coding have over getContext("2d");Please answer both question if you can. Edited by L8V2L
Link to comment
Share on other sites

I wish to save an InkScape file, and be able to open it up in a text editor, and easily be able to edit the code as an html SVG inline code, and also be able to insert it into w3school to render out as the example display with their SVG inline code.

 

Have you looked at File>Save As... Plain SVG?

 

http://wiki.inkscape.org/wiki/index.php/PlainSVG

  • Like 1
Link to comment
Share on other sites

Have you looked at File>Save As... Plain SVG? http://wiki.inkscape.org/wiki/index.php/PlainSVG

That what I did, but it didn't seem to work... I might didn't recognize it, cause of what the photo I choose to convert it to SVG, but a simple square and I can see it now. Thanks anyway. Edited by L8V2L
Link to comment
Share on other sites

SVG and canvas are not compatible. One stores data about shapes, the other manipulates a matrix of pixels.

But one can be converted to different format. There must be away to transfer the data into a different format to the canvas from raw SVG inline code. By doing this, I can see how it could give one more control, and greater manipulation over the shape using SVG. The canvas have a data object, and other methods and properties and manipulate data.
Link to comment
Share on other sites

I want to right svg code from JavaScript. Can anyone help me figure out what I did wrong?The console show no error.plus I see that there are svg object in the console it self, but from searching the web, also w3.org show and said that they are read only; i.e. SVGRect; <-- How would I use this, or is it just a reference for the compiler or interpreter?

<!DOCTYPE html><html><body><h1 id = "h1">My first SVG</h1><svg id = "svg0" width="100" height="100">   Sorry, your browser does not support inline SVG.</svg>  <script>var h1 = document.getElementsByTagName("h1");h1[0].innerHTML += "yo";var svg = document.getElementsByTagName("svg");svg[0].innerHTML = '<circle x= 0 y = "0" cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />';</script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

You're free to make a Javascript application that reads SVG files and draws them on a canvas.

Their so much I want to learn... But with my "refer to pic" I'm concentrating on JavaScript; by that I mean, the only thing I will use other then JavaScript is api for, or that can be manipulated by JavaScript... I have read over and over these tutorial on JavaScript... little by little getting the important of JavaScript... I will not stop... I will not. My knowledge is being guide by to force I see now, JavaScript, and HTML, for what ever touch those, I reach to understand. I want to understand... I want to evolve from my novice state... no matter how long it'll take, I will keep going over this until I get it... Cause for me... this is it, this is it or defeat, and if it is defeat, then it is death to be... I will not turn to that. No matter... I must keep reading, reaching, forcing my self(and not even since I general do enjoy this) to want this...I wish to manauplate svg from JavaScript, since it is a node from the dom, and it's own dom, then it is possible, how would I go about this... plus I found searching through the dom that there are svg object with in it... but seem to be read only... judging on searching the web, and w3.org... are those just for reference for when one is writing the code on the wed or something?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...