Yay, CoffeeScript!
This commit is contained in:
parent
4e244a8895
commit
94003fc16f
23
Makefile
Normal file
23
Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
#export PATH := $(PWD)/vendor/bin:$(PATH)
|
||||
|
||||
CC=$(PWD)/vendor/bin/coffee
|
||||
SCRIPT_DIR=js
|
||||
COFFEE_FILES := $(wildcard $(SCRIPT_DIR)/*.coffee)
|
||||
JS_FILES=$(COFFEE_FILES:$(SCRIPT_DIR)/%.coffee=$(SCRIPT_DIR)/%.js)
|
||||
|
||||
all: coffee
|
||||
|
||||
coffee: $(JS_FILES)
|
||||
|
||||
$(SCRIPT_DIR)/%.js: $(SCRIPT_DIR)/%.coffee
|
||||
$(CC) -c $<
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Cleanup
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm $(SCRIPT_DIR)/*.js
|
@ -9,7 +9,8 @@
|
||||
"google/apiclient": "^2.0.0@RC"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*"
|
||||
"phpunit/phpunit": "4.*",
|
||||
"npm-asset/coffee-script": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["lib/"]
|
||||
|
63
composer.lock
generated
63
composer.lock
generated
@ -4,8 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "b24a0007ade6b73266663de233c8dd86",
|
||||
"content-hash": "61659d06b06498fbcab8c3ba1b5e4c99",
|
||||
"hash": "c16fe5d634e2d6392c87fbf9c4d05519",
|
||||
"content-hash": "59fa10158328c7f6a6432c72fc6fb721",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bower-asset/material-design-lite",
|
||||
@ -942,6 +942,65 @@
|
||||
],
|
||||
"time": "2015-06-14 21:17:01"
|
||||
},
|
||||
{
|
||||
"name": "npm-asset/coffee-script",
|
||||
"version": "1.10.0",
|
||||
"dist": {
|
||||
"type": "tar",
|
||||
"url": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.10.0.tgz",
|
||||
"reference": null,
|
||||
"shasum": "12938bcf9be1948fa006f92e0c4c9e81705108c0"
|
||||
},
|
||||
"require-dev": {
|
||||
"npm-asset/docco": "~0.7.0",
|
||||
"npm-asset/highlight.js": "~8.0.0",
|
||||
"npm-asset/jison": ">=0.2.0",
|
||||
"npm-asset/uglify-js": "~2.2",
|
||||
"npm-asset/underscore": "~1.5.2"
|
||||
},
|
||||
"bin": {
|
||||
"coffee": "./bin/coffee",
|
||||
"cake": "./bin/cake"
|
||||
},
|
||||
"type": "npm-asset-library",
|
||||
"extra": {
|
||||
"npm-asset-bugs": {
|
||||
"url": "https://github.com/jashkenas/coffeescript/issues"
|
||||
},
|
||||
"npm-asset-main": "./lib/coffee-script/coffee-script",
|
||||
"npm-asset-directories": {
|
||||
"lib": "./lib/coffee-script"
|
||||
},
|
||||
"npm-asset-repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jashkenas/coffeescript.git"
|
||||
},
|
||||
"npm-asset-scripts": {
|
||||
"test": "node ./bin/cake test",
|
||||
"test-harmony": "node --harmony ./bin/cake test"
|
||||
},
|
||||
"npm-asset-engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"npm-asset-prefer-global": true
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeremy Ashkenas"
|
||||
}
|
||||
],
|
||||
"description": "Unfancy JavaScript",
|
||||
"homepage": "http://coffeescript.org",
|
||||
"keywords": [
|
||||
"coffeescript",
|
||||
"compiler",
|
||||
"javascript",
|
||||
"language"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "1.0",
|
||||
|
25
js/frs.coffee
Normal file
25
js/frs.coffee
Normal file
@ -0,0 +1,25 @@
|
||||
checkValidity = ->
|
||||
if @required
|
||||
optId = @selectedIndex
|
||||
selOpt = @options[optId]
|
||||
if selOpt.value is ''
|
||||
@parentNode.classList.add 'is-invalid'
|
||||
else
|
||||
@parentNode.classList.remove 'is-invalid'
|
||||
|
||||
document.addEventListener 'DOMContentLoaded', (event) ->
|
||||
all_selects = document.getElementsByTagName 'select'
|
||||
for own i, xsel of all_selects
|
||||
xvalue = xsel.dataset.value
|
||||
#console.log 'Value of %o = %o', xsel, xvalue
|
||||
# Walk all options, compare to desired value and set if matches
|
||||
for o, ov of xsel.options
|
||||
if ov.value is xvalue
|
||||
xsel.selectedIndex = o
|
||||
break
|
||||
|
||||
# Add eventlistener to change is-invalid state and run once
|
||||
xsel.addEventListener 'change', checkValidity
|
||||
event = document.createEvent 'HTMLEvents'
|
||||
event.initEvent 'change', true, true
|
||||
xsel.dispatchEvent event
|
36
js/frs.js
36
js/frs.js
@ -1,36 +0,0 @@
|
||||
function checkValidity() {
|
||||
if (this.required) {
|
||||
var optId = this.selectedIndex;
|
||||
var selOpt = this.options[optId];
|
||||
if (selOpt.value == '') {
|
||||
this.parentNode.classList.add('is-invalid');
|
||||
} else {
|
||||
this.parentNode.classList.remove('is-invalid');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var all_selects = document.getElementsByTagName('select');
|
||||
for (var i in all_selects) {
|
||||
if (!all_selects.hasOwnProperty(i)) {
|
||||
continue;
|
||||
}
|
||||
var xsel = all_selects[i];
|
||||
var xvalue = xsel.dataset.value;
|
||||
//console.log('Value of %o = %o', xsel, xvalue);
|
||||
// Walk all options, compare to desired value and set if matches
|
||||
for (var o in xsel.options) {
|
||||
if (xsel.options[o].value == xvalue) {
|
||||
xsel.selectedIndex = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add eventlistener to change is-invalid state and run once
|
||||
xsel.addEventListener('change', checkValidity);
|
||||
var event = document.createEvent('HTMLEvents');
|
||||
event.initEvent('change', true, true);
|
||||
xsel.dispatchEvent(event);
|
||||
}
|
||||
});
|
16
js/session.coffee
Normal file
16
js/session.coffee
Normal file
@ -0,0 +1,16 @@
|
||||
window.page_load_time = Math.floor(Date.now() / 1000);
|
||||
window.expire_time = window.page_load_time + window.seconds_left;
|
||||
|
||||
window.updateTimeLeft = ->
|
||||
now = Math.floor Date.now() / 1000
|
||||
time_left = window.expire_time - now
|
||||
obj = document.getElementById 'session_expires'
|
||||
minutes = Math.floor time_left / 60
|
||||
seconds = time_left % 60
|
||||
if minutes+seconds > 0
|
||||
obj.innerHTML = ' (' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2) + ')'
|
||||
else
|
||||
obj?.innerHTML = ''
|
||||
window.clearInterval window.updateTimer
|
||||
|
||||
window.updateTimer = window.setInterval 'updateTimeLeft();', 1000
|
@ -20,24 +20,7 @@
|
||||
<div class="frs-ribbon"></div>
|
||||
<main class="frs-main mdl-layout__content">
|
||||
|
||||
<script>
|
||||
var page_load_time = Math.floor(Date.now() / 1000);
|
||||
var seconds_left = {{session_time_left}};
|
||||
var expire_time = page_load_time + seconds_left;
|
||||
|
||||
function updateTimeLeft() {
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
var time_left = expire_time - now;
|
||||
var obj = document.getElementById('session_expires');
|
||||
var minutes = Math.floor(time_left / 60);
|
||||
var seconds = time_left % 60;
|
||||
if (minutes+seconds > 0) {
|
||||
obj.innerHTML = ' (' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2) + ')';
|
||||
} else {
|
||||
obj.innerHTML = '';
|
||||
window.clearInterval(window.updateTimer);
|
||||
}
|
||||
}
|
||||
|
||||
var updateTimer = window.setInterval('updateTimeLeft();', 1000);
|
||||
</script>
|
||||
<script>
|
||||
var seconds_left = {{session_time_left}};
|
||||
</script>
|
||||
<script src="js/session.js"></script>
|
||||
|
Reference in New Issue
Block a user