ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
JSMin_lib.php File Reference

Go to the source code of this file.

Data Structures

class  JSMinException
 Generic exception class related to JSMin. More...
class  FileOpenFailedJSMinException
 A JSMin exception indicating that a file provided for input or output could not be properly opened. More...
class  UnterminatedCommentJSMinException
 A JSMin exception indicating that an unterminated comment was encountered in input. More...
class  UnterminatedStringLiteralJSMinException
 A JSMin exception indicatig that an unterminated string literal was encountered in input. More...
class  UnterminatedRegExpLiteralJSMinException
 A JSMin exception indicatig that an unterminated regular expression lieteral was encountered in input. More...
class  JSMin
 Main JSMin application class. More...

Variables

const JSMIN_VERSION = '0.2'
 JSMin_lib.php (for PHP 4, 5)
const EOF = FALSE
 How fgetc() reports an End Of File.
const ORD_NL = ord("\n")
 Some ASCII character ordinals.
const ORD_space = ord(' ')
const ORD_cA = ord('A')
const ORD_cZ = ord('Z')
const ORD_a = ord('a')
const ORD_z = ord('z')
const ORD_0 = ord('0')
const ORD_9 = ord('9')
const JSMIN_ACT_FULL = 1
 Constant describing an action() : Output A.
const JSMIN_ACT_BUF = 2
 Constant describing an action() : Copy B to A.
const JSMIN_ACT_IMM = 3
 Constant describing an action() : Get the next B.

Variable Documentation

const EOF = FALSE

How fgetc() reports an End Of File.

N.B. : use === and not == to test the result of fgetc() ! (see manual)

Definition at line 92 of file JSMin_lib.php.

Referenced by HTML5\EOF(), JSMin\get(), JSMin\minify(), JSMin\next(), and JSMin\peek().

const JSMIN_ACT_BUF = 2

Constant describing an action() : Copy B to A.

Get the next B. (Delete A).

Definition at line 156 of file JSMin_lib.php.

Referenced by JSMin\action(), and JSMin\minify().

const JSMIN_ACT_FULL = 1

Constant describing an action() : Output A.

Copy B to A. Get the next B.

Definition at line 150 of file JSMin_lib.php.

Referenced by JSMin\action(), and JSMin\minify().

const JSMIN_ACT_IMM = 3

Constant describing an action() : Get the next B.

(Delete B).

Definition at line 162 of file JSMin_lib.php.

Referenced by JSMin\action(), and JSMin\minify().

const JSMIN_VERSION = '0.2'

JSMin_lib.php (for PHP 4, 5)

PHP adaptation of JSMin, published by Douglas Crockford as jsmin.c, also based on its Java translation by John Reilly.

Permission is hereby granted to use the PHP version under the same conditions as jsmin.c, which has the following notice :


Copyright (c) 2002 Douglas Crockford (www.crockford.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The Software shall be used for Good, not Evil.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Author
David Holmes dholm.nosp@m.es@c.nosp@m.fdsof.nosp@m.twar.nosp@m.e.net of CFD Labs, France
Gaetano Giunta
Version
Id:

Please note, this is a brutal and simple conversion : it could undoubtedly be improved, as a PHP implementation, by applying more PHP-specific programming features.

Exceptions and all PHP 5 - only features ahve been removed for compat with PHP 4

Note : whereas jsmin.c works specifically with the standard input and output streams, this implementation only falls back on them if file pathnames are not provided to the JSMin() constructor.

Examples comparing with the application compiled from jsmin.c :

jsmin < orig.js > mini.js JSMin.php orig.js mini.js JSMin.php orig.js > mini.js JSMin.php - mini.js < orig.js jsmin < orig.js JSMin.php orig.js JSMin.php orig.js - jsmin > mini.js JSMin.php - mini.js JSMin.php > mini.js jsmin comm1 comm2 < a.js > b.js JSMin.php a.js b.js comm1 comm2 JSMin.php a.js b.js -c comm1 comm2 JSMin.php a.js –comm comm1 comm2 > b.js JSMin.php -c comm1 comm2 < a.js > b.js (etc...)

See JSMin.php -h (or –help) for command-line documentation.

NEW AND IMPROVED in version 0.2: to take advantage of this file in your own code, you can do the following:

define('JSMIN_AS_LIB', true); // prevents auto-run on include include('jsmin.php'); // the JSMin class now works on php strings, too $jsMin = new JSMin(file_get_contents('e:/htdocs/awstats_misc_tracker.js'), false); // in that case, the modifies string is returned by minify(): $out = $jsMin->minify(); Version of this PHP translation.

Definition at line 85 of file JSMin_lib.php.

const ORD_0 = ord('0')

Definition at line 105 of file JSMin_lib.php.

Referenced by JSMin\isAlphaNum().

const ORD_9 = ord('9')

Definition at line 106 of file JSMin_lib.php.

Referenced by JSMin\isAlphaNum().

const ORD_a = ord('a')

Definition at line 103 of file JSMin_lib.php.

Referenced by JSMin\isAlphaNum().

const ORD_cA = ord('A')

Definition at line 101 of file JSMin_lib.php.

Referenced by JSMin\isAlphaNum().

const ORD_cZ = ord('Z')

Definition at line 102 of file JSMin_lib.php.

Referenced by JSMin\isAlphaNum().

const ORD_NL = ord("\n")

Some ASCII character ordinals.

N.B. : PHP identifiers are case-insensitive !

Definition at line 99 of file JSMin_lib.php.

Referenced by JSMin\action(), and JSMin\next().

const ORD_space = ord(' ')

Definition at line 100 of file JSMin_lib.php.

Referenced by JSMin\get().

const ORD_z = ord('z')

Definition at line 104 of file JSMin_lib.php.

Referenced by JSMin\isAlphaNum().