Skip to content
Browse files

No duplicate questions. Delete category only shows when editing now.

  • Loading branch information...
1 parent 66defee commit 7f65006ffa8c462ef3ae2cefe912d8bebe482687 @iambrandonn committed Feb 18, 2013
Showing with 39 additions and 35 deletions.
  1. +1 −0 addEdit.css
  2. +1 −0 addEdit.js
  3. +37 −35 main.js
View
1 addEdit.css
@@ -47,6 +47,7 @@
text-shadow: 1px 2px 1px #460000;
background: #EB0000;
margin-left: 30px;
+ display: none;
}
.saveButton {
View
1 addEdit.js
@@ -102,6 +102,7 @@ common.renderCategories(excludeBuiltinCategories, categoryClickedCallback);
var listToEdit = getListNameFromQueryString();
if (listToEdit.length > 0) {
+ $('.deleteButton').show();
$('.categoryName').val(listToEdit);
var loadedList = localStorage.getItem(listToEdit);
if (loadedList) {
View
72 main.js
@@ -1,4 +1,4 @@
-/*global console, Handlebars, common, samples */
+/*global Handlebars, common, samples */
var SpeechRecognition = window.mozSpeechRecognition ||
window.msSpeechRecognition ||
window.oSpeechRecognition ||
@@ -17,7 +17,6 @@ var problemsForSelectedCategory;
function getQuestionFromList(theList) {
var index = getRandomInteger(theList.length) - 1;
- console.log(index);
return theList[index];
}
@@ -69,39 +68,42 @@ function getRandomInteger(ceiling) {
function showNextProblem() {
var problemText;
- switch (selectedCategory) {
- case 'builtin-addition':
- currentProblem = generateAdditionProblem();
- problemText = currentProblem.firstNumber + ' + ' + currentProblem.secondNumber;
- break;
- case 'builtin-subtraction':
- currentProblem = generateSubtractionProblem();
- problemText = currentProblem.firstNumber + ' - ' + currentProblem.secondNumber;
- break;
- case 'builtin-multiplication':
- currentProblem = generateMultiplicationProblem();
- problemText = currentProblem.firstNumber + ' x ' + currentProblem.secondNumber;
- break;
- case 'builtin-division':
- currentProblem = generateDivisionProblem();
- problemText = currentProblem.firstNumber + ' / ' + currentProblem.secondNumber;
- break;
- case 'builtin-capitals':
- currentProblem = getQuestionFromList(samples.capitals);
- problemText = currentProblem.key;
- break;
- case 'builtin-chemSymbols':
- currentProblem = getQuestionFromList(samples.chemSymbols);
- problemText = currentProblem.key;
- break;
- case 'builtin-spanish':
- currentProblem = getQuestionFromList(samples.spanishWords);
- problemText = currentProblem.key;
- break;
- default:
- currentProblem = getQuestionFromList(window.problemsForSelectedCategory);
- problemText = currentProblem.key;
- break;
+ var previousProblem = currentProblem;
+ while (previousProblem === currentProblem) {
+ switch (selectedCategory) {
+ case 'builtin-addition':
+ currentProblem = generateAdditionProblem();
+ problemText = currentProblem.firstNumber + ' + ' + currentProblem.secondNumber;
+ break;
+ case 'builtin-subtraction':
+ currentProblem = generateSubtractionProblem();
+ problemText = currentProblem.firstNumber + ' - ' + currentProblem.secondNumber;
+ break;
+ case 'builtin-multiplication':
+ currentProblem = generateMultiplicationProblem();
+ problemText = currentProblem.firstNumber + ' x ' + currentProblem.secondNumber;
+ break;
+ case 'builtin-division':
+ currentProblem = generateDivisionProblem();
+ problemText = currentProblem.firstNumber + ' / ' + currentProblem.secondNumber;
+ break;
+ case 'builtin-capitals':
+ currentProblem = getQuestionFromList(samples.capitals);
+ problemText = currentProblem.key;
+ break;
+ case 'builtin-chemSymbols':
+ currentProblem = getQuestionFromList(samples.chemSymbols);
+ problemText = currentProblem.key;
+ break;
+ case 'builtin-spanish':
+ currentProblem = getQuestionFromList(samples.spanishWords);
+ problemText = currentProblem.key;
+ break;
+ default:
+ currentProblem = getQuestionFromList(window.problemsForSelectedCategory);
+ problemText = currentProblem.key;
+ break;
+ }
}
document.getElementsByClassName('problem')[0].textContent = problemText;
}

0 comments on commit 7f65006

Please sign in to comment.
Something went wrong with that request. Please try again.