Index: trunk/phase3/maintenance/minify.php |
— | — | @@ -0,0 +1,111 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Minify a file or set of files |
| 5 | + */ |
| 6 | + |
| 7 | +require_once( dirname( __FILE__ ) . '/Maintenance.php' ); |
| 8 | + |
| 9 | +class MinifyScript extends Maintenance { |
| 10 | + var $outDir; |
| 11 | + |
| 12 | + public function __construct() { |
| 13 | + parent::__construct(); |
| 14 | + $this->addOption( 'outfile', |
| 15 | + 'File for output. Only a single file may be specified for input.', |
| 16 | + false, true ); |
| 17 | + $this->addOption( 'outdir', |
| 18 | + "Directory for output. If this is not specified, and neither is --outfile, then the\n" . |
| 19 | + "output files will be sent to the same directories as the input files.", |
| 20 | + false, true ); |
| 21 | + $this->mDescription = "Minify a file or set of files.\n\n" . |
| 22 | + "If --outfile is not specified, then the output file names will have a .min extension\n" . |
| 23 | + "added, e.g. jquery.js -> jquery.min.js."; |
| 24 | + |
| 25 | + } |
| 26 | + |
| 27 | + public function execute() { |
| 28 | + if ( !count( $this->mArgs ) ) { |
| 29 | + $this->error( "minify.php: At least one input file must be specified." ); |
| 30 | + exit( 1 ); |
| 31 | + } |
| 32 | + |
| 33 | + if ( $this->hasOption( 'outfile' ) ) { |
| 34 | + if ( count( $this->mArgs ) > 1 ) { |
| 35 | + $this->error( '--outfile may only be used with a single input file.' ); |
| 36 | + exit( 1 ); |
| 37 | + } |
| 38 | + |
| 39 | + // Minify one file |
| 40 | + $this->minify( $this->getArg( 0 ), $this->getOption( 'outfile' ) ); |
| 41 | + return; |
| 42 | + } |
| 43 | + |
| 44 | + $outDir = $this->getOption( 'outdir', false ); |
| 45 | + |
| 46 | + foreach ( $this->mArgs as $arg ) { |
| 47 | + $inPath = realpath( $arg ); |
| 48 | + $inName = basename( $inPath ); |
| 49 | + $inDir = dirname( $inPath ); |
| 50 | + |
| 51 | + if ( strpos( $inName, '.min.' ) !== false ) { |
| 52 | + echo "Skipping $inName\n"; |
| 53 | + continue; |
| 54 | + } |
| 55 | + |
| 56 | + if ( !file_exists( $inPath ) ) { |
| 57 | + $this->error( "File does not exist: $arg" ); |
| 58 | + exit( 1 ); |
| 59 | + } |
| 60 | + |
| 61 | + $extension = $this->getExtension( $inName ); |
| 62 | + $outName = substr( $inName, 0, -strlen( $extension ) ) . 'min.' . $extension; |
| 63 | + if ( $outDir === false ) { |
| 64 | + $outPath = $inDir . '/' . $outName; |
| 65 | + } else { |
| 66 | + $outPath = $outDir . '/' . $outName; |
| 67 | + } |
| 68 | + |
| 69 | + $this->minify( $inPath, $outPath ); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + public function getExtension( $fileName ) { |
| 74 | + $dotPos = strrpos( $fileName, '.' ); |
| 75 | + if ( $dotPos === false ) { |
| 76 | + $this->error( "No file extension, cannot determine type: $arg" ); |
| 77 | + exit( 1 ); |
| 78 | + } |
| 79 | + return substr( $fileName, $dotPos + 1 ); |
| 80 | + } |
| 81 | + |
| 82 | + public function minify( $inPath, $outPath ) { |
| 83 | + $extension = $this->getExtension( $inPath ); |
| 84 | + echo basename( $inPath ) . ' -> ' . basename( $outPath ) . '...'; |
| 85 | + |
| 86 | + $inText = file_get_contents( $inPath ); |
| 87 | + if ( $inText === false ) { |
| 88 | + $this->error( "Unable to open file $inPath for reading." ); |
| 89 | + exit( 1 ); |
| 90 | + } |
| 91 | + $outFile = fopen( $outPath, 'w' ); |
| 92 | + if ( !$outFile ) { |
| 93 | + $this->error( "Unable to open file $outPath for writing." ); |
| 94 | + exit( 1 ); |
| 95 | + } |
| 96 | + |
| 97 | + switch ( $extension ) { |
| 98 | + case 'js': |
| 99 | + $outText = JSMin::minify( $inText ); |
| 100 | + break; |
| 101 | + default: |
| 102 | + $this->error( "No minifier defined for extension \"$extension\"" ); |
| 103 | + } |
| 104 | + |
| 105 | + fwrite( $outFile, $outText ); |
| 106 | + fclose( $outFile ); |
| 107 | + echo " ok\n"; |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +$maintClass = 'MinifyScript'; |
| 112 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/phase3/maintenance/minify.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 113 | + native |
Index: trunk/phase3/skins/common/jquery.js |
— | — | @@ -4377,71 +4377,8 @@ |
4378 | 4378 | }); |
4379 | 4379 | })(); |
4380 | 4380 | |
4381 | | -/* JavaScript for MediaWIki JS2 */ |
4382 | | - |
4383 | 4381 | /** |
4384 | | - * This is designed to be directly compatible with (and is essentially taken |
4385 | | - * directly from) the mv_embed code for bringing internationalized messages into |
4386 | | - * the JavaScript space. As such, if we get to the point of merging that stuff |
4387 | | - * into the main branch this code will be uneeded and probably cause issues. |
| 4382 | + * Add a suitable MW-specific alias |
4388 | 4383 | */ |
4389 | | - |
4390 | | -/** |
4391 | | - * Mimics the no-conflict method used by the js2 stuff |
4392 | | - */ |
4393 | 4384 | $j = jQuery.noConflict(); |
4394 | | -/** |
4395 | | - * Provides js2 compatible mw functions |
4396 | | - */ |
4397 | | -if( typeof mw == 'undefined' || !mw ){ |
4398 | | - mw = { }; |
4399 | | - /** |
4400 | | - * Provides js2 compatible onload hook |
4401 | | - * @param func Function to call when ready |
4402 | | - */ |
4403 | | - mw.ready = function( func ) { |
4404 | | - $j(document).ready( func ); |
4405 | | - } |
4406 | | - // Define a dummy mw.load function: |
4407 | | - mw.load = function( deps, callback ) { callback(); }; |
4408 | | - |
4409 | | - // Deinfe a dummy mw.loadDone function: |
4410 | | - mw.loadDone = function( className ) { }; |
4411 | | - |
4412 | | - // Creates global message object if not already in existence |
4413 | | - if ( !gMsg ) var gMsg = {}; |
4414 | | - |
4415 | | - /** |
4416 | | - * Caches a list of messages for later retrieval |
4417 | | - * @param {Object} msgSet Hash of key:value pairs of messages to cache |
4418 | | - */ |
4419 | | - mw.addMessages = function ( msgSet ){ |
4420 | | - for ( var i in msgSet ){ |
4421 | | - gMsg[ i ] = msgSet[i]; |
4422 | | - } |
4423 | | - } |
4424 | | - /** |
4425 | | - * Retieves a message from the global message cache, performing on-the-fly |
4426 | | - * replacements using MediaWiki message syntax ($1, $2, etc.) |
4427 | | - * @param {String} key Name of message as it is in MediaWiki |
4428 | | - * @param {Array} args Array of replacement arguments |
4429 | | - */ |
4430 | | - function gM( key, args ) { |
4431 | | - var ms = ''; |
4432 | | - if ( key in gMsg ) { |
4433 | | - ms = gMsg[ key ]; |
4434 | | - if ( typeof args == 'object' || typeof args == 'array' ) { |
4435 | | - for ( var v in args ){ |
4436 | | - var rep = '\$'+ ( parseInt(v) + 1 ); |
4437 | | - ms = ms.replace( rep, args[v]); |
4438 | | - } |
4439 | | - } else if ( typeof args =='string' || typeof args =='number' ) { |
4440 | | - ms = ms.replace( /\$1/, args ); |
4441 | | - } |
4442 | | - return ms; |
4443 | | - } else { |
4444 | | - return '[' + key + ']'; |
4445 | | - } |
4446 | | - } |
4447 | | - |
4448 | | -} |
| 4385 | + |
Index: trunk/phase3/skins/common/jquery.min.js |
— | — | @@ -430,7 +430,4 @@ |
431 | 431 | top+=Math.max(docElem.scrollTop,body.scrollTop),left+=Math.max(docElem.scrollLeft,body.scrollLeft);return{top:top,left:left};};jQuery.offset={initialize:function(){if(this.initialized)return;var body=document.body,container=document.createElement('div'),innerDiv,checkDiv,table,td,rules,prop,bodyMarginTop=body.style.marginTop,html='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';rules={position:'absolute',top:0,left:0,margin:0,border:0,width:'1px',height:'1px',visibility:'hidden'};for(prop in rules)container.style[prop]=rules[prop];container.innerHTML=html;body.insertBefore(container,body.firstChild);innerDiv=container.firstChild,checkDiv=innerDiv.firstChild,td=innerDiv.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(checkDiv.offsetTop!==5);this.doesAddBorderForTableAndCells=(td.offsetTop===5);innerDiv.style.overflow='hidden',innerDiv.style.position='relative';this.subtractsBorderForOverflowNotVisible=(checkDiv.offsetTop===-5);body.style.marginTop='1px';this.doesNotIncludeMarginInBodyOffset=(body.offsetTop===0);body.style.marginTop=bodyMarginTop;body.removeChild(container);this.initialized=true;},bodyOffset:function(body){jQuery.offset.initialized||jQuery.offset.initialize();var top=body.offsetTop,left=body.offsetLeft;if(jQuery.offset.doesNotIncludeMarginInBodyOffset) |
432 | 432 | top+=parseInt(jQuery.curCSS(body,'marginTop',true),10)||0,left+=parseInt(jQuery.curCSS(body,'marginLeft',true),10)||0;return{top:top,left:left};}};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};} |
433 | 433 | return results;},offsetParent:function(){var offsetParent=this[0].offsetParent||document.body;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static')) |
434 | | -offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return null;return val!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom",lower=name.toLowerCase();jQuery.fn["inner"+name]=function(){return this[0]?jQuery.css(this[0],lower,false,"padding"):null;};jQuery.fn["outer"+name]=function(margin){return this[0]?jQuery.css(this[0],lower,false,margin?"margin":"border"):null;};var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(document.documentElement["client"+name],document.body["scroll"+name],document.documentElement["scroll"+name],document.body["offset"+name],document.documentElement["offset"+name]):size===undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,typeof size==="string"?size:size+"px");};});})();$j=jQuery.noConflict();if(typeof mw=='undefined'||!mw){mw={};mw.ready=function(func){$j(document).ready(func);} |
435 | | -mw.load=function(deps,callback){callback();};mw.loadDone=function(className){};if(!gMsg)var gMsg={};mw.addMessages=function(msgSet){for(var i in msgSet){gMsg[i]=msgSet[i];}} |
436 | | -function gM(key,args){var ms='';if(key in gMsg){ms=gMsg[key];if(typeof args=='object'||typeof args=='array'){for(var v in args){var rep='\$'+(parseInt(v)+1);ms=ms.replace(rep,args[v]);}}else if(typeof args=='string'||typeof args=='number'){ms=ms.replace(/\$1/,args);} |
437 | | -return ms;}else{return'['+key+']';}}} |
\ No newline at end of file |
| 434 | +offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return null;return val!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom",lower=name.toLowerCase();jQuery.fn["inner"+name]=function(){return this[0]?jQuery.css(this[0],lower,false,"padding"):null;};jQuery.fn["outer"+name]=function(margin){return this[0]?jQuery.css(this[0],lower,false,margin?"margin":"border"):null;};var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(document.documentElement["client"+name],document.body["scroll"+name],document.documentElement["scroll"+name],document.body["offset"+name],document.documentElement["offset"+name]):size===undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,typeof size==="string"?size:size+"px");};});})();$j=jQuery.noConflict(); |
\ No newline at end of file |
Index: trunk/phase3/skins/common/Makefile |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +jquery.min.js: jquery.js |
| 3 | + php ../../maintenance/minify.php $< --outfile $@ |
Property changes on: trunk/phase3/skins/common/Makefile |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 4 | + native |
Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -1028,3 +1028,8 @@ |
1029 | 1029 | if ( ie6_bugs ) { |
1030 | 1030 | importScriptURI( stylepath + '/common/IEFixes.js' ); |
1031 | 1031 | } |
| 1032 | + |
| 1033 | +// For future use. |
| 1034 | +mw = {}; |
| 1035 | + |
| 1036 | + |
Index: trunk/phase3/includes/JSMin.php |
— | — | @@ -0,0 +1,291 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * jsmin.php - PHP implementation of Douglas Crockford's JSMin. |
| 5 | + * |
| 6 | + * This is pretty much a direct port of jsmin.c to PHP with just a few |
| 7 | + * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and |
| 8 | + * outputs to stdout, this library accepts a string as input and returns another |
| 9 | + * string as output. |
| 10 | + * |
| 11 | + * PHP 5 or higher is required. |
| 12 | + * |
| 13 | + * Permission is hereby granted to use this version of the library under the |
| 14 | + * same terms as jsmin.c, which has the following license: |
| 15 | + * |
| 16 | + * -- |
| 17 | + * Copyright (c) 2002 Douglas Crockford (www.crockford.com) |
| 18 | + * |
| 19 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 20 | + * this software and associated documentation files (the "Software"), to deal in |
| 21 | + * the Software without restriction, including without limitation the rights to |
| 22 | + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 23 | + * of the Software, and to permit persons to whom the Software is furnished to do |
| 24 | + * so, subject to the following conditions: |
| 25 | + * |
| 26 | + * The above copyright notice and this permission notice shall be included in all |
| 27 | + * copies or substantial portions of the Software. |
| 28 | + * |
| 29 | + * The Software shall be used for Good, not Evil. |
| 30 | + * |
| 31 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 32 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 33 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 34 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 35 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 36 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 37 | + * SOFTWARE. |
| 38 | + * -- |
| 39 | + * |
| 40 | + * @package JSMin |
| 41 | + * @author Ryan Grove <ryan@wonko.com> |
| 42 | + * @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c) |
| 43 | + * @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port) |
| 44 | + * @license http://opensource.org/licenses/mit-license.php MIT License |
| 45 | + * @version 1.1.1 (2008-03-02) |
| 46 | + * @link http://code.google.com/p/jsmin-php/ |
| 47 | + */ |
| 48 | + |
| 49 | +class JSMin { |
| 50 | + const ORD_LF = 10; |
| 51 | + const ORD_SPACE = 32; |
| 52 | + |
| 53 | + protected $a = ''; |
| 54 | + protected $b = ''; |
| 55 | + protected $input = ''; |
| 56 | + protected $inputIndex = 0; |
| 57 | + protected $inputLength = 0; |
| 58 | + protected $lookAhead = null; |
| 59 | + protected $output = ''; |
| 60 | + |
| 61 | + // -- Public Static Methods -------------------------------------------------- |
| 62 | + |
| 63 | + public static function minify($js) { |
| 64 | + $jsmin = new JSMin($js); |
| 65 | + return $jsmin->min(); |
| 66 | + } |
| 67 | + |
| 68 | + // -- Public Instance Methods ------------------------------------------------ |
| 69 | + |
| 70 | + public function __construct($input) { |
| 71 | + $this->input = str_replace("\r\n", "\n", $input); |
| 72 | + $this->inputLength = strlen($this->input); |
| 73 | + } |
| 74 | + |
| 75 | + // -- Protected Instance Methods --------------------------------------------- |
| 76 | + |
| 77 | + protected function action($d) { |
| 78 | + switch($d) { |
| 79 | + case 1: |
| 80 | + $this->output .= $this->a; |
| 81 | + |
| 82 | + case 2: |
| 83 | + $this->a = $this->b; |
| 84 | + |
| 85 | + if ($this->a === "'" || $this->a === '"') { |
| 86 | + for (;;) { |
| 87 | + $this->output .= $this->a; |
| 88 | + $this->a = $this->get(); |
| 89 | + |
| 90 | + if ($this->a === $this->b) { |
| 91 | + break; |
| 92 | + } |
| 93 | + |
| 94 | + if (ord($this->a) <= self::ORD_LF) { |
| 95 | + throw new JSMinException('Unterminated string literal.'); |
| 96 | + } |
| 97 | + |
| 98 | + if ($this->a === '\\') { |
| 99 | + $this->output .= $this->a; |
| 100 | + $this->a = $this->get(); |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + case 3: |
| 106 | + $this->b = $this->next(); |
| 107 | + |
| 108 | + if ($this->b === '/' && ( |
| 109 | + $this->a === '(' || $this->a === ',' || $this->a === '=' || |
| 110 | + $this->a === ':' || $this->a === '[' || $this->a === '!' || |
| 111 | + $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
| 112 | + |
| 113 | + $this->output .= $this->a . $this->b; |
| 114 | + |
| 115 | + for (;;) { |
| 116 | + $this->a = $this->get(); |
| 117 | + |
| 118 | + if ($this->a === '/') { |
| 119 | + break; |
| 120 | + } elseif ($this->a === '\\') { |
| 121 | + $this->output .= $this->a; |
| 122 | + $this->a = $this->get(); |
| 123 | + } elseif (ord($this->a) <= self::ORD_LF) { |
| 124 | + throw new JSMinException('Unterminated regular expression '. |
| 125 | + 'literal.'); |
| 126 | + } |
| 127 | + |
| 128 | + $this->output .= $this->a; |
| 129 | + } |
| 130 | + |
| 131 | + $this->b = $this->next(); |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + protected function get() { |
| 137 | + $c = $this->lookAhead; |
| 138 | + $this->lookAhead = null; |
| 139 | + |
| 140 | + if ($c === null) { |
| 141 | + if ($this->inputIndex < $this->inputLength) { |
| 142 | + $c = substr($this->input, $this->inputIndex, 1); |
| 143 | + $this->inputIndex += 1; |
| 144 | + } else { |
| 145 | + $c = null; |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + if ($c === "\r") { |
| 150 | + return "\n"; |
| 151 | + } |
| 152 | + |
| 153 | + if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
| 154 | + return $c; |
| 155 | + } |
| 156 | + |
| 157 | + return ' '; |
| 158 | + } |
| 159 | + |
| 160 | + protected function isAlphaNum($c) { |
| 161 | + return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
| 162 | + } |
| 163 | + |
| 164 | + protected function min() { |
| 165 | + $this->a = "\n"; |
| 166 | + $this->action(3); |
| 167 | + |
| 168 | + while ($this->a !== null) { |
| 169 | + switch ($this->a) { |
| 170 | + case ' ': |
| 171 | + if ($this->isAlphaNum($this->b)) { |
| 172 | + $this->action(1); |
| 173 | + } else { |
| 174 | + $this->action(2); |
| 175 | + } |
| 176 | + break; |
| 177 | + |
| 178 | + case "\n": |
| 179 | + switch ($this->b) { |
| 180 | + case '{': |
| 181 | + case '[': |
| 182 | + case '(': |
| 183 | + case '+': |
| 184 | + case '-': |
| 185 | + $this->action(1); |
| 186 | + break; |
| 187 | + |
| 188 | + case ' ': |
| 189 | + $this->action(3); |
| 190 | + break; |
| 191 | + |
| 192 | + default: |
| 193 | + if ($this->isAlphaNum($this->b)) { |
| 194 | + $this->action(1); |
| 195 | + } |
| 196 | + else { |
| 197 | + $this->action(2); |
| 198 | + } |
| 199 | + } |
| 200 | + break; |
| 201 | + |
| 202 | + default: |
| 203 | + switch ($this->b) { |
| 204 | + case ' ': |
| 205 | + if ($this->isAlphaNum($this->a)) { |
| 206 | + $this->action(1); |
| 207 | + break; |
| 208 | + } |
| 209 | + |
| 210 | + $this->action(3); |
| 211 | + break; |
| 212 | + |
| 213 | + case "\n": |
| 214 | + switch ($this->a) { |
| 215 | + case '}': |
| 216 | + case ']': |
| 217 | + case ')': |
| 218 | + case '+': |
| 219 | + case '-': |
| 220 | + case '"': |
| 221 | + case "'": |
| 222 | + $this->action(1); |
| 223 | + break; |
| 224 | + |
| 225 | + default: |
| 226 | + if ($this->isAlphaNum($this->a)) { |
| 227 | + $this->action(1); |
| 228 | + } |
| 229 | + else { |
| 230 | + $this->action(3); |
| 231 | + } |
| 232 | + } |
| 233 | + break; |
| 234 | + |
| 235 | + default: |
| 236 | + $this->action(1); |
| 237 | + break; |
| 238 | + } |
| 239 | + } |
| 240 | + } |
| 241 | + |
| 242 | + return $this->output; |
| 243 | + } |
| 244 | + |
| 245 | + protected function next() { |
| 246 | + $c = $this->get(); |
| 247 | + |
| 248 | + if ($c === '/') { |
| 249 | + switch($this->peek()) { |
| 250 | + case '/': |
| 251 | + for (;;) { |
| 252 | + $c = $this->get(); |
| 253 | + |
| 254 | + if (ord($c) <= self::ORD_LF) { |
| 255 | + return $c; |
| 256 | + } |
| 257 | + } |
| 258 | + |
| 259 | + case '*': |
| 260 | + $this->get(); |
| 261 | + |
| 262 | + for (;;) { |
| 263 | + switch($this->get()) { |
| 264 | + case '*': |
| 265 | + if ($this->peek() === '/') { |
| 266 | + $this->get(); |
| 267 | + return ' '; |
| 268 | + } |
| 269 | + break; |
| 270 | + |
| 271 | + case null: |
| 272 | + throw new JSMinException('Unterminated comment.'); |
| 273 | + } |
| 274 | + } |
| 275 | + |
| 276 | + default: |
| 277 | + return $c; |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + return $c; |
| 282 | + } |
| 283 | + |
| 284 | + protected function peek() { |
| 285 | + $this->lookAhead = $this->get(); |
| 286 | + return $this->lookAhead; |
| 287 | + } |
| 288 | +} |
| 289 | + |
| 290 | +// -- Exceptions --------------------------------------------------------------- |
| 291 | +class JSMinException extends Exception {} |
| 292 | +?> |
\ No newline at end of file |
Property changes on: trunk/phase3/includes/JSMin.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 293 | + native |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -132,6 +132,7 @@ |
133 | 133 | 'Interwiki' => 'includes/Interwiki.php', |
134 | 134 | 'IP' => 'includes/IP.php', |
135 | 135 | 'Job' => 'includes/JobQueue.php', |
| 136 | + 'JSMin' => 'includes/JSMin.php', |
136 | 137 | 'LCStore_DB' => 'includes/LocalisationCache.php', |
137 | 138 | 'LCStore_CDB' => 'includes/LocalisationCache.php', |
138 | 139 | 'LCStore_Null' => 'includes/LocalisationCache.php', |