Permalink
Browse files

Built the flags list and wired it up.

  • Loading branch information...
1 parent dba6efe commit 7644d682541c88886930571259eb84110ecaa1a2 @SlexAxton committed Jan 19, 2011
Showing with 64 additions and 4 deletions.
  1. +40 −1 index.html
  2. +24 −3 js/uglifui.js
View
@@ -9,8 +9,47 @@
<h1>UglifUI</h1>
<form id="ugForm" action="" method="GET">
<fieldset>
+ <div id="flagContainer">
+ <h3>Flags</h3>
+ <ul id="flagList">
+ <li>
+ <label for="no-mangle">No Mangle</label>
+ <input type="checkbox" id="no-mangle" name="no-mangle" />
+ </li>
+ <li>
+ <label for="no-squeeze">No Squeeze</label>
+ <input type="checkbox" id="no-squeeze" name="no-squeeze" />
+ </li>
+ <li>
+ <label for="mangle-toplevel">Mangle Top-Level</label>
+ <input type="checkbox" id="mangle-toplevel" name="mangle-toplevel" />
+ </li>
+ <li>
+ <label for="no-seqs">No Sequences</label>
+ <input type="checkbox" id="no-seqs" name="no-seqs" />
+ </li>
+ <li>
+ <label for="no-dead-code">No Dead Code</label>
+ <input type="checkbox" id="no-dead-code" name="no-dead-code" />
+ </li>
+ <li>
+ <label for="no-copyright">No Copyright</label>
+ <input type="checkbox" id="no-copyright" name="no-copyright" /></li>
+ <li>
+ <label for="extra">Extra</label>
+ <input type="checkbox" id="extra" name="extra" checked="checked" /></li>
+ <li>
+ <label for="unsafe">Unsafe</label>
+ <input type="checkbox" id="unsafe" name="unsafe" checked="checked" /></li>
+ <li>
+ <label for="max-line-len">Max Line Len</label>
+ <input type="checkbox" id="max-line-len" name="max-line-len" />
+ <input type="number" id="linelen" name="linelen" />
+ </li>
+ </ul>
+ </div>
<label for="code">Code</label><br />
- <textarea rows="20" cols="105" id="code"></textarea>
+ <textarea rows="20" cols="105" id="code">(function( global ){ var lol = 5; lol = lol.toString(); })();</textarea>
<br />
<input type="submit" id="uglify" value="Uglify" />
</fieldset>
View
@@ -34,25 +34,46 @@
this.elements.ta_code = $('#code');
// The form element
this.elements.frm_uglify = $('#ugForm');
+ // List of flags
+ this.elements.ul_flags = $('#flagList');
},
getCode : function () {
return this.elements.ta_code.val();
},
getFlags : function () {
- return [];
+ var flags = [],
+ linelen = $('#max-line-len'),
+ lineval = global.parseInt( $('#linelen').val(), 10 );
+
+ // Loop through and add the correct flags
+ this.elements.ul_flags.find(':checked:not(#max-line-len)').each(function ( key, elem ) {
+ flags.push( '--' + elem.id );
+ });
+
+ // Special case for line len (with a sane minimum)
+ if ( linelen.is( ':checked' ) && lineval > 3 ) {
+ flags.push( '--max-line-len' );
+ flags.push( lineval + "" );
+ }
+
+ return flags;
},
submit : function () {
- this.elements.ta_code.val( uglify( this.getCode(), this.getFlags() ) );
+ var code = this.getCode(),
+ flags = this.getFlags();
+ console.log( code, flags );
+ this.elements.ta_code.val( uglify( code, flags ) );
},
hookEvents : function () {
var self = this;
// Hook up the submit event
- this.elements.frm_uglify.submit(function (){
+ this.elements.frm_uglify.submit(function ( e ) {
+ e.preventDefault();
self.submit();
return false;
});

0 comments on commit 7644d68

Please sign in to comment.