Last active
August 29, 2015 14:16
-
-
Save Pro/18959a4c1cdeb3dfc961 to your computer and use it in GitHub Desktop.
THW Theorie Shortcuts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name THW Theorie Shortcuts | |
// @namespace * | |
// @include http://www.thw-theorie.de/index.php?show=fragen | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js | |
// ==/UserScript== | |
/* == Installation == | |
1. Firefox Greasmonkey Addon Installieren: https://addons.mozilla.org/de/firefox/addon/greasemonkey/ | |
2. Auf dieser Seite rechts oben auf die Schaltfläche "Raw" klicken | |
3. Ein Dialogfenster fragt um Bestätigung zur Installtion | |
4. Die THW Seite öffnen: http://www.thw-theorie.de | |
5. Die Boxen neben den Fragen können jetzt mit den Nummern-Tasten 1 bis 9 entsprechend aktiviert/deaktiviert werden | |
6. Leertaste oder '^' (links neben der 1) sendet die Frage ab bzw. wechselt nach dem Absenden zur nächsten Frage. | |
7. Viel Spaß beim Lernen! | |
*/ | |
this.$ = this.jQuery = jQuery.noConflict(true); | |
function toggleCheckbox(index) { | |
var cbxInput = $('table.fragebkg input[type=checkbox]:eq('+index+')'); | |
if (cbxInput.length == 0) { | |
alert("Keine Antwortmöglichkeit mit Nummer: " + (index+1)); | |
return; | |
} | |
cbxInput.prop('checked', !cbxInput.prop("checked")); | |
} | |
function submitAnswers() { | |
$('table.fragebkg').parents("form").submit(); | |
} | |
function KeyCheck(e) | |
{ | |
if (e.keyCode >= 49 && e.keyCode <=59 ) {// between '1' and '9' | |
toggleCheckbox(e.keyCode-49); | |
} else if (e.keyCode == '160' || e.keyCode=='32') { // '^' or spacebar | |
submitAnswers(); | |
} | |
} | |
window.addEventListener('keydown', KeyCheck, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment