| 8 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
|
|
6 |
Copyright (C) 2014~2025 Min-Jhin,Chen
|
|
|
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
10 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
#使用命名空間qbpwcf
|
|
|
26 |
namespace qbpwcf;
|
|
|
27 |
|
|
|
28 |
#assets dir
|
|
|
29 |
$assetsDir="assets_of_javaScript::qbpwcfJavaScript_20241228";
|
|
|
30 |
|
|
|
31 |
#產生 qbpwcfJavaScript
|
|
|
32 |
#函式說明:
|
|
|
33 |
#建立qbpwcf專屬的js函式庫
|
|
|
34 |
#回傳結果
|
|
|
35 |
#$result["funciton"],當前函式的名稱.
|
|
|
36 |
#$result["status"],執行的狀態,"true"代表正常,"false"代表不正常.
|
|
|
37 |
#$result["error"],錯誤訊息
|
|
|
38 |
#$result["content"],語法.
|
|
|
39 |
#必填參數:
|
|
|
40 |
#無.
|
|
|
41 |
#可省略參數:
|
|
|
42 |
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
|
|
|
43 |
$conf["noScriptTag"]="false";
|
|
|
44 |
#參考資料:
|
|
|
45 |
#無.
|
|
|
46 |
#備註:
|
|
|
47 |
#無.
|
|
|
48 |
$qbpwcfJavaScript=javaScript::qbpwcfJavaScript($conf);
|
|
|
49 |
unset($conf);
|
|
|
50 |
|
|
|
51 |
#如果產生失敗
|
|
|
52 |
if($qbpwcfJavaScript["status"]==="false")
|
|
|
53 |
{
|
|
|
54 |
|
|
|
55 |
#show detail info
|
|
|
56 |
var_dump($qbpwcfJavaScript);
|
|
|
57 |
|
|
|
58 |
#結束執行,並回傳shell 1.
|
|
|
59 |
exit(1);
|
|
|
60 |
|
|
|
61 |
}#if end
|
|
|
62 |
|
|
|
63 |
#印出 js
|
|
|
64 |
echo $qbpwcfJavaScript["content"];
|
|
|
65 |
|
|
|
66 |
#執行目標程式
|
|
|
67 |
#函式說明:
|
|
|
68 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
69 |
#回傳結果:
|
|
|
70 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
71 |
#$result["error"],錯誤訊息陣列
|
|
|
72 |
#$result["function"],當前執行的函數名稱
|
|
|
73 |
#$result["content"],要執行的javaScript語法
|
|
|
74 |
#必填參數:
|
|
|
75 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
76 |
$conf["script"]="
|
|
|
77 |
|
|
|
78 |
//初始化參數
|
|
|
79 |
var params={};
|
|
|
80 |
|
|
|
81 |
//設定websocket位置
|
|
|
82 |
params.url='wss://sock-ws.qbpwcf.org';
|
|
|
83 |
|
|
|
84 |
//要傳輸的資料
|
|
|
85 |
params.data={};
|
|
|
86 |
|
|
|
87 |
//用來識別是所需要資料的id
|
|
|
88 |
params.data.id=crypto.randomUUID();
|
|
|
89 |
|
|
|
90 |
//取得對應的回應
|
|
|
91 |
var response=await window.qbpwcf.ws.init(params);
|
|
|
92 |
|
|
|
93 |
//debug
|
|
|
94 |
console.log(response);
|
|
|
95 |
|
|
|
96 |
";
|
|
|
97 |
#可省略參數:
|
|
|
98 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
99 |
#$conf["onReady"]="true";
|
|
|
100 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
101 |
#$conf["globalJs"]=array();
|
|
|
102 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
103 |
#$conf["jsFunciton"]=array();
|
|
|
104 |
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
|
|
|
105 |
#$conf["noScriptTag"]="false";
|
|
|
106 |
#參考資料:
|
|
|
107 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
108 |
#備註:
|
|
|
109 |
#無.
|
|
|
110 |
$toScript=javaScript::toScript($conf);
|
|
|
111 |
unset($conf);
|
|
|
112 |
|
|
|
113 |
#如果執行失敗
|
|
|
114 |
if($toScript["status"]==="false"){
|
|
|
115 |
|
|
|
116 |
#show detail info
|
|
|
117 |
var_dump($toScript);
|
|
|
118 |
|
|
|
119 |
#結束執行,並回傳shell 1.
|
|
|
120 |
exit(1);
|
|
|
121 |
|
|
|
122 |
}#if end
|
|
|
123 |
|
|
|
124 |
#印出js語法
|
|
|
125 |
echo $toScript["content"];
|