From 81f3340cd369e46cc5a8fe6517c5eba1106fa40f Mon Sep 17 00:00:00 2001 From: leemachin Date: Mon, 25 Jun 2012 22:42:45 +0100 Subject: [PATCH] Obligatory CoffeeScript version So you can fuck your Rails apps --- fuckit.coffee | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 fuckit.coffee diff --git a/fuckit.coffee b/fuckit.coffee new file mode 100644 index 0000000..b2f891c --- /dev/null +++ b/fuckit.coffee @@ -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;