Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed debugging js scroll #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<html>
<head>
<meta charset ="utf-8">
<title>Javascript Demo</title>
<style>
body {
Expand All @@ -10,7 +11,6 @@
text-align: center;
margin-top:20%;
}

#magic{
color: #777;
border-right: 1px solid #777;
Expand All @@ -25,31 +25,29 @@

<script>

var words = ["fun", "exciting", "about not giving up", "being helpful", "being open", "what I learned at CodingDojo!"],
var words = ["fun", "exciting","about not giving up","being helpful","being open", "what I learned at CodingDojo!"],
el = document.getElementById('magic'),
word_counter = 0,
character_counter = 0;

for (var i = 0; i < words.length; i++) {
words[i] = words[i].replace(" ",'\xa0');
}
function updateText()
{
el.innerHTML = el.innerHTML+words[word_counter][character_counter++];

if(character_counter == words[word_counter].length)
if(character_counter == words[word_counter].length + 1)
{
word_counter++; //choose a different word
character_counter = 0; //start over with the first character of the word
el.innerHTML = ''; //set the html to be blank

//if we're displaying the last word, go back to the first word
if(word_counter == words.length)
word_counter = 0;
}
}

setInterval(updateText,300);

</script>

</body>

</html>
</html>
68 changes: 68 additions & 0 deletions index2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<html>
<head>
<title>Javascript Demo</title>
<style>
body {
background-color:black;
font-family: monospace;
color:white;
font-size:50px;
text-align: center;
margin-top:20%;
}

#magic{
color: #777;
border-right: 1px solid #777;
padding-right: 7px;
display: inline;
}
</style>
</head>
<body>

Coding is <div id="magic"></div>

<script>

var words = ["fun", "exciting", "about not giving up", "being helpful", "being open", "what I learned at CodingDojo!"],
el = document.getElementById('magic'),
word_counter = 0,
character_counter = 0;
// for (var i = 0; i < words.length; i++) {
// var str = words[i]
// for (var j = 0; j < str.length; j++ ) {
// if ([words][i][j] == [words][i][j].fromCharCode(160)){
// words[i][j] == ' '
// }
// }
// };
function updateText()
{

el.innerHTML = el.innerHTML+words[word_counter][character_counter++];


if(character_counter == words[word_counter].length + 1)
{
word_counter++; //choose a different word
character_counter = 0;

//start over with the first character of the word
el.innerHTML = ''; //set the html to be blank

//if we're displaying the last word, go back to the first word
if(word_counter == words.length)
word_counter = 0;

}
}

setInterval(updateText,300);
}
updateText()
</script>

</body>

</html>