Subversion Repositories php-qbpwcf

Rev

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

Rev Author Line No. Line
8 liveuser 1
<?php
2
 
3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
239 liveuser 6
    Copyright (C) 2014~2026 MIN ZHI, CHEN
8 liveuser 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_20240910";
30
 
226 liveuser 31
#產生 qbpwcfJavaScript
8 liveuser 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);
226 liveuser 57
 
8 liveuser 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 button=document.createElement('button');
226 liveuser 80
 
8 liveuser 81
	//設置按鈕上的文字
82
	button.innerText='click to choose file to upload';
226 liveuser 83
 
84
	//綁定按鈕的事件
8 liveuser 85
	button.addEventListener('click',async function()
86
	{
226 liveuser 87
 
8 liveuser 88
		//選擇要上傳的檔案
89
		await window.qbpwcf.clientFile.init();
226 liveuser 90
 
8 liveuser 91
	});
226 liveuser 92
 
8 liveuser 93
	//放置按鈕
94
	document.body.appendChild(button);
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);
226 liveuser 118
 
8 liveuser 119
	#結束執行,並回傳shell 1.
120
	exit(1);
121
 
122
	}#if end
123
 
124
#印出js語法
226 liveuser 125
echo $toScript["content"];