forked from mattdiamond/fuckitjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mattdiamond#11 from leemachin/master
Obligatory CoffeeScript version
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
### | ||
FuckItJS v2.0.0-alpha | ||
Note: this is ALPHA software and may result in | ||
irreversible brain damage | ||
### | ||
|
||
$ -> | ||
|
||
$.ajaxSetup { cache: true } | ||
|
||
_FuckIt = window.FuckIt; | ||
|
||
FuckIt = (script) -> | ||
req = $.ajax { | ||
url: script, | ||
dataType: 'text' | ||
} | ||
|
||
success = (result) -> | ||
window.fuckedScript = result | ||
eval window.fuckedScript | ||
|
||
error = -> | ||
throw new Error "Could not load script: #{script}" | ||
|
||
req.then success, error | ||
|
||
window.onError = (error, url, line) -> | ||
if not window.fuckedScript then return | ||
|
||
parsed = window.fuckedScript.split "\n" | ||
parsed.splice line - 1, 1 | ||
|
||
window.fuckedScript = parsed.join "\n" | ||
|
||
$.getScript 'FuckIt.js', () -> | ||
eval window.fuckedScript | ||
|
||
return true | ||
|
||
FuckIt.noConflict = () -> | ||
window.FuckIt = _FuckIt | ||
FuckIt | ||
|
||
FuckIt.moreConflict = () -> | ||
window[prop] = FuckIt for prop in window when prop isnt 'location' | ||
|
||
window.FuckIt = FuckIt; |