Fontz Quiz Timer & Keyboard Shortcuts

Adds stopwatch to quiz pages; use Ctrl+S to submit and continue on quiz and quiz answer pages

目前為 2015-09-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Fontz Quiz Timer & Keyboard Shortcuts
// @namespace   http://idlewords.net
// @description Adds stopwatch to quiz pages; use Ctrl+S to submit and continue on quiz and quiz answer pages
// @include     http://50.116.7.11:9998/learningQuizController_turk/quiz
// @include     http://50.116.7.11:9998/learningQuizController_turk/quiz_answer
// @include     http://50.116.7.11:9998/learningQuizController_turk/main_menu
// @version     0.4
// @require     https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @require     https://greasyfork.org/scripts/12377-timecircles/code/TimeCircles.js?version=73868
// @resource    customCSS http://git.wimbarelds.nl/TimeCircles/inc/TimeCircles.css
// @grant       GM_addStyle
// @grant       GM_getResourceText
// ==/UserScript==

this.$ = this.jQuery = jQuery.noConflict(true);

var keycode = 83; // 83 = S. Change this to a valid code from http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes to change the keyboard shortcut

var newCSS = GM_getResourceText ("customCSS");
GM_addStyle (newCSS);

$(document).ready(function() {
	if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/quiz_answer') {
		$(document).keydown(function(event) {
			if (event.which == keycode && event.ctrlKey) {
				event.preventDefault();
				$("input[name='Continue']").click();
			}
		});
		$("form[class='nobox']").after("<p>Questions Completed: " + localStorage.getItem('questions') + "</p>")
	}
});

$(window).load(function() {
	if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/quiz') {
		$("div[align='right']").append("<span>" + localStorage.getItem('questions') + "</span>").before(
			$("<div></div>")
				.css({'height': '200px', 'width': '500', 'align': 'left'})
				.addClass('timer')
		);
		$(".timer").TimeCircles({
			time: {
			    Days: { show: false },
			    Hours: { show: false },
			    Minutes: { color: "#BBFFBB" },
			    Seconds: { color: "#FF9999" }
			}
		});
		$(document).keydown(function(event) {
			if (event.which == keycode && event.ctrlKey) {
				event.preventDefault();
				$(".timer").TimeCircles().stop();
				localStorage.setItem('questions', parseInt(localStorage.getItem('questions')) + 1);
				$("#submitButton").click();
			} else if (event.which == 89 || event.which == 49 || event.which == 97) {
				event.preventDefault();
				$("#deformfield1-0").prop('checked', true);
			} else if (event.which == 78 || event.which == 50 || event.which == 98) {
				event.preventDefault();
				$("#deformfield1-1").prop('checked', true);
			}
		});
	} else if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/main_menu') {
		setTimeout(function(){$('div#bodycontainer p').eq(0).before('Questions Answered: ' + $('circle').length);},1000);
		if (localStorage.getItem('questions') === null) {
			localStorage.setItem('questions', $('circle').length);
		}
	}
});