CWIS Developer Documentation
Public Member Functions | Public Attributes | List of all members
JavaScriptPacker Class Reference

Public Member Functions

 __construct ($_script, $_encoding=62, $_fastDecode=true, $_specialChars=false)
 
 pack ()
 

Public Attributes

const IGNORE = '$1'
 
const JSFUNCTION_unpack
 
const JSFUNCTION_decodeBody
 
const JSFUNCTION_encode10
 
const JSFUNCTION_encode36
 
const JSFUNCTION_encode62
 
const JSFUNCTION_encode95
 

Detailed Description

Definition at line 69 of file JavaScriptPacker.php.

Constructor & Destructor Documentation

JavaScriptPacker::__construct (   $_script,
  $_encoding = 62,
  $_fastDecode = true,
  $_specialChars = false 
)

Definition at line 86 of file JavaScriptPacker.php.

Member Function Documentation

JavaScriptPacker::pack ( )

Definition at line 96 of file JavaScriptPacker.php.

Member Data Documentation

const JavaScriptPacker::IGNORE = '$1'

Definition at line 71 of file JavaScriptPacker.php.

const JavaScriptPacker::JSFUNCTION_decodeBody
Initial value:
=
' if (!\'\'.replace(/^/, String)) {
// decode all the values we need
while ($count--) {
$decode[$encode($count)] = $keywords[$count] || $encode($count);
}
// global replacement function
$keywords = [function ($encoded) {return $decode[$encoded]}];
// generic match
$encode = function () {return \'\\\\w+\'};
// reset the loop counter - we are now doing a global replace
$count = 1;
}
'

Definition at line 475 of file JavaScriptPacker.php.

const JavaScriptPacker::JSFUNCTION_encode10
Initial value:
=
'function($charCode) {
return $charCode;
}'

Definition at line 509 of file JavaScriptPacker.php.

const JavaScriptPacker::JSFUNCTION_encode36
Initial value:
=
'function($charCode) {
return $charCode.toString(36);
}'

Definition at line 516 of file JavaScriptPacker.php.

const JavaScriptPacker::JSFUNCTION_encode62
Initial value:
=
'function($charCode) {
return ($charCode < _encoding ? \'\' : arguments.callee(parseInt($charCode / _encoding))) +
(($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36));
}'

Definition at line 523 of file JavaScriptPacker.php.

const JavaScriptPacker::JSFUNCTION_encode95
Initial value:
=
'function($charCode) {
return ($charCode < _encoding ? \'\' : arguments.callee($charCode / _encoding)) +
String.fromCharCode($charCode % _encoding + 161);
}'

Definition at line 531 of file JavaScriptPacker.php.

const JavaScriptPacker::JSFUNCTION_unpack
Initial value:
=
'function($packed, $ascii, $count, $keywords, $encode, $decode) {
while ($count--) {
if ($keywords[$count]) {
$packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]);
}
}
return $packed;
}'

Definition at line 455 of file JavaScriptPacker.php.


The documentation for this class was generated from the following file: