Giter Club home page Giter Club logo

coffeemarklet's Introduction

CoffeeMarklet

A little module for converting CoffeeScript to a bookmarklet.

What it does

  1. Compiles the CoffeeScript to Javascript using coffee-script.js
  2. Minifies the code using Google's Closure Compiler (Simple mode)
  3. Wraps the code for use as a bookmarklet, optionally with clever stuff by Ben Alman for loading jQuery.

Usage

The easiest way is to just use the tool here: http://johtso.github.com/CoffeeMarklet/


coffeemarklet(coffeescript, callback, [add_jquery, [jquery_version]])

coffeescript - String - The CoffeeScript to be converted.

callback - Function - The callback that will be passed the resulting bookmarklet.

add_jquery - Boolean - If true wraps the function in code adding jQuery to the page. Defaults to true.

jquery_version - String - The minimum jQuery version to be loaded.

Example

Source CoffeeScript:

alert ('Hello' for i in [0..5]).join(', ')

Resulting bookmarklet without jQuery:

javascript:(function(){var a;alert(function(){var b;b=[];for(a=0;a<=5;a++)b.push("Hello");return b}().join(", "))}).call(this);

And with jQuery:

javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.6.1",function($,L){alert("CoffeeScript and jQuery "+$.fn.jquery+"!");});

coffeemarklet's People

Contributors

johtso avatar rev22 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.