コード例 #1
0
ファイル: jsmip.php プロジェクト: thatsme111/jsmip
 public function getMinifiedJavascript($filename)
 {
     //using google's closure compiler api
     $closure_compiler = new PhpClosure();
     $this->javascript = $closure_compiler->add($filename)->advancedMode()->useClosureLibrary()->hideDebugInfo()->write();
     // $filename = "../lib/jquery/jquery_closure_advance.js";
     // $this->javascript = file_get_contents($filename);
     //read variable declaration inside code
     $this->readAllFunctions();
     //set global variables
     $this->setGlobalVariables();
     //process literal and replace them by array position
     $this->processStringLiterals();
     //redefine function declaration replace function(){content} -> z("");
     $this->redefineFunctionDeclaration();
     // echo strlen($this->getJavascriptWithScope());
     return $this->getJavascriptWithScope();
 }
コード例 #2
0
    // convert codes to binary string
    $dictionary_count = 256;
    $bits = 8;
    // ceil(log($dictionary_count, 2))
    $return = "";
    $rest = 0;
    $rest_length = 0;
    foreach ($codes as $code) {
        $rest = ($rest << $bits) + $code;
        $rest_length += $bits;
        $dictionary_count++;
        if ($dictionary_count >> $bits) {
            $bits++;
        }
        while ($rest_length > 7) {
            $rest_length -= 8;
            $return .= chr($rest >> $rest_length);
            $rest &= (1 << $rest_length) - 1;
        }
    }
    return $return . ($rest_length ? chr($rest << 8 - $rest_length) : "");
}
//
// Now my stuff
//
$c = new PhpClosure();
if (!file_exists(sys_get_temp_dir() . "/js-cache/")) {
    @mkdir(sys_get_temp_dir() . "/js-cache/");
}
$c->add("../ajax-node.js")->add("QUnit.zag.js")->add("QUnit.tests.js")->godMode(false)->advancedMode()->cacheDir(sys_get_temp_dir() . "/js-cache/")->write();
コード例 #3
0
<?php

include "../php-closure.php";
$c = new PhpClosure();
$c->add("js/animation.js")->add("js/color.js")->advancedMode()->useClosureLibrary()->cacheDir("/tmp/js-cache/")->write();
コード例 #4
0
ファイル: example.php プロジェクト: sebcode/php-closure
<?php

define('LIB_DIR', getcwd() . 'lib/');
include LIB_DIR . 'third-party/php-closure.php';
$c = new PhpClosure();
$c->add('my-app.js')->addDir('/js/')->add('popup.js')->add('popup.soy')->advancedMode()->cacheDir('/tmp/js-cache/')->localCompile()->write();
コード例 #5
0
ファイル: combine.php プロジェクト: kxopa/WebSite-PHP
include "../config/config.inc.php";
include_once "utils_session.inc.php";
@session_set_cookie_params(0, "/", $_SERVER['SERVER_NAME'], false, true);
@session_name(formalize_to_variable(SITE_NAME));
@session_start();
$_GET['files'] = str_replace("|", "/", $_GET['files']);
if ($_GET['type'] == "js") {
    include "php-closure.php";
    $c = new PhpClosure();
    $nb_file = 0;
    $array_files = explode(',', $_GET['files']);
    for ($i = 0; $i < sizeof($array_files); $i++) {
        $file = "../js/" . $array_files[$i];
        $file2 = "../../" . $array_files[$i];
        if (file_exists($file) && is_file($file)) {
            $c->add($file);
            $nb_file++;
        } else {
            if (file_exists($file2) && is_file($file2)) {
                $c->add($file2);
                $nb_file++;
            } else {
                if (is_file($file)) {
                    echo "alert('Unable to load js file: " . $file . "');\n";
                } else {
                    if (is_file($file2)) {
                        echo "alert('Unable to load js file: " . $file2 . "');\n";
                    }
                }
            }
        }
コード例 #6
0
<?php

include "../php-closure.php";
$c = new PhpClosure();
$c->add("js/animation.js")->add("js/color.js")->advancedMode()->useClosureLibrary()->useCodeUrl("http://yourhost.com/php-closure/examples/")->cacheDir("/tmp/js-cache/")->write();