Skip to content

Commit

Permalink
restart button working:
Browse files Browse the repository at this point in the history
  • Loading branch information
mobeets committed Dec 5, 2013
1 parent c7a2370 commit 598e27c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
15 changes: 14 additions & 1 deletion js/typed.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
}

this.isPaused = false;
this.isRestart = false;
// All systems go!
this.init();
this.build();
Expand All @@ -73,7 +74,11 @@

, updateStatus: function(){
this.isPaused = $('.typing-status').html() == 'PLAY ';
// console.log(this.isPaused);
this.isRestart = $('.restart-status').html() == 'RESTART';
}

, resetStatus: function(){
$('.restart-status').html('');
}

// pass current string state to each function
Expand Down Expand Up @@ -121,6 +126,10 @@
if (!self.isPaused){
curStrPos++;
}
if (self.isRestart){
curStrPos = 0;
self.resetStatus();
}
// loop the function
self.typewrite(curString, curStrPos);
// if the array position is at the stopping position
Expand Down Expand Up @@ -187,6 +196,10 @@
if (!self.isPaused){
curStrPos--;
}
if (self.isRestart){
curStrPos = curString.length;
self.resetStatus();
}
// loop the function
self.backspace(curString, curStrPos);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ input {
margin: 0;
}
.menu-item-icon:hover {
opacity: 0.4;
opacity: 0.3;
}
.menu-item-icon:active {
position: relative;
Expand Down
8 changes: 6 additions & 2 deletions templates/tweet.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
console.log(val + '.');
$('.typing-status').html(val == "PLAY " ? play_it() : pause_it());
}
function ReplayButtonClicked() {
val = $('.restart-status').html("RESTART");
console.log('Restarting.');
}

function play_it() {
$('.typing-status').html("PAUSE");
Expand All @@ -71,8 +75,8 @@
<a class="local_link"><img src="/static/link-icon.png" class="msg-icon" alt="Link here"></a>
<a class="ext_link"><img src="/static/twitter-icon.png" class="msg-icon" alt="View tweet"></a>
<div class="via-section"><span class="date_link"></span> (via @NYerFiction)</div>
<div class="pause-button" onclick="PauseButtonClicked();"><span class="typing-status">PAUSE</span></div>
<div class="redo-button hide-children" onclick=""></div>
<div class="pause-button hide-children" onclick="PauseButtonClicked();"><span class="typing-status">PAUSE</span></div>
<div class="redo-button hide-children" onclick="ReplayButtonClicked();"><span class="restart-status"></span></div>
</div>
</div>
<div id="nav-wrapper">
Expand Down

0 comments on commit 598e27c

Please sign in to comment.