Subversion Repositories php-qbpwcf

Rev

Rev 226 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2026 MIN ZHI, CHEN

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/

#使用命名空間qbpwcf
namespace qbpwcf;

#assets dir
$assetsDir="assets_of_javaScript::qbpwcfJavaScript_20240912";

#產生 qbpwcfJavaScript
#函式說明:
#建立qbpwcf專屬的js函式庫
#回傳結果
#$result["funciton"],當前函式的名稱.
#$result["status"],執行的狀態,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息
#$result["content"],語法.
#必填參數:
#無.
#可省略參數:
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
$conf["noScriptTag"]="false";
#參考資料:
#無.
#備註:
#無.
$qbpwcfJavaScript=javaScript::qbpwcfJavaScript($conf);
unset($conf);

#如果產生失敗
if($qbpwcfJavaScript["status"]==="false")
{

        #show detail info
        var_dump($qbpwcfJavaScript);

        #結束執行,並回傳shell 1.
        exit(1);

}#if end

#印出 js
echo $qbpwcfJavaScript["content"];

#執行目標程式
#函式說明:
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
#回傳結果:
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
#$result["error"],錯誤訊息陣列
#$result["function"],當前執行的函數名稱
#$result["content"],要執行的javaScript語法
#必填參數:
#$conf["script"],字串,要執行的javaScript語法.
$conf["script"]="

        //設定空白頁面
        window.qbpwcf.openWindow.params.url='".$assetsDir."/blank.php';

        //設定開啟視窗後要作的事情
        window.qbpwcf.openWindow.actionAfterOpen=function(Window){

                //debug
                console.log(Window);

                //取得新視窗的document參考
                var documentInWindow=Window.document;

                //設置其body的內容
                documentInWindow.body.innerHTML='<h1>test</h1>';

                }//function end

        //開啟window
        await window.qbpwcf.openWindow.func();

        ";
#可省略參數:
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
#$conf["onReady"]="true";
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
#$conf["globalJs"]=array();
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
#$conf["jsFunciton"]=array();
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
#$conf["noScriptTag"]="false";
#參考資料:
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
#備註:
#無.
$toScript=javaScript::toScript($conf);
unset($conf);

#如果執行失敗
if($toScript["status"]==="false"){

        #show detail info
        var_dump($toScript);

        #結束執行,並回傳shell 1.
        exit(1);

        }#if end

#印出js語法
echo $toScript["content"];