Subversion Repositories qbpwcf-lib(archive)

Rev

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

Rev Author Line No. Line
785 liveuser 1
<?php
2
 
841 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
 
785 liveuser 25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
28
#assets dir
29
$assetsDir="assets of javaScript::qbpwcfJavaScript_20240911";
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 button=document.createElement('button');
80
 
81
	//設置按鈕上的文字
82
	button.innerText='click to choose file to upload';
83
 
84
	//綁定按鈕的事件	
85
	button.addEventListener('click',async function(){
86
 
87
		//選擇要上傳的檔案
88
		var file=await window.qbpwcf.clientFile.init();
89
 
90
		//當沒有選擇檔案時
91
		while(Object.keys(file).length===0){
92
 
93
			//debug
94
			console.log(file,Object.keys(file).length,'no file selected');
95
 
96
			//跳出while
97
			break;	
98
 
99
			}//while end
100
 
101
		});
102
 
103
	//放置按鈕
104
	document.body.appendChild(button);
105
 
106
	";
107
#可省略參數:
108
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
109
#$conf["onReady"]="true";
110
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
111
#$conf["globalJs"]=array();
112
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
113
#$conf["jsFunciton"]=array();
114
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
115
#$conf["noScriptTag"]="false";
116
#參考資料:
117
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
118
#備註:
119
#無.
120
$toScript=javaScript::toScript($conf);
121
unset($conf);
122
 
123
#如果執行失敗
124
if($toScript["status"]==="false"){
125
 
126
	#show detail info
127
	var_dump($toScript);
128
 
129
	#結束執行,並回傳shell 1.
130
	exit(1);
131
 
132
	}#if end
133
 
134
#印出js語法
135
echo $toScript["content"];