CMS  Version 3.9
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 74 of file javascript_packer.inc.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 91 of file javascript_packer.inc.

92  {
93  $this->_script = $_script . "\n";
94  if (array_key_exists($_encoding, $this->LITERAL_ENCODING))
95  $_encoding = $this->LITERAL_ENCODING[$_encoding];
96  $this->_encoding = min((int)$_encoding, 95);
97  $this->_fastDecode = $_fastDecode;
98  $this->_specialChars = $_specialChars;
99  }

Member Function Documentation

◆ pack()

JavaScriptPacker::pack ( )

Definition at line 101 of file javascript_packer.inc.

101  {
102  $this->_addParser('_basicCompression');
103  if ($this->_specialChars)
104  $this->_addParser('_encodeSpecialChars');
105  if ($this->_encoding)
106  $this->_addParser('_encodeKeywords');
107 
108  // go!
109  return $this->_pack($this->_script);
110  }

Member Data Documentation

◆ IGNORE

const JavaScriptPacker::IGNORE = '$1'

Definition at line 76 of file javascript_packer.inc.

◆ JSFUNCTION_decodeBody

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 480 of file javascript_packer.inc.

◆ JSFUNCTION_encode10

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

Definition at line 514 of file javascript_packer.inc.

◆ JSFUNCTION_encode36

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

Definition at line 521 of file javascript_packer.inc.

◆ JSFUNCTION_encode62

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 528 of file javascript_packer.inc.

◆ JSFUNCTION_encode95

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

Definition at line 536 of file javascript_packer.inc.

◆ JSFUNCTION_unpack

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 460 of file javascript_packer.inc.


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