Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b6b57f
commit 0e3b3eb
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ pids | |
logs | ||
results | ||
|
||
lib | ||
node_modules | ||
npm-debug.log | ||
npm-debug.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "piescore", | ||
"description": "Utility functions", | ||
"main": "./lib/piescore.js", | ||
"version": "0.1.0", | ||
"author": "Jakob Mattsson <jakob.mattsson@gmail.com> (jakobmattsson.se)", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:jakobmattsson/piescore.git" | ||
}, | ||
"engines": { | ||
"node": ">=0.6.0" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "1.3.x" | ||
}, | ||
"scripts": { | ||
"prepublish": "coffee -c -o lib src" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
exports.makeObject = -> | ||
obj = {} | ||
for i in [0..arguments.length/2] | ||
obj[arguments[i*2]] = arguments[i*2+1] | ||
obj | ||
|
||
exports.argsToArray = -> | ||
x for x in arguments | ||
|
||
exports.block = (f) -> f() | ||
|
||
exports.toKeyValues = (source) -> | ||
Object.keys(source).map (key) -> | ||
key: key | ||
value: source[key] | ||
|
||
exports.attachEvent = (obj, eventName, callback) -> | ||
onEventName = "on" + eventName | ||
if obj.addEventListener | ||
obj.addEventListener(eventName, callback, false) | ||
else if obj.attachEvent | ||
obj.attachEvent(onEventName, callback) | ||
else | ||
currentEventHandler = obj[onEventName] | ||
obj[onEventName] = () -> | ||
if typeof currentEventHandler == 'function' | ||
currentEventHandler.apply(this, arguments) | ||
callback.apply(this, arguments) | ||
|
||
exports.removeChildren = (element) -> | ||
argsToArray(element.children).forEach (x) -> | ||
element.removeChild(x) | ||
|
||
exports.replaceChildren = (id, node) -> | ||
parent = window.document.getElementById id | ||
underline.removeChildren parent | ||
parent.appendChild node | ||
|