Created
December 17, 2011 05:37
-
-
Save aklaswad/1489353 to your computer and use it in GitHub Desktop.
LESS PAD
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>LESS PAD</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
| <script src="http://lesscss.googlecode.com/files/less-1.1.5.min.js"></script> | |
| <script> | |
| $( function () { | |
| var parser = new window.less.Parser(); | |
| var parse = function () { | |
| var src = $('#less').val(); | |
| try { | |
| parser.parse(src, function (err, tree) { | |
| if (err) { | |
| $('#error').text( err.message ).show(); | |
| } | |
| else { | |
| $('#error').hide(); | |
| $('#css').val(tree.toCSS()); | |
| } | |
| }); | |
| } | |
| catch (e) { | |
| $('#error').text( e.message ).show(); | |
| } | |
| }; | |
| $('#compile').on('click', parse); | |
| $('#auto-compile').on('change', function () { | |
| if ( $(this).is(':checked') ) | |
| $('#less').on( 'keyup', parse ); | |
| else | |
| $('#less').off( 'keyup', parse ); | |
| }); | |
| }); | |
| </script> | |
| <style> | |
| #less-editor { | |
| width: 50%; | |
| float: left; | |
| } | |
| #css-editor { | |
| width: 50%; | |
| float: right; | |
| } | |
| #less, #css { | |
| width: 80%; | |
| height: 500px; | |
| } | |
| #error { | |
| color: #f00; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="header"> | |
| <button id="compile">Compile</button> | |
| <span><input type="checkbox" id="auto-compile"/> Auto Compile</span> | |
| <span id="error"></span> | |
| </div> | |
| <div id="less-editor"> | |
| <h1>less</h1> | |
| <textarea id="less"></textarea> | |
| </div> | |
| <div id="css-editor"> | |
| <h1>css</h1> | |
| <textarea id="css"></textarea> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment