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

Speedup / Slowdown button #75

Open
wants to merge 1 commit into
base: dev
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
5 changes: 3 additions & 2 deletions spritz.html
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<link href='https://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<link href='https://rawgithub.com/Miserlou/OpenSpritz/master/style.css' rel='stylesheet' type='text/css'>
<link href='https://rawgithub.com/Miserlou/OpenSpritz/master/style.css' rel='stylesheet' type='text/css'>

<div id="spritz_holder">
<div id="spritz_container">
Expand All @@ -15,7 +15,7 @@
<div id="guide_bottom">
――――――――――――――――――――――
</div>

<button type="button" id="spritz_slower">-</button>
<select id="spritz_selector">
<option value="0">Select WPM</option>
<option value="200">200wpm</option>
Expand All @@ -34,6 +34,7 @@
<option value="900">900wpm</option>
<option value="950">950wpm</option>
</select>
<button type="button" id="spritz_faster">+</button>

<button type="button" id="spritz_toggle">Pause</button>

Expand Down
43 changes: 39 additions & 4 deletions spritz.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function create_spritz(){
//getURL("https://rawgithub.com/Miserlou/OpenSpritz/dev/spritz.html", function(data){

// This won't work in Firefox because an old bug and won't work in Chrome because of security stuff:
//getURL("spritz.html", function(data){
//getURL(window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1) + "spritz.html", function(data){

//getURL("https://rawgithub.com/Miserlou/OpenSpritz/dev/spritz.html", function(data){
getURL("https://rawgithub.com/Miserlou/OpenSpritz/master/spritz.html", function(data){
getURL("https://rawgithub.com/Miserlou/OpenSpritz/dev/spritz.html", function(data){
//getURL("https://rawgithub.com/Miserlou/OpenSpritz/master/spritz.html", function(data){
var spritzContainer = document.getElementById("spritz_container");

if (!spritzContainer) {
Expand Down Expand Up @@ -134,6 +134,40 @@ function spritzify(input){
}
});

var changespeed = function () {
stopSpritz();
if (document.getElementById("spritz_selector").selectedIndex > 0)
{
startSpritz();
}
};

document.getElementById("spritz_selector").addEventListener("change", changespeed);

var goslower = function () {
var el = document.getElementById('spritz_selector');
if (el.selectedIndex > 1) {
el.selectedIndex = el.selectedIndex - 1;
}
stopSpritz();
startSpritz();
}

document.getElementById("spritz_slower").addEventListener("click", goslower);

var gofaster = function () {
var el = document.getElementById('spritz_selector');
if (el.length > el.selectedIndex + 1) {
el.selectedIndex = el.selectedIndex + 1;
}
stopSpritz();
startSpritz();
}

document.getElementById("spritz_faster").addEventListener("click", gofaster);



function updateValues(i) {

var p = pivot(all_words[i]);
Expand All @@ -146,7 +180,8 @@ function spritzify(input){

document.getElementById("spritz_toggle").style.display = "block";
document.getElementById("spritz_toggle").textContent = "Pause";

wpm = parseInt(document.getElementById("spritz_selector").value, 10);
ms_per_word = 60000/wpm;
running = true;

spritz_timers.push(setInterval(function() {
Expand Down
8 changes: 8 additions & 0 deletions style.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ body{
float: left;
width: auto;
}
#spritz_slower{
float: left;
width: auto;
}

#spritz_toggle{
float: left;
width: auto;
}

#spritz_faster{
float: left;
width: auto;
}
.invisible{
font-family: 'Droid Sans Mono', sans-serif;
color: #ffffff;
Expand Down