[ Index ]

PHP Cross Reference of YOURLS




/includes/vendor/ozh/bookmarkletgen/src/Ozh/Bookmarkletgen/ -> Bookmarkletgen.php (summary)

(no description)

File Size: 197 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Bookmarkletgen:: (7 methods):

Class: Bookmarkletgen  - X-Ref

BookmarkletGen : converts readable Javascript code into a bookmarklet link

Features :
- removes comments
- compresses code, not literal strings
function someName( param ) { alert( "this is a string" ) }
will return:
function%20someName(param){alert("this is a string")}
- wraps code into a self invoking function

This is basically a slightly enhanced PHP port of the excellent Bookmarklet Crunchinator

crunch( $code )   X-Ref
Main function, calls all others

param: string $code  Javascript code to bookmarkletify
return: string        Bookmarklet link

encodeURIComponent( $str )   X-Ref
PHP port of Javascript function encodeURIComponent

From http://stackoverflow.com/a/1734255/36850

param: string $str  String to encode
return: string       Encoded string

kill_comments( $code )   X-Ref
Kill comment lines and blocks

param: string $code  Commented Javascript code
return: string        Commentless code

compress_white_space( $code )   X-Ref
Compress white space

Remove some extraneous spaces and make the whole script a one liner

param: string $code  Javascript code
return: string        Compressed code

combine_strings( $code )   X-Ref
Combine any consecutive strings

In the case we have two consecutive quoted strings (eg: "hello" + "world"), save a couple more
length and combine them

param: string $code  Javascript code
return: string        Javascript code

replace_strings( $code )   X-Ref
Replace all literal strings (eg: "hello world") with a placeholder and collect them in an array

The idea is that strings cannot be trimmed or white-space optimized: take them out first before uglifying
the code, then we'll reinject them back in later

param: string $code  Javascript code
return: string        Javascript code with placeholders (eg "__1__") instead of literal strings

restore_strings( $code )   X-Ref
Restore literal strings by replacing their placeholders with actual strings

param: string $code  Javascript code with placeholders
return: string        Javascript code with actual strings

Generated: Sat Oct 1 05:10:01 2022 Cross-referenced by PHPXref 0.7.1