Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 789 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
789 liveuser 1
<?php
2
 
839 liveuser 3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~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
 
789 liveuser 25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
28
#assets dir
29
$assetsDir="assets_of_javaScript::qbpwcfJavaScript_20240912";
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
	window.qbpwcf.openWindow.params.url='".$assetsDir."/blank.php';
80
 
81
	//設定開啟視窗後要作的事情
82
	window.qbpwcf.openWindow.actionAfterOpen=function(Window){
83
 
84
		//debug
85
		console.log(Window);
86
 
87
		//取得新視窗的document參考
88
		var documentInWindow=Window.document;
89
 
90
		//設置其body的內容
91
		documentInWindow.body.innerHTML='<h1>test</h1>';
92
 
93
		}//function end
94
 
95
	//開啟window
96
	await window.qbpwcf.openWindow.func();
97
 
98
	";
99
#可省略參數:
100
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
101
#$conf["onReady"]="true";
102
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
103
#$conf["globalJs"]=array();
104
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
105
#$conf["jsFunciton"]=array();
106
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
107
#$conf["noScriptTag"]="false";
108
#參考資料:
109
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
110
#備註:
111
#無.
112
$toScript=javaScript::toScript($conf);
113
unset($conf);
114
 
115
#如果執行失敗
116
if($toScript["status"]==="false"){
117
 
118
	#show detail info
119
	var_dump($toScript);
120
 
121
	#結束執行,並回傳shell 1.
122
	exit(1);
123
 
124
	}#if end
125
 
126
#印出js語法
127
echo $toScript["content"];