Rev 891 | Rev 911 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2024 Min-Jhin,ChenThis file is part of QBPWCF.QBPWCF is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with QBPWCF. If not, see <http://www.gnu.org/licenses/>.*/namespace qbpwcf;/*類別說明:javaScript應用的類別.備註:無.*/class javaScript{/*#函式說明:#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#必填參數:#$method,物件,為物件實體或類別名稱,會自動置入該參數.#$arguments,陣列,為呼叫方法時所用的參數.#參考資料:#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic*/public function __call($method,$arguments){#取得當前執行的函式$result["function"]=__FUNCTION__;#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";#設置所丟入的參數$result["error"][]=$arguments;#回傳結果return $result;}#function __call end/*#函式說明:#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#必填參數:#$method,物件,為物件實體或類別名稱,會自動置入該參數.#$arguments,陣列,為呼叫方法時所用的參數.#參考資料:#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic*/public static function __callStatic($method,$arguments){#取得當前執行的函式$result["function"]=__FUNCTION__;#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";#設置所丟入的參數$result["error"][]=$arguments;#回傳結果return $result;}#function __callStatic end/*#函式說明:#script 語法開始#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列.#$result["warning"],警告訊息陣列.#$result["founded"],識別是否有找到要匯入的js檔案,若有指定jsPosition參數才會回傳該結果.#$result["function"],當前執行的函數名稱.#$result["content"],javaScript語法.#$result["argv"], 使用的參數.#必填參數:#$conf["include"],字串,是否要匯入外部js庫,"true"爲要匯入;"false"爲沒有要匯入。$conf["include"]="true";#可省略參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置,預設為當前檔案的位置.#$conf["fileArgu"]=__FILE__;#$conf["jsPosition"],字串,要匯入的js檔案位置,請與參數"fileArgu"一起設置,用了該參數後,該<script src="jsFileAddr"></script>裡面放的程式將不會運作.#$conf["jsPosition"]="";#$conf["web"],字串,true代表是網頁系統的位置,"false"代表是檔案系統的位置,預設為"true".#$conf["web"]="true";#$conf["allowNotExist"],字串,預設為"true",代表允許js檔案於server端檢查後不存在的結果;反之為"false".#$conf["allowNotExist"]="true";#$conf["importWhenExist"],字串,預設為"true",代表有存在才輸出匯入的語法;反之為"false".#$conf["importWhenExist"]="true";#參考資料:#無.#備註:#無.*/public static function start(&$conf){#初始化要回傳的變數$result=array();#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#記錄當前執行的函數名稱$result["argv"]=$conf;#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("include");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("jsPosition","web","fileArgu","allowNotExist","importWhenExist");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"true",__FILE__,"true","true");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果 $conf["include"] 其值爲 "true"if($conf["include"]==="true"){#如果 $conf["jsPosition"] 有設定if(isset($conf["jsPosition"])){#var_dump($conf["jsPosition"]);#轉換成檔案系統路徑#函式說明:#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.#回傳結果:#$result["status"],"true"爲建立成功,"false"爲建立失敗.#$result["error"],錯誤訊息陣列.#$result["function"],函數名稱.#$result["argu"],使用的參數.#$result["content"],網址,若是在命令列執行,則為"null".#$result["webPathFromRoot"],相對於網頁根目錄的路徑.#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.#必填參數:#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["jsPosition"];#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];#可省略參數:#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];#備註:#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);unset($conf["fileAccess::getInternetAddressV2"]);#var_dump($getInternetAddressV2);#如果檢查不通過if($getInternetAddressV2["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$getInternetAddressV2;#回傳結果return $result;}#if end#用成網路位置$conf["jsPosition"]=$getInternetAddressV2["content"];#檢查要匯入的js檔案是否存在#函式說明:檢查多個檔案與資料夾是否存在.#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息陣列.#$resutl["function"],當前執行的涵式名稱.#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。#必填參數:$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["jsPosition"]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];#可省略參數#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".$conf["fileAccess::checkMultiFileExist"]["disableWebSearch"]="false";#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,於設為"true".$conf["fileAccess::checkMultiFileExist"]["web"]="true";#參考資料來源:#http://php.net/manual/en/function.file-exists.php#http://php.net/manual/en/control-structures.foreach.php$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);unset($conf["fileAccess::checkMultiFileExist"]);#debug#var_dump($checkMultiFileExist);#如果檢查要匯入的js檔案失敗if($checkMultiFileExist["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkMultiFileExist;#回傳結果return $result;}#if end#如果檢查要匯入的js檔案不存在if($checkMultiFileExist["varExist"][0]=="false"){#設置沒有找到 js 檔案$result["founded"]="false";#如果不允許 server 端找不到 js 檔案if($conf["allowNotExist"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"][]="要匯入的js檔案「".$checkMultiFileExist["varName"][0]."」不存在";#取得原生的錯誤訊息$result["error"][]=$checkMultiFileExist;#回傳結果return $result;}#if end#執行到這邊代表允許 server 端找不到 js 檔案#設置警告提示$result["warning"][]="要匯入的js檔案「".$checkMultiFileExist["varName"][0]."」不存在";}#if end#反之else{#設置有找到 js 檔案$result["founded"]="true";}#else end#設定要匯入的js函式庫$conf["jsPosition"]=" src=\"".$checkMultiFileExist["varNameWebPath"][0]."\" ";}#if end#反之else{#將$conf["jsPosition"]設爲空字串$conf["jsPosition"]="";}#else end}#if end#反之else{#將$conf["jsPosition"]設爲空字串$conf["jsPosition"]="";}#else end#debug#var_dump($result);#如果有是找到js檔案的識別if(isset($result["founded"])){#如果找不到js檔案,且沒有要求也要輸出匯入js的標籤if( $result["founded"]==="false" && $conf["importWhenExist"]==="true" ){#清空匯入js的標籤$conf["jsPosition"]="";}#if end}#if end#設置要回傳javascript語法$result["content"]="<script type=\"text/javascript\" ".$conf["jsPosition"]." >";#設置執行正常$result["status"]="true";#回傳結果return $result;}#function start end/*#函式說明:#script 語法結束#script 語法開始#回傳結果:#javaScript語法#必填參數:#無.#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function end(){return "</script>";}#function end/*#函式說明:#彈出視窗#回傳結果:#$result["status"],執行正確與否,"true"為執行正確,"false"為執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],JavaScript語法.#$result["function"],當前執行的函數名稱#必填參數:#$conf["alertSentence"],字串,爲要彈出式視窗的內容,"\\n"代表換行.$conf["alertSentence"]="";#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function alertWindow(&$conf){#初始化要回傳的內容$result=array();#當前執行的函數名稱$result["function"]=__FUNCTION__;#初始化要回傳的語法$result["content"]="";#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("alertSentence");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("closeWindow");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#debug#var_dump($checkResult);#exit;#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果 $conf["alertSentence"] 不存在的話"if(!isset($conf["alertSentence"])){#設置錯誤識別$result["status"]="false";#設置錯誤訊息$result["error"][]="\$conf[\"alertSentence\"]參數未設定";#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#函式說明:#script 語法開始#回傳結果:#javaScript語法#必填參數:$conf["javaScript"]["start"]["include"]="false";#是否要匯入外部js庫。"true"爲要匯入;"false"爲沒有要匯入。#可省略參數:#$conf["jsPosition"]="";#要匯入的js檔案位置。$javaScriptStart=javaScript::start($conf["javaScript"]["start"]);unset($conf["javaScript"]["start"]);#如果 js 語法開始失敗if($javaScriptStart["status"]=="false"){#設置錯誤識別$result["status"]="false";#設置錯誤訊息$result["error"]=$javaScriptStart;#回傳結果return $result;}#if end#串接js開始的語法$result["content"]=$result["content"].$javaScriptStart["content"];#增加出現警示視窗的語法$result["content"]=$result["content"]."alert('".$conf["alertSentence"]."');";#javaScript結束$result["content"]=$result["content"].javaScript::end();#執行到這邊代表執行成功#設置執行正常$result["status"]="true";#回傳結果return $result;}#function alertWindos end/*#函式說明:#若存在sessions變數則將其內容用彈出式視窗呈現,並移除session的內容.#回傳結果:#$result["status"],執行正確與否,"true"為執行正確,"false"為執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],彈出視窗的語法.#$result["function"],函式名稱.#必填參數:#$conf["sessionName"],字串,session變數的key名稱.$conf["sessionName"]="";#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function alertWindowFromSession($conf){#初始化要回傳的內容$result=array();#當前執行的函數名稱$result["function"]=__FUNCTION__;#初始化要回傳的語法$result["content"]="";#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("sessionName");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("closeWindow");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#debug#var_dump($checkResult);#exit;#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#函式說明:#取得session變數裡面的數值,然後卸除該session變數#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表有誤.#$result["error"],錯誤訊息#$result["warning"],警告訊息#$result["founded"],是否找到session變數,"true"代表找到,"false"代表沒找到.#$result["content"],取得的變數內容#必填參數:$conf["session"]["getSessionValue"]["sessionVarName"]=$conf["sessionName"];#要取得內容的session變數#可省略參數:$conf["session"]["getSessionValue"]["unsetSessionVar"]="true";#"true"代表要卸除session變數#參考資料:#http://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available#可變變數->http://emn178.pixnet.net/blog/post/80119035-php%E6%95%99%E5%AD%B8---%E8%AE%8A%E6%95%B8%28variables%29#卸除參考的原始變數->http://stackoverflow.com/questions/6654538/php-function-to-unset-variables-passed-by-reference$getSessionValue=session::getSessionValue($conf["session"]["getSessionValue"]);unset($conf["session"]["getSessionValue"]);#如果 $getSessionValue["status"] 等於 "false"if($getSessionValue["status"]=="false"){#設置錯誤識別$result["status"]="false";#設置錯誤訊息$result["error"]=$getSessionValue;#回傳結果return $result;}#if end#如果找不到session變數if($getSessionValue["founded"]=="false"){#設置語法為空$result["content"]="";#設置警告訊息$result["warning"][]="名為「".$conf["sessionName"]."」的session變數不存在";#設置執行正常$result["status"]="true";#回傳結果return $result;}#if end#取得session變數的內容$msg=$getSessionValue["content"];#函式說明:#彈出視窗#回傳結果:#$result["status"],執行正確與否,"true"為執行正確,"false"為執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],avaScript語法.#必填的參數$conf["javaScript"]["alertWindow"]["alertSentence"]=$msg;#爲要彈出式視窗的內容。$js=javaScript::alertWindow($conf["javaScript"]["alertWindow"]);unset($conf["javaScript"]["alertWindow"]);#如果 $js["status"] 等於 "false"if($js["status"]=="false"){#設置錯誤識別$result["status"]="false";#設置錯誤訊息$result["error"]=$js;#回傳結果return $result;}#if end#取得彈出視窗的語法$result["content"]=$js["content"];#設置錯誤識別$result["status"]="true";#回傳結果return $result;}#function alertWindowFromSession end/*#函式說明:#根據sesssion變數的內容來彈出視窗來進行提示#回傳內容:#$result["status"],執行是否正常,"true"代表執行正常,"false"代表執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],javaScript語法,當session變數無法取得時,將會回傳"".#$result["function"],當前執行的函數名稱#必填參數:$conf["sessionName"]="";#要取得的session變數名稱.#可省略參數:#$conf["altMethod"]="true";#爲當彈出式視窗無法使用時,可以改用的臨時處理辦法。若爲"true",則代表要採用臨時的應變措施,預設為"false".#參考資料:#無.#備註:#功能需要確認*/public static function alertSessionVarWindows(&$conf){#初始化要回傳的內容$result=array();#當前執行的函數名稱$result["function"]=__FUNCTION__;#初始化要回傳的語法$result["content"]="";#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("sessionName");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("altMethod");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#函式說明:#取得session變數裡面的數值,然後卸除該session變數#回傳結果:#$result,取得的變數內容#必填參數:$conf["session"]["getSessionValue"]["sessionVarName"]=$conf["sessionName"];#要取得內容的session變數#可省略參數:$conf["session"]["getSessionValue"]["unsetSessionVar"]="true";#"true"代表要卸除session變數#參考資料:#http://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available#可變變數->http://emn178.pixnet.net/blog/post/80119035-php%E6%95%99%E5%AD%B8---%E8%AE%8A%E6%95%B8%28variables%29#卸除參考的原始變數->http://stackoverflow.com/questions/6654538/php-function-to-unset-variables-passed-by-reference$assignSessionValueToVar=session::getSessionValue($conf["session"]["getSessionValue"]);unset($conf["session"]["getSessionValue"]);#如果 $assignSessionValueToVar["status"] 等於 "false"if($assignSessionValueToVar["status"]=="false"){#設置執行錯誤識別$result["status"]="false";#設置錯誤訊息$result["error"]=$assignSessionValueToVar;#回傳結果return $result;}#if end#如果 $assignSessionValueToVar["founded"] 等於 "false"if($assignSessionValueToVar["founded"]=="false"){#設置語法內容$result["content"]="";#執行到這邊代表執行成功,設置執行成功識別$result["status"]="true";#回傳結果return $result;}#if end#若 $conf["altMethod"] 爲 "true"if($conf["altMethod"]=="true"){#用應變措施來印出提示文字。$result["content"]="<center><p><font color=red><strong><b>".$assignSessionValueToVar["content"]."</strong></b></font><p></center>";#設置執行成功$result["status"]="true";#回傳結果return $result;}#if end#函式說明:#彈出視窗#回傳結果:#$result["status"],執行正確與否,"true"為執行正確,"false"為執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],avaScript語法.#必填的參數$conf["javaScript"]["alertWindow"]["alertSentence"]=$assignSessionValueToVar["content"];#爲要彈出式視窗的內容。$javaScript["alertWindow"]=javaScript::alertWindow($conf["javaScript"]["alertWindow"]);unset($conf["javaScript"]["alertWindow"]);#如果 $javaScript["alertWindow"]["status"] 等於 "false"if($javaScript["alertWindow"]["status"]=="false"){#設置執行錯誤識別$result["status"]="false";#設置錯誤訊息$result["error"]=$javaScript["alertWindow"];#回傳結果return $result;}#if end#設置語法內容$result["content"]=$javaScript["alertWindow"]["content"];#執行到這邊代表執行成功,設置執行成功識別$result["status"]="true";#回傳結果return $result;}#alertSessionVarWindows end/*#函式說明:#改變背景顏色#回傳結果:#$result["status"],執行正確與否,"true"為執行正確,"false"為執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],彈出視窗的語法.#$result["function"],函式名稱.#必填參數:#$conf["color"],字串,爲要改變成什麼顏色,ex 'pink' 'blue' 'green' 'white' 'black' 'red' 'orange'$conf["color"]="";#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function changeBackgroundColor($conf){#初始化要回傳的內容$result=array();#當前執行的函數名稱$result["function"]=__FUNCTION__;#初始化要回傳的語法$result["content"]="";#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("color");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("closeWindow");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#設定背景顏色$script="document.bgColor='".$conf["color"]."'";#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]=$script;#可省略參數:#$conf["onReady"],字串,是否要在網頁載入完再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立script語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行成功識別$result["status"]="true";#回傳結果return $result;}#function changeBackgroundColor end/*#函式說明:#建立透過javaScript傳送post數值到特定頁面,並且取得頁面的回應,將之結果放置在特定的區塊裏面的js函式.#回傳結果:#$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],JavaScript的語法#$result["function"],當前執行的函數名稱#必填參數:#$conf["receivePage"],字串,要接收數值的頁面.$conf["receivePage"]="";#$conf["jsFunctionName"],字串,ajax裏面的js涵式名稱.$conf["jsFunctionName"]="";#可省略參數:#$conf["scriptTag"],是否要用<script></script>包住,預設為"false",不包住;"true"為包住.#$conf["scriptTag"]="false";#$conf["varNameArray"],字串陣列,要傳送的數值名稱,預設為array("is_ajax").#$conf["varNameArray"]=array("is_ajax");#$conf["varValueArray"],陣列,要傳送的數值內容,預設為array("true");#$conf["varValueArray"]=array("true");#$conf["jsVarNameArray"],字串陣列,要傳送的js數值名稱.$conf["jsVarNameArray"]=array("");#$conf["jsVarValueArray"],陣列,要傳送的js數值內容.$conf["jsVarValueArray"]=array("");#$conf["responsePalaceId"],字串,回傳的內容要呈現於哪個<span id = ? ></span>、<div id= ? ></div>區塊之間。#$conf["responsePalaceId"]="";#$conf["condition"],字串,立即執行ajax的條件.#$conf["condition"]="";#$conf["conditionComment"],字串,立即執行ajax的條件註解,預設為$conf["condition"].#$conf["conditionComment"]="";#$conf["sendNow"],字串,是否要在document.ready後馬上執行ajax,預設為"false",代表不要,"true"代表要.#$conf["sendNow"]="false";#$conf["redir_url"],字串,是否要在要求成功後進行轉址的動作,轉址到$conf["redir_url"],若存在$conf["successAction"],則以$conf["successAction"]為主.#$conf["redir_url"]="";#$conf["successAction"],字串,ajax要求成功後做的事情.#$conf["successAction"]="";#參考資料:#http://www.w3school.com.cn/php/php_ajax_suggest.asp#建議允許不傳送任何get參數.#備註:#無.*/public static function ajaxSendPostValue($conf){#初始化要回傳的內容$result=array();#當前執行的函數名稱$result["function"]=__FUNCTION__;#初始化要回傳的語法$result["content"]="";#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("receivePage","jsFunctionName");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("scriptTag","responsePalaceId","sendNow","varNameArray","varValueArray","jsVarNameArray","jsVarValueArray","redir_url","successAction","condition","conditionComment");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","array","array","array","array","string","string","string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false",null,"false",array("is_ajax"),array("true"),null,null,null,null,null,null);#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("varValueArray","jsFunctionName");$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("jsVarNameArray","jsVarValueArray");#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#初始化儲存要傳送的post變數$sendStr=array();#有幾個 $conf["varNameArray"] 就執行幾次for($i=0;$i<count($conf["varNameArray"]);$i++){#設置post變數$sendStr[$conf["varNameArray"][$i]]=$conf["varValueArray"][$i];}#for end#轉成 url encode 格式$sendStr=http_build_query($sendStr);#如果存在 $conf["jsVarNameArray"]if(isset($conf["jsVarNameArray"])){#針對每個js變數for($i=0;$i<count($conf["jsVarNameArray"]);$i++){#串接js變數$sendStr=$sendStr."'+'&".$conf["jsVarNameArray"][$i]."='+".$conf["jsVarValueArray"][$i];#如果是最後一筆if($i===(count($conf["jsVarNameArray"])-1)){#補上 "+'"$sendStr=$sendStr."+'";}#if end}#foreach end}#if end#初始化馬上執行ajax的js語法$sendNow="";#如果 $conf["sendNow"] 為 "true"...if($conf["sendNow"]==="true"){#設置馬上執行ajax$sendNow=$conf["jsFunctionName"]."();";}#if end#設置不對回應做處理$actionWhenGotResponse="";#如果有設置 $conf["responsePalaceId"]if(isset($conf["responsePalaceId"])){#設置收到ajax的回應後要把內容吐到特定id的標籤裡面$actionWhenGotResponse="document.getElementById('".$conf["responsePalaceId"]."').innerHTML=xmlhttp.responseText;";}#if end#如果有設置 $conf["redir_url"]if(isset($conf["redir_url"])){#設置要轉址$actionWhenGotResponse="window.location.href='".$conf["redir_url"]."'";}#if end#如果有設置 $conf["successAction"]if(isset($conf["successAction"])){#設置ajax成功要做的事情$actionWhenGotResponse=$conf["successAction"];}#if end//js函數的開頭$scriptHead="//傳送post變數到指定頁面。function ".$conf["jsFunctionName"]."(){";//js函數的結尾$scriptTail="}//js function end";#建立 XMLDoc,傳值$script="//建立 XMLDocif(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}//if endelse{// code for IE6, IE5xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}//else end//如果服務端有回傳完稱的狀態xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState==4 && xmlhttp.status==200){//將回應進行處理".$actionWhenGotResponse."}//if end}//function end//設定要求的屬性、目的、是否不要同步xmlhttp.open('POST','".$conf["receivePage"]."',true);//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定 要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//要傳送的數值名稱與數值內容,ex:num1=100&num2=50xmlhttp.send('".$sendStr."');";#如果有執行的條件if(isset($conf["condition"])){#函式說明:#javascript的if...esle if...判斷式.#回傳結果:#$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],JavaScript的語法#$result["function"],當前執行的函數名稱#必填參數:#無:#可省略參數:#$conf["scriptTag"],是否要用<script></script>包住,預設為"false",不包住;"true"為包住.#$conf["scriptTag"]="false";#$conf["condition"],陣列,每個判斷式的條件,若有多個則會依序判斷下去.$conf["javascript::jsIf"]["condition"]=array($conf["condition"]);#如果有設定條件註解if(isset($conf["conditionComment"])){#$conf["conditionComment"],陣列,每個判斷式的註解,預設為$conf["condition"].$conf["javascript::jsIf"]["conditionComment"]=array($conf["conditionComment"]);}#if end#$conf["todo"],陣列,每個判斷式成立時要做的事情.$conf["javascript::jsIf"]["todo"]=array($script);#$conf["todoComment"],陣列,每件要做的事情之註解,預設為"do something...".$conf["javascript::jsIf"]["todoComment"]=array("start ajax...");$jsIf=javascript::jsIf($conf["javascript::jsIf"]);unset($conf["javascript::jsIf"]);#如果設置條件失敗if($jsIf["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$jsIf;#回傳結果return $result;}#if end#設置執行函式的條件$script=$jsIf["content"];}#if end#組合成完整的js函數$script=$scriptHead.$script.$scriptTail;#如果要將script用<script></script>包住.if($conf["scriptTag"]==="true"){#建立完整的<script>#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$sendNow;#可省略參數:#$conf["onReady"],字串,是否要在網頁載入完再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.$conf["javaScript::toScript"]["jsFunciton"]=array($script);#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#反之else{#取得js語法$result["content"]=$script;}#else end#執行到這代表執行成功$result["status"]="true";#回傳javascript語法return $result;}# function sendPostValue end/*#函式說明:#透過javaScript傳送get數值到特定頁面,並且取得頁面的回應,將之結果放置在特定的區塊裏面。#回傳的內容:#$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],JavaScript的語法#$result["function"],當前執行的函數名稱#必填參數:#$conf["receivePage"],字串,要接收數值的頁面。$conf["receivePage"]="";#$conf["var"],陣列,要傳送的變數名稱與內容,$conf["var"]["name"]=$value,代表變數名為$name,值為$value.$conf["var"]=array();#$conf["jsFunctionName"],字串,ajax裏面的js涵式名稱,使用該function的範例 jsFunction(this.value) ,這樣就會把表單的數值傳進去$conf["jsFunctionName"]="";#可省略參數:#$conf["responsePalaceId"],字串,回傳的內容要呈現於哪個<span id = ? ></span>、<div id= ? ></div>區塊之間。#$conf["responsePalaceId"]="";#$conf["sendNow"],字串,是否要在document.ready後馬上執行ajax,預設為"false",代表不要,"true"代表要.#$conf["sendNow"]="false";#參考資料:#http://www.w3school.com.cn/php/php_ajax_suggest.asp#http://www.w3schools.com/php/php_ajax_php.asp#備註:#無.*/public static function ajaxSendGetValue($conf){#初始化要回傳的內容$result=array();#初始化要回傳的語法$result["content"]="";#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("receivePage","var","jsFunctionName");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("responsePalaceId","sendNow");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#初始化馬上執行ajax的js語法$sendNow="";#如果 $conf["sendNow"] 為 "true"...if($conf["sendNow"]==="true"){#設置馬上執行ajax$sendNow=$conf["jsFunctionName"]."();";}#if end#設置不對回應做處理$actionWhenGotResponse="";#如果有設置 $conf["responsePalaceId"]if(isset($conf["responsePalaceId"])){#設置收到ajax的回應後要把內容吐到特定id的標籤裡面$actionWhenGotResponse="document.getElementById('".$conf["responsePalaceId"]."').innerHTML=xmlhttp.responseText;";}#if end#url_encode get request$conf["var"]="?".http_build_query($conf["var"]);#建立ajax的script#傳送post變數到指定頁面的函式開始.$script="function ".$conf["jsFunctionName"]."(){if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}//if endelse{// code for IE6, IE5xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}// else end//如果服務端有回傳完稱的狀態xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState==4 && xmlhttp.status==200){//將回應進行處理".$actionWhenGotResponse."}//if end}//function end//設定要用get傳送的數值xmlhttp.open('GET','".$conf["receivePage"].$conf["var"]."',true);//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//傳送要求xmlhttp.send();}//function end";#建立完整的<script>#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$sendNow;#可省略參數:#$conf["onReady"],字串,是否要在網頁載入完再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.$conf["javaScript::toScript"]["jsFunciton"]=array($script);#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#執行到這代表執行成功$result["status"]="true";#回傳javascript語法return $result;}# function sendGetValue end/*#函式說明:#建立從當前iframe去增加其他iframe裏面元素的數值內容的js函數.#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列.#$result["function"],當前執行的函數名稱.#$result["content"],javaScript語法.#必填參數:$conf["idVarName"]="inputElementId";#目標iframe底下的javaScript變數名稱,其變數值應爲元素的id.$conf["jsFunctionName"]="sendKey";#該javaScript的涵式名稱.#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function addOtherIframeInterElementValueFromThisIframe($conf){#初始化要回傳的變數$result=array();#初始化javaScript語法$result["content"]="";#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("idVarName","jsFunctionName");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("jsPosition");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#debug#var_dump($checkResult);#exit;#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#javaScript開始$conf["javaScript"]["start"]["include"]="false";#是否要匯入外部js庫。"true"爲要匯入;"false"爲沒有要匯入。$javaScriptStart=javaScript::start($conf["javaScript"]["start"]);unset($conf["javaScript"]["start"]);#javaScript語法開始失敗if($javaScriptStart["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$javaScriptStart;#回傳結果return $result;}#if end#串接javaScript開始的語法$result["content"]=$result["content"].$javaScriptStart["content"];#從當前iframe去增加其他iframe裏面元素的數值內容的javaScript涵式$result["content"]=$result["content"]."//將數值傳到別到iframe裡的元素//必填的參數://frameId,要存取的目標iframe的id//key,要增加的數值內容//參考資料來源://http://www.dotblogs.com.tw/puma/archive/2008/11/13/5982.aspx//http://stackoverflow.com/questions/13757943/access-a-variable-of-iframe-from-parentfunction ".$conf["jsFunctionName"]."(frameId,key){//將目標iframe元素物件化,並取得其idvar iframe = parent.document.getElementById(frameId);//取得其iframe底下的變數var id=iframe.contentWindow.".$conf["idVarName"].";//將目標iframe裏的元素物件化,並取得其idvar inputField=iframe.contentDocument.getElementById(id);//將要傳送的數值連在目標iframe裏元素的內容後面。inputField.value = inputField.value+key;}//function sendKey end";#javaScript結束$result["content"]=$result["content"].javaScript::end();#設置執行正常$result["status"]="true";#回傳結果return $result;}#function/*#函式說明:#建立從當前iframe去刪除其他iframe裏面元素的數值內容的js函數#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列.#$result["function"],當前執行的函數名稱.#$result["content"],javaScript語法.#必填參數:$conf["idVarName"]="inputElementId";#目標iframe底下的javaScript變數名稱,其變數值應爲元素的id$conf["jsFunctionName"]="delOne";#該javaScript的涵式名稱#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function delOtherIframeInterElementValueFromThisIframe($conf){#初始化要回傳的變數$result=array();#初始化javaScript語法$result["content"]="";#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("idVarName","jsFunctionName");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("jsPosition");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#debug#var_dump($checkResult);#exit;#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#javaScript開始$conf["javaScript"]["start"]["include"]="false";#是否要匯入外部js庫。"true"爲要匯入;"false"爲沒有要匯入。$javaScriptStart=javaScript::start($conf["javaScript"]["start"]);unset($conf["javaScript"]["start"]);#如果 javaScript 開始if($javaScriptStart["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#串接javaScript開始的語法$result["content"]=$result["content"].$javaScriptStart["content"];#從當前iframe去增加其他iframe裏面元素的數值內容的javaScript涵式$result["content"]=$result["content"]."//將別的iframe裡的元素刪除一個字//必填的參數://frameId,要存取的目標iframe的id//key,要增加的數值內容//參考資料來源://http://www.dotblogs.com.tw/puma/archive/2008/11/13/5982.aspx//http://stackoverflow.com/questions/13757943/access-a-variable-of-iframe-from-parent//http://www.w3school.com.cn/js/jsref_split.asp//http://www.w3school.com.cn/js/jsref_join.aspfunction ".$conf["jsFunctionName"]."(frameId){//將目標iframe元素物件化,並取得其idvar iframe = parent.document.getElementById(frameId);//取得其iframe底下的變數var id=iframe.contentWindow.".$conf["idVarName"].";//將目標iframe裏的元素物件化,並取得其idvar inputField=iframe.contentDocument.getElementById(id);//取得原始的字串內容var strValue=inputField.value;//將表單原始的字串內容,變成陣列var strArray=strValue.split('');//取得陣列的長度var strArrayLength=strArray.length;//將陣列的最後一個元素移除strArray[strArrayLength-1]='';//將陣列合併爲字串var deledStr = strArray.join('');//更改表單的字串內容爲移除了最後一個字的結果inputField.value = deledStr;}//function sendKey end";#javaScript結束$result["content"]=$result["content"].javaScript::end();#設置執行正常$result["status"]="true";#回傳結果return $result;}#function/*#函式說明:#列印當前頁面#回傳結果:#列印的javaScript語法.#必填參數:#無.#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function printWebPage(){#初始化要回傳的javaScript語法$result="<body onload=window.print()>";#回傳語法return $result;}#function printWebPage end/*#函式說明:#確認視窗,回傳的javaScript結果可在要觸發的元素裡面搭配「onclink=本函數回傳的內容」,來使連結或按鈕確定觸發或不觸發.#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列.#$result["function"],當前執行的函數名稱.#$result["content"],javaScript語法,不含<script>標籤.#必填參數:#$conf["alertSentenceArray"],字串陣列彈出式視窗的內容,每個元素代表每一列的內容.$conf["alertSentenceArray"]=array();#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function confirmWindow(&$conf){#初始化要回傳的變數$result=array();#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("alertSentenceArray");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("alertSentenceArray");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array();#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#回傳結果的confirm視窗語法開始$result["content"]="return confirm('";#針對每個 $conf["alertSentenceArray"]foreach($conf["alertSentenceArray"] as $sentence){#接上每列內容$result["content"]=$result["content"].$sentence."\\n";}#foreach end#回傳結果的confirm視窗語法結束$result["content"]=$result["content"]."')";#設置執行正常$result["status"]="true";#回傳結果return $result;}#function confirmWindow end/*#函式說明:#依據需要加上<script></script>標籤,並且可以指定要匯入的js檔案.#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],javaScript語法#$result["importJS"],匯入js的語法,必定含有<script></script>標籤.#必填參數:#$conf["jsProgramSection"],陣列字串,不含<script></script>標籤的javsScript程式碼,可以放多個script程式.$conf["jsProgramSection"]=array("");#可省略參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置,預設為當前檔案的位置.#$conf["fileArgu"]=__FILE__;#$conf["jsPosition"],字串,要匯入的js檔案位置.#$conf["jsPosition"]="";#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".#$conf["noScriptTag"]="false";#參考資料:#無.#備註:#無.*/public static function addScriptTag(&$conf){#初始化要回傳的變數$result=array();#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化要回傳的變數$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("jsProgramSection");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("jsPosition","fileArgu","noScriptTag");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,__FILE__,"false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果 $conf["jsPosition"] 存在if(isset($conf["jsPosition"])){#函式說明:#script 語法開始#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],javaScript語法#必填參數:#如果 $conf["jsPosition"] 存在if(isset($conf["jsPosition"])){#$conf["include"],字串,是否要匯入外部js庫,"true"爲要匯入;"false"爲沒有要匯入。$conf["javaScript::start"]["include"]="true";}#if end#反之else{#$conf["include"],字串,是否要匯入外部js庫,"true"爲要匯入;"false"爲沒有要匯入。$conf["javaScript::start"]["include"]="false";}#else end#可省略參數:#如果有設置 $conf["fileArgu"]if(isset($conf["fileArgu"])){#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置,預設為當前檔案的位置.$conf["javaScript::start"]["fileArgu"]=$conf["fileArgu"];}#if end#如果 $conf["jsPosition"] 存在if(isset($conf["jsPosition"])){#$conf["jsPosition"],字串,要匯入的js檔案位置,請與參數"fileArgu"一起設置.$conf["javaScript::start"]["jsPosition"]=$conf["jsPosition"];}#if end#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,於設為"true".#$conf["userDir"]="true";$start=javaScript::start($conf["javaScript::start"]);unset($conf["javaScript::start"]);#如果建立匯入js的語法失敗if($start["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$start;#回傳結果return $result;}#if end#取得匯入js的語法$result["importJS"]=$result["content"].$start["content"];#script結束#函式說明:#script 語法結束#回傳結果:#javaScript語法$result["importJS"]=$result["importJS"].javaScript::end();}#if end#如果要 script tagif($conf["noScriptTag"]==="false"){#函式說明:#script 語法開始#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],javaScript語法#必填參數:#$conf["include"],字串,是否要匯入外部js庫,"true"爲要匯入;"false"爲沒有要匯入。$conf["javaScript::start"]["include"]="true";#可省略參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置,預設為當前檔案的位置.#$conf["fileArgu"]=__FILE__;#$conf["jsPosition"],字串,要匯入的js檔案位置,請與參數"fileArgu"一起設置.$conf["javaScript::start"]["jsPosition"]=$conf["jsPosition"];#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,於設為"true".#$conf["userDir"]="true";$start=javaScript::start($conf["javaScript::start"]);unset($conf["javaScript::start"]);#如果建立匯入js的語法失敗if($start["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$start;#回傳結果return $result;}#if end#反之else{#取得匯入js的語法$result["content"]=$result["content"].$start["content"];}#else end#$conf["jsProgramSection"] 有幾個元素就執行幾次foreach($conf["jsProgramSection"] as $script){#換行,然後加上script程式$result["content"]=$result["content"]."\r\n".$script;}#foreach end#script結束#函式說明:#script 語法結束#回傳結果:#javaScript語法$result["content"]=$result["content"]."\r\n".javaScript::end();}#if end#反之不要 script tagelse{#$conf["jsProgramSection"] 有幾個元素就執行幾次foreach($conf["jsProgramSection"] as $script){#換行,然後加上script程式$result["content"]=$result["content"]."\r\n".$script;}#foreach end}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function addScriptTag end/*#函式說明:#匯入js檔案#回傳結果:#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.#$result["functin"],字串,當前函數的名稱.#$result["error"],陣列,錯訊訊息.#$result["argu"],陣列,使用的參數.#$result["content"],字串,匯入js的語法.#必填參數:#$conf["jsFileLocation"],陣列字串,多個js檔案的位置與名稱,每個元素代表一個js檔案的位置,js副檔名會自動補上.$conf["jsFileLocation"]=array("");#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.$conf["fileArgu"]=__FILE__;#可省略參數:#$conf["web"],字串,true代表是網頁系統的位置,"false"代表是檔案系統的位置,預設為"true".#$conf["web"]="true";#參考資料:#php預設常數=>http://php.net/manual/zh/language.constants.predefined.php#備註:#無.*/public static function import(&$conf){#初始化要回傳的內容$result=array();#設置當前執行的函數$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#取得參數$result["argv"]=$conf;#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("jsFileLocation","fileArgu");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$checkResult;#回傳結果return $result;}#if end#初始化匯入js檔案的語法$result["content"]="";#針對每個要匯入的javaScript樣式foreach($conf["jsFileLocation"] as $jsLocation){#補上 js 副檔名$jsLocation=$jsLocation.".js";#取得網頁位置#函式說明:#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.#回傳結果:#$result["status"],"true"爲建立成功,"false"爲建立失敗.#$result["error"],錯誤訊息陣列.#$result["function"],函數名稱.#$result["argu"],使用的參數.#$result["content"],網址,若是在命令列執行,則為"null".#$result["webPathFromRoot"],相對於網頁根目錄的路徑.#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.#必填參數:#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.$conf["fileAccess::getInternetAddressV2"]["address"]=$jsLocation;#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];#可省略參數:#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];#備註:#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);unset($conf["fileAccess::getInternetAddressV2"]);#如果執行失敗if($getInternetAddressV2["status"]==="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$getInternetAddressV2;#回傳結果return $result;}#if end#取得網頁位置$jsLocation=$getInternetAddressV2["content"];#var_dump($jsLocation);#函式說明:#script 語法開始#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],javaScript語法#必填參數:$conf["javaScript::start"]["include"]="true";#是否要匯入外部js庫。"true"爲要匯入;"false"爲沒有要匯入。#可省略參數:$conf["javaScript::start"]["jsPosition"]=$jsLocation;#要匯入的js檔案位置。#$conf["javaScript::start"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.$conf["javaScript::start"]["fileArgu"]=$conf["fileArgu"];#$conf["javaScript::start"]["web"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,於設為"true".$conf["javaScript::start"]["web"]=$conf["web"];$start=javaScript::start($conf["javaScript::start"]);unset($conf["javaScript::start"]);#如果script語法開始失敗if($start["status"]=="false"){#設置執行不正常$result["status"]="false";#設置錯誤訊息$result["error"]=$start;#回傳結果return $result;}#if end#串接每個要匯入js檔案的語法$result["content"]=$result["content"].$start["content"].javaScript::end();}#foreach end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function import end/*#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["script"]="";#可省略參數:#$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#備註:#無.*/public static function toScript(&$conf){#初始化要回傳的變數$result=array();#初始化javaScript語法$result["content"]="";#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("script");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("onReady","jsFunciton","globalJs","noScriptTag");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","array","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true",null,null,"false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果不要script標籤if($conf["noScriptTag"]==="true"){#如果存在 $conf["globalJs"]if(isset($conf["globalJs"])){#針對每個全域jsforeach($conf["globalJs"] as $jsSection){#取得javaScript開始的語法$result["content"]=$result["content"].$jsSection;}#foreach end}#if end#如果存在 $conf["jsFunciton"]if(isset($conf["jsFunciton"])){#針對每個js函式foreach($conf["jsFunciton"] as $jsSection){#取得javaScript開始的語法$result["content"]=$result["content"].$jsSection;}#foreach end}#if end#如果 $conf["onReady"] 為 "true"if($conf["onReady"]==="true"){#用ready條件包住要執行的script內容$conf["script"]="//run in lastwindow.addEventListener('load',async function(event){//console.log('All resources finished loading!');".$conf["script"]."});";#串接要執行的script$result["content"]=$result["content"].$conf["script"];}#if end}#if end#反之else{#javaScript開始$conf["javaScript"]["start"]["include"]="false";#是否要匯入外部js庫。"true"爲要匯入;"false"爲沒有要匯入。#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置.#$conf["javaScript"]["start"]["fileArgu"]=$conf["fileArgu"];$javaScriptStart=javaScript::start($conf["javaScript"]["start"]);unset($conf["javaScript"]["start"]);#如果 javaScript 開始失敗if($javaScriptStart["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$javaScriptStart;#回傳結果return $result;}#if end#取得javaScript開始的語法$result["content"]=$result["content"].$javaScriptStart["content"];#如果存在 $conf["globalJs"]if(isset($conf["globalJs"])){#針對每個要放置的js全域變數宣告foreach($conf["globalJs"] as $gloJs){#串接js全域變數宣告$result["content"]=$result["content"].$gloJs;}#foreach end}#if end#如果存在 $conf["jsFunciton"]if(isset($conf["jsFunciton"])){#針對每個要放置的js函數foreach($conf["jsFunciton"] as $jsFunc){#串接js函數$result["content"]=$result["content"].$jsFunc;}#foreach end}#if end#如果 $conf["onReady"] 為 "true"if($conf["onReady"]==="true"){#用ready條件包住要執行的script內容$conf["script"]="//run in lastwindow.addEventListener('load',async function(event){//console.log('All resources finished loading!');".$conf["script"]."});";#串接要執行的script$result["content"]=$result["content"].$conf["script"];}#if end#反之else{#串接要執行的script$result["content"]=$result["content"].$conf["script"];}#elsd end#串接 <script>$result["content"]=$result["content"].javaScript::end();}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function toScript end/*#函式說明:#測試 webStorage 是否有支援,若印出'Web Storage supported'則代表有支援;若為'Sorry! No Web Storage support..'則代表不支援.#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#無.#可省略參數:#無.#參考資料:#無.#備註:#無.*/public static function localStorageTest(){#初始化要回傳的變數$result=array();#記錄當前執行的函數名稱$result["function"]=__FUNCTION__;#測試 web storage js$jsStr="if(typeof(Storage) !== undefined){// Code for localStorage/sessionStorage.document.write('Web Storage supported');}else{document.write('Sorry! No Web Storage support..');}";#函式說明:#將要執行的script語法透過該函式執行#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$jsStr;$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function webStorageTest end/*#函式說明:#儲存變數到local storage#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["key"],字串,要儲存的key為何.$conf["key"]="";#$conf["val"],字串,要儲存的val為何.$conf["val"]="";#可省略參數:#$conf["json"],字串,要儲存的內容是否為json,亦即javascript的物件,"true"代表是,會將$conf["val"]用json_encode函數處理;"false"代表不是,預設為"false".#$conf["json"]="";#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".#$conf["noScriptTag"]="false";#參考資料:#無.#備註:#無.*/public static function saveToLocalStorage(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("key","val");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("key");#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("json","noScriptTag");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果要轉成json字串if($conf["json"]==="true"){#javascript 字串$jsStr="localStorage.".$conf["key"]." = '".json_encode($conf["val"])."';";}#if end#反之不用轉換else{#javascript 字串$jsStr="localStorage.".$conf["key"]." = '".$conf["val"]."';";}#else end#如果要 script tagif($conf["noScriptTag"]=="false"){#函式說明:#將要執行的script語法透過該函式執行#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$jsStr;$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#反之不要 script tagelse{#取得js語法$result["content"]=$jsStr;}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function saveToLocalStorage end/*#函式說明:#儲存變數到session storage#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["key"],字串,要儲存的key為何.$conf["key"]="";#$conf["val"],字串,要儲存的val為何.$conf["val"]="";#可省略參數:#$conf["json"],字串,要儲存的內容是否為json,亦即javascript的物件,"true"代表是,會將$conf["val"]用json_encode函數處理;"false"代表不是,預設為"false".#$conf["json"]="";#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".#$conf["noScriptTag"]="false";#參考資料:#無.#備註:#無.*/public static function saveToSessionStorage(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("key","val");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("key");#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("json","noScriptTag");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果要轉成json字串if($conf["json"]==="true"){#javascript 字串$jsStr="sessionStorage.".$conf["key"]." = '".json_encode($conf["val"])."';";}#if end#反之不用轉換else{#javascript 字串$jsStr="sessionStorage.".$conf["key"]." = '".$conf["val"]."';";}#else end#如果要 script tagif($conf["noScriptTag"]=="false"){#函式說明:#將要執行的script語法透過該函式執行#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$jsStr;$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#反之不要 script tagelse{#取得js語法$result["content"]=$jsStr;}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function saveToSessionStorage end/*#函式說明:#取得儲存在local storage的變數#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["key"],字串,要儲存的key為何.$conf["key"]="";#$conf["storeVar"],字串,要儲存到哪個javascript變數裡面.$conf["storeVar"]="";#可省略參數:#$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".#$conf["noScriptTag"]="false";#$conf["json"],字串要取出的資料是否json,"true"代表是,"false"代表不是,預設為"false".#$conf["json"]="false";#參考資料:#無.#備註:#無.*/public static function getLocalStorage(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("key","storeVar");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("key");#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noScriptTag","json");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果要抓的變數不是jsonif($conf["json"]==="false"){#設置抓取local storage 變數的 js 語法$jsStr="//判斷 local storage 變數是否存在if(localStorage.".$conf["key"]."!=undefined){//取得 local storage 變數".$conf["storeVar"]."=localStorage.".$conf["key"].";}";}#if end#反之為json變數else{#設置抓取local storage 變數的 js 語法$jsStr="//判斷 local storage 變數是否存在if(localStorage.".$conf["key"]."!=undefined){//取得 local storage 變數".$conf["storeVar"]."=JSON.parse(localStorage.".$conf["key"].");}";}#else end#如果要 script tagif($conf["noScriptTag"]==="false"){#函式說明:#將要執行的script語法透過該函式執行#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$jsStr;$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#反之不要<script></script>else{$result["content"]=$jsStr;}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function getLocalStorage end/*#函式說明:#取得儲存在session storage的變數#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["key"],字串,要儲存的key為何.$conf["key"]="";#$conf["storeVar"],字串,要儲存到哪個javascript變數裡面.$conf["storeVar"]="";#可省略參數:#$conf["noScriptTag"],字串,是否不要<script></script>,"true"代表不要,"false"代表不用,預設為"false".#$conf["noScriptTag"]="false";#$conf["json"],字串要取出的資料是否json,"true"代表是,"false"代表不是,預設為"false".#$conf["json"]="false";#參考資料:#無.#備註:#無.*/public static function getSessionStorage(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("key","storeVar");#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("key");#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noScriptTag","json");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果要抓的變數不是jsonif($conf["json"]==="false"){#設置抓取local storage 變數的 js 語法$jsStr="//判斷 local storage 變數是否存在if(sessionStorage.".$conf["key"]."!=undefined){//取得 local storage 變數".$conf["storeVar"]."=sessionStorage.".$conf["key"].";}";}#if end#反之為json變數else{#設置抓取local storage 變數的 js 語法$jsStr="//判斷 local storage 變數是否存在if(localStorage.".$conf["key"]."!=undefined){//取得 local storage 變數".$conf["storeVar"]."=JSON.parse(localStorage.".$conf["key"].");}";}#else end#如果要 script tagif($conf["noScriptTag"]==="false"){#函式說明:#將要執行的script語法透過該函式執行#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$jsStr;$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#反之不要<script></script>else{$result["content"]=$jsStr;}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function getSessionStorage end/*#函式說明:#移除儲存在local storage的變數#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["key"],字串,要儲存的key為何.$conf["key"]="";#可省略參數:#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".#$conf["noScriptTag"]="false";#參考資料:#無.#備註:#無.*/public static function rmLocalStorage(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("key",);#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("key");#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noScriptTag");#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查失敗if($checkResult["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#如果檢查不通過if($checkResult["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkResult;#回傳結果return $result;}#if end#javascript 字串$jsStr="localStorage.removeItem(\"".$conf["key"]."\");";#如果要 script tagif($conf["noScriptTag"]=="false"){#函式說明:#將要執行的script語法透過該函式執行#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法,標籤「<script></script>」會自動補上.$conf["javaScript::toScript"]["script"]=$jsStr;$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js語法失敗if($toScript["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#反之不要 script tagelse{#取得js語法$result["content"]=$jsStr;}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function rmLocalStorage end/*#函式說明:#透過作業系統顯示提示訊息#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["argu"],所使用的參數.#$result["content"],js語法.#$result["jsFuncName"],使用的js函數名稱.#必填參數:#$conf["name"],字串,提示功能的名稱,用於建立js函數的名稱.$conf["name"]="";#$conf["text"],陣列字串,提示的內容,每個元素代表一列文字,目前似乎不會換行.$conf["text"]=array();#可省略參數:#$conf["bodyAndIcon"],字串,"true"代表要使用body與icon,預設為"false"代表不使用.#$conf["bodyAndIcon"]="false";#$conf["body"],字串陣列,提示的body內容,每個元素代表一列文字,預設為空陣列.#$conf["body"]=array();#$conf["icon"],字串,提示所用的icon位置,預設為null.#$conf["icon"]="";#$conf["sound"],字串,提示出現要使用的音效,預設為null,目前沒有瀏覽器支援.#$conf["sound"]="";#$conf["ms"],字串,訊息幾毫秒後要消失,預設為3000毫秒.#$conf["ms"]="3000";#$conf["runNow"],字串,是否要馬上執行,預設為"true"代表要,"false"代表不要.#$conf["runNow"]="true";#$conf["scriptTag"],字串,是否要用<script></script>包住js語法,預設為"true"要包住,"false"為不包住.#$conf["scriptTag"]="true"#參考資料:#https://developer.mozilla.org/en-US/docs/Web/API/notification#備註:#參數bodyAndIcon似乎可以移除#建議加上檢查icon與sound是否存在的檢查#如果沒有要求瀏覽器使用Notify的權限,則即便之前允許過,第一次也一定會失敗*/public static function systemNotify(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name","text");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.#$conf["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.#$conf["skipableVariableCanNotBeEmpty"]=array();#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("bodyAndIcon","body","icon","sound","ms","runNow","scriptTag");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string","string","string","string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false",array(),"null","null","3000","true","true");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#轉換 $conf["text"] 為字串#函式說明:#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["function"],當前執行的function名稱#$result["error"],錯誤訊息陣列.#$result["content"],處理好的字串.#必填參數:#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.$conf["arrays::arrayToString"]["inputArray"]=$conf["text"];#可省略參數:#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;$conf["arrays::arrayToString"]["spiltSymbol"]=" ";$conf["text"]=arrays::arrayToString($conf["arrays::arrayToString"]);unset($conf["arrays::arrayToString"]);#如果轉換失敗if($conf["text"]["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$conf["text"];#回傳結果return $result;}#if end#取得處理好的字串$conf["text"]=$conf["text"]["content"];#轉換 $conf["body"] 為字串#函式說明:#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["function"],當前執行的function名稱#$result["error"],錯誤訊息陣列.#$result["content"],處理好的字串.#必填參數:#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.$conf["arrays::arrayToString"]["inputArray"]=$conf["body"];#可省略參數:#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;$conf["arrays::arrayToString"]["spiltSymbol"]=" ";$conf["body"]=arrays::arrayToString($conf["arrays::arrayToString"]);unset($conf["arrays::arrayToString"]);#如果轉換失敗if($conf["body"]["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$conf["body"];#回傳結果return $result;}#if end#取得轉換好的內容$conf["body"]=$conf["body"]["content"];#初始化js語法$js="";#如果要馬上執行if($conf["runNow"]==="true"){#語法$js="function notify_".$conf["name"]."(){// Let's check if the browser supports notificationsif(!('Notification' in window)){//This browser does not support system notificationsreturn false;}// Let's check whether notification permissions have already been grantedelse if(Notification.permission==='granted'){useOp='".$conf["bodyAndIcon"]."';// If the user accepts, let's create a notification//argumentsvar options={tag:'".$conf["name"]."',body:'".$conf["body"]."',icon:'".$conf["icon"]."',sound:'".$conf["sound"]."',}if(useOp==='false'){//show notifyvar notification = new Notification('".$conf["text"]."');}else if(useOp==='true'){//show notify with optionsvar notification = new Notification('".$conf["text"]."',options);}//notify window will disapear in ".$conf["ms"]."setTimeout(notification.close.bind(notification),".$conf["ms"].");//debugnotification.onerror=function(message, source, lineno, colno, error){//alert(message.toSource());//alert(source.toSource());//alert(lineno.toSource());//alert(colno.toSource());//alert(error.toSource());};}// Otherwise, we need to ask the user for permissionelse if(Notification.permission!=='denied'){Notification.requestPermission(function(permission){useOp='".$conf["bodyAndIcon"]."';// If the user accepts, let's create a notificationif(permission==='granted'){//argumentsvar options={tag:'".$conf["name"]."',body:'".$conf["body"]."',icon:'".$conf["icon"]."',sound:'".$conf["sound"]."',}if(useOp==='false'){//show notifyvar notification = new Notification('".$conf["text"]."');}else if(useOp==='true'){//show notify with optionsvar notification = new Notification('".$conf["text"]."',options);}//notify window will disapear in ".$conf["ms"]."setTimeout(notification.close.bind(notification),".$conf["ms"].");//debugnotification.onerror=function(message, source, lineno, colno, error){//alert(message.toSource());//alert(source.toSource());//alert(lineno.toSource());//alert(colno.toSource());//alert(error.toSource());};}});}}//notify js function end//if have iconif('".$conf["icon"]."'!=='null'){//wait for icon to loadvar icon = new Image();icon.onload = function(){notify_".$conf["name"]."();}icon.src = '".$conf["icon"]."';}else{notify_".$conf["name"]."();}";}#if end#如果沒有要馬上執行else if($conf["runNow"]==="false"){#語法$js="function notify_".$conf["name"]."(){// Let's check if the browser supports notificationsif(!('Notification' in window)){//This browser does not support system notificationsreturn false;}// Let's check whether notification permissions have already been grantedelse if(Notification.permission==='granted'){useOp='".$conf["bodyAndIcon"]."';// If the user accepts, let's create a notification//argumentsvar options={tag:'".$conf["name"]."',body:'".$conf["body"]."',icon:'".$conf["icon"]."',sound:'".$conf["sound"]."',}if(useOp==='false'){//show notifyvar notification = new Notification('".$conf["text"]."');}else if(useOp==='true'){//show notify with optionsvar notification = new Notification('".$conf["text"]."',options);}//notify window will disapear in ".$conf["ms"]."setTimeout(notification.close.bind(notification),".$conf["ms"].");}// Otherwise, we need to ask the user for permissionelse if(Notification.permission!=='denied'){Notification.requestPermission(function(permission){useOp='".$conf["bodyAndIcon"]."';// If the user accepts, let's create a notificationif(permission==='granted'){//argumentsvar options={tag:'".$conf["name"]."',body:'".$conf["body"]."',icon:'".$conf["icon"]."',sound:'".$conf["sound"]."',}if(useOp==='false'){//show notifyvar notification = new Notification('".$conf["text"]."');}else if(useOp==='true'){//show notify with optionsvar notification = new Notification('".$conf["text"]."',options);}//notify window will disapear in ".$conf["ms"]."setTimeout(notification.close.bind(notification),".$conf["ms"].");}});}}//notify js function end";}#if end#轉換 $conf["scriptTag"] 給 javaScript::addScriptTag 使用if($conf["scriptTag"]==="true"){$conf["scriptTag"]="false";}#if endelse if($conf["scriptTag"]==="false"){$conf["scriptTag"]="true";}#if end#to js#函式說明:#依據需要加上<script></script>標籤,並且可以指定要匯入的js檔案.#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],javaScript語法#$result["importJS"],匯入js的語法,必定含有<script></script>標籤.#必填參數:#$conf["jsProgramSection"],陣列字串,不含<script></script>標籤的javsScript程式碼,可以放多個script程式.$conf["javaScript::addScriptTag"]["jsProgramSection"]=array($js);#可省略參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置,預設為當前檔案的位置.#$conf["fileArgu"]=__FILE__;#$conf["jsPosition"],字串,要匯入的js檔案位置.#$conf["jsPosition"]="";#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".$conf["javaScript::addScriptTag"]["noScriptTag"]=$conf["scriptTag"];$addScriptTag=javaScript::addScriptTag($conf["javaScript::addScriptTag"]);unset($conf["javaScript::addScriptTag"]);#如果轉成script失敗if($addScriptTag["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$addScriptTag;#回傳結果return $result;}#if end#取得js函數名稱$result["jsFuncName"]="notify_".$conf["name"];#取得js語法$result["content"]=$addScriptTag["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function systemNotify end/*#函式說明:#開新視窗,可以隱藏瀏覽器的元件。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["argu"],所使用的參數.#$result["content"],js語法.#$result["jsFuncName"],使用的js函數名稱.#必填參數:#$conf["url"],字串,要開新視窗的網址.$conf["url"]="";#$conf["function"],字串,js開新視窗函式的名稱.$conf["function"]="";#可省略參數:#$conf["name"],字串 ,視窗的名稱,指定後可以直接存取其內容.#$conf["name"]="";#$conf["width"],字串,新視窗的寬度.#$conf["width"]="";#$conf["height"],字串,新視窗的高度.#$conf["height"]="";#$conf["toolbar"],字串,是否要工具列,"true"代表要,"false"代表不要,預設為"false".#$conf["toolbar"]="";#$cpnf["menubar"],字串,是否要選單列,"true"代表要,"false"代表不要,預設為"false".#$conf["menubar"]="";#$conf["scrollbars"],字串,是否要滾軸,"true"代表要,"false"代表不要,預設為"true".#$conf["scrollbars"]="";#$conf["resizable"],字串,是否可以改變視窗大小,"true"代表可以,"false"代表不可以,預設為"true".#$conf["resizable"]="";#$conf["location"],字串,是否要顯示地址列,"true"代表要,"false"代表不要,預設為"false".#$conf["location"]="";#$conf["status"],字串,是否要顯示狀態列,"true"代表要,"false"代表不要,預設為"false".#$conf["status"]="";#$conf["titlebar"],字串,是否要顯示視窗標題,"true"代表要,"false"代表不要,預設為"true".#$conf["titlebar"]="";#$conf["returnWindowVarName"],字串,開啟的視窗要儲存到哪個全域變數,請提供window.後面的名稱即可,預設不使用,直接return.#$conf["returnWindowVarName"]="";#參考資料:#http://www.w3schools.com/jsref/met_win_open.asp#http://www.blueshop.com.tw/board/FUM20041006152641OLG/BRD20080107111600L3T.html#備註:#無.*/public static function openWindow(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("url","function");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("function");#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("width","height");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("name","width","height","toolbar","menubar","scrollbars","resizable","location","status","titlebar","returnWindowVarName");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string","string","string","string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("",null,null,"false","false","true","true","false","false","true",null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php#建議:#增加可省略參數全部不能為空字串或空陣列的參數功能.$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#取得js函數的名稱$result["jsFuncName"]=$conf["function"];#開新視窗的參數$opt=array();#如果有設定 $conf["width"]if(isset($conf["width"])){#如果不是 "screen"if($conf["width"]!=="screen"){#設定寬度$opt[]="width=".$conf["width"];}#if end}#if end#如果有設定 $conf["height"]if(isset($conf["height"])){#如果不是 "screen"if($conf["height"]!=="screen"){#設定高度$opt[]="height=".$conf["height"];}#if end}#if end#如果 $conf["toolbar"] 為 "true"if($conf["toolbar"]==="true"){#設為 "yes"$conf["toolbar"]="yes";}#if end#反之else{#設為 "no"$conf["toolbar"]="no";}#if end#設定 toolbar$opt[]="toolbar=".$conf["toolbar"];#如果 $conf["menubar"] 為 "true"if($conf["menubar"]==="true"){#設置為 "yes"$conf["menubar"]="yes";}#if end#反之else{#設置為 "no"$conf["menubar"]="no";}#else end#設定 menubar$opt[]="menubar=".$conf["menubar"];#如果滾軸要設置if($conf["scrollbars"]==="true"){#設置為 "yes"$conf["scrollbars"]="yes";}#if end#反之else{#設置為 "no"$conf["scrollbars"]="no";}#else end#設置 scrollbars$opt[]="scrollbars=".$conf["scrollbars"];#如果 $conf["resizable"] 為 "true"if($conf["resizable"]==="true"){#設置為 "yes"$conf["resizable"]="yes";}#if end#反之else{#設置為 "no"$conf["resizable"]="no";}#else end#設置 resizable$opt[]="resizable=".$conf["resizable"];#如果 $conf["location"] 為 "true"if($conf["location"]==="true"){#設置為 "yes"$conf["location"]="yes";}#if end#反之else{#設置為 "no"$conf["location"]="no";}#else end#設置 location$opt[]="location=".$conf["location"];#如果 $conf["status"] 為 "true"if($conf["status"]==="true"){#設置為 "yes"$conf["status"]="yes";}#if end#反之else{#設置為 "no"$conf["status"]="no";}#else end#設置 status$opt[]="status=".$conf["status"];#如果 $conf["titlebar"] 為 "true"if($conf["titlebar"]==="true"){#設置為 "yes"$conf["titlebar"]="yes";}#if end#反之else{#設置為 "no"$conf["titlebar"]="no";}#else end#設置 location$opt[]="titlebar=".$conf["titlebar"];#設置開新視窗的opt#函式說明:#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["function"],當前執行的function名稱#$result["error"],錯誤訊息陣列.#$result["content"],處理好的字串.#必填參數:#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.$conf["arrays::arrayToString"]["inputArray"]=$opt;#可省略參數:#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;$conf["arrays::arrayToString"]["spiltSymbol"]=",";#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。$conf["arrays::arrayToString"]["skipEnd"]="true";$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);unset($conf["arrays::arrayToString"]);#如果轉換失敗if($arrayToString["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$arrayToString;#回傳結果return $result;}#if end#儲存轉換好的字串$opt=$arrayToString["content"];#如果 $conf["width"] 與 $conf["height"] 都是 "screen"if($conf["width"]==="screen" && $conf["height"]==="screen"){#設置最大大小的視窗寬高$cusWidthHeight=",width='+window.screen.width+','+'height='+window.screen.height";}#if end#反之else{#設置為 ""$cusWidthHeight="'";}#else end#如果有指定要儲存到window中的變數if(isset($conf["returnWindowVarName"])){#設置儲存到指定的window中變數$conf["returnWindowVarName"]="window.".$conf["returnWindowVarName"]."=";}#if end#反之else{#設置直接return$conf["returnWindowVarName"]="return ";}#else end#開新視窗的js function$js="//open window functino ".$conf["function"]."function ".$conf["function"]."(){//開啟新視窗設定".$conf["returnWindowVarName"]."window.open('".$conf["url"]."','".$conf["name"]."','".$opt.$cusWidthHeight.");}//function ".$conf["function"]." end";#轉換成js語法#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="";#可省略參數:#$conf["onReady"],字串,是否要在網頁載入完再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.$conf["javaScript::toScript"]["jsFunciton"]=array($js);#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉換成js失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function openWindows end/*#函式說明:#javascript的if...esle if...判斷式.#回傳結果:#$result["status"],執行正確與否,"true"代表執行正確,"false"代表執行失敗.#$result["error"],錯誤訊息陣列.#$result["content"],JavaScript的語法#$result["function"],當前執行的函數名稱#必填參數:#無:#可省略參數:#$conf["scriptTag"],是否要用<script></script>包住,預設為"false",不包住;"true"為包住.#$conf["scriptTag"]="false";#$conf["condition"],陣列,每個判斷式的條件,若有多個則會依序判斷下去.#$conf["condition"]=array();#$conf["conditionComment"],陣列,每個判斷式的註解,預設為$conf["condition"].#$conf["conditionComment"]=array();#$conf["todo"],陣列,每個判斷式成立時要做的事情.#$conf["todo"]=array();#$conf["todoComment"],陣列,每件要做的事情之註解,預設為"do something...".#$conf["todoComment"]=array();#參考資料:#無.#備註:#無.*/public static function jsIf(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf==null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],參數是否都通過檢查,"true",代表有通過檢查,"false"代表沒有通過檢查。#必填參數:#$conf["checkedVar"],陣列,要檢查的變數陣列名稱為?$conf["variableCheck::checkSkipableVarType"]["checkedVar"]=$conf;#$conf["sikpableVarNameArray"],字串陣列,要檢查型態是否設定正確的變數名稱陣列.$conf["variableCheck::checkSkipableVarType"]["sikpableVarNameArray"]=array("scriptTag","condition","conditionComment","todo","todoComment");#$argu,要直接存取的陣列變數名稱,變數前面加上「&」,如果要在別的函式裡面使用本函式,請記得將變動過結果($argu)給使用該函式的設定變數(通常是$conf=$argu).$argu=&$conf;#可省略參數:#$conf["skipableVarTypeArray"],字串陣列,要檢查的每個變數,其型態應該要為何,null代表不指定變數形態.$conf["variableCheck::checkSkipableVarType"]["skipableVarTypeArray"]=array("string","array","array","array","array");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的變數要初始化為什麼,null代表不指定.$conf["variableCheck::checkSkipableVarType"]["skipableVarDefaultValue"]=array("false",null,null,null,null);$checkSkipableVarType=variableCheck::checkSkipableVarType($conf["variableCheck::checkSkipableVarType"],$argu);unset($conf["variableCheck::checkSkipableVarType"]);#如果檢查失敗if($checkSkipableVarType["status"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkSkipableVarType;#回傳結果return $result;}#if end#如果檢查不通過if($checkSkipableVarType["passed"]=="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkSkipableVarType;#回傳結果return $result;}#if end#初始化js script.$script="";#產生判斷式與要做的事情.#計數$times=0;#有幾個判斷式就執行幾次foreach($conf["condition"] as $index=>$condi){#如果沒有設置條件的註解if(!isset($conf["conditionComment"])){#設置預設的註解$condiComment="if...";}#if end#反之單獨這條件沒設定註解else if(!isset($conf["conditionComment"][$index])){#設置預設的註解$condiComment="if...";}#if end#反之else{#設定條件式註解$condiComment=$conf["conditionComment"][$index];}#else end#如果沒有設置要做的事之註解if(!isset($conf["todoComment"])){#設置預設的註解$todoComment="do something...";}#if end#反之單獨這條件沒設定設置要做的事之註解else if(!isset($conf["todoComment"][$index])){#設置預設的註解$todoComment="do something...";}#if end#反之有設置註解else{#設置的註解$todoComment=$conf["todoComment"][$index];}#else end#如果存在要做的事情if(isset($conf["todo"][$index])){#計數加1$times++;#判斷是第幾次,來決定if...else if...的呈現.switch($times){#如果是第一個條件case 1:#設置判斷與要做的事情$script=$script."//if ".$condiComment."if(".$condi."){//".$todoComment."".$conf["todo"][$index]."}//if end";#跳出switchbreak;default:#設置判斷與要做的事情$script=$script."//else if ".$condiComment."else if(".$condi."){//".$todoComment."".$conf["todo"][$index]."}//if end";}#switch end}#if end}#foreach end#判斷有無要加<script></script>if($conf["scriptTag"]==="true"){#函式說明:#依據需要加上<script></script>標籤,並且可以指定要匯入的js檔案.#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],javaScript語法#$result["importJS"],匯入js的語法,必定含有<script></script>標籤.#必填參數:#$conf["jsProgramSection"],陣列字串,不含<script></script>標籤的javsScript程式碼,可以放多個script程式.$conf["javaScript::addScriptTag"]["jsProgramSection"]=array($script);#可省略參數:#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑,請與參數"jsPosition"一起設置,預設為當前檔案的位置.#$conf["fileArgu"]=__FILE__;#$conf["jsPosition"],字串,要匯入的js檔案位置.#$conf["jsPosition"]="";#$conf["noScriptTag"],字串,是否不要用script tag包住回傳的內容($result["content"]),"true"代表不要用,"false"代表要用,預設為"false".#$conf["noScriptTag"]="false";$addScriptTag=javaScript::addScriptTag($conf["javaScript::addScriptTag"]);unset($conf["javaScript::addScriptTag"]);#如果加上script標籤失敗if($addScriptTag["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$addScriptTag;#回傳結果return $result;}#if end#取得js語法$result["content"]=$addScriptTag["content"];}#if end#反之else{#取得js語法$result["content"]=$script;}#else end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function jsIF end/*#函式說明:#建立qbpwcf專屬的js函式庫#回傳結果#$result["funciton"],當前函式的名稱.#$result["status"],執行的狀態,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息#$result["content"],語法.#必填參數:#無.#可省略參數:#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.#$conf["noScriptTag"]="false";#參考資料:#無.#備註:#無.*/public static function qbpwcfJavaScript(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],執行不正常結束的錯訊息陣列.#$result["simpleError"],簡單表示的錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["argu"],設置給予的參數.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可省略參數:#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");#$conf["mustBeFilledVariableName"]=array();#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".#$conf["mustBeFilledVariableType"]=array();#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.#$conf["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array();#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noScriptTag");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".#$conf["disallowAllSkipableVarIsEmpty"]="";#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".#$conf["disallowAllSkipableVarIsEmptyArray"]="";#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".#$conf["disallowAllSkipableVarNotExist"]="";#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料:#array_keys=>http://php.net/manual/en/function.array-keys.php#備註:#無.$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果執行出錯if($checkArguments["status"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查不通過if($checkArguments["passed"]==="false"){#設置錯誤狀態$result["status"]="false";#設置錯誤提示$result["error"]=$checkArguments;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//debugconsole.log('override addEventListener');//參考資料 https://stackoverflow.com/questions/446892/how-to-find-event-listeners-on-a-dom-node-when-debugging-or-from-the-javascript//override addEventListener, when not native codeif(Element.prototype.addEventListener.toString().includes('native code')!==true){Element.prototype._addEventListener = Element.prototype.addEventListener;Element.prototype.addEventListener = function(a,b,c){this._addEventListener(a,b,c);if(!this.eventListenerList) {this.eventListenerList = {};}if(!this.eventListenerList[a]) {this.eventListenerList[a] = [];}this.eventListenerList[a].push(b);};}//if end//debug//console.log('add scrollingListMiddleEvent');//新增當視窗大小改變時的事件window.scrollingListMiddleEvent();//frame 大小調整 - start//立馬跑一次window.changeFrameEleHeightToFullLessSource.run.call();//綁定事件window.addEventListener('resize',window.changeFrameEleHeightToFullLessSource.run);//frame 大小調整 - end//div frame 大小調整 - start//立馬跑一次window.changeDivFrameEleHeightToFullLessSource.run.call();//綁定事件window.addEventListener('resize',window.changeDivFrameEleHeightToFullLessSource.run);//frame 大小調整 - end//綁定檢查reCAPTCHA的事件getGoogle_reCAPTCHA_res_event();//托移的事件window.dragEventHandler.func.call();//如果沒有 window.qbpwcfif(window.qbpwcf===undefined){//初始化為空物件window.qbpwcf={};}//if end//close Iconwindow.qbpwcf.closeIcon='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpvc2I9Imh0dHA6Ly93d3cub3BlbnN3YXRjaGJvb2sub3JnL3VyaS8yMDA5L29zYiIKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgd2lkdGg9IjEwNS43ODE3Mm1tIgogICBoZWlnaHQ9IjEwNS4zNDM0NG1tIgogICB2aWV3Qm94PSIwIDAgMTA1Ljc4MTcyIDEwNS4zNDM0NCIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnOCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45MitkZXZlbCB1bmtub3duIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9zZUljb24uc3ZnIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzMiI+CiAgICA8bGluZWFyR3JhZGllbnQKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDQzMTUiCiAgICAgICBvc2I6cGFpbnQ9InNvbGlkIj4KICAgICAgPHN0b3AKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MTsiCiAgICAgICAgIG9mZnNldD0iMCIKICAgICAgICAgaWQ9InN0b3A0MzEzIiAvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0MzkxIgogICAgICAgeD0iLTAuMDY4OTc3MTAzIgogICAgICAgd2lkdGg9IjEuMTM3OTU0MiIKICAgICAgIHk9Ii0wLjA3NTI5OTk5MyIKICAgICAgIGhlaWdodD0iMS4xNTA2Ij4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIxLjAwNjI1NDMiCiAgICAgICAgIGlkPSJmZUdhdXNzaWFuQmx1cjQzOTMiIC8+CiAgICA8L2ZpbHRlcj4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0NDM4IgogICAgICAgeD0iLTAuMDIyNjIyOTA0IgogICAgICAgd2lkdGg9IjEuMDQ1MjQ1OCIKICAgICAgIHk9Ii0wLjAyNTU1NTYxNCIKICAgICAgIGhlaWdodD0iMS4wNTExMTEyIj4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIwLjIyMTcwNjAxIgogICAgICAgICBpZD0iZmVHYXVzc2lhbkJsdXI0NDQwIiAvPgogICAgPC9maWx0ZXI+CiAgICA8ZmlsdGVyCiAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICBzdHlsZT0iY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzOnNSR0IiCiAgICAgICBpZD0iZmlsdGVyNDQ0NiIKICAgICAgIHg9Ii0wLjAyMzIzMjg0NyIKICAgICAgIHdpZHRoPSIxLjA0NjQ2NTgiCiAgICAgICB5PSItMC4wMjQ4MTk1NDUiCiAgICAgICBoZWlnaHQ9IjEuMDQ5NjM5MSI+CiAgICAgIDxmZUdhdXNzaWFuQmx1cgogICAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICAgIHN0ZERldmlhdGlvbj0iMC4yMjIwOTQyOCIKICAgICAgICAgaWQ9ImZlR2F1c3NpYW5CbHVyNDQ0OCIgLz4KICAgIDwvZmlsdGVyPgogIDwvZGVmcz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSIxMzAuNTY4NjgiCiAgICAgaW5rc2NhcGU6Y3k9IjIwMS4zNDg0NSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzQ0ODgiCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtcm90YXRpb249IjAiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTYwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI4MzYiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiIC8+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNSI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgc3R5bGU9ImRpc3BsYXk6aW5saW5lIgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MC4wNTQwMzQsLTg5LjA0MzUyMikiPgogICAgPGcKICAgICAgIGlkPSJnNDQ4OCIKICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDIuNjU1MDQ0MywwLDAsMi44NTQ2OTA3LC0xMTAuOTk1MTgsLTMyNi45MjY1MikiPgogICAgICA8ZWxsaXBzZQogICAgICAgICByeT0iMTYuMDM1OTI3IgogICAgICAgICByeD0iMTcuNTA1ODg0IgogICAgICAgICBjeT0iMTY0LjE2NTUxIgogICAgICAgICBjeD0iODAuNTc4NzIiCiAgICAgICAgIGlkPSJwYXRoMzQ3NCIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MC4zO2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MC4yNjQ5OTk5OTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxO2ZpbHRlcjp1cmwoI2ZpbHRlcjQzOTEpO2ltYWdlLXJlbmRlcmluZzphdXRvIiAvPgogICAgICA8cmVjdAogICAgICAgICB0cmFuc2Zvcm09InJvdGF0ZSgtNDIuODA4OTU1KSIKICAgICAgICAgcnk9IjAiCiAgICAgICAgIHk9IjE3NC41NTY0OSIKICAgICAgICAgeD0iLTY3LjM5ODc1OCIKICAgICAgICAgaGVpZ2h0PSIyLjE1MjIwNjQiCiAgICAgICAgIHdpZHRoPSIyOS4yNzk2NDgiCiAgICAgICAgIGlkPSJyZWN0NDQxMyIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiNmZmZmMDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MTtmaWx0ZXI6dXJsKCNmaWx0ZXI0NDQ2KSIgLz4KICAgICAgPHJlY3QKICAgICAgICAgdHJhbnNmb3JtPSJyb3RhdGUoLTEzOS4wMzQ0MikiCiAgICAgICAgIHJ5PSIwIgogICAgICAgICB5PSItNzMuMDUwOTQ5IgogICAgICAgICB4PSItMTgyLjk2MjUyIgogICAgICAgICBoZWlnaHQ9IjIuMTUyMjA2NCIKICAgICAgICAgd2lkdGg9IjI5LjI3OTY0OCIKICAgICAgICAgaWQ9InJlY3Q0NDEzLTMiCiAgICAgICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZjAwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1vcGFjaXR5OjE7ZmlsdGVyOnVybCgjZmlsdGVyNDQzOCkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K';";#可省略參數:#$conf["onReady"],字串,是否要在網頁載入完再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.$conf["javaScript::toScript"]["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.$conf["javaScript::toScript"]["jsFunciton"][]="//調整滾軸表單的置中效果事件function scrollingListMiddleEvent(){//綁定視窗resize的事件window.addEventListener('resize',function(event){//debug//console.log('resized');//調整滾軸表單的置中效果scrollingListMiddleFunction();});}//function scrollingListMiddleEvent end";$conf["javaScript::toScript"]["jsFunciton"][]="//調整滾軸表單的置中效果function scrollingListMiddleFunction(){//取得下拉式選單的divvar rootDiv=document.getElementById('scrollingListRootDiv');//如果沒有下拉式選單的divif(rootDiv===null){//debug//console.log('沒有下拉式選單的div');return false;}//if end//取得下拉式選單的外框高度var listOutterDivHeight=rootDiv.children[0].clientHeight;//下拉式選單的外框高度//console.log(listOutterDivHeight);//取得下拉式選單的內寬高度var listInnerDivHeight=rootDiv.children[0].children[0].clientHeight;//下拉式選單的內寬高度//console.log(listInnerDivHeight);//如果有滾軸if(rootDiv.children[0].scrollTopMax!==0 && rootDiv.children[0].scrollTopMax!==undefined){//debug//console.log('有滾軸');//debug//console.log(rootDiv.children[0].scrollTopMax);//取消選項內框與選單外框的高度rootDiv.children[0].children[0].style['margin-top']='unset';//結束 eventreturn false;}//if end//沒有滾軸//debug//console.log('沒有滾軸');//計算選項內框與選單外框的高度var marginTop=((listOutterDivHeight-listInnerDivHeight)/2).toString()+'px';//debug//console.log(marginTop);//如果是火狐瀏覽器if(navigator.userAgent.includes('Firefox')){//設置選項內框與選單外框的高度,已便讓選項列表上下置中於選單外框rootDiv.children[0].children[0].style.marginTop=marginTop;}//if end}//function scrollingListMiddleFunction end";$conf["javaScript::toScript"]["jsFunciton"][]="//變更iframe自己的高度為螢幕高度減去來源iframe高度的functionvar changeFrameEleHeightToFullLessSource={changeSizeFrameId:null,fixedSizeFrameId:null,run:function(){var changeSizeFrameId=window.changeFrameEleHeightToFullLessSource.changeSizeFrameId;var fixedSizeFrameId=window.changeFrameEleHeightToFullLessSource.fixedSizeFrameId;//如果未設置則結束函式if(changeSizeFrameId===null || fixedSizeFrameId===null){return false;}var bottomDiv=document.getElementById(fixedSizeFrameId).parentElement;var bottomDivH=bottomDiv.clientHeight;var windowH=document.body.clientHeight;var topDiv=document.getElementById(changeSizeFrameId).parentElement;var topDivH=topDiv.clientHeight;var bottomDivStyle=window.getComputedStyle(bottomDiv,null);//console.log('original height is '+bottomDivStyle['height']);//console.log('var windowH is '+windowH);//console.log('var topDivH is '+topDivH);var newBottomDivH=windowH-topDivH+'px';bottomDiv.style.height=windowH-topDivH+'px';//console.log('altered height is '+newBottomDivH);}}";$conf["javaScript::toScript"]["jsFunciton"][]="//變更div frame 自己的高度為螢幕高度減去來源 div frame 高度的 functionvar changeDivFrameEleHeightToFullLessSource={changeSizeFrameId:null,fixedSizeFrameId:null,run:function(){var changeSizeFrameId=window.changeDivFrameEleHeightToFullLessSource.changeSizeFrameId;var fixedSizeFrameId=window.changeDivFrameEleHeightToFullLessSource.fixedSizeFrameId;//如果未設置則結束函式if(changeSizeFrameId===null || fixedSizeFrameId===null){//console.log('no target');return false;}var bottomDiv=document.getElementById(fixedSizeFrameId);var bottomDivH=bottomDiv.clientHeight;var windowH=document.body.clientHeight;var topDiv=document.getElementById(changeSizeFrameId);var topDivH=topDiv.clientHeight;var bottomDivStyle=window.getComputedStyle(bottomDiv,null);//console.log('original height is '+bottomDivStyle['height']);//console.log('var windowH is '+windowH);//console.log('var topDivH is '+topDivH);var newBottomDivH=windowH-topDivH+'px';bottomDiv.style.height=windowH-topDivH+'px';//console.log('altered height is '+newBottomDivH);}}";$conf["javaScript::toScript"]["jsFunciton"][]="// custom blob function startvar MyBlobBuilder = function() {this.parts = [];}MyBlobBuilder.prototype.append = function(part) {this.parts.push(part);this.blob = undefined; // Invalidate the blob};MyBlobBuilder.prototype.getBlob = function(mimeType) {if(mimeType===''){mimeType=\"text/plain\";}if (!this.blob) {this.blob = new Blob(this.parts, { type: mimeType });}return this.blob;};// custom blob function end";$conf["javaScript::toScript"]["jsFunciton"][]="// 建構子 conDownloadAgent startvar conDownloadAgent=function(){this.xmlhttp=''; //XMLHttpRequestthis.fileUrl=''; //要下載的檔案urlthis.resHeaders=''; //回傳的headerthis.resHeadersArray=[];//回傳的header arraythis.fileContent=new Blob(); //檔案的2元碼this.filePartContent=[]; //2元碼檔案內容的片段陣列.this.fileContentBase64=''; //檔案的base64碼this.fileMimeType=''; //檔案的mime tpyethis.fileName=''; //檔案的名稱this.start=0; //要下載的檔案部分bytes位置開頭this.end=0; //要下載的檔案部分bytes位置結束this.total=0; //要下載的檔案總共bytes數this.partSize=1024; //一次要下載多少bytesthis.retryIn=3; //當下載的長度不對,或下載失敗,幾秒後重新連線.this.getPart=function(){//如果沒有指定檔案的網址if(this.fileUrl===''){//提示錯誤console.log('fileUrl 未指定!');//結束程式return false;}//if end//檢查檔案下載好了沒if(this.validateFile===false){//結束程式return false;}//if end//如果存在 xml http request 屬性if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}//if end//反之代表為ie 5,6else{// code for IE6, IE5xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}// else end//取得當前物件var thisClone=this;//如果服務端有回傳完稱的狀態xmlhttp.addEventListener('loadend',function(){//取得 xmlhttp 的回應var xmlhttp=this;//取得 conDownloadAgent 的物件var conDownloadAgent=thisClone;//將取得的內容用2元碼儲存var blob = new Blob([xmlhttp.response]);//儲存該段的2元碼conDownloadAgent.filePartContent.push(blob);//取得回傳的 headerconDownloadAgent.resHeaders=xmlhttp.getAllResponseHeaders();//取得回傳的 header 陣列conDownloadAgent.resHeadersArray=conDownloadAgent.resHeaders.split('\\r\\n');//另存 headervar headerArray=conDownloadAgent.resHeadersArray;//針對每個 headerfor(var i=0;i<headerArray.length;i++){//取得其中一個 headervar oneHeader=headerArray[i];//檢查有無關鍵字 'Content-Range: bytes 'var foundKeyWord=oneHeader.includes('Content-Range: bytes ');//如果有找到關鍵字if(foundKeyWord===true){//取得實際應該要取得的 bytes 跟總共有多少 bytesvar contentRange=oneHeader.split('Content-Range: bytes ');var contentRange=contentRange[1];var bytesInfo=contentRange.split('/');//實際上的檔案總bytesconDownloadAgent.total=parseInt(bytesInfo[1]);//解析本次取得的bytes位置開頭與結尾var revInfo=bytesInfo[0].split('-');//本次取得的bytes位置開頭conDownloadAgent.start=parseInt(revInfo[0]);//本次取得的bytes位置結束conDownloadAgent.end=parseInt(revInfo[1]);}//if end//檢查有無關鍵字 'Content-Disposition: inline; filename='var foundKeyWord=oneHeader.includes('Content-Disposition: inline; filename=');//如果有找到關鍵字且尚未取得檔單的名稱if(foundKeyWord===true && conDownloadAgent.fileName===''){//解析檔案的名稱var fileInfo=oneHeader.split('Content-Disposition: inline; filename=');//取得檔案名稱conDownloadAgent.fileName=fileInfo[1];}//if end//檢查有無關鍵字 'Content-Type: 'var foundKeyWord=oneHeader.includes('Content-Type: ');//如果有找到關鍵字且尚未取得檔案的mimeTypeif(foundKeyWord===true && conDownloadAgent.fileMimeType===''){//解析檔案的mimeTypevar fileInfo=oneHeader.split('Content-Type: ');//取得檔案mimeTypeconDownloadAgent.fileMimeType=fileInfo[1];}//if end}//for end//如果取得的檔案內容長度不為header提供的總長度.if(conDownloadAgent.filePartContent[conDownloadAgent.filePartContent.length-1].size!==conDownloadAgent.end-conDownloadAgent.start+1){//換算要多少豪秒var retryInNms=conDownloadAgent.retryIn*1000;//debugconsole.log('該段長度不對,'+conDownloadAgent.retryIn+'秒後重新下載');//conDownloadAgent.retryIn秒後再度嘗試下載setTimeout(function(){//遞迴呼叫自己,繼續下載conDownloadAgent.getPart();},retryInNms);//結束程式return;}//if end//如果取得的長度結尾不為 實際上的檔案總bytes-1if(conDownloadAgent.end!==conDownloadAgent.total-1){//取得尚未下載到的bytesvar unDownBytes=conDownloadAgent.total-1-conDownloadAgent.end;//如果剩下的bytes大於 conDownloadAgent.partSizeif(unDownBytes>conDownloadAgent.partSize){//設置新的要下載bytes位置開頭conDownloadAgent.start=parseInt(conDownloadAgent.end)+1;//設置新的要下載bytes位置結束conDownloadAgent.end=parseInt(conDownloadAgent.end)+parseInt(conDownloadAgent.partSize);}//if end//反之剩下不到 conDownloadAgent.partSize 未下載else{//設置新的要下載bytes位置開頭conDownloadAgent.start=parseInt(conDownloadAgent.end)+1;//設置新的要下載bytes位置結束conDownloadAgent.end=parseInt(conDownloadAgent.end)+unDownBytes;}//else end//遞迴呼叫自己,繼續下載conDownloadAgent.getPart();}//if end//反之代表下載完成else{//debugconsole.log('下載完成');//下載檔案conDownloadAgent.get();}//else end});//設定要用get傳送的數值xmlhttp.open('GET',this.fileUrl,true);//預設 mimeTypevar mimeType='application/x-www-form-urlencoded';//如果有 fileMimeTypeif(this.fileMimeType!==''){//另存 mimeTypevar mimeType=this.fileMimeType;}//if end//設定 headerxmlhttp.setRequestHeader('Content-type',mimeType);//設定要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//設置取得的回應為blob(2元密)xmlhttp.responseType = 'blob';//設置要求的範圍xmlhttp.setRequestHeader('Range','bytes='+this.start+'-'+this.end);//設置request的timeout(毫秒)//xmlhttp.timeout=this.timeout*1000;//傳送要求xmlhttp.send();};//function get part end//產生下載檔案的連結,並點擊之this.get=function(){//取得當前物件var conDownloadAgent=this;//debugconsole.log('建立base64的link來下載檔案');//檢查檔案下載好了沒if(this.validateFile===false){//結束程式return false;}//if end//建立blob物件var myBlobBuilder = new MyBlobBuilder();//針對每個blob部分for(var i=0;i<conDownloadAgent.filePartContent.length;i++){//append該部分的blobmyBlobBuilder.append(conDownloadAgent.filePartContent[i]);}//for end//取得append後的內容conDownloadAgent.fileContent = myBlobBuilder.getBlob(conDownloadAgent.fileMimeType);//讀取blob的內容var reader = new FileReader();//增加讀取完檔案後要做的事情reader.addEventListener('loadend',function(){//return false;//儲存base64的檔案內容conDownloadAgent.fileContentBase64=reader.result;//建立元素avar aNode = document.createElement('a');//組成link的內容aNode.href=conDownloadAgent.fileContentBase64;//設置link為不顯示的樣式aNode.style.display='none';//設置link的id為aNode.id='conDownloadLink';//放置linkdocument.body.appendChild(aNode);//點擊下載的linkdocument.getElementById(aNode.id).click();//移除下載的linkdocument.getElementById(aNode.id).remove();});//reader.addEventListener end//讀取檔案的2元碼reader.readAsDataURL(conDownloadAgent.fileContent);};//function get end//檢查檔案是否下載好了, return true/falsethis.validateFile=function(){//如果沒有檔案大小if(conDownloadAgent.total===''){//debugconsole.log('檔案未下載完成');//結束程式return false;}//if end//取得所下載檔案的大小var fileSize=conDownloadAgent.total;//初始化取得的檔案大小var gettedFileSize=0;//檢查是否有下載完成檔案,針對每個blob部分for(var i=0;i<conDownloadAgent.filePartContent.length;i++){//累加取得的檔案大小gettedFileSize=gettedFileSize+conDownloadAgent.filePartContent[i].size;}//for end//如果要下載檔案的大小不等於實際上所下載到的長度if(fileSize!==gettedFileSize){//debugconsole.log('檔案未下載完成');//結束程式return false;}//if end//回傳 true 檔案已經下載好了return true;}//function validateFile end};//function conDownloadAgent end";$conf["javaScript::toScript"]["jsFunciton"][]="/*函式說明:驗證 gGoogle reCAPTCHA 的回應回傳結果:false,代表驗證失敗.true,代表有進行驗證流程必填參數key,session keyvalue,value store in session key*/var getGoogle_reCAPTCHA_res=function(key='google_reCAPTCHA_pass',val=document.URL){//如果沒有 recaptcha 元素存在if(document.getElementById('g-recaptcha-response')===null){//回傳結果return false;}//if end//取得 reCAPTCHA 的回應res=document.getElementById('g-recaptcha-response').value;//如果數值是空的,代表用戶沒有驗證if(res===''){//回傳結果return false;}//if end//反之用 ajax 跟 Server 端驗證else{//建立 XMLDocif(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();//設置 server 應該要回傳 jsonxmlhttp.responseType='json';}//if endelse{// code for IE6, IE5xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}//else end//如果服務端有回傳完成的狀態xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState==4 && xmlhttp.status==200){//如果回應為通過if(xmlhttp.response.status==='true' || xmlhttp.response.status===true){//將 recaptcha 移除document.getElementsByClassName('g-recaptcha')[0].remove();}//if end}//if end}//function end//設定要求的屬性、目的、是否不要同步xmlhttp.open('POST','../json/authenticate/gl_reCAPTCHA_server.php',true);//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定 要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//要傳送的數值名稱與數值內容,ex:num1=100&num2=50xmlhttp.send('response='+res+'&key='+key+'&val='+val);}//else end//有進入驗證流程return true;}";$conf["javaScript::toScript"]["jsFunciton"][]="/*涵式說明:提供偵測可能已經通過reCAPCHA,接着進行驗證回傳的結果是否正確.*/var getGoogle_reCAPTCHA_res_event=function(){//如果沒有 recaptcha 元素存在if(document.getElementsByClassName('g-recaptcha').length===0){//回傳結果return false;}//if end//取得產生reCAPCHA內容的divgrdiv=document.getElementsByClassName('g-recaptcha')[0];//滑鼠進來grdiv.addEventListener('mouseenter',function(){//檢查有無通過驗證getGoogle_reCAPTCHA_res();});//滑鼠離開grdiv.addEventListener('mouseout',function(){//檢查有無通過驗證getGoogle_reCAPTCHA_res();});}";$conf["javaScript::toScript"]["jsFunciton"][]="//如果 window.qbpwcf 不存在if(window.qbpwcf===undefined){//初始化 window qbpwcf 物件window.qbpwcf={};}//if end/*涵式說明:將同 data-form-id 的input/textarea內容用表單的方式傳送出去(POST)params.ele, 要綁定事件的元素.params.formId, 用來識別表單群體的名稱.params.url, 表單要傳送到的地方.params.method, GET or POST.*/window.qbpwcf.sendByDataFormId=function(params){//如果沒有eleif(params.ele===undefined){//結束執行return;}//if end//取得要取得的elevar ele=params.ele;//如果沒有formIdif(params.formId===undefined){//預設為 'qbpwcf_form'params.formId='qbpwcf_form';}//if end//取得要取得的formIdvar formId=params.formId;//如果沒有formIdif(params.url===undefined){//預設為當前網址params.url=location.href;}//if end//取得表單要傳送到的地方var url=params.url;//如果沒有methodif(params.method===undefined){//預設為postparams.method='POST';}//if end//限定為postvar method=params.method;//綁定點擊事件params.ele.addEventListener('click',async function(event){//如果沒有鎖頭if(this.dataset.lock===undefined){//設置為上鎖this.dataset.lock==='false';}//if end//如果已經上鎖了if(this.dataset.lock==='true'){//結束執行return false;}//if end//上鎖this.dataset.lock='true';//取得所有 inputsvar dataFormId='data-form-id=\"'+formId+'\"';dataFormId='input['+dataFormId+']';eval('var inputDataFormId=\''+dataFormId+'\'');var inputs=document.querySelectorAll(inputDataFormId);//取得所有 textareavar dataFormId='data-form-id=\"'+formId+'\"';dataFormId='textarea['+dataFormId+']';eval('var textareaDataFormId=\''+dataFormId+'\'');var textareas=document.querySelectorAll(textareaDataFormId);//debugconsole.log(inputs,textareas);//初始化查詢的字串var queryStr='';//如果有inputif(inputs.length!==0){//針對每個inputfor(var i=0;i<inputs.length;i++){//如果不是空的if(queryStr!==''){//串接'&'queryStr=queryStr+'&';}//if end//加上查詢內容queryStr=queryStr+inputs[i].name+'='+encodeURIComponent(inputs[i].value);}//for end}//if end//如果有textareaif(textareas.length!==0){//針對每個textareafor(var i=0;i<textareas.length;i++){//如果不是空的if(queryStr!==''){//串接'&'queryStr=queryStr+'&';}//if end//加上查詢內容queryStr=queryStr+textareas[i].name+'='+encodeURIComponent(textareas[i].value);}//for end}//if end//初始化查詢的字串console.log('queryStr='+queryStr);//如果沒有任何inputif(inputs.length===0 && textareas.length===0){//結束執行return;}//if end//debugconsole.log('params.method='+params.method);console.log('params.url='+params.url);//傳送表單/*設置 window.qbpwcf.ajaxP 函數說明:傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.參數:params={};params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';params.headers={name:value};params.url='url to request';params.preAc='function name to call before send request';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};參考資料:https://eyesofkids.gitbooks.io/javascript-start-es6-promise/content/contents/ch11_snippets.htmlhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise*/ajaxP_params={};ajaxP_params.data=queryStr;ajaxP_params.method=params.method;ajaxP_params.url=params.url;var res = await window.qbpwcf.ajaxP.call(this,ajaxP_params);//debugconsole.log(res);//解鎖this.dataset.lock='false';});}";$conf["javaScript::toScript"]["jsFunciton"][]="//如果 window.qbpwcf 不存在if(window.qbpwcf===undefined){//初始化 window qbpwcf 物件window.qbpwcf={};}//if end//初始化物件window.qbpwcf.postDataAttr={};/*函式說明:設置點擊元素後會傳遞data屬性為名稱與其數值為表單數值給特定url,然後依照片段show到當前頁面.參數說明:element,要綁定事件的元素.url,表單要傳送到的位置.method,傳送的方法,有POST跟GET兩種範例用法:element=document.getElementsByClassName('quickDayLog')[0];window.qbpwcf.postDataAttr.func.call(this,element,'logRes.php','POST','rootDiv');*/window.qbpwcf.postDataAttr.func=function(element,url,method,rootDiv){//綁定事件到元素上element.addEventListener('click',function(event){//取得目標urlwindow.qbpwcf.postDataAttr.url=url;//取得表單傳遞方式window.qbpwcf.postDataAttr.method=method;//取得抓取回應並要放置到哪個id的div裡面window.qbpwcf.postDataAttr.rootDiv=rootDiv;//初始化要傳送的表單物件window.qbpwcf.postDataAttr.params={};//取得元素的datadataset=element.dataset;//針對每個表單名稱for(i=0;i<Object.keys(dataset).length;i++){//取得表單名稱key=Object.keys(dataset)[i];//取得表單內容val=eval('dataset.'+key);//取得表單的內容eval('window.qbpwcf.postDataAttr.params.'+key+'='+val);}//for end//遞迴取得回應並放在特定div裡面window.qbpwcf.tailAny.func.call(this,window.qbpwcf.postDataAttr.params,window.qbpwcf.postDataAttr.url,window.qbpwcf.postDataAttr.method,window.qbpwcf.postDataAttr.rootDiv);});//function end};";$conf["javaScript::toScript"]["jsFunciton"][]="/*涵式說明:統一處理托移事件*/// drag event handler startwindow.dragEventHandler={};//儲存被拖移的元素window.dragEventHandler.dragged={};//儲存被壓住的元素window.dragEventHandler.dropped={};/*可以被托移的物件範例<style>.dropzone {width: 200px;height: 20px;color: white;background: blue;margin-bottom: 10px;}</style><div class='dropzone'><div draggable='true'>This div is draggable</div></div><div class='dropzone'></div><div class='dropzone'></div><div class='dropzone'></div>*//*處理被拖移元素壓住其他元素後的事件處理函式,宣告即可設定如何處理.參數被托移的元素obj.dragged被壓住的元素obj.droppedwindow.dragEventHandler.handler=function(param){};若不宣告則,如果被壓住的div有 'dropzone' 類別,才會動作.*//*參考資料:https://developer.mozilla.org/en-US/docs/Web/API/Document/drag_event*///事件綁定的函式window.dragEventHandler.func=function(){//events fired on the draggable targetdocument.addEventListener('drag', function(event) {});//開始托移document.addEventListener('dragstart', function(event) {//讓被托移的目標可以被被看到event.dataTransfer.setData('text/plain',null);// store a ref. on the dragged elemwindow.dragEventHandler.dragged = event.target;// make it half transparentevent.target.style.opacity = .5;});//在被托移物品上移動時./* events fired on the drop targets */document.addEventListener('dragover', function(event) {// prevent default to allow dropevent.preventDefault();});//移到別的元素時觸發document.addEventListener('dragenter', function(event) {// highlight potential drop target when the draggable element enters itif (event.target.className == 'dropzone'){event.target.style.opacity = .5;}});//移開移動到的元素時觸發document.addEventListener('dragleave', function(event) {// unhighlight of potential drop target when the draggable element leaves itif (event.target.className == 'dropzone') {//設置不透明event.target.style.opacity = 1.0;}});//放開移動中的元素時觸發document.addEventListener('drop', function(event) {// prevent default action (open as link for some elements)event.preventDefault();// 取得被壓的元素window.dragEventHandler.dropped=event.target// move dragged elem to the selected drop targetif (event.target.className == 'dropzone') {//設置不透明event.target.style.opacity = 1.0;}});}//托移結束document.addEventListener('dragend', function(event) {// reset the transparencyevent.target.style.opacity = '';//初始化要回傳的元素obj={};//設置被托移的元素obj.dragged=window.dragEventHandler.dragged;//設置被壓住的元素obj.dropped=window.dragEventHandler.dropped;//debugconsole.log(obj);if(window.dragEventHandler.handler!==undefined){if(typeof(window.dragEventHandler.handler)==='function'){window.dragEventHandler.handler.call(this,obj);}}//採用預設的做法else{//被壓住的不是div就停止if(window.dragEventHandler.dropped.tagName!=='DIV'){return false;}//目標div有幾個類別就執行幾次for(i=0;i<window.dragEventHandler.dropped.classList.length;i++){//如果被壓住的div有 'dropzone' 類別,才會動作.if(window.dragEventHandler.dropped.classList[i]==='dropzone'){//覆蓋到目標元素window.dragEventHandler.dropped.innerHTML=window.dragEventHandler.dragged.outerHTML;//移除被移開的元素window.dragEventHandler.dragged.innerHTML='';//結束迴圈break;}}}});// drag event handler end";$conf["javaScript::toScript"]["jsFunciton"][]="/*導頁的函式:*///如果沒有 window.redirectURLif(window.redirectURL===undefined){//宣告 window.redirectURL 為空物件window.redirectURL={};}//if end//設置 window.redirectURL 變數為 function,參數為 paramswindow.redirectURL=function(params){//如果 params.url 未定義if(params.url===undefined){//設置要回傳的物件result={};//設置執行錯誤result.status=false;//設置錯誤訊息陣列result.error=[];//設置錯誤訊息result.error.push('params.url undefined');//回傳結果return result;}//if end//如果 params.countdownSec 未定義if(params.countdownSec===undefined){//直接導頁到 params.urlwindow.location.href=params.url;}//if end//反之else{//設置過了 params.countdownSec 秒後要做的事情.setTimeout(function(){//導頁到 params.urlwindow.location.href=params.url;},params.countdownSec*1000);}//else end}//if end";$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:遞迴取得特定頁面產生的內容.參數:parmas,要傳送的參數名稱與其數值.url,要求的網址.method,要求的方法,GET或POST二擇一.resRootDivId,回應的內容要放在div的id為resRootDivId的地方裡面.範例用法:params={};params.key=val;//用於查尋的變數名稱與數值內容continue=true;//是否要不斷執行.window.tailAny.func.call(this,params,'/tailLogRes.php','POST','rootDiv');要求的網址回應如下:res,回應的物件res.lines,回應的內容列.res.id,最新識別欄位與數值.*///如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//初始化 window.tailAny 物件window.qbpwcf.tailAny={};//初始化 window.qbpwcf.tailAny.continue 為 true,代表遞迴執行.window.qbpwcf.tailAny.continue=true;//初始化 將結果輸出到畫面上的函式//res,為ajax抓到的結果json.//rootDivId,為回應要放到id為rootDivId的div裡面.window.qbpwcf.tailAny.outputFunc=function(res,rootDivId){//針對每個輸出的行for(var i=0;i<res.lines.length;i++){//如果內容不為空if(res.lines[i]!==''){//set output linediv=document.createElement('div');text=document.createTextNode(res.lines[i]);div.appendChild(text);}//if end//反之else{//set output linediv=document.createElement('div');//建立換行語法p=document.createElement('p');//放置換行語法div.appendChild(p);}//else end//show output linerootDiv=document.getElementById(xmlhttp.mother.rootDivId);rootDiv.prepend(div);}//for end}//function window.qbpwcf.tailAny.outputFunc end//初始化 window.tailAny 函式window.qbpwcf.tailAny.func=function(params,url,method,resRootDivId){//取得使用的參數 paramsthis.params=params;//初始化儲存新的get and post變數this.newParams='';//初始化要查尋的 urlthis.url=url;//取得methodthis.method=method;//初始化持續執行this.continue=window.qbpwcf.tailAny.continue;//放置回應的 div id 字串this.rootDivId=resRootDivId;//取得query參數長度pl=Object.keys(params).length;//針對每隔 query 參數for(var i=0;i<pl;i++){//&符號字串var andStr='&';//如果是第一個 query 參數if(i===0){//&符號字串andStr=''}//if end//串接查詢字串,並 url encodethis.newParams=this.newParams+andStr+encodeURIComponent(Object.keys(params)[i])+'='+encodeURIComponent(Object.values(params)[i]);}//for end//如果是 GET 方法if(method==='GET'){//設置查詢的urlthis.url=this.url+'?'+this.newParams;}//if endxmlhttp=new XMLHttpRequest();xmlhttp.mother=this;xmlhttp.responseType='json';xmlhttp.open(method,this.url,true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState===4 && xmlhttp.status===200){//get responseres=xmlhttp.response;//將結果放到畫面上window.qbpwcf.tailAny.outputFunc.call(this,res,xmlhttp.mother.rootDivId);//如果有新的識別欄位與數值if(res.id!==undefined){//取消舊的識別欄位xmlhttp.mother.params={};//如果有新的識別欄位for(i=0;i<Object.keys(res.id).length;i++){//取得識別欄位col=Object.keys(res.id)[i];//取得新的識別號碼val=eval('res.id.'+col);//放上新的識別碼eval('xmlhttp.mother.params.'+col+'='+val);}//for end}//if end//如果要繼續if(xmlhttp.mother.continue){//遞迴window.qbpwcf.tailAny.func(xmlhttp.mother.params,xmlhttp.mother.url,xmlhttp.mother.method,xmlhttp.mother.rootDivId);}//if end//反之要暫停else{//設置無限等待var intervalTail = window.setInterval(function(){//console.log(window.qbpwcf.tailAny.continue);//如果要繼續了if(xmlhttp.mother.continue){//清除無限等待clearInterval(intervalTail);//遞迴window.qbpwcf.tailAny.func(xmlhttp.mother.params,xmlhttp.mother.url,xmlhttp.mother.method,xmlhttp.mother.rootDivId);}//if end},1000);}//else end}//if end}//function end//如果是 GET 方法if(method==='GET'){//不夾帶內容xmlhttp.send();}//if end//反之是 POST 方法else{//夾帶內容xmlhttp.send(this.newParams);}//else end}//function end";$conf["javaScript::toScript"]["jsFunciton"][]="//如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//設置 window.qbpwcf.gatDataDynamic 物件window.qbpwcf.gatDataDynamic={};/*函式說明:當按下案鍵後放開時若元素數值長度符合則要連續取得資料.參數說明:element,要綁定事件的元素.length,目標算術數值長度要為多少才要執行params,篩選資料的參數物件.url,要求的網址.method,要求的方法,有'POST'跟'GET'.rootDiv,要放置回應到id為rootDiv的div裡面.範例呼叫方式:element=document.getElementById('customTime');params={};params.start=element.value;window.qbpwcf.gatDataDynamic.func.call(this,element,8,params,'/logRes.php','POST','rootDiv');*///設置當前函式的變數window.qbpwcf.gatDataDynamic.func=function(element,length,params,url,method,rootDiv){//debug//console.log(element,length,params,url,method,rootDiv);//儲存內容長度要為多少window.qbpwcf.gatDataDynamic.length=length;//儲存要傳遞的條件window.qbpwcf.gatDataDynamic.params=params;//儲存要傳送要求到哪個頁面window.qbpwcf.gatDataDynamic.url=url;//儲存傳遞的方式window.qbpwcf.gatDataDynamic.method=method;//儲存回應的div idwindow.qbpwcf.gatDataDynamic.rootDiv=rootDiv;//初始化暫存的物件window.qbpwcf.gatDataDynamic.tmp={};//初始化暫存最新表單數值的長度window.qbpwcf.gatDataDynamic.tmp.latestValueLength=0;//綁定事件到該元素身上element.addEventListener('keyup',function(event){//取得使用的參數名稱paramName=Object.keys(window.qbpwcf.gatDataDynamic.params)[0];//取得事件觸發後的參數數值eval('window.qbpwcf.gatDataDynamic.params.'+paramName+'=\''+event.target.value+'\'');//誤觸if(event.isComposing || event.keyCode === 229) {//取消執行return false;}//if end//如果長度跟之前比沒有變化,且按下的不為Enter鍵if(event.target.value.length===window.qbpwcf.gatDataDynamic.tmp.latestValueLength && event.keyCode !== 13){//取消執行return false;}//if end//反之長度有變化else{//更新最新變化後的數值長度window.qbpwcf.gatDataDynamic.tmp.latestValueLength=event.target.value.length;}//else end//如果長度不對if(event.target.value.length!==window.qbpwcf.gatDataDynamic.length){//取消執行return false;}//if end//連續取得內容window.qbpwcf.tailAny.func.call(this,window.qbpwcf.gatDataDynamic.params,window.qbpwcf.gatDataDynamic.url,window.qbpwcf.gatDataDynamic.method,window.qbpwcf.gatDataDynamic.rootDiv);});//event end}//function end";$conf["javaScript::toScript"]["jsFunciton"][]="//如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//設置 window.qbpwcf.sequenceQuery 物件window.qbpwcf.sequenceQuery={};/*涵式說明:循序query避免timeout.參數說明:url,字串,要query的網址.name,字串,欲傳送的post變數名稱.queue,代辦事項,陣列,遇到元素內容為'null'者,代表結束query;初次查詢設置為[]即可.callback,物件,要呼叫的涵式名稱與參數,結構如下:{func:'function name';params:'params';}範例:url='path2query';name='action';queue=[];callback={name:'console.log',params:'debug',};window.qbpwcf.sequenceQuery.func.call(this,url,name,queue,callback);*///設置當前函式的變數window.qbpwcf.sequenceQuery.func=function(url,name,queue,callback){//如果網址未指定if(url===undefined){//結束執行return false;}//if end//save url to globalwindow.qbpwcf.sequenceQuery.url=url;//save name to globalwindow.qbpwcf.sequenceQuery.name=name;//save callback to globalwindow.qbpwcf.sequenceQuery.callback={};window.qbpwcf.sequenceQuery.callback.name=callback.name;window.qbpwcf.sequenceQuery.callback.params=callback.params;//debug//console.log(window.qbpwcf.sequenceQuery.callback);//初始化參數params={};//設置參數eval('params.'+name+'=queue');//debug//console.log(params);//初始化參數 window.tailAny.params 字串window.qbpwcf.sequenceQuery.params='';//針對物件中的每個keyObject.keys(params).forEach(function(key){//&符號字串andStr='';//如果參數目前不為空if(window.qbpwcf.sequenceQuery.params!==''){//&符號字串andStr='\&';}//if end//串接查詢字串,並 url encodewindow.qbpwcf.sequenceQuery.params=window.qbpwcf.sequenceQuery.params+andStr+encodeURIComponent(key)+'='+encodeURIComponent(eval('params.'+key));//debug//console.log(window.qbpwcf.sequenceQuery);});//debug//console.log(window.qbpwcf.sequenceQuery.params);xmlhttp=new XMLHttpRequest();xmlhttp.responseType='json';xmlhttp.timeout=60000;xmlhttp.open('POST',url,true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState===4 && xmlhttp.status===200){//get responseres=xmlhttp.response;//debug//console.log(res);//如果執行失敗if(res.status==='false'){//結束執行return false;}//if end//取得回應的內容content=res.content;//debug//console.log(content);//如果遇到null元素if(content[0]==='null'){//callbackeval(window.qbpwcf.sequenceQuery.callback.name+'.call(this,window.qbpwcf.sequenceQuery.callback.params)');//結束執行return true;}//if end//遞迴window.qbpwcf.sequenceQuery.func.call(this,window.qbpwcf.sequenceQuery.url,window.qbpwcf.sequenceQuery.name,content,window.qbpwcf.sequenceQuery.callback);}//if end}//function end//夾帶內容xmlhttp.send(window.qbpwcf.sequenceQuery.params);};";$conf["javaScript::toScript"]["jsFunciton"][]="//如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//設置 window.qbpwcf.modal 物件window.qbpwcf.modal={};//預設的 modal 標題是由 div 組成window.qbpwcf.modal.title=document.createElement('div');//預設的 modal 標題window.qbpwcf.modal.title.innerText='Confirm window';//預設的 modal 標題樣式window.qbpwcf.modal.title.style.fontWeight='bold';//預設的 modal 標題背景顏色window.qbpwcf.modal.bgColor='#DDDDFF';//預設的 modal 內文window.qbpwcf.modal.content=document.createTextNode('Are you sure?');//預設的 取消 按鈕內容window.qbpwcf.modal.cancle='Cancel';//預設的 取消 按鈕背景顏色window.qbpwcf.modal.cancleBgColor='#FFDDDD';//預設的取消按鈕點擊後要做的事情window.qbpwcf.modal.cancelAction=function(e){//delete whole confirm windowdocument.getElementById('qbpwcf.bgDiv').remove();document.getElementById('qbpwcf.modalRootDiv').remove();}//預設的 確認 按鈕內容window.qbpwcf.modal.confirm='Confirm';//預設的 確認 按鈕背景顏色window.qbpwcf.modal.confirmBgColor='#DDFFFF';//預設的確認按鈕要做的事情window.qbpwcf.modal.confirmAction=function(e){alert('you click confirm');window.qbpwcf.modal.cancelAction.call(this);}//modal的最寬高設定物件window.qbpwcf.modal.RootDiv={};//modal的寬度比例,1~99window.qbpwcf.modal.RootDiv.width='80';//modal距離高度的比例window.qbpwcf.modal.RootDiv.top='10';//建立顯示 qbpwcf modal 的函式window.qbpwcf.modal.show=function(){//建立背景divbgDiv=document.createElement('div');//設定樣式為全螢幕bgDiv.style.width='100vw';bgDiv.style.height='100vh';bgDiv.style.backgroundColor='grey';bgDiv.style.opacity='0.7';bgDiv.style.position='fixed';bgDiv.style.top='0px';bgDiv.style.left='0px';bgDiv.style.zIndex='10000';//設定idbgDiv.id='qbpwcf.bgDiv';//確認視窗的divmodalRootDiv=document.createElement('div');//設定idmodalRootDiv.id='qbpwcf.modalRootDiv';//確認視窗的modal樣式modalRootDiv.style.width=window.qbpwcf.modal.RootDiv.width+'vw';modalRootDiv.style.top=window.qbpwcf.modal.RootDiv.top+'vh';modalRootDiv.style.backgroundColor='white';modalRootDiv.style.position='fixed';modalRootDiv.style.left=((100-window.qbpwcf.modal.RootDiv.width)/2)+'vw';modalRootDiv.style.zIndex='10001';modalRootDiv.style.borderRadius='10px';//modal title divmodalTitleDiv=document.createElement('div');//set modal title contentmodalTitleDiv.appendChild(window.qbpwcf.modal.title);//set modal title bg colormodalTitleDiv.style.backgroundColor=window.qbpwcf.modal.bgColor;//set modal title line height attrmodalTitleDiv.style.minHeight='20px';//set modal title line height attrmodalTitleDiv.style.borderRadius='inherit';//set modal title line height attrmodalTitleDiv.style.paddingLeft='5px';//put modal title to modal root divmodalRootDiv.appendChild(modalTitleDiv);//modal content divmodalContentDiv=document.createElement('div');//set modal content textmodalContentDiv.appendChild(window.qbpwcf.modal.content);//set modal content stylemodalContentDiv.style.textAlign='center';modalContentDiv.style.lineHeight=(window.qbpwcf.modal.RootDiv.height-10)+'vh';//put modal content to modal root divmodalRootDiv.appendChild(modalContentDiv);//modal bottom divmodalBottomDiv=document.createElement('div');//set modal bottom line heightmodalBottomDiv.style.lineHeight='6vh';//set modal bptton text align style to rightmodalBottomDiv.style.textAlign='right';//set modal bottom 圓角modalBottomDiv.style.borderRadius='5px';//set modal bottom background colormodalBottomDiv.style.backgroundColor=modalRootDiv.style.backgroundColor;//modal close buttoncancleSpan=document.createElement('span');//字體為粗體字cancleSpan.style.fontWeight='bold';//set model close button text contentcancleSpan.innerText=window.qbpwcf.modal.cancle;//set cancle button background colorcancleSpan.style.backgroundColor=window.qbpwcf.modal.cancleBgColor;//cancle button 元素間的距離cancleSpan.style.marging='5vw';//cancle button 元素的範圍cancleSpan.style.padding='1vh';//cancle button 不超出範圍cancleSpan.style.position='relative';cancleSpan.style.bottom='4vh';//cancle button 圓角cancleSpan.style.borderRadius='100px';//cancle button pointercancleSpan.style.cursor='pointer';//okSpan button right top & bottomcancleSpan.style.top='0px';cancleSpan.style.bottom='0px';//設置點擊 cancle button 要做的事情.cancleSpan.addEventListener('click',function(e){window.qbpwcf.modal.cancelAction(e);});//modal ok buttonokSpan=document.createElement('span');//字體為粗體字okSpan.style.fontWeight='bold';//set model ok button text contentokSpan.innerText=window.qbpwcf.modal.confirm;//set ok button background colorokSpan.style.backgroundColor=window.qbpwcf.modal.confirmBgColor;//okSpan button 元素間的距離okSpan.style.marginLeft='5vw';okSpan.style.marginRight='5vw';//okSpan button 元素的範圍okSpan.style.padding='1vh';//okSpan button 不超出範圍okSpan.style.position='relative';okSpan.style.bottom='4vh';//okSpan button 圓角okSpan.style.borderRadius='100px';//okSpan button pointerokSpan.style.cursor='pointer';//okSpan button right top & bottomokSpan.style.top='0px';okSpan.style.bottom='0px';//設置點擊 cancle button 要做的事情.okSpan.addEventListener('click',function(e){window.qbpwcf.modal.confirmAction(e);});//put cancle and ok button to modal bottom divmodalBottomDiv.appendChild(cancleSpan);modalBottomDiv.appendChild(okSpan);//put modal bottom div to modal root divmodalRootDiv.appendChild(modalBottomDiv);//bgDiv放置到當前 windowdocument.body.appendChild(bgDiv);//put root modal div to bodydocument.body.appendChild(modalRootDiv);}//if end";$conf["javaScript::toScript"]["jsFunciton"][]="//如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//如果未設定 window.qbpwcf.form 物件if(window.qbpwcf.form===undefined){//設置 window.qbpwcf.form 為空物件window.qbpwcf.form={};}//if end/*如果回覆的結果是json,且具有location屬性,則會進行導頁.window.qbpwcf.form.fakeScrollingList(),建構子,初始化fakeScrollingList.window.qbpwcf.form.eleId,選單呈現的元素 id 為什麼,亦即要點擊的元素其id.window.qbpwcf.form.targetEle,選單呈現的元素為,若 eleId 為 '' 且該變數不等於 '' 就會採用.window.qbpwcf.form.closeIcon,關閉按鈕的設定window.qbpwcf.form.noActionOption,物件,name為顯示的內容;value為選單的數值.window.qbpwcf.form.sendOnClickWhenOnly2options,布林值,預設為false,不啟用;反之為true代表點選元素後就直接送出最後一個選項的數值.啟用條件為window.qbpwcf.form.options只有一個元素.window.qbpwcf.form.donotSendFrom,布林值,預設為false,代表選擇了要傳送的項目後,會傳送表單,設置為true代表不會傳送表單只會將選項對應的數值內容交給 window.qbpwcf.form.callback 陣列中的 callback 處理.window.qbpwcf.form.hiddenVar,陣列,每個元素為物件,物件的屬性有name為變數的名稱;value為選單的數值.window.qbpwcf.form.defaultOption,物件,name為顯示的內容;value為選單的數值.window.qbpwcf.form.options,陣列,每個元素為物件,物件的屬性有name為顯示的內容;value為選單的數值.window.qbpwcf.form.recPage,字串,為接收要求的網址,預設為當前頁面.window.qbpwcf.form.sendVarName,傳送表單時的選項對應的變數名稱,預設為'variable'.window.qbpwcf.form.callback,針對所選擇的選項內容,要交由哪些函式處理,形態為陣列.window.qbpwcf.form.getTarget(),抓要變成fakeScrolling List的元素.window.qbpwcf.form.show(),顯示fake Scrolling list.*///設置 this 物件,建構子.window.qbpwcf.form.fakeScrollingList=function(){//要用 fake scrolling list 選單呈現的元素 id 為?this.eleId='';//要用 fake scrolling list 選單呈現的元素為,若 eleId 為 '' 且該變數不等於 '' 就會採用.this.targetEle='';//fake scrolling list 預設選單關閉的 叉叉按鈕this.closeIcon='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpvc2I9Imh0dHA6Ly93d3cub3BlbnN3YXRjaGJvb2sub3JnL3VyaS8yMDA5L29zYiIKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgd2lkdGg9IjEwNS43ODE3Mm1tIgogICBoZWlnaHQ9IjEwNS4zNDM0NG1tIgogICB2aWV3Qm94PSIwIDAgMTA1Ljc4MTcyIDEwNS4zNDM0NCIKICAgdmVyc2lvbj0iMS4xIgogICBpZD0ic3ZnOCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45MitkZXZlbCB1bmtub3duIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9zZUljb24uc3ZnIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzMiI+CiAgICA8bGluZWFyR3JhZGllbnQKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDQzMTUiCiAgICAgICBvc2I6cGFpbnQ9InNvbGlkIj4KICAgICAgPHN0b3AKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzAwMDAwMDtzdG9wLW9wYWNpdHk6MTsiCiAgICAgICAgIG9mZnNldD0iMCIKICAgICAgICAgaWQ9InN0b3A0MzEzIiAvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0MzkxIgogICAgICAgeD0iLTAuMDY4OTc3MTAzIgogICAgICAgd2lkdGg9IjEuMTM3OTU0MiIKICAgICAgIHk9Ii0wLjA3NTI5OTk5MyIKICAgICAgIGhlaWdodD0iMS4xNTA2Ij4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIxLjAwNjI1NDMiCiAgICAgICAgIGlkPSJmZUdhdXNzaWFuQmx1cjQzOTMiIC8+CiAgICA8L2ZpbHRlcj4KICAgIDxmaWx0ZXIKICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgIHN0eWxlPSJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM6c1JHQiIKICAgICAgIGlkPSJmaWx0ZXI0NDM4IgogICAgICAgeD0iLTAuMDIyNjIyOTA0IgogICAgICAgd2lkdGg9IjEuMDQ1MjQ1OCIKICAgICAgIHk9Ii0wLjAyNTU1NTYxNCIKICAgICAgIGhlaWdodD0iMS4wNTExMTEyIj4KICAgICAgPGZlR2F1c3NpYW5CbHVyCiAgICAgICAgIGlua3NjYXBlOmNvbGxlY3Q9ImFsd2F5cyIKICAgICAgICAgc3RkRGV2aWF0aW9uPSIwLjIyMTcwNjAxIgogICAgICAgICBpZD0iZmVHYXVzc2lhbkJsdXI0NDQwIiAvPgogICAgPC9maWx0ZXI+CiAgICA8ZmlsdGVyCiAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICBzdHlsZT0iY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzOnNSR0IiCiAgICAgICBpZD0iZmlsdGVyNDQ0NiIKICAgICAgIHg9Ii0wLjAyMzIzMjg0NyIKICAgICAgIHdpZHRoPSIxLjA0NjQ2NTgiCiAgICAgICB5PSItMC4wMjQ4MTk1NDUiCiAgICAgICBoZWlnaHQ9IjEuMDQ5NjM5MSI+CiAgICAgIDxmZUdhdXNzaWFuQmx1cgogICAgICAgICBpbmtzY2FwZTpjb2xsZWN0PSJhbHdheXMiCiAgICAgICAgIHN0ZERldmlhdGlvbj0iMC4yMjIwOTQyOCIKICAgICAgICAgaWQ9ImZlR2F1c3NpYW5CbHVyNDQ0OCIgLz4KICAgIDwvZmlsdGVyPgogIDwvZGVmcz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSIxMzAuNTY4NjgiCiAgICAgaW5rc2NhcGU6Y3k9IjIwMS4zNDg0NSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzQ0ODgiCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtcm90YXRpb249IjAiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTYwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI4MzYiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiIC8+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNSI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgc3R5bGU9ImRpc3BsYXk6aW5saW5lIgogICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MC4wNTQwMzQsLTg5LjA0MzUyMikiPgogICAgPGcKICAgICAgIGlkPSJnNDQ4OCIKICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDIuNjU1MDQ0MywwLDAsMi44NTQ2OTA3LC0xMTAuOTk1MTgsLTMyNi45MjY1MikiPgogICAgICA8ZWxsaXBzZQogICAgICAgICByeT0iMTYuMDM1OTI3IgogICAgICAgICByeD0iMTcuNTA1ODg0IgogICAgICAgICBjeT0iMTY0LjE2NTUxIgogICAgICAgICBjeD0iODAuNTc4NzIiCiAgICAgICAgIGlkPSJwYXRoMzQ3NCIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MC4zO2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6IzAwMDAwMDtzdHJva2Utd2lkdGg6MC4yNjQ5OTk5OTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxO2ZpbHRlcjp1cmwoI2ZpbHRlcjQzOTEpO2ltYWdlLXJlbmRlcmluZzphdXRvIiAvPgogICAgICA8cmVjdAogICAgICAgICB0cmFuc2Zvcm09InJvdGF0ZSgtNDIuODA4OTU1KSIKICAgICAgICAgcnk9IjAiCiAgICAgICAgIHk9IjE3NC41NTY0OSIKICAgICAgICAgeD0iLTY3LjM5ODc1OCIKICAgICAgICAgaGVpZ2h0PSIyLjE1MjIwNjQiCiAgICAgICAgIHdpZHRoPSIyOS4yNzk2NDgiCiAgICAgICAgIGlkPSJyZWN0NDQxMyIKICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiNmZmZmMDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MTtmaWx0ZXI6dXJsKCNmaWx0ZXI0NDQ2KSIgLz4KICAgICAgPHJlY3QKICAgICAgICAgdHJhbnNmb3JtPSJyb3RhdGUoLTEzOS4wMzQ0MikiCiAgICAgICAgIHJ5PSIwIgogICAgICAgICB5PSItNzMuMDUwOTQ5IgogICAgICAgICB4PSItMTgyLjk2MjUyIgogICAgICAgICBoZWlnaHQ9IjIuMTUyMjA2NCIKICAgICAgICAgd2lkdGg9IjI5LjI3OTY0OCIKICAgICAgICAgaWQ9InJlY3Q0NDEzLTMiCiAgICAgICAgIHN0eWxlPSJvcGFjaXR5OjE7ZmlsbDojZmZmZjAwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLWRhc2hhcnJheTpub25lO3N0cm9rZS1vcGFjaXR5OjE7ZmlsdGVyOnVybCgjZmlsdGVyNDQzOCkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K';//fake scrolling list 預設選項選到哪個就不傳送表單this.noActionOption={name:'Please select one option',value:''};//布林值,預設為false,不啟用;反之為true代表點選元素後就直接送出最後一個選項的數值.啟用條件為window.qbpwcf.form.options只有一個元素.this.sendOnClickWhenOnly2options=false;//預設選擇了要傳送的項目後,會傳送表單,設置為true代表不會傳送表單只會將選項對應的數值內容交給 this.callback 陣列中的 callback 處理.this.donotSendFrom=false;//fake scrolling list 選單傳送出去時要加上的隱藏變陣列this.hiddenVar=[];//fake scrolling list 選單傳送出去時要加上的隱藏變數名稱與內容,預設為hiddenVarName數值為hiddenVarValuethis.hiddenVar.push({name:'hiddenVarName',value:'hidenVarValue'});//fake scrolling list 選項的預設項目this.defaultOption=this.noActionOption;//fake scrolling list 的選項資訊this.options=[];//預設只有一個選擇了不會送出的選項this.options.push(this.noActionOption);//接受要求的頁面,預設為當前頁面this.recPage=location.href;//傳送表單時的選項對應的變數名稱,預設為'variable'.this.sendVarName='variable';//選項送出後,取得的回應要作為參數呼叫哪些 callbackthis.callback=[];//預設的 callback 為 console.logthis.callback.push(console.log);//取得目標元素的涵式this.getTarget=function(){//如果沒有設置目標if(this.eleId===''){//元素變數也為空的話if(this.targetEle===''){//提示錯誤console.error('Please Defined eleId');//結束執行return false;}//if end//反之else{//存參考var fakeScrollingList=this.targetEle}//else end}//if end//反之有設定idelse{//用id取得下拉式選單var fakeScrollingList=document.getElementById(this.eleId);}//else end//回傳點擊要觸發fakeScrollingList效果的元素return fakeScrollingList;}//function end//顯示 fake scrolling listthis.show=function(){//取得要綁定事件的元素var fakeScrollingList=this.getTarget();//可以下拉的項目用手指頭圖示fakeScrollingList.style.cursor='pointer';//設置 this 給 fakeScrollingList 的 addEventListener 事件fakeScrollingList.mother=this;//點擊選單之後fakeScrollingList.addEventListener('click',function(event){//取消預設點擊的效果event.preventDefault();//取得下拉式選單內容var inputSelect=event.target;//讓下拉式選單趕緊隱藏inputSelect.style.opacity='0';//解析選項的資訊var optionsInfo=fakeScrollingList.mother.options;//取得選項的數目var opLen=optionsInfo.length;//新增覆蓋全螢幕的divvar root=document.createElement('div');//設置最外層div的idroot.id='scrollingListRootDiv';//移除重複的選單if(document.getElementById('scrollingListRootDiv')!==null){//移除之document.getElementById('scrollingListRootDiv').remove();}//if end//設置最外層div的樣式root.classList.add('__qbpwcf_scrollingListRootDiv');//新增為了將不足divForMiddle可見高度的選項們置中的divvar divForMiddle=document.createElement('div');//設置為了上下置中的div樣式divForMiddle.classList.add('__qbpwcf_scrollingListOutterDiv');//初始化記錄選擇的選項indexvar selectedOptionIndex=0;//針對每個選項for(var i=0;i<opLen;i++){//取得選項實際數值var opVal=optionsInfo[i].value;//取得選項顯示名稱var opShow=optionsInfo[i].name;//建立選項的divvar opDiv=document.createElement('div');//讓選項上下置中opDiv.style.paddingTop='15px';//設置選項div的classopDiv.setAttribute('class','__qbpwcf_inputSelect __qbpwcf_inputSelect_hover');//設置裡面的文字要換行的時候改用...表示opDiv.style.whiteSpace='nowrap';opDiv.style.width='100%';opDiv.style.overflow='hidden';opDiv.style.textOverflow='ellipsis';//偶數欄位if(i%2===0){//設置選項div底色為藍色opDiv.style.backgroundColor='CCCCFF';}//反之為奇數欄位else{//設置選項div底色為紅色opDiv.style.backgroundColor='FFCCCC';}//解析選項的資訊var oriOptionsInfo=this.options;//建立選項名稱文字節點var textnode = document.createTextNode(opShow);//將文字放進選項的divopDiv.appendChild(textnode);//設置選項對應的實際數值opDiv.dataset.val=opVal;//設置選項對應的索引opDiv.dataset.index=i;//將選項放進為了上下左右置中的divdivForMiddle.appendChild(opDiv);}//for end//新增為了上下左右置中的divvar divForCenterMiddle=document.createElement('div');//設置為了內部元素都上下左右置中的div樣式divForCenterMiddle.classList.add('__qbpwcf_scrollingListInnerDiv');//將上下置中的選項們放進可以上下左右置中的divdivForCenterMiddle.appendChild(divForMiddle);//將選項放進最外層的divroot.appendChild(divForCenterMiddle);//將整個div放到body裡面document.body.appendChild(root);//調整滾軸表單的置中效果scrollingListMiddleFunction();//取得所有選項var allOptions=document.getElementsByClassName('__qbpwcf_inputSelect_hover');//移動滾軸讓原本選擇的選項盡量置中//取得選單的滾軸上端位置最大值var scrollingListScrollTopMax=document.getElementById('scrollingListRootDiv').children[0].scrollTopMax;//如果有滾軸if(scrollingListScrollTopMax!==0){//如果是第一個選項if(selectedOptionIndex===0){//滾軸拉到最上面document.getElementById('scrollingListRootDiv').children[0].scrollTop=0;}//if end//如果之前選擇的選項索引剛好等於 opLen/2else if(((selectedOptionIndex+1)===(opLen/2))){//取得新的滾軸高度var newScrollTop=scrollingListScrollTopMax/2;//設置滾軸的上端位置document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;}//if end//如果之前選擇的選項索引小於半else if((selectedOptionIndex+1)<(opLen/2)){//取得新的滾軸高度var newScrollTop=scrollingListScrollTopMax/opLen*selectedOptionIndex+1;//設置滾軸的上端位置document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;}//if end//如果之前選擇的選項索引過半else if((selectedOptionIndex+1)>(opLen/2)){//取得新的滾軸高度var newScrollTop=scrollingListScrollTopMax-scrollingListScrollTopMax/opLen*(opLen-selectedOptionIndex-1);//設置滾軸的上端位置document.getElementById('scrollingListRootDiv').children[0].scrollTop=newScrollTop;}//if end//如果是最後一個選項else if(selectedOptionIndex===opLen){//如果是最後一個選項document.getElementById('scrollingListRootDiv').children[0].scrollTop=scrollingListScrollTopMax;}//if end//不應該跑到的地方else{//debugconsole.log('error occur!');}//else end}//if end//針對每個選項for(var i=0;i<allOptions.length;i++){//取得this設定allOptions[i].mother=fakeScrollingList.mother;//綁定所有選項的 'click' 事件allOptions[i].addEventListener('click',async function(event){//取得點擊到的選項var clickedOption=event.target;//取得點擊到的選項數值var clickedValue=clickedOption.dataset.val;//取得點擊到的選項索引var clickedNo=clickedOption.dataset.index;//取得點擊到的選項名稱var clickedName=clickedOption.innerHTML;//如果不需要傳送表單if(this.mother.donotSendFrom){//取得要移除 scrolling list 的 divvar divToDel=document.getElementById('scrollingListRootDiv');//移除 scrolling list divdivToDel.remove();//針對每個要呼叫的 callback funcfor(var j=0;j<this.mother.callback.length;j++){//callbackthis.mother.callback[j].call(this,clickedValue);}//for end//復原下拉式選單inputSelect.style.opacity='unset';//結束執行return true;}//if end//如果不是不需要傳送數值的選項if(fakeScrollingList.mother.noActionOption.name!==clickedName && fakeScrollingList.mother.noActionOption.value!==clickedValue){//建立表單物件var queryStr='';//新增表單的名稱與對應的數值queryStr=queryStr+fakeScrollingList.mother.sendVarName+'='+encodeURIComponent(clickedValue);//針對每個隱藏的表單變數for(var j=0;j<fakeScrollingList.mother.hiddenVar.length;j++){//附加到要傳算的表單變數裡面queryStr=queryStr+'&'+fakeScrollingList.mother.hiddenVar[j].name+'='+encodeURIComponent(fakeScrollingList.mother.hiddenVar[j].value);}//for end//復原下拉式選單inputSelect.style.opacity='unset';/*設置 window.qbpwcf.ajaxP 函數說明:傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.參數:params={};params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';params.headers={name:value};params.url='url to request';params.preAc='function name to call before send request';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};參考資料:https://eyesofkids.gitbooks.io/javascript-start-es6-promise/content/contents/ch11_snippets.htmlhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise*/var params={};params.method='POST';params.url=fakeScrollingList.mother.recPage;params.data=queryStr;//取得回應var res = await window.qbpwcf.ajaxP.call(this,params);//取得要移除 scrolling list 的 divvar divToDel=document.getElementById('scrollingListRootDiv');//移除 scrolling list divdivToDel.remove();//針對每個要呼叫的 callback funcfor(var j=0;j<fakeScrollingList.mother.callback.length;j++){//callbackfakeScrollingList.mother.callback[j].call(this,res);}//for end//如果json的回應有 location屬性if(res.json.hasOwnProperty('location')){//導頁location.href=res.json.location;}//if end}//if end});//function end}//for end//建立 close iconvar closeIcon = document.createElement('img');//設置 close icon 的樣式closeIcon.style['position']='fixed';closeIcon.style['top']='15%';closeIcon.style['left']='85%';closeIcon.style['width']='5%';closeIcon.style['min-width']='30px';closeIcon.style['max-width']='50px';closeIcon.style['cursor']='pointer';//設置 close icon img 的 src 屬性closeIcon.src=fakeScrollingList.mother.closeIcon;//設置 close icon img 的idcloseIcon.id='qbpwcfScrollingListCloseIcon';//取得 scrollingList 的 root divvar slrd=document.getElementById('scrollingListRootDiv');//將 close icon outer div 放到 scrollingList 的 root div 裡面document.getElementById('scrollingListRootDiv').appendChild(closeIcon);//取得 close icon imgvar closeIcon=document.getElementById('qbpwcfScrollingListCloseIcon');//新增 close icon img 的點擊事件closeIcon.addEventListener('click',function(){//取得要移除 scrolling list 的 divvar divToDel=document.getElementById('scrollingListRootDiv');//移除 scrolling list divdivToDel.remove();//復原下拉式選單inputSelect.style.opacity='unset';});//addEventLister//如果有啟用且只有一個選項則自動點擊最後一個選項if(fakeScrollingList.mother.sendOnClickWhenOnly2options && opLen===2){//debugconsole.log('try auto click last option');//取得選項們的外框var optionOutBoderDiv=document.querySelector('div#scrollingListRootDiv').children[0].children[0];//點擊最後一個選項optionOutBoderDiv.children[1].click();}//if end});//function end}//function end}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="//如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//如果未設定 window.qbpwcf.ajax 物件if(window.qbpwcf.ajax===undefined){//設置 window.qbpwcf.ajax 為空物件window.qbpwcf.ajax={};}//if end/*設置 window.qbpwcf.ajax 函數說明:傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.參數:params={};params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';params.headers={name:value};params.url='url to request';params.resType='json';params.preAc='function name to call before send request';params.aftAc='function name to call after send request,default params is data to send';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};*/window.qbpwcf.ajax=function(params){//檢查參數 params.methodif(params.method===undefined){//初始化為 'POST'params.method='POST';}//if end//檢查參數 params.urlif(params.url===undefined){//初始化為當前頁面params.url=location.href;}//if end//檢查參數 params.resTypeif(params.resType===undefined){//初始化為'json'params.resType='json';}//if end//檢查參數 params.preAcif(params.preAc===undefined){//初始化為提示傳送 ajax 前params.preAc=function(){//debugif(window.debug){//提示傳送 ajax 前console.log('before sand request...');}//if end};//funcitno end}//if end//檢查參數 params.aftAcif(params.aftAc===undefined){//初始化為提示傳送 ajax 後params.aftAc=function(){//debugif(window.debug){//提示傳送 ajax 後console.log('after sand request...');}//if end};//funcitno end}//if end//檢查參數 params.dataif(params.data===undefined){//初始化變數qkey1='q';//初始化變數q的數值內容為'test by qbpwcf'v1='test by qbpwcf';//初始要傳送的參數params.data=key1+'='+encodeURIComponent(v1);}//if end//如果支援 ajaxif(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarivar xmlhttp=new XMLHttpRequest();}//if end//不支援,應該是IE5、IE6else{// code for IE6, IE5var xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}// else end//如果服務端有回傳完稱的狀態xmlhttp.onreadystatechange=function(){//debug//console.log(xmlhttp);//如果狀態為1if(xmlhttp.readyState==1){//傳送 ajax 前要做的事情params.preAc.call(this);}//if end//如果狀態為4if(xmlhttp.readyState==4){//且response code為200if(xmlhttp.status==200){//得到回傳結果後要做的事情,參數為回傳的結果.params.aftAc.call(this,xmlhttp.response);}//if end//反之回傳狀態碼else{//得到回傳結果後要做的事情,參數為回傳的結果.params.aftAc.call(this,xmlhttp.status);}//else end}//if end}//function end//設定回傳的資料形態xmlhttp.responseType=params.resType;//如果是 'GET'if(params.method==='GET'){//如果data不為空物件if(params.data.toString()!=='[object Object]'){//加上get用的'?'params.url=params.url+'?'+params.data;}//if end}//if end//設定要用get傳送的數值xmlhttp.open(params.method,params.url,true);//如果有設置 headerif(params.headers!==undefined){//儲存迴圈的次數var count=Object.keys(params.headers).length;//針對每個自己加的 headerfor(var i=0;i<count;i++){//加上自定的 headerxmlhttp.setRequestHeader(Object.keys(params.headers)[i],Object.values(params.headers)[i]);}//for end}//if end//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//如果是 'POST'if(params.method==='POST'){//如果data不為空物件if(params.data.toString()!=='[object Object]'){//傳送要求xmlhttp.send(params.data);}//if end//反之data存在資料else{//傳送要求,POST為空xmlhttp.send();}//else end}//if end//反之是 GET 或 HEAD 或 OPTIONSelse if(params.method==='GET' || params.method==='HEAD' || params.method==='OPTIONS'){//直接傳送要求xmlhttp.send();}//else end}//function window.qbpwcf.ajax end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="//如果未設定 window.qbpwcf 物件if(window.qbpwcf===undefined){//設置 window.qbpwcf 為空物件window.qbpwcf={};}//if end//如果未設定 window.qbpwcf.ajaxP 物件if(window.qbpwcf.ajaxP===undefined){//設置 window.qbpwcf.ajax 為空物件window.qbpwcf.ajaxP={};}//if end/*設置 window.qbpwcf.ajaxP 函數說明:傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.參數:params={};params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';params.headers={name:value};params.url='url to request';params.preAc='function name to call before send request';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};參考資料:https://eyesofkids.gitbooks.io/javascript-start-es6-promise/content/contents/ch11_snippets.htmlhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise*/window.qbpwcf.ajaxP=function(params){return new Promise(function(resolve, reject){//檢查參數 params.methodif(params.method===undefined){//初始化為 'POST'params.method='POST';}//if end//檢查參數 params.urlif(params.url===undefined){//初始化為當前頁面params.url=location.href;}//if end//檢查參數 params.preAcif(params.preAc===undefined){//初始化為提示傳送 ajax 前params.preAc=function(){//debugif(window.debug){//提示傳送 ajax 前console.log('before sand request...');}//if end};//funcitno end}//if end//檢查參數 params.dataif(params.data===undefined){//初始化變數qkey1='q';//初始化變數q的數值內容為'test by qbpwcf'v1='test by qbpwcf';//初始要傳送的參數params.data=key1+'='+encodeURIComponent(v1);}//if end//如果支援 ajaxif(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safarivar xmlhttp=new XMLHttpRequest();}//if end//不支援,應該是IE5、IE6else{// code for IE6, IE5var xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}// else end//如果服務端有回傳完稱的狀態xmlhttp.onreadystatechange=function(){//debug//console.log(xmlhttp);//如果狀態為1if(xmlhttp.readyState==1){//傳送 ajax 前要做的事情params.preAc.call(this);}//if end//如果狀態為4if(xmlhttp.readyState==4){//且response code為200if(xmlhttp.status===200){var tmp=document.createElement('div');tmp.innerHTML=xmlhttp.response;//初始化記錄結果的變數var res={};//記錄指定解讀格式的內容res.dom=tmp;//記錄得到的純文字內容res.text=xmlhttp.responseText;//嘗試try{//記錄json格式的內容res.json=JSON.parse(res.text);}//抓取例外catch(exception){//記錄錯誤訊息res.json=exception;}//receiveresolve(res);}//if end//反之回傳狀態碼else{//rejectreject(xmlhttp.status);}//else end}//if end}//function end//如果是 'GET'if(params.method==='GET'){//如果data不為空物件if(params.data.toString()!=='[object Object]'){//加上get用的'?'params.url=params.url+'?'+params.data;}//if end}//if end//設定要用get傳送的數值xmlhttp.open(params.method,params.url,true);//如果有設置 headerif(params.headers!==undefined){//儲存迴圈的次數var count=Object.keys(params.headers).length;//針對每個自己加的 headerfor(var i=0;i<count;i++){//加上自定的 headerxmlhttp.setRequestHeader(Object.keys(params.headers)[i],Object.values(params.headers)[i]);}//for end}//if end//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//如果是 'POST'if(params.method==='POST'){//如果data不為空物件if(params.data.toString()!=='[object Object]'){//傳送要求xmlhttp.send(params.data);}//if end//反之data存在資料else{//傳送要求,POST為空xmlhttp.send();}//else end}//if end//反之是 GET 或 HEAD 或 OPTIONSelse if(params.method==='GET' || params.method==='HEAD' || params.method==='OPTIONS'){//直接傳送要求xmlhttp.send();}//else end});//Promise end}//function window.qbpwcf.ajaxP end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:window.qbpwcf.tail ,物件,提供遞迴執行取得內容並顯示的功能.window.qbpwcf.tail.url, 提供連線內容的頁面,預設為當前頁面.window.qbpwcf.tail.continue ,true代表繼續執行;false代表暫停.window.qbpwcf.tail.rootDiv.id ,儲存回應的div其id,預設為'qbbpwcfTailRootDivID'.window.qbpwcf.tail.ajax(line2start) ,啟用該功能的函式,參數line2start為要從第幾行開始讀取,-1代表從最尾端開始.*///initial window.qbpwcfif(window.qbpwcf===undefined){//初始化 window.qbpwcfwindow.qbpwcf={};}//if end//initial window.qbpwcf.tailif(window.qbpwcf.tail===undefined){//初始化 window.qbpwf.tailwindow.qbpwcf.tail={};//初始化繼續執行window.qbpwcf.tail.continue=true;}//if end//如果沒有指定要求內容的頁面if(window.qbpwcf.tail.url===undefined){//初始化為當前頁面window.qbpwcf.tail.url=location.href;}//if end//create root divwindow.qbpwcf.tail.rootDiv = document.createElement('div');//如果位指定div idif(window.qbpwcf.tail.rootDiv.id===undefined || window.qbpwcf.tail.rootDiv.id===''){//預設為 qbbpwcfTailRootDivIDwindow.qbpwcf.tail.rootDiv.id='qbpwcfTailRootDivID';}//if end//設置周期執行的涵式window.qbpwcf.tail.ajax = function(line2start){console.log(window.qbpwcf.tail.rootDiv.id);//初始化 root div 的 selectorvar selector='div.'+window.qbpwcf.tail.rootDiv.id;//若 root div 不存在if(document.querySelector(selector)===null){//建立之document.body.appendChild(window.qbpwcf.tail.rootDiv);}//if endxmlhttp=new XMLHttpRequest();//xmlhttp.responseType='json';xmlhttp.open('POST',window.qbpwcf.tail.url,true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState===4 && xmlhttp.status===200){//get responseres=xmlhttp.response;//try parse res to json//參考資料//https://stackoverflow.com/questions/4467044/proper-way-to-catch-exception-from-json-parsetry{json=JSON.parse(res);}catch(e){//console.log(e);}console.log(json);//如果json不存在if(json===undefined || json===null){//取得文字結果res=xmlhttp.responseText//如果輸出有逗號.if(res.includes(',')){//用逗號分割回應res=res.split(',');//取得回應的陣列長度rLength=res.length;}//if end//儲存最新的行內容window.qbpwcf.tail.latsLineContent=null;//針對每個回應for(i=0;i<rLength-1;i++){//解密內容res[i]=JSON.parse(decodeURIComponent(atob(res[i])).replaceAll('+',' '));//取得讀取到的行數.window.qbpwcf.tail.lineNum=res[i].lineNum;//針對每行輸出for(var j=0;j<res[i].lines;j++){//如果內容跟上一行相同.if(window.qbpwcf.tail.latsLineContent===res[i].content[j]){//跳過continue;}//if end//反之else{//更新最新一列的內容window.qbpwcf.tail.latsLineContent=res[i].content[j];}//else end//set output linevar div=document.createElement('div');var text=document.createTextNode(res[i].content[j]);div.appendChild(text);//如果內容為空if(res[i].content[j]===''){//建立<br>var br=document.createElement('br');//遷入<br>div.appendChild(br);}//show output linevar rootDiv=document.getElementById(window.qbpwcf.tail.rootDiv.id);rootDiv.prepend(div);}//for end}//for end}//if end//反之有pasrer出jsonelse{//取得jsonres=json;//取得真實內容res=res.content;//取得回應的陣列長度rLength=res.length;//針對每筆輸出for(var i=0;i<rLength;i++){//針對每行輸出for(var j=0;j<rLength;j++){//set output linevar div=document.createElement('div');var text=document.createTextNode(res[j]);div.appendChild(text);//如果內容為空if(res[j]===''){//建立<br>var br=document.createElement('br');//遷入<br>div.appendChild(br);}//show output linevar rootDiv=document.getElementById(window.qbpwcf.tail.rootDiv.id);rootDiv.prepend(div);}//for end}//for end}//else end//if json !=nullif(json!=null){console.log(json.lineNum);//遞迴window.qbpwcf.tail.ajax.call(this,json.lineNum+1);//清空變數json=null;}//if endelse{//如果當前行數不等於空if(window.qbpwcf.tail.lineNum!==undefined && window.qbpwcf.tail.lineNum!==null){//遞迴window.qbpwcf.tail.ajax.call(this,window.qbpwcf.tail.lineNum);}//if endelse{//遞迴window.qbpwcf.tail.ajax.call(this,-1);}//else end}//else end}//if end}//function end//如果要繼續if(window.qbpwcf.tail.continue){//繼續xmlhttp.send('line2start='+line2start);}//if end//反之要暫停else{//設置無限等待var intervalTail = window.setInterval(function(){//提示已經暫停console.log('paused');//如果要繼續了if(window.qbpwcf.tail.continue){//清除無限等待clearInterval(intervalTail);//繼續xmlhttp.send('line2start='+line2start);}//if end},1000);}//else end}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="//initial window.qbpwcfif(window.qbpwcf===undefined){//初始化 window.qbpwcfwindow.qbpwcf={};}//if end//initial window.qbpwcf.screenShareif(window.qbpwcf.screenShare===undefined){//初始化 window.qbpwcf.screenSharewindow.qbpwcf.screenShare={};}//if end/*函式說明:分享螢幕畫面.參數說明:parmas={};params.displayOptions={};params.startEle=''; //點擊後開始分享螢幕的元素id參考資料:https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capturehttps://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Recording_APIhttps://developer.mozilla.org/en-US/docs/Web/API/MediaSource/addSourceBufferhttps://developer.mozilla.org/en-US/docs/Web/API/Blobhttps://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/shifthttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBufferhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Arrayhttps://ithelp.ithome.com.tw/articles/10195525https://developer.mozilla.org/zh-TW/docs/Web/API/Blob#備註:#錄製好的畫面無法在別的畫面播放.*/window.qbpwcf.screenShare.init=function(params){//初始化參數if(params.startEle===undefined){params.startEle='';}//if end//初始化參數if(params.displayOptions===undefined){//參數params.displayOptions={video: {cursor: 'always',},audio: {echoCancellation: true,noiseSuppression: true,sampleRate: 44100,},};}// if end//全域化 displayOptionswindow.qbpwcf.screenShare.displayOptions=params.displayOptions;//如果無指定點擊後開始分享畫面的元素if(params.startEle===''){//移除既有的分享畫面divscreenShareBtn=document.getElementById('window.qbpwcf.screenShare.startId');//如果有該按鈕if(screenShareBtn!==null){//移除之screenShareBtn.remove();}//建立 div 物件div=document.createElement('div');//綁定點擊事件div.addEventListener('click',function(){window.qbpwcf.screenShare.startCapture();});//設置固位置的 css 樣式div.style.position='fixed';div.style.bottom='10px';div.style.right='10px';//設置背景顏色為藍色div.style.backgroundColor='#AAAAFF';//設置滑鼠指標過去為 pointerdiv.style.cursor='pointer';//設置 div 的 iddiv.id='window.qbpwcf.screenShare.startId';//給予提文字div.innerText='按我開始分享畫面';//取得預設的開始錄影參數;params.startEle=div;//放置 divdocument.body.appendChild(div);}//if end//反之else{//設置點擊就開始分享畫面的事件params.startEle.addEventListener('click',function(){window.qbpwcf.screenShare.startCapture();});}//else end//建立 video div 物件window.qbpwcf.screenShare.videoElem=document.createElement('video');window.qbpwcf.screenShare.videoElem.autoplay=true;window.qbpwcf.screenShare.videoElem.style.width='100vw';window.qbpwcf.screenShare.videoElem.style.height='100vh';window.qbpwcf.screenShare.videoElem.style.border='solid 1px silver';window.qbpwcf.screenShare.videoElem.id='video';//放置 video divdocument.body.appendChild(window.qbpwcf.screenShare.videoElem);}//function window.qbpwcf.screenShare.init end//開始截取畫面window.qbpwcf.screenShare.startCapture = async function(){//try starttry{//顯示畫面window.qbpwcf.screenShare.videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia(window.qbpwcf.screenShare.displayOptions);window.qbpwcf.screenShare.dumpOptionsInfo();//設定錄製畫面的設定var options = { mimeType: 'video/webm; codecs=vp8' };window.qbpwcf.screenShare.mediaRecorder = new MediaRecorder(window.qbpwcf.screenShare.videoElem.srcObject, options);//初始化儲存錄影的片段window.qbpwcf.screenShare.recordedChunks=[];//當有資料可以錄製時window.qbpwcf.screenShare.mediaRecorder.ondataavailable=window.qbpwcf.screenShare.handleDataAvailable;//開始錄製window.qbpwcf.screenShare.mediaRecorder.start();//設置每1秒就要求一次錄取的資料window.qbpwcf.screenShare.interval = setInterval(function(){//debugif(window.debug){console.log(window.qbpwcf.screenShare.mediaRecorder);}//if end//如果停止錄影了if(window.qbpwcf.screenShare.mediaRecorder.state==='inactive'){//結束循環要求錄取的資料clearInterval(window.qbpwcf.screenShare.interval);}//if end//手動要求目前錄製window.qbpwcf.screenShare.mediaRecorder.requestData();//如果要繼續了if(window.qbpwcf.screenShare.continue){//清除無限等待clearInterval(window.qbpwcf.screenShare.interval);}//if end},1000);} //try end//catch errorcatch(err){//debugconsole.error(err);}//catch end}//function end//結束截取畫面跟音訊window.qbpwcf.screenShare.stopCapture = function(){let tracks = window.qbpwcf.screenShare.videoElem.srcObject.getTracks();tracks.forEach(track => track.stop());videoElem.srcObject = null;}//funciton end//輸出當前錄影的各項資訊window.qbpwcf.screenShare.dumpOptionsInfo = function(){//debugif(window.debug){//debugconsole.log(window.qbpwcf.screenShare.videoElem.srcObject);}//if endconst videoTrack = window.qbpwcf.screenShare.videoElem.srcObject.getVideoTracks()[0];//debugif(window.debug){console.log('Track settings:');console.log(JSON.stringify(videoTrack.getSettings(), null, 2));console.log('Track constraints:');console.log(JSON.stringify(videoTrack.getConstraints(), null, 2));}//if end}//function end//ondataavailable event 要執行的函式window.qbpwcf.screenShare.handleDataAvailable = function(e){//debugif(window.debug){console.log('data-available');}//if end//如果有資料if (e.data.size > 0){//記錄資料window.qbpwcf.screenShare.recordedChunks.push(e.data);//debugif(window.debug){console.log(window.qbpwcf.screenShare.recordedChunks);}//if end//取得最舊的資料blob=window.qbpwcf.screenShare.recordedChunks.shift();//debugif(window.debug){//blob.type='video/webm; codecs=vp8'console.log(blob);}//if end//建立 reader 物件reader = new FileReader();//如果開啟完畢reader.addEventListener('loadend',function(e){//debugif(window.debug){console.log(e);}//if end//取得 arrayBUfferbuf=e.originalTarget.result;//debugif(window.debug){console.log(buf);}//if end//用8位數2進位來表示intArray = new Int8Array(buf);//儲存成json字串json = JSON.stringify(intArray);//初始化要傳遞的變數物件內容toDb={};toDb.dbAddr='localhost';toDb.dbName='qbpwcf';toDb.dbUser='root';toDb.dbPass='dolbyhometheater';toDb.dtName='int8array';toDb.cols=['json'];toDb.vals=[json];//加密要傳輸的變數toDb=btoa(encodeURIComponent(JSON.stringify(toDb)));//儲存到資料庫params={};params.method='POST';params.url='/qbpwcf/db/toDb.php';params.resType='json';//params.preAc='function name to call before send request';//params.aftAc='function name to call after send request';params.data='params='+toDb;window.qbpwcf.ajax(params);});//funciton end//讀取 blob 成 arrayBufferreader.readAsArrayBuffer(blob);}//if end}//function end//用戶觀賞分享的畫面window.qbpwcf.screenShare.client=function(){//建立 videoR div 物件window.qbpwcf.screenShare.videoR=document.createElement('video');window.qbpwcf.screenShare.videoR.autoplay=true;window.qbpwcf.screenShare.videoR.style.width='100vw';window.qbpwcf.screenShare.videoR.style.height='100vh';window.qbpwcf.screenShare.videoR.style.border='solid 1px silver';window.qbpwcf.screenShare.videoR.id='videoR';//放置 videoR divdocument.body.appendChild(window.qbpwcf.screenShare.videoR);//建立 media source 物件window.qbpwcf.screenShare.mediaSourceForR = new MediaSource();//設置 video tag 的內容來源//window.qbpwcf.screenShare.videoR.src=URL.createObjectURL(window.qbpwcf.screenShare.mediaSourceForR); //old methodwindow.qbpwcf.screenShare.videoR.srcObject=window.qbpwcf.screenShare.mediaSourceForR; //new method//初始化用戶取得的最新視訊片段idwindow.qbpwcf.screenShare.clientDataId=0;//建立當打開媒體來源時window.qbpwcf.screenShare.mediaSourceForR.addEventListener('sourceopen',window.qbpwcf.screenShare.clientRecursive);}//functino end//用戶觀賞分享的畫面用的遞回函式window.qbpwcf.screenShare.clientRecursive=function(event){//debugif(window.debug){console.log(event);}//if end//如果尚無資料if(window.qbpwcf.screenShare.clientDataId===0){//設置輸出的編碼window.qbpwcf.screenShare.sourceBuffer = window.qbpwcf.screenShare.mediaSourceForR.addSourceBuffer('video/webm; codecs=vp8');}//if end//初始化要傳遞的變數物件內容toDb={};toDb.dbAddr='localhost';toDb.dbName='qbpwcf';toDb.dbUser='root';toDb.dbPass='dolbyhometheater';toDb.dtName='int8array';toDb.cols=['id','json'];toDb.orderItem='id';toDb.ascORdesc='desc';toDb.numLimit='1';//toDb.WhereColumnName=['id'];//toDb.WhereColumnOperator=['>'];//toDb.WhereColumnValue=[window.qbpwcf.screenShare.clientDataId+''];//debugif(window.debug){console.log(toDb);}//if end//加密要傳輸的變數toDb=btoa(encodeURIComponent(JSON.stringify(toDb)));//從Server取得資料params={};params.method='POST';params.url='/qbpwcf/db/dbOut.php';params.resType='json';params.preAc=function(res){//debugif(window.debug){console.log('loading');}//if end};params.aftAc=function(res){//debugif(window.debug){console.log(res);}//if end//如果尚無資料if(res.dataContent===null){//debugif(window.debug){//提示讀取到結尾了console.log('read EOL');}//if end//遞迴window.qbpwcf.screenShare.clientRecursive();//結束執行return true;}//if end//取得idid=res.dataContent.id[0];//如果id有變if(window.qbpwcf.screenShare.clientDataId!==id){//取得新idwindow.qbpwcf.screenShare.clientDataId=id;//讀取片段資料json=res.dataContent.json[0];//debugif(window.debug){console.log(json);}//if end//parse jsonjson=JSON.parse(json);//debugif(window.debug){console.log(json);}//if end//用int8Array的方式儲存intArray=new Int8Array(Object.values(json));//debugif(window.debug){console.log(intArray);}//if end//debugif(window.debug){console.log(intArray.buffer);}//if end//轉換成blobblob=new Blob(intArray,{type:'video/webm'});//debugif(window.debug){console.log(blob);}//if end//建立 reader 物件readerR = new FileReader();//如果開啟完畢readerR.addEventListener('loadend',function(e){//debugif(window.debug){console.log(e);}//if end//取得 arrayBUfferbuf=e.originalTarget.result;//debugif(window.debug){console.log(buf);}//if end//debugif(window.debug){console.log(window.qbpwcf.screenShare.sourceBuffer);}//if end//append bufferwindow.qbpwcf.screenShare.sourceBuffer.appendBuffer(buf);// Wait for the sourcebuffer to be ready to load all other chunkswindow.qbpwcf.screenShare.sourceBuffer.addEventListener('updateend',window.qbpwcf.screenShare.clientRecursive);//debugif(window.debug){console.log(window.qbpwcf.screenShare.sourceBuffer);}//if end});//addEventListener end//讀取 blob 成 arrayBufferreaderR.readAsArrayBuffer(blob);//遞迴window.qbpwcf.screenShare.clientRecursive();}//if end//反之else{//遞迴window.qbpwcf.screenShare.clientRecursive();}//else end}//function endparams.data='params='+toDb;window.qbpwcf.ajax(params);}//function end";/*desc:等待既有圖片讀取完畢後,再讀取更清楚的圖片,取代之.參考資料:https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener*/$conf["javaScript::toScript"]["jsFunciton"][]="//img thumbnails 效果window.qbpwcf.imgThumbnails=function(thumbnails,oriImgUrl){//如果變數 thumbnails 跟 oriImg 其中一個不是 objectif( typeof(thumbnails)!=='object' || typeof(oriImgUrl)!=='string' ){//提示錯誤訊息console.error('thumbnails not a object');//提示錯誤訊息console.error('oriImgUrl not a string');//結束執行return false;}//if end//event只跑一次的設定參數var Optional={};Optional.once=true;//事件,當圖片檔案讀取完畢後執行thumbnails.addEventListener('load',function(e){/*設置 window.qbpwcf.ajax 函數說明:傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.參數:params={};params.method='POST' or 'GET';params.headers={name:value};params.url='url to request';params.resType='json';params.preAc='function name to call before send request';params.aftAc='function name to call after send request';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use '';*/params={};params.method='GET';params.url=oriImgUrl;params.resType='blob';//帶入 img objparams.imgObj=e.target;params.aftAc=function(res){//new reader objvar reader = new FileReader();//reader evevntreader.addEventListener('loadend', function(e){//置換圖片位置為 base64 data urlreader.imgObj.src=e.target.result;});//帶入 img objreader.imgObj=params.imgObj;//讀取圖片為 data urlreader.readAsDataURL(res);};window.qbpwcf.ajax(params);},Optional);//functino end}//function end";/*desc:低解析度的指定圖片讀取完畢後,再讀取更清楚的圖片,取代之.參考資料:https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous*/$conf["javaScript::toScript"]["jsFunciton"][]="//img thumbnails 效果,用 async 實作window.qbpwcf.imgThumbAsync=async function(element,thumbUrl,oriImgUrl){//如果變數 element 不是 object 或 thumbUrl 跟 oriImg 其中一個不是 stringif( typeof(element)!=='object' || typeof(thumbUrl)!=='string' || typeof(oriImgUrl)!=='string' ){//提示錯誤訊息console.error('element is not a object');//提示錯誤訊息console.error('thumbUrl is not a string');//提示錯誤訊息console.error('oriImgUrl is not a string');//結束執行return false;}//if end//載入低解析度的圖片,將Promise儲存到res裡面var res = await fetch(thumbUrl);//如果沒有讀取成功if(await res.status!==200){//回傳失敗return false;}//if end//顯示低解析度的圖片element.src=URL.createObjectURL(await res.blob());//載入原始圖片,將Promise儲存到res裡面var res = await fetch(oriImgUrl);//如果沒有讀取成功if(await res.status!==200){//回傳失敗return false;}//if end//顯示原始的圖片element.src=URL.createObjectURL(await res.blob());//回傳正確return true;}//function end";/*desc:低解析度的多個指定圖片讀取完畢後,再讀取更清楚的圖片,取代之,且同步執行.參考資料:https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await*/$conf["javaScript::toScript"]["jsFunciton"][]="//多張img thumbnails 效果,用 async 實作window.qbpwcf.multiImgThumbAsync=async function(element,thumbUrl,oriImgUrl){//儲存要同步執行的工作var tasks=[];//針對每個陣列元素做事情,不需要中斷.element.forEach(function(value,key){//不等待結果趕緊執行下一個tasks.push(window.qbpwcf.imgThumbAsync(value,thumbUrl[key],oriImgUrl[key]));});//等待每個工作執行結束await Promise.all(tasks);//回傳正確return true;}//function end";$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:偷偷摸摸地傳送表單,並觸發事件參數:params={};參數為一物件params.formEle=[];為每個表單元素.params.target='';為表單要傳送到的目的地.params.successFunc='';為表單回覆為成功時要做的事情,回應為一物件,有一屬性為'status',其數值為'true'.params.failedFunc='';為表單回覆為失敗時要做的事情,回應為一物件,有一屬性為'status',其數值為'false'.*/window.qbpwcf.slientSubmit=function(params){//取得表單元素的keyvar formKeys=Object.keys(params.formEle);//取得表單key的數量var formLength=formKeys.length;//針對每個 keyfor(var i=0;i<formLength;i++){//該表單,綁定失去焦點的事件,看其來沒有效果params.formEle[i].addEventListener('focusout',function(e){//如果輸入內容為空if(e.target.value===''){//聚焦選單e.target.focus();}//if end});//event blur end//該表單,綁定內容變化的事件params.formEle[i].addEventListener('change',function(e){//針對每個表單for(var j=0;j<formLength;j++){//如果有表單未填寫if(params.formEle[j].value===''){//結束迴圈break;}//if end//到這邊代表表單都有填寫if(j===formLength-1){//驗證表單 - start//初始化表單變數var post='';//針對每個表單for(var k=0;k<formLength;k++){//記錄表單名稱var formName=params.formEle[k].name;//記錄表單數值var formValue=params.formEle[k].value;//當是第一個表單時if(k==0){//串接變數post=post+formName+'='+encodeURIComponent(formValue);}//if end//中間的表單else{//串接變數post=post+'&'+formName+'='+encodeURIComponent(formValue);}//else end}//for end/*設置 window.qbpwcf.ajax 函數說明:傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.參數:params={};params.method='POST' or 'GET';params.headers={name:value};params.url='url to request';params.resType='json';params.preAc='function name to call before send request';params.aftAc='function name to call after send request';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use '';*/var ajParams={};ajParams.method='POST';ajParams.url=params.target;ajParams.resType='json';ajParams.data=post;ajParams.aftAc=function(res){//驗證正確if(res.status==='true'){//運行驗證成功的函式params.successFunc(res);}//if end//反之驗證失敗else if(params.failedFunc!==undefined){//運行驗證失敗的函式params.failedFunc(res);}//if end};window.qbpwcf.ajax(ajParams);//驗證表單 - end}//if end}//for end//結束程式return false;});//event blur end}//for end}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:偵測目標是否可以連線後要做的事情.參數:params,物件.params.url,服務網址.params.timeout,偵測的毫秒數上限.params.callback,偵測完服務後要執行的函式,參數為偵測的結果可以連線為true,不可連線為false.*/window.qbpwcf.connectable={};window.qbpwcf.connectable.func=function(params){//如果 url 未定義if(params===undefined){//回傳 falsereturn false;}//if end//如果 url 未定義if(params.url===undefined){//初始化為 https://www.google.comthis.url='https://www.google.com';}//if end//反之else{//設置 urlthis.url=params.url;}//else end//如果 timeout 未定義if(params.timeout===undefined){//初始化為1秒鐘this.timeout=1000;}//if end//反之else{//設置 timeoutthis.timeout=params.timeout;}//else end//如果 callback 未定義if(params.callback===undefined){//初始化 callbackthis.callback=function(res){console.log(res);}//function end}//if end//反之else{//設置 callbackthis.callback=params.callback;}//else end//預設尚未偵測完成 params.url 的服務狀況this.detectServiceFin=false;//預設 params.url 的服務狀況為正常this.serviceBlock=false;//儲存timeout物件this.checkServiceBlockTimeout={};/*說明:傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.參數:params={};params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';params.headers={name:value};params.url='url to request';params.resType='json';params.preAc='function name to call before send request';params.aftAc='function name to call after send request';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};*/var params={};params.timeout=this.timeout;params.detectServiceFin=this.detectServiceFin;params.serviceBlock=this.serviceBlock;params.checkServiceBlockTimeout=this.checkServiceBlockTimeout;params.callback=this.callback;params.method='GET';params.data={};params.url=this.url;params.preAc=function(){//取得 xmlhttp物件var xmlhttp=this;//設置過了 params.timeout 秒中後要做的事情.params.checkServiceBlockTimeout=setTimeout(function(){//中斷連線xmlhttp.abort();//提示目標被封鎖了console.log(params.url+' is blocked');//設置服務不正常,被阻擋了params.serviceBlock=true;//設置偵測google連線完畢params.detectServiceFin=true;},params.timeout,xmlhttp);}params.aftAc=function(res){//debugconsole.log('res='+res);//清除 timeout 的 flagclearTimeout(params.checkServiceBlockTimeout);//設置偵測google連線完畢params.detectServiceFin=true;}window.qbpwcf.ajax(params);//設置無限等待var intervalTail = window.setInterval(function(){//如果已經偵測好google的連線狀況if(params.detectServiceFin){//清除無限等待clearInterval(intervalTail);console.log(params.callback);//如果存在要callback的函式if(params.callback!==undefined){//debugconsole.log('beafore callback');//callbackparams.callback.call(this,params.serviceBlock);}//if end}//if end},100);}//function window.qbpwcf.connectable end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:設置網頁要套用的字形.參數:無.參考資料:https://developer.mozilla.org/en-US/docs/Web/API/FontFacehttps://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFacehttps://developer.mozilla.org/en-US/docs/Web/CSS/@font-face => 直接用 CSS 下載字形https://fontlibrary.org/ => 免費字體下載https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet => CSS 樣式 in Javascripthttps://developer.mozilla.org/en-US/docs/Web/API/Document/styleSheets => 取得 CSS 樣式集合https://developer.mozilla.org/en-US/docs/Web/API/StyleSheethttps://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheethttps://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule => 新增 css 樣式*/window.qbpwcf.fonts={};//default font pathwindow.qbpwcf.fonts.path='liberation-mono/LiberationMono-Regular.ttf';//load font functionwindow.qbpwcf.fonts.load=async function(){//建立font物件var font = new FontFace('qbpwcfFont', 'url(/qbpwcf/fonts/'+this.path+')');//告訴瀏覽器載入字形,並等待其執行完再往下執行//因為 FontFace 類別的 load 方法回傳為 Promise ,因此要等待其回傳結果所以要用 await 關鍵字.await font.load();//新增字形到網頁文件document.fonts.add(font);//新增 qbpwcfFont 類別的網頁字形document.styleSheets[0].insertRule("."'.qbpwcfFont {font-family:qbpwcfFont;}'".");//避免重複新增class,先移除之document.body.classList.remove('qbpwcfFont');//套用字形document.body.classList.add('qbpwcfFont');}//list aviable fontswindow.qbpwcf.fonts.list=function(){//開發中console.log('list fonts');}";#js function$conf["javaScript::toScript"]["jsFunciton"][]="//記錄點擊當下的用戶資訊window.qbpwcf.recordClientInfo=function(){console.log('建構中');}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:解析cookie資料*/window.qbpwcf.cookie={};//記錄原始cookiewindow.qbpwcf.cookie.ori=document.cookie;//如果有 cookie 存在if(window.qbpwcf.cookie.ori!=''){//記錄cookie的數量window.qbpwcf.cookie.count=document.cookie.split(';').length;//初始化用名稱來記錄cookie的內容window.qbpwcf.cookie.byName={};//有幾個cookie就執行幾次for(var i=0;i<window.qbpwcf.cookie.count;i++){//取得cookievar cookieStr=document.cookie.split(';')[i];//取得cookie名稱var cookieName=cookieStr.split('=')[0];//取得cookie內容var cookieValue=cookieStr.split('=')[1];//記錄coockieeval('window.qbpwcf.cookie.byName[\''+cookieName+'\']=cookieValue');//如果有經過編碼if(cookieValue!==decodeURIComponent(cookieValue)){/*設置 window.qbpwcf.ajax 函數說明:傳送ajax,指定傳送前要做什麼事情,傳送後要做什麼事情.參數:params={};params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';params.headers={name:value};params.url='url to request';params.resType='json';params.preAc='function name to call before send request';params.aftAc='function name to call after send request,default params is data to send';params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};*/params={};params.method='POST';params.url='/qbpwcf/unserialize/';//帶入 cookieNameparams.cookieName=cookieName;params.aftAc=function(res){//如果有json回應if(res!==null){//取得cookie解析後的結果eval('window.qbpwcf.cookie.byName.'+params.cookieName+'=res');}//if end};params.data='data='+cookieValue;window.qbpwcf.ajax.call(this,params);}//if end}//for end}//if end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:dialog,類似modal的方法.*/window.qbpwcf.dialog={};/*用dialog確認要做的事情*///初始化儲存 confirm dialog 物件window.qbpwcf.dialog.confirm={};//初始化相關屬性window.qbpwcf.dialog.confirm.clear=function(){//初始化儲存 confirm dialog 的實體window.qbpwcf.dialog.confirm.instance=null;//初始化儲存 confirm dialog 結束後取得的內容window.qbpwcf.dialog.confirm.result={};//初始化儲存 confirm dialog 詢問的內容文字window.qbpwcf.dialog.confirm.text='Are you sure?';//初始化儲存 confirm dialog 取消按鈕的顯示文字window.qbpwcf.dialog.confirm.cancelBtnText='Cancel';//初始化儲存 confirm dialog 確定按鈕的顯示文字window.qbpwcf.dialog.confirm.okBtnText='Confirm';//初始化 confirm dialog 的內容window.qbpwcf.dialog.confirm.content='';//初始化 confirm dialog 的 dom 內容window.qbpwcf.dialog.confirm.customDom={};}//function end//立刻初始化相關屬性window.qbpwcf.dialog.confirm.clear();//初始化設置好 confirm dialog 後要觸發的函式window.qbpwcf.dialog.confirm.prepareCallback=function(){//取得 cancel 的按鈕var cancel_btn=document.querySelector('button#dialog_cancel_btn');//按鈕的事件cancel_btn.addEventListener('click',function(){//設置結果為 'false'window.qbpwcf.dialog.confirm.result='false';//關閉dialogwindow.qbpwcf.dialog.confirm.instance.close();});//取得 confirm 的按鈕var confirm_btn=document.querySelector('button#dialog_confirm_btn');//按鈕的事件confirm_btn.addEventListener('click',function(){//設置結果為 'true'window.qbpwcf.dialog.confirm.result='true';//關閉dialogwindow.qbpwcf.dialog.confirm.instance.close();});}//function end/*初始化關閉 confirm dialog 後要觸發的函式params為取得的內容結果.*/window.qbpwcf.dialog.confirm.closeCallback=function(params){//debugconsole.log(params);}//fucntion end//顯示 confirm dialogwindow.qbpwcf.dialog.confirm.func=function(){//回傳 Promisereturn new Promise(function(resolve, reject){//建立dialog物件var dialog=document.createElement('dialog');//取得參考window.qbpwcf.dialog.confirm.instance=dialog;//dialog的確認內容var dialogConfirmText=document.createTextNode(window.qbpwcf.dialog.confirm.text);//建立放置按鈕的divvar divDialogButton=document.createElement('div');//建立放置取消按鈕的spanvar spanCancelButton=document.createElement('span');//設置取消按鈕靠左對齊spanCancelButton.style.float='left';//建立dialog cancel按鈕var buttonDialogCancel=document.createElement('button');//設置dialog cancel按鈕的idbuttonDialogCancel.id='dialog_cancel_btn';//設置dialog cancel按鈕的文字內容buttonDialogCancel.innerText=window.qbpwcf.dialog.confirm.cancelBtnText;//將取消按鈕放置到spanspanCancelButton.appendChild(buttonDialogCancel);//放置取消按鈕span到divdivDialogButton.append(spanCancelButton);//建立放置確認按鈕的spanvar spanConfirmButton=document.createElement('span');//設置確認按鈕靠右對齊spanConfirmButton.style.float='right';//建立dialog confirm按鈕var buttonDialogConfirm=document.createElement('button');//設置dialog confirm按鈕的idbuttonDialogConfirm.id='dialog_confirm_btn';//設置dialog confirm按鈕的文字內容buttonDialogConfirm.innerText=window.qbpwcf.dialog.confirm.okBtnText;//將確認鈕放置到spanspanConfirmButton.appendChild(buttonDialogConfirm);//放置確認按鈕span到divdivDialogButton.append(spanConfirmButton);//建立要作為dialog內容的divvar divDialogConent=document.createElement('div');//建立dialog確認內容的divvar divDialogConfrimText=document.createElement('div');//設置dialog確認內容的文字要置中divDialogConfrimText.style.textAlign='center';//設置dialog確認內容的文字divDialogConfrimText.appendChild(dialogConfirmText);//放置dialog的確認內容divDialogConent.appendChild(divDialogConfrimText);//放置dialog的按鈕divDialogConent.appendChild(divDialogButton);//如果有指定 dom 內容if(window.qbpwcf.dialog.confirm.customDom.outerHTML!=undefined){//建立 divvar div=document.createElement('div');//將dom放置到div裡面div.appendChild(window.qbpwcf.dialog.confirm.customDom);//設置 div dom 內容在前divDialogConent.prepend(div);}//if end//更新 confirm dialog 的內容window.qbpwcf.dialog.confirm.content=divDialogConent;//設置dialog的內容dialog.appendChild(window.qbpwcf.dialog.confirm.content);//設置iddialog.id='qbpwcf_dialog';//放置dialogdocument.body.appendChild(dialog);//呼叫 window.qbpwcf.dialog.confirm.prepareCallbackwindow.qbpwcf.dialog.confirm.prepareCallback.call(this);//取得dialogvar qbpwcf_dialog=document.querySelector('dialog#qbpwcf_dialog');//顯示modalqbpwcf_dialog.showModal();//當dialog關閉時觸發qbpwcf_dialog.addEventListener('close',function(event){//取得dialog回傳的結果var result=window.qbpwcf.dialog.confirm.result;//將回傳結果交給函式 window.qbpwcf.dialog.confirm.callback處理window.qbpwcf.dialog.confirm.closeCallback.call(this,result);//回傳結果給Promiseresolve(result);//移除dialog元素qbpwcf_dialog.remove();});});}//function end/*用dialog取得密碼.*///初始化儲存 getPassword dialog 的物件window.qbpwcf.dialog.getPassword={};//初始化儲存 getPassword dialog 的實體window.qbpwcf.dialog.getPassword.instance=null;//初始化儲存 getPassword dialog 結束後取得的內容window.qbpwcf.dialog.getPassword.result={};//初始化儲存 getPassword dialog 確認輸入的按鈕顯示文字window.qbpwcf.dialog.getPassword.text='Next';//初始化getPassword dialog的內容window.qbpwcf.dialog.getPassword.content='';//初始化設置好getPassword dialog內容要觸發的函式window.qbpwcf.dialog.getPassword.prepareCallback=function(){//取得輸入的密碼var password=document.querySelector('input#dialog_pass');//如果輸入內容改變password.addEventListener('change',function(){//儲存輸入的密碼window.qbpwcf.dialog.getPassword.result=password.value;});//取得關閉的按鈕var closeBtn=document.querySelector('button#dialog_btn');//關閉按鈕的事件closeBtn.addEventListener('click',function(){//關閉dialogwindow.qbpwcf.dialog.getPassword.instance.close();});}//function end/*初始化關閉getPassword dialog後要觸發的函式params為取得的內容結果.*/window.qbpwcf.dialog.getPassword.closeCallback=function(params){//debugconsole.log(params);}//fucntion end//顯示 getPassword dialogwindow.qbpwcf.dialog.getPassword.func=function(){//建立dialog物件var dialog=document.createElement('dialog');//取得參考window.qbpwcf.dialog.getPassword.instance=dialog;//更新 dialog 的內容window.qbpwcf.dialog.getPassword.content='<input type=\'password\' value=\'\' autocomplete=\'off\' id=\'dialog_pass\'><button id=\'dialog_btn\'>'+window.qbpwcf.dialog.getPassword.text+'</button>';//設置dialog的內容dialog.innerHTML=window.qbpwcf.dialog.getPassword.content;//設置iddialog.id='qbpwcf_dialog';//放置dialogdocument.body.appendChild(dialog);//呼叫 window.qbpwcf.dialog.getPassword.prepareCallbackwindow.qbpwcf.dialog.getPassword.prepareCallback.call(this);//取得dialogvar qbpwcf_dialog=document.querySelector('dialog#qbpwcf_dialog');//顯示modalqbpwcf_dialog.showModal();//當dialog關閉時觸發qbpwcf_dialog.addEventListener('close',function(event){//取得輸入的密碼var password=document.querySelector('input#dialog_pass');//儲存輸入的密碼window.qbpwcf.dialog.getPassword.result=password.value;//取得dialog回傳的結果var result=window.qbpwcf.dialog.getPassword.result;//將回傳結果交給函式 window.qbpwcf.dialog.getPassword.callback處理window.qbpwcf.dialog.getPassword.closeCallback.call(this,result);//移除dialog元素qbpwcf_dialog.remove();});}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:sleep*///初始化window.qbpwcf.sleep={};//執行的定義//參數sec代表要sleep多久,單位為秒.window.qbpwcf.sleep.func=function(sec){//回傳 Promisereturn new Promise(resolve => {//sec秒後才會結束setTimeout(() => {resolve(sec);}, sec*1000);});}//window.qbpwcf.sleep.func end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:slide,輪播任何東西.*///初始化window.qbpwcf.slide={};//初始化要播放的內容 html、css、javaScript 字串.//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unterminated_string_literalwindow.qbpwcf.slide.eles=[];//初始化放置投影片的div區域window.qbpwcf.slide.displayDivByQuerySelector='div#slide';//初始化投影片的滯留時間,預設為3秒,時間到就換下一個投影片.window.qbpwcf.slide.showTime=3;//說明://將 html、css、javaScript 轉換為 dom//參數://htmlStr 內容必須有此結構 html > body > div > anyTag(content to show)window.qbpwcf.slide.toDom=function(htmlStr){//回傳 Promisereturn new Promise(resolve => {//debug//console.log(htmlStr);//initial DOMParservar domParser = new DOMParser();//確保內容格式正確,若為影片,則播放結束後才會結束.//script starthtmlStr=htmlStr+'\<script\>';//綁定 load 事件htmlStr=htmlStr+'window.addEventListener(\'load\',function(event){';//debug//htmlStr=htmlStr+'console.log(document.querySelector(\'div\'));';//取得第一個divhtmlStr=htmlStr+'var containerDiv=document.querySelector(\'div\');';//debug//htmlStr=htmlStr+'console.log(event);';//htmlStr=htmlStr+'console.log(containerDiv);';//如果不存在,則提示錯誤htmlStr=htmlStr+'if(containerDiv===null){console.error(\'containerDiv div not exixt\');}';//設置container div 的 id 為 window_qbpwcf_slidehtmlStr=htmlStr+'containerDiv.id=\'window_qbpwcf_slide\';';//設置container div 為背景htmlStr=htmlStr+'containerDiv.style.zIndex=-1;';//設置container div 為透明htmlStr=htmlStr+'containerDiv.style.opacity=0;';//設置container div 為相對位置htmlStr=htmlStr+'containerDiv.style.position=\'absolute\';';//設置最小寬度跟父元素一樣htmlStr=htmlStr+'containerDiv.style.minWidth=\'inherit\';';//設置最大寬度跟父元素一樣htmlStr=htmlStr+'containerDiv.style.maxWidth=\'inherit\';';//設置最小高度跟父元素一樣htmlStr=htmlStr+'containerDiv.style.minHeight=\'inherit\';';//設置最大高度跟父元素一樣htmlStr=htmlStr+'containerDiv.style.maxHeight=\'inherit\';';//如果有里層元素 - starthtmlStr=htmlStr+'if(containerDiv.children.length!==0){';//設置最小寬度跟父元素一樣htmlStr=htmlStr+'containerDiv.children[0].style.minWidth=\'inherit\';';//設置最大寬度跟父元素一樣htmlStr=htmlStr+'containerDiv.children[0].style.maxWidth=\'inherit\';';//設置最小高度跟父元素一樣htmlStr=htmlStr+'containerDiv.children[0].style.minHeight=\'inherit\';';//設置最大高度跟父元素一樣htmlStr=htmlStr+'containerDiv.children[0].style.maxHeight=\'inherit\';';//取得要呈現的內容htmlStr=htmlStr+'var contentToShow=containerDiv.children[0];';//如果有里層元素 - endhtmlStr=htmlStr+'}';//反之裡層不為element,可能為textNode - starthtmlStr=htmlStr+'else{';//取得要呈現的內容htmlStr=htmlStr+'var contentToShow=containerDiv.childNodes[0];';//設置內容左右置中htmlStr=htmlStr+'containerDiv.style.textAlign=\'center\';';//設置內容高度為 100vhhtmlStr=htmlStr+'containerDiv.style.lineHeight=\'100vh\';';//反之裡層不為element,可能為textNode - endhtmlStr=htmlStr+'}';//若內容是不為video,設置可立即換頁.htmlStr=htmlStr+'if(contentToShow.tagName!==\'VIDEO\'){containerDiv.dataset.canChangeNow=true;}';//反之內容為videohtmlStr=htmlStr+'else{';//設置不可立即換頁htmlStr=htmlStr+'containerDiv.dataset.canChangeNow=false;';//設置影片靜音htmlStr=htmlStr+'contentToShow.muted=true;';//禁止影片自動播放htmlStr=htmlStr+'contentToShow.autoplay=false;';//新增影片播放完之後的事件htmlStr=htmlStr+'contentToShow.addEventListener(\'ended\',function(){';//設置可立即換頁htmlStr=htmlStr+'containerDiv.dataset.canChangeNow=true;';//ended 事件結束htmlStr=htmlStr+'});';//else endhtmlStr=htmlStr+'}';//若內容是img,設置按照比例自動縮放//https://code-boxx.com/keep-image-aspect-ratio/htmlStr=htmlStr+'if(contentToShow.tagName===\'IMG\'){contentToShow.style.objectFit=\'scale-down\';}';//load 事件結束htmlStr=htmlStr+'});';//script endhtmlStr=htmlStr+'\</script\>';//html to domvar dom=domParser.parseFromString(htmlStr,'text/html');//回傳轉成 dom 的 htmlresolve(dom.documentElement);});}//window.qbpwcf.slide.toDom end//將多個 html、css、javaScript 轉換為 domwindow.qbpwcf.slide.toDoms=function(htmlStrArray){//回傳 Promisereturn new Promise(resolve => {//初始化要回傳的內容var doms=[];//初始化用來存放排序後的 domsvar tempDoms=[];//針對每個要輪播的內容htmlStrArray.forEach(async function(value,key){//將 html to domvar dom=await window.qbpwcf.slide.toDom.call(this,value);//記錄排序順序dom.order=key;//保存到 doms 陣列裡面doms.push(dom);//如果每個都解析成 dom 了if(doms.length===htmlStrArray.length){//初始化要尋找的索引var indexToFind=0;//初始化最後的索引var maxlidex=htmlStrArray.length-1;//按照 order 重新排序for(var i=0;i<=maxlidex;i++){//如果是要找的索引if(doms[i].order===indexToFind){//放置domtempDoms.push(doms[i]);//要尋找的索引+1indexToFind++;//重新搜尋i=-1;//繼續迴圈continue;}//if end}//for end//回傳轉成 dom 的 arrayresolve(tempDoms);}//if end});//forEach end});//回傳 Promise end}//window.qbpwcf.slide.toDoms end//將 dom 給 ifrmae 執行完後,回傳其 documentwindow.qbpwcf.slide.loadDom=function(dom){//回傳 Promisereturn new Promise(resolve => {//建立 iframevar iframe=document.createElement('iframe');//隱藏 iframeiframe.style.display='none';//放置 iframedocument.body.appendChild(iframe);//取得 iframe 的 documentvar documentInIframe=iframe.contentDocument;//讓 iframe 開始接收內容documentInIframe.open();//綁定 iframe load 事件iframe.addEventListener('load',function(){//回傳 iframe documentresolve(documentInIframe.documentElement);});//讓 iframe 接收指定內容documentInIframe.write(dom.outerHTML);//讓 iframe 結束接收內容documentInIframe.close();});//回傳 Promise end}//window.qbpwcf.slide.loadDom end//將多個 dom 給 ifrmae 執行完後,回傳其 document 集合window.qbpwcf.slide.loadDoms=function(doms){//回傳 Promisereturn new Promise(resolve => {//初始化儲存 iframe documentvar iframeDocs=[];//初始化儲存排序過後的 iframe documentvar tempIframeDocs=[];//針對每個domdoms.forEach(async function(value,key){//取得 iframe documentvar iframeDoc=await window.qbpwcf.slide.loadDom.call(this,value);//記錄排序順序iframeDoc.order=key;//儲存iframeDocs.push(iframeDoc);//如果每個都解析成 dom 了if(iframeDocs.length===doms.length){//初始化要尋找的索引var indexToFind=0;//初始化最後的索引var maxlidex=doms.length-1;//按照 order 重新排序for(var i=0;i<=maxlidex;i++){//如果是要找的索引if(iframeDocs[i].order===indexToFind){//放置iframeDoctempIframeDocs.push(iframeDocs[i]);//要尋找的索引+1indexToFind++;//重新搜尋i=-1;//繼續迴圈continue;}//if end}//for end//回傳各個 iframe documentresolve(tempIframeDocs);}//if end});//forEach end});//回傳 Promise end}//window.qbpwcf.slide.loadDoms end//執行的定義window.qbpwcf.slide.func=async function(){//取得要輪播的元素var eles=window.qbpwcf.slide.eles;//如果沒有要輪播的內容if(eles.length===0){//提示錯誤訊息console.error('Array(window.qbpwcf.slide.eles) should not be empty');//結束執行return false;}//if end//取得放置輪播的div QuerySelectorStringvar displayDivByQuerySelector=window.qbpwcf.slide.displayDivByQuerySelector;//取得放置輪播的divvar displayDiv=document.querySelector(displayDivByQuerySelector);//如果沒有找到放置輪播內容的divif(displayDiv===null){//提示錯誤訊息console.error('result of querySelector by '+displayDivByQuerySelector+' is null');//結束執行return false;}//if end//取得每個slide的最小播放時間var showTime=window.qbpwcf.slide.showTime;//將輪播內容轉換為domsvar doms = await window.qbpwcf.slide.toDoms.call(this,eles);//debug//console.log(doms);//取得每個 iframe 的 documentvar iframeDocs = await window.qbpwcf.slide.loadDoms.call(this,doms);//debug//console.log(iframeDocs);//放置讀取好的投影片for(var i=0;i<iframeDocs.length;i++){//取得容器 divvar containerDiv=iframeDocs[i].querySelector('div');//放置要播放的內容displayDiv.appendChild(containerDiv);}//for end//初始化索引為0i=0;//無窮迴圈while(true){//如果目標不存在if(iframeDocs[i]===undefined){//重新計數i=0;//下一輪continue;}//if end//取得所有投影片var slides=displayDiv.querySelectorAll('div#window_qbpwcf_slide');//針對每個投影片for(var j=0;j<slides.length;j++){//設置放在背景slides[j].style.zIndex=-1;//設置為透明slides[j].style.opacity=0;//設置為absolute,不占用空間slides[j].style.position='absolute';}//for end//取得當前播放的內容var prePlayContent=displayDiv.querySelectorAll('div#window_qbpwcf_slide')[i];//當前要播放的內容移到前景prePlayContent.style.zIndex='unset';//顯示當前要播放的內容prePlayContent.style.opacity='unset';//設置為unset,要占用空間prePlayContent.style.position='unset';//如果有子元素if(prePlayContent.children.length>0){//如果是影片if(prePlayContent.children[0].tagName==='VIDEO'){//播放之prePlayContent.children[0].play();}//if end}//if end//播放 showTime 秒await window.qbpwcf.sleep.func(showTime);//如果尚不行置換slidewhile(prePlayContent.dataset.canChangeNow==='false'){//多播放 1 秒await window.qbpwcf.sleep.func(1);}//while end//如果有子元素if(prePlayContent.children.length>0){//如果是影片if(prePlayContent.children[0].tagName==='VIDEO'){//設置下次要等待影片播放完才能換頁prePlayContent.dataset.canChangeNow=false;}//if end}//if end//執行到這邊代表可以置換slide了//計數增加i++;}//while end}//window.qbpwcf.slide.func end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:取得用戶端的檔案.回傳結果:result.data,取得檔案的 base64 dataresult.mime,取得檔案的 mimeresult.base64,取得檔案的純 base64 部分參考資料:https://developer.mozilla.org/en-US/docs/Web/API/Filehttps://developer.mozilla.org/en-US/docs/Web/API/FileListhttps://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accepthttps://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL_statichttps://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL*///初始化window.qbpwcf.clientFile={};//取得用戶端檔案的參數設定window.qbpwcf.clientFile.params={};//初始化multiple參數為falsewindow.qbpwcf.clientFile.params.multiple=false;//初始化accept參數為''window.qbpwcf.clientFile.params.accept='';//設置只接受videowindow.qbpwcf.clientFile.acceptVideoOnly=function(){//設置accept為'video/*'window.qbpwcf.clientFile.params.accept='video/*';}//function end//設置只接受audiowindow.qbpwcf.clientFile.acceptAudioOnly=function(){//設置accept為'audio/*'window.qbpwcf.clientFile.params.accept='audio/*';}//function end//設置只接受imagewindow.qbpwcf.clientFile.acceptImageOnly=function(){//設置accept為'image/*'window.qbpwcf.clientFile.params.accept='image/*';}//function end//累加允許的檔案類型window.qbpwcf.clientFile.acceptAppend=function(type){//如果已經有內容if(window.qbpwcf.clientFile.params.accept!=''){//增加允許的類型window.qbpwcf.clientFile.params.accept=window.qbpwcf.clientFile.params.accept+','+type;}//if end//反之尚無設定else{//設置允許的類型window.qbpwcf.clientFile.params.accept=type;}//else end}//function end//觸發選擇檔案的視窗後,若沒有選擇到的檔案,會強制使用者再度選擇,預設為'false'不啟用;反之為'true'要啟用.window.qbpwcf.clientFile.forceSelectFileAfterTrigger='false';//取得用戶端的檔案,使用時前面請加上 await 才能取得回應.window.qbpwcf.clientFile.init=async function(){//建立 inputvar input=document.createElement('input');//設置 type 為檔案input.type='file';//設置multiple參數input.multiple=window.qbpwcf.clientFile.params.multiple;//設置multiple參數input.accept=window.qbpwcf.clientFile.params.accept;//初始化要回傳的結果物件input.result={};//預設使用者尚未取消選取檔案input.canceled='false';//當選擇的檔案有異動input.onchange=function(){//轉換與取得ObjectURLinput.result.url=URL.createObjectURL(input.files[0]);//初始化 FileReadervar reader = new FileReader();//讀取檔案reader.readAsDataURL(input.files[0]);//當檔案讀取完畢後reader.onload=function(){//取得檔案的 base64 datainput.result.data = reader.result;//取得檔案的 mimeinput.result.mime = input.result.data.split(':')[1].split(';')[0];//取得檔案的純 base64 部分input.result.base64 = input.result.data.split(',')[1];}//function end};//function end//綁定使用按下取消的事件//參考資料://https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/cancel_eventinput.addEventListener('cancel',function(event){//debug//console.log(event,Object.keys(input.result).length);return false;//如果沒有結果if(Object.keys(input.result).length===0){//設置被按下cancel了input.canceled='true';}//if end});//觸發使用者選擇檔案input.click();//無窮迴圈while(true){//如果使用者取消了if(input.canceled==='true'){//回傳結果return input.result;}//if end//休息一秒await window.qbpwcf.sleep.func(1);//debugconsole.log('wait file selected');//如果有結果if(input.result!={}){//如果if(//url存在input.result.url!=undefined&&//data存在input.result.data!=undefined&&//mime存在input.result.mime!=undefined&&//base64存在input.result.base64!=undefined){//執行到這代表資料都有了//結束迴圈break;}//if end}//if end}//while end//回傳結果return input.result;};";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:text_editor,編輯文字.*///初始化window.qbpwcf.text_editor={};//用於取得顯示輸入內容的區塊window.qbpwcf.text_editor.selector='';//執行window.qbpwcf.text_editor.init=function(){//取得用來顯示輸入內容的 selectorvar displayTag=document.querySelector(window.qbpwcf.text_editor.selector);//取得一開始的內容,用一個div代表一行.var lines=displayTag.children;//關注用來顯示輸入內容的元素後displayTag.addEventListener('focus',function(event){//取得觸發的元素var eTarget=event.target;//debugconsole.log(eTarget);//建立暫存的textInputvar tempInput=document.createElement('input');//設置為單行輸入tempInput.type='text';//break pointreturn;//初始化內容tempInput.value=contentOfTag;//關注之tempInput.focus();//若內容有改變tempInput.addEventListener('change',function(event){//更新用來顯示輸入的內容displayTag.innerText=this.value;});});}";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:openWindow,由javaScript開啟可管控的視窗,甚至存取其內容.範例://第一段var script=document.createElement('script');script.src='https://latest.qbpwcf.org/qbpwcf/javaScript/qbpwcf.php';document.head.appendChild(script);//第二段window.qbpwcf.openWindow.params.url=window.location.href;window.qbpwcf.openWindow.saveSourceAtTheEnd='true';await window.qbpwcf.openWindow.func();參考資料:https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURLhttps://developer.mozilla.org/en-US/docs/Web/API/File/File*///初始化物件window.qbpwcf.openWindow={};//初始化參數window.qbpwcf.openWindow.init=function(){//初始化參數物件window.qbpwcf.openWindow.params={};//初始化目標網址window.qbpwcf.openWindow.params.url='https://sourceforge.net/projects/qbpwc/';//初始化要將window.open()儲存到哪個全域變數裡面.window.qbpwcf.openWindow.params.varName='qbpwcf_openWindow_instance';//初始化給予 window.open() 的第三個參數.window.qbpwcf.openWindow.params.windowFeatures='';//初始化window.open()後,其回應的html sourcewindow.qbpwcf.openWindow.resSource='';//初始化window.open()後,要執行什麼操作,參數Window為其opened的Window的.window.qbpwcf.openWindow.actionAfterOpen=function(Window){//預設的提示訊息console.log('do something after window.oepn()');}//actionAfterOpen end//預設window.open()後經過處理後結果不要下載下來window.qbpwcf.openWindow.saveSourceAtTheEnd='false';}//funciton end//初始化參數window.qbpwcf.openWindow.init();//window.openwindow.qbpwcf.openWindow.func=async function(){//window.open()並儲存回傳的結果window[window.qbpwcf.openWindow.params.varName]=await window.open(window.qbpwcf.openWindow.params.url,'_blank',window.qbpwcf.openWindow.params.windowFeatures);//如果執行失敗if(!(window[window.qbpwcf.openWindow.params.varName])){//提示錯誤訊息console.error('The window wasn\'t allowed to open. This is likely caused by built-in popup blockers.');//結束執行return;}//if end//加入load事件window[window.qbpwcf.openWindow.params.varName].addEventListener('load',function(event){//debug//console.log(this);//呼叫開啟後要做度事情window.qbpwcf.openWindow.actionAfterOpen(this);//取得html原始碼window.qbpwcf.openWindow.resSource='<html>'+window[window.qbpwcf.openWindow.params.varName].document.head.outerHTML+window[window.qbpwcf.openWindow.params.varName].document.body.outerHTML+'</html>';//如果要下載內容if(window.qbpwcf.openWindow.saveSourceAtTheEnd=='true'){//建立檔案Filevar filed2download=new File([window.qbpwcf.openWindow.resSource],'filed2download');//建立用來讀取檔案的FileReadervar fileReader=new FileReader();//檔案讀取完畢後fileReader.addEventListener('load',function(event){//取得dataUrldataUrl=fileReader.result;//建立 avar a=document.createElement('a');//設置連結為dataUrla.href=dataUrl;//點擊開始下載a.click();});//讀取檔案為 dataUrl]fileReader.readAsDataURL(filed2download);}//if end});}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:儲存當前頁面的原始碼範例:window.qbpwcf.saveSource();*///儲存當前頁面原始碼window.qbpwcf.saveSource=async function(){//取得原始碼var sourceStr='<html>'+document.head.outerHTML+document.body.outerHTML+'</html>';//建立File,檔案名稱隨機產生.var file2download=new File([sourceStr],'file2download');//建立用來讀取檔案的FileReadervar fileReader=new FileReader();//檔案讀取完畢後fileReader.addEventListener('load',function(event){//取得dataUrldataUrl=fileReader.result;//建立 avar a=document.createElement('a');//設置連結為dataUrla.href=dataUrl;//點擊開始下載a.click();});//讀取檔案為 dataUrlfileReader.readAsDataURL(file2download);}//function end";#js function$conf["javaScript::toScript"]["jsFunciton"][]="/*說明:將要執行的任務交由 web socket 處理.範例://初始化參數var params={};//設定websocket位置params.url='wss://'+location.hostname+':443/';//要傳輸的資料params.data={};//用來識別是所需要資料的idparams.data.id=crypto.randomUUID();//取得對應的回應var response=await window.qbpwcf.ws.init(params);*///該方法的物件window.qbpwcf.ws={};//連線到web socket,並傳輸資料,會回傳promise.亦即要在 async function 中使用,且使用 await 來取得結果.window.qbpwcf.ws.init=async function(params){//回傳 Promisereturn new Promise(function(resolve, reject){//若無參數if(Object.keys(params).length==0){//初始化參數params={};//設定websocket位置params.url='wss://'+location.hostname+':443/';//要傳輸的資料params.data={};//用來識別是所需要資料的idparams.data.id=crypto.randomUUID();//收到資料後要做的事情params.callback=function(msg){//debugconsole.log('run callback');}//function end}//if end//如果沒有儲存所有wss連線的變數存在if(this.qbpwcf.ws.wss==undefined){//初始化為空物件this.qbpwcf.ws.wss={};}//if end//設置 既有的 web socket 實體清單 參考var wsList={//取得本函式的參數參考'params':params,//取得既有的 web socket 實體清單'list':Object.keys(window.qbpwcf.ws.wss),}//wsList end//針對每個實體清單for(key in wsList.list){//如果有同樣目標的連線if(key==params.url){//使用既有的連線var conn=value;//如果有要傳遞資料if(params.data!={}){//傳遞資料conn.send(JONS.toString(params.data));//如果更新要識別的id?//...}//if end//結束forbreak;}//if end}//for end//設定webSocket的連線目標var conn = new WebSocket(params.url);//設置上層參考conn.mother=this.qbpwcf.ws;//設置本函式參數的參考conn.params=params;//儲存可以使用的連線window.qbpwcf.ws.wss[params.url]=conn;//建立與當連線成功後conn.onopen = function(e){//如果有要傳遞資料if(params.data!={}){//debugconsole.log(params.data);//將訊息顯現在consoleconsole.log('send:'+JSON.stringify(params.data));//傳遞資料conn.send(JSON.stringify(params.data));}//if end}//function end//當有收到訊息時conn.onmessage = function(e){//將訊息顯現在consoleconsole.log('received:'+e.data);//解析成jsonvar revJson=JSON.parse(e.data);//如果有 idif(revJson.id!=undefined){//如果id符合if(revJson.id==params.data.id){//卸除idrevJson.id=undefined;//resolve, await 可以有結果.resolve(revJson);}//if end}//if end//callback,收到資料後要做的事情.this.params.callback(e.data);}//function end//當連線斷開後conn.onclose = async function(e){//等待1秒await window.qbpwcf.sleep.func(1);//重新嘗試一次.this.mother.init(this.params);}//function end//當遇到錯誤時conn.onerror = function(e){//初始化要回傳的結果var result={};//設置錯誤訊息result.error=e;//設置執行失敗result.status='false';//回傳結果, await 可以有結果.reject(result);}//function end});//Promise end}//function end";#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.$conf["javaScript::toScript"]["noScriptTag"]=$conf["noScriptTag"];#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立script失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得建立好的js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function qbpwcfJavaScript end/*#函式說明:#分段續載檔案#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["content"],js語法.#必填參數:#$conf["url"],字串,下載檔案的url.$conf["url"]="";#可省略參數:#$conf["scriptTag"],字串,是否要用<script>標籤包起來,預設為"true"代表要;"false"代表不要.#$conf["scriptTag"]="true";#$conf["partSize"],字串,一次要下載多少bytes,預設為"1024",亦即1kb.#$conf["partSize"]="1024";#$conf["retryIn"],字串,如果下載失敗或不完整,要幾秒後再度嘗試,預設為3.#$conf["retryIn"]="3";#參考資料:#無.#備註:#尚不支援,關閉瀏覽器後再續載.#server 端需要搭配 fileAccess::partDownload 方可運行*/public static function conDownload(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["argu"],設置給予的參數.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填寫的參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("url");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("scriptTag","partSize","retryIn");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("scriptTag","partSize","retryIn");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","1024","3","60");#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".#$conf["disallowAllSkipableVarIsEmpty"]="";#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".#$conf["disallowAllSkipableVarIsEmptyArray"]="";#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查參數不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#續載的js$result["content"]="var myConDownloadAgent=new conDownloadAgent();myConDownloadAgent.fileUrl='".$conf["url"]."';myConDownloadAgent.partSize='".$conf["partSize"]."';myConDownloadAgent.retryIn=".$conf["retryIn"].";myConDownloadAgent.getPart();";#如果要用<script>標籤包起來if($conf["scriptTag"]==="true"){#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]=$result["content"];#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["javaScript::toScript"]["onReady"]=$conf["onReady"];#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果轉成script失敗if($toScript["status"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];}#if end#設置執行正常$result["status"]="true";#回傳結果return $result;}#function conDownload end/*#函式說明:#建立rwd的置頂menu,橫向span選單遇到寬度不足會變成div選單,其中第一個元素爲Logo.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["firstEleId"],字串,選單的擡頭元素id.$conf["firstEleId"]="";#$conf["otherEleClass"],字串,除擡頭選單外項目的共同類別名稱.$conf["otherEleClass"]="";#可省略參數:#$conf["bgColor"],字串,選單的背景顏色,預設爲"#FFFFFF".#$conf["bgColor"]="";#參考資料:#無.#備註:#bgColor尚未實作#固定在頂端或底端的功能未實作*/public static function rwdMenu($conf){return css::rwdMenu($conf);}#function rwdMenu end/*#函式說明:#建立廣告幻燈片,實際上為div的背景會隨着時間變化.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["divId"],字串,廣告區域的div id.$conf["divId"]="";#$conf["divClass"],字串,廣告區域用於套用動畫效果的div class名稱.$conf["divClass"]="";#$conf["adImg"],字串陣列,廣告圖片的網站陣列.$conf["adImg"]=array();#可省略參數:#無.#參考資料:#無.#備註:#bgColor尚未實作#固定在頂端或底端的功能未實作*/public static function adImg($conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("divId","divClass","adImg");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("bgColor");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("bgColor");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("#FFFFFF");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("headOrTail","target","styleAttr","styleVal","content");#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查參數不通過if($checkArguments["passed"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#ad bar#函式說明:#<div>區塊,裡面可以指定css的class樣式,可以指定提示文字.#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.#$result["functin"],字串,當前函數的名稱.#$result["error"],陣列,錯訊訊息.#$result["content"],字串,含有<div>標籤的內容.#必填參數:#$conf["contentArray"],字串陣列,要放入的內容陣列.$conf["css::divSection"]["contentArray"]=array("");#可省略參數#$conf["id"],字串,div區塊的id.$conf["css::divSection"]["id"]=$conf["divId"];#$conf["styleAttr"],字串陣列,給div區段要套用的style樣式屬性.$conf["css::divSection"]["styleAttr"]=array("width","height","background-size");#$conf["styleVal"],字串陣列,給div區段要套用的style樣式數值.$conf["css::divSection"]["styleVal"]=array("100vw","100vh","cover");#$conf["class"],字串,div區段要套用的css樣式.$conf["css::divSection"]["class"]=$conf["divClass"];#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容.#$conf["title"]=array();#$conf["oneScreenSize"],字串,div區塊是否要占一個螢幕的大小,預設為"false"不設定,"true"為設定成一個螢幕的大小.#$conf["oneScreenSize"]="false";#$conf["textAlignCenter"],字串,div區塊是否要置中,預設為$conf["oneScreenSize"]的值,"false"為不置中,"true"代表要置中.$conf["css::divSection"]["textAlignCenter"]="true";#$conf["data"],字串陣列,每個要設置的屬性data內容,例如array("option1"=>"A","option2"=>"B"),預設不使用.#$conf["data"]=array();$divSection=css::divSection($conf["css::divSection"]);unset($conf["css::divSection"]);#如果建立div區塊失敗if($divSection["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$divSection;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$divSection["content"];#儲存廣告圖片的計數$adImgCount=count($conf["adImg"]);#函式說明:#製作針對 css class 的動畫,請套用在div上,才會有效果#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["content"],css動畫設定的語法#$result["function"],當前執行的函數#$result["error"],涵式錯誤訊息陣列#$result["warning"],警告訊息陣列#必填參數:#$conf["name"],字串,css動畫的名稱.$conf["css::animation"]["name"]=$conf["divClass"];#$conf["durationTime"],字串,整個動畫需要幾秒完成,例如"5s".$durationTime=$adImgCount*5;$durationTime=$durationTime."s";$conf["css::animation"]["durationTime"]=$durationTime;#$conf["iteration"],字串,整個動畫要重複幾次,"infinite"代表不斷地重複,"0"代表不重複執行.$conf["css::animation"]["iteration"]="infinite";#$conf["direction"],字串,動畫要怎麼樣重複,"alternate"代表來回執行,"normal"代表正常執行.$conf["css::animation"]["direction"]="alternate";#$conf["delay"],字串,動畫要延遲幾秒開始,例如"0s".$conf["css::animation"]["delay"]="0s";#$conf["speedMode"],字串,動畫執行過程的速度要用什麼模式來執行,"linear"代表等速,"ease"代表起始跟結尾是靜止的,中間是最快的.$conf["css::animation"]["speedMode"]="linear";#可省略參數:#每個廣告圖片的依存時間百分比.$perImgPercentage=(int)(100/$adImgCount/2);#$conf["keyFrameStartPoint"],字串陣列,各個動畫單位開始的時間百分比,"0%"與"from"代表一開始,"100%"與"to"代表時間結束.#$conf["css::animation"]["keyFrameStartPoint"]=array("0%","10%","30%","70%","90%","100%");#針對每個廣告圖片for($i=1;$i<=$adImgCount*2;$i=$i+2){#如果是第一個if($i===1){#起始點$conf["css::animation"]["keyFrameStartPoint"][]="0%";$conf["css::animation"]["keyFrameStartPoint"][]=$perImgPercentage*$i."%";}#if end#反之如果是最後一個else if($i===$adImgCount*2-1){#最後一點$conf["css::animation"]["keyFrameStartPoint"][]=$perImgPercentage*($i)."%";$conf["css::animation"]["keyFrameStartPoint"][]="100%";}#if end#其他狀況else{#擺兩個點,在區間內呈現$conf["css::animation"]["keyFrameStartPoint"][]=$perImgPercentage*($i-1)."%";#$i多加1$conf["css::animation"]["keyFrameStartPoint"][]=$perImgPercentage*($i+1)."%";}#else end}#for end#debug#var_dump($conf["css::animation"]["keyFrameStartPoint"]);#$conf["keyFrameCssMoveAttribute"],二維字串陣列,各個動畫影格子的與動畫相關的css屬性.#$conf["keyFrameCssMoveAttribute"][]=array();#$conf["keyFrameCssMoveValue"],二維字串陣列,各個動畫影格子的與動畫相關的css屬性.#$conf["keyFrameCssMoveValue"][]=array();#$conf["keyFrameCssAttribute"],二維字串陣列,各個動畫影格子的一般非動畫的css屬性.#跑 $adImgCount*2 的次數for($i=0;$i<$adImgCount*2;$i++){$conf["css::animation"]["keyFrameCssAttribute"][]=array("background-image");}#for end#$conf["keyFrameCssValue"],二維字串陣列,各個動畫格子的css屬性數值.#跑 $adImgCount 的次數for($i=0;$i<$adImgCount;$i++){#兩個點的圖片要一致$conf["css::animation"]["keyFrameCssValue"][]=array("url('".$conf["adImg"][$i]."')");$conf["css::animation"]["keyFrameCssValue"][]=array("url('".$conf["adImg"][$i]."')");}#for end#參考資料:#css動畫,http://blogger.gtwang.org/2013/12/using-css3-animation.html#w3c的animation-keyframes,http://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp$animation=css::animation($conf["css::animation"]);unset($conf["css::animation"]);#如果建立動畫失敗if($animation["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$animation;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$animation["content"];#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//debugconsole.log('loaded');//get scroll divvar scrollDiv=document.getElementById('".$conf["divId"]."');//set click one to 0scrollDiv.dataset.clickOnce=0;//scrolliv click eventscrollDiv.addEventListener('click',function(e){//set scroll div idvar scrollDivId='".$conf["divId"]."';//get scroll divvar scrollDiv=document.getElementById(scrollDivId);//如果已經點擊過一次了if(scrollDiv.dataset.clickOnce==='1'){//結束事件return true;}//if end//觸發者非divif(e.target.id!==scrollDivId){//debugconsole.log(e.target.id+'!=='+scrollDivId);//debugconsole.log(e.target);//end functionreturn false;}//if end//debugconsole.log(e.target);//get target computed stylevar tcs=window.getComputedStyle(e.target,null);//debugconsole.log(tcs);//get style background image urlvar tcsBg=tcs.backgroundImage;//debugconsole.log(tcsBg);//split by '/'var splitedStr=tcsBg.split('/');//debugfor(i=0;i<splitedStr.length;i++){//show each section strconsole.log(splitedStr[i]);}//for end//get clicked image file namevar clickedImgName=splitedStr[splitedStr.length-1].split('\")')[0];//debugconsole.log(clickedImgName);//split by '\"'var splitedStr=tcsBg.split('\"');//get clickedImgUrlvar clickedImgUrl=splitedStr[1];//debugconsole.log(clickedImgUrl);//delete applied classscrollDiv.classList={};//set clicked imagescrollDiv.style.backgroundImage='url('+clickedImgUrl+')';//設置點擊過一次了scrollDiv.dataset.clickOnce='1';//scrolliv click eventscrollDiv.addEventListener('click',function(e){//set scroll div idvar scrollDivId='".$conf["divId"]."';//get scroll divvar scrollDiv=document.getElementById(scrollDivId);//如果已經點擊過一次了if(scrollDiv.dataset.clickOnce!=='1'){//結束執行return true;}//if end//debugconsole.log('should change to next pic');//debugconsole.log(e.target);//get target computed stylevar tcs=window.getComputedStyle(e.target,null);//debugconsole.log(tcs);//get style background image urlvar tcsBg=tcs.backgroundImage;//debugconsole.log(tcsBg);//split by '/'var splitedStr=tcsBg.split('/');//debugfor(i=0;i<splitedStr.length;i++){//show each section strconsole.log(splitedStr[i]);}//for end//get clicked image file namevar clickedImgName=splitedStr[splitedStr.length-1].split('\")')[0];//debugconsole.log(clickedImgName);//split by '\"'var splitedStr=tcsBg.split('\"');//get clickedImgUrlvar clickedImgUrl=splitedStr[1];//debugconsole.log(clickedImgUrl);//set img arrayvar imgArray=".json_encode($conf["adImg"]).";//無窮迴圈for(i=0;i<".$adImgCount.";i++){//如果找到點擊的圖片if(clickedImgUrl.includes(imgArray[i])){//debugconsole.log(i+'<".$adImgCount."');//如果是最後一張圖片if(i===".$adImgCount."-1){//設置為第一張圖片i=0;}//反之+1else{i++;}//else end//debugconsole.log('set img to '+imgArray[i]);//set clicked imagescrollDiv.style.backgroundImage='url('+imgArray[i]+')';//debugconsole.log('end for');//end forbreak;}//if end}//for end});//scrollDiv addEventListener end});//scrollDiv click event end";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立 script 語法失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}//function adImg end/*#函式說明:#區塊輪播的效果#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["place"],字串,輪播區塊要在哪個元素裡面呈現,其區塊特徵為何?(請參閱javascript的querySelector函式).$conf["place"]="";#$conf["slideDiv"],字串陣列,每個投影片的div區塊特徵(請參閱javascript的querySelector函式).$conf["slideDiv"]=array("");#可省略參數:#$conf["sec"],字串,過幾秒就要置換成下一張投影片,預設為"5",代表每5秒就換一張投影片.#$conf["sec"]="5";#參考資料:#無.#備註:#無.*/public static function slideDiv(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("place","slideDiv");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("sec");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("sec");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("5");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("headOrTail","target","styleAttr","styleVal","content");#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查參數不通過if($checkArguments["passed"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//取得內部要放置投影片內容的區塊var displayArea=document.querySelector('".$conf["place"]."');//get left valuevar leftP=displayArea.offsetLeft+'px';//get top valuevar topP=displayArea.offsetTop+'px';//get width valuevar widthP=displayArea.clientWidth;//get height valuevar heightP=displayArea.clientHeight;//不顯示原始內容displayArea.style.opacity=0;displayArea.style.zIndex=-1;//取得投影片的數量var slideCount=".count($conf["slideDiv"])."//宣告儲存投影片陣列的變數var slide=[];";#針對每個投影片foreach($conf["slideDiv"] as $index=>$slide){#串接js內容$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."//取得投影片的區塊元素var content=document.querySelector('".$slide."');//強制設定其位置為看不到的地方content.style.position='absolute';content.style.left='-100vw';content.style.top='-100vh';//設置投影片的資訊var info={};//設置投影片的left資訊info.left=getComputedStyle(content).left;//設置投影片的top資訊info.top=getComputedStyle(content).top;//初始化儲存單一投影片的結構var slideObject={};//設置投影片的內容slideObject.content=content;//設置投影片的資訊slideObject.info=info;//儲存投影片到陣列slide.push(slideObject);";}#串接js的內容.$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."//debug//console.log(slide);//設置投影片置換的等待秒數var sec=".$conf["sec"].";//設置等待時間的函式var timeout=function(sec){return new Promise(resolve =>{setTimeout(() =>{resolve(sec);}, sec*1000);});}//建立與執行隨着畫面大小改變而更新播放區域資訊的函式var updateDisplayInfo=window.addEventListener('resize',function(){//更新投影區域資訊leftP=displayArea.offsetLeft+'px';topP=displayArea.offsetTop+'px';widthP=displayArea.clientWidth+'px';heightP=displayArea.clientHeight+'px';//初始化要更新的投影片索引為-1var showedSlideIndex=-1;//針對每個投影片for(var i=0;i<slideCount;i++){//如果是正在顯示的投影片if(slide[i].content.dataset.show==='true'){//取得當前播放的投影片索引showedSlideIndex=i;}}//如果有抓取到正在播放的投影片索引if(showedSlideIndex!==-1){//更新正在投影的投影片slide[showedSlideIndex].content.style.top=topP;slide[showedSlideIndex].content.style.left=leftP;slide[showedSlideIndex].content.style.width=widthP;slide[showedSlideIndex].content.style.height=heightP;}});//宣告置換投影片的函式var changeSlide=async function(page){//debug//console.log('start chaneg slide');//如果要顯示的投影片編號超出範圍if(page > slideCount - 1){//代表是要顯示第一張投影片page=0;}//取得要隱藏的投影片編號var lastSlideNo=page-1;//如果要隱藏的投影片編號是負的if(lastSlideNo < 0){//代表要隱藏的投影片編號最後一張lastSlideNo = slideCount - 1;}//隱藏上一張投影片slide[lastSlideNo].content.style.top=slide[lastSlideNo].info.top;slide[lastSlideNo].content.style.left=slide[lastSlideNo].info.left;slide[lastSlideNo].content.dataset.show='false';//顯示下一張投影片slide[page].content.style.top=topP;slide[page].content.style.left=leftP;slide[page].content.style.width=widthP;slide[page].content.style.height=heightP;slide[page].content.dataset.show='true';//等待時間await timeout.call(this,sec);//呼叫自己changeSlide.call(this,page+1);}//每過了 sec 秒後就置換投影片changeSlide.call(this,0);";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the#備註:#無.$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立 script 語法失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function slideDiv end/*#函式說明:#簡易版區塊輪播的效果,要輪播的內容為$conf["place"]特徵區塊的children元素.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["place"],字串,輪播區塊要在哪個元素裡面呈現,其區塊特徵為何?(請參閱javascript的querySelector函式).$conf["place"]="";#可省略參數:#$conf["sec"],字串,過幾秒就要置換成下一張投影片,預設為"5",代表每5秒就換一張投影片.#$conf["sec"]="5";#參考資料:#無.#備註:#無.*/public static function slideDivSimple(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("place");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("sec");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("sec");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("5");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("headOrTail","target","styleAttr","styleVal","content");#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查參數不通過if($checkArguments["passed"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//取得要放置投影片內容的區塊var displayArea=document.querySelector('".$conf["place"]."');//如果無投影片的內容存在if(displayArea.children.length<1){//提示錯誤console.error('無投影片內容');//結束執行return;}//if end//設置投影片的數量var slideCount=displayArea.children.length;//設置投影片置換的等待秒數var sec=".$conf["sec"].";//設置等待時間的函式var timeout=function(sec){return new Promise(resolve =>{setTimeout(() =>{resolve(sec);}, sec*1000);});}//宣告置換投影片的函式var changeSlide=async function(page){//隱藏所有投影片for(var i=0;i<slideCount;i++){//隱藏投影片displayArea.children[i].style.display='none';}//for end//如果page超過上限if(page===slideCount){//設置為第1個投影片page=0;}//顯示投影片displayArea.children[page].style.display='inline-block';//等待時間await timeout.call(this,sec);//呼叫自己changeSlide.call(this,page+1);}//每過了 sec 秒後就置換投影片changeSlide.call(this,0);";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the#備註:#無.$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立 script 語法失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}/*#函式說明:#建立點擊後會移到最頂端的 span icon,位於頂端時則會隱藏.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["id"],字串,廣告區域的span id.$conf["id"]="";#可省略參數:#$conf["img"],字串,gotop的icon位置與名稱,預設爲base64加密svg圖檔.#$conf["img"]="";#$conf["mimeType"],字串,圖檔的mime type,預設爲image/*.#$conf["mimeType"]="image/*";#$conf["fileArgu"],字串, __FILE__ 的內容,若有設置img參數,則也要設置該參數.#$conf["fileArgu"]=__FILE__;#$conf["bottom"],字串,icon距離底部的位置.$conf["bottom"]="";#$conf["right"],字串,icon距離右部的位置.$conf["right"]="";#參考資料:#無.#備註:#bgColor尚未實作#固定在頂端或底端的功能未實作*/public static function goTopIcon(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("id");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("img","bottom","right","fileArgu","mimeType");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("img","bottom","right","fileArgu","mimeType");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"30px","30px",null,null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果有設置 $conf["img"] 跟 $conf["fileArgu"]if( isset($conf["img"]) && isset($conf["fileArgu"]) ){#移到最上面的icon#函式說明:#用data:mimeType;base64,imgVar的形式來提供圖片的連結,亦即圖片儲存在變數裡面,本函式包含顯示圖片的語法.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息#$result["content"],圖片的連結資訊#$result["function"],當前執行的函數名稱#必填參數:#$conf["imgPosition"],要轉存成2元碼的圖片檔案位置與名稱$conf["img::data"]["imgPosition"]=$conf["img"];#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.$conf["img::data"]["fileArgu"]=$conf["fileArgu"];#可省略參數:#$conf["alt"],若沒有圖片要用什麼文字顯示。#$conf["alt"]="";#$conf["style"],字串陣列,要使用的style,key為樣式名稱,value為樣式值.#$conf["style"]=array();#$conf["class"],圖片要套用的css樣式名稱.#$conf["class"]="";#如果有設置 $conf["mimeType"]if(isset($conf["mimeType"])){#$conf["mimeType"],2元碼的內容是什麼,預設為"image/*".$conf["img::data"]["mimeType"]=$conf["mimeType"];}#if end#$conf["compressType"],2元碼壓縮的方式,預設為"base64".#$conf["compressType"]="base64";#$conf["delImg"],讀取完圖片檔案後,要移除圖片嗎?"true"代表要移除,"false"代表不要移除,預設為"false".#$conf["delImg"]="false";#參考資料:#將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php$data=img::data($conf["img::data"]);unset($conf["img::data"]);#如果建立 span section 失敗if($data["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$data;#回傳結果return $result;}#if end}#if end#反之設置爲else{#預設的 go top svg base64 encode$data["content"]="<img src=\"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiCiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIgogICB3aWR0aD0iOTAiCiAgIGhlaWdodD0iOTAiCiAgIHZpZXdCb3g9IjAgMCA4OS45OTk5OSA4OS45OTk5OTkiCiAgIGlkPSJzdmcyIgogICB2ZXJzaW9uPSIxLjEiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuOTEgcjEzNzI1IgogICBzb2RpcG9kaTpkb2NuYW1lPSJ0b3Auc3ZnIgogICBpbmtzY2FwZTpleHBvcnQtZmlsZW5hbWU9Ii9ob21lL2xpdmV1c2VyL3B1YmxpY19odG1sL3NhbXBsZVBhZ2UvZmFjdG9yeS9pbWcvdG9wLnN2Zy5wbmciCiAgIGlua3NjYXBlOmV4cG9ydC14ZHBpPSI5MCIKICAgaW5rc2NhcGU6ZXhwb3J0LXlkcGk9IjkwIj4KICA8ZGVmcwogICAgIGlkPSJkZWZzNCIgLz4KICA8c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgaWQ9ImJhc2UiCiAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEuMCIKICAgICBpbmtzY2FwZTpwYWdlb3BhY2l0eT0iMC4wIgogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiCiAgICAgaW5rc2NhcGU6em9vbT0iMS40IgogICAgIGlua3NjYXBlOmN4PSI0NS4xMDA5NjYiCiAgICAgaW5rc2NhcGU6Y3k9IjEzMS45NjQ5MiIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0ibW0iCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzMzNTkiCiAgICAgc2hvd2dyaWQ9InRydWUiCiAgICAgc2hvd2d1aWRlcz0iZmFsc2UiCiAgICAgaW5rc2NhcGU6d2luZG93LXdpZHRoPSIxOTIwIgogICAgIGlua3NjYXBlOndpbmRvdy1oZWlnaHQ9IjEwMjMiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjAiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjMxIgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiCiAgICAgaW5rc2NhcGU6c2hvd3BhZ2VzaGFkb3c9ImZhbHNlIgogICAgIHNob3dib3JkZXI9InRydWUiCiAgICAgdW5pdHM9InB4Ij4KICAgIDxpbmtzY2FwZTpncmlkCiAgICAgICB0eXBlPSJ4eWdyaWQiCiAgICAgICBpZD0iZ3JpZDMzNjQiIC8+CiAgPC9zb2RpcG9kaTpuYW1lZHZpZXc+CiAgPG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhNyI+CiAgICA8cmRmOlJERj4KICAgICAgPGNjOldvcmsKICAgICAgICAgcmRmOmFib3V0PSIiPgogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0PgogICAgICAgIDxkYzp0eXBlCiAgICAgICAgICAgcmRmOnJlc291cmNlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvU3RpbGxJbWFnZSIgLz4KICAgICAgICA8ZGM6dGl0bGUgLz4KICAgICAgPC9jYzpXb3JrPgogICAgPC9yZGY6UkRGPgogIDwvbWV0YWRhdGE+CiAgPGcKICAgICBpbmtzY2FwZTpsYWJlbD0iTGF5ZXIgMSIKICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIgogICAgIGlkPSJsYXllcjEiCiAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwtOTYyLjM2MjIyKSI+CiAgICA8ZwogICAgICAgaWQ9ImczMzU5IgogICAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMC45OTkzNzg1OCwwLDAsMS4wNDIxOTk3LC0zMTIuODc2ODUsNzkwLjE2OTMxKSI+CiAgICAgIDxnCiAgICAgICAgIGlkPSJnMzMzOCIKICAgICAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMC45OTE2NDk1LDAsMCwxLjAyNDkzNTQsMi42MzA5MTk2LC01LjU1NTczMDYpIj4KICAgICAgICA8cmVjdAogICAgICAgICAgIHN0eWxlPSJmaWxsOiNmZmZmZmY7c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjIuNjY5MTU5NjUiCiAgICAgICAgICAgaWQ9InJlY3QzMzQ1IgogICAgICAgICAgIHdpZHRoPSI4OC4zMzA4NDEiCiAgICAgICAgICAgaGVpZ2h0PSI4MS41NTk4NDUiCiAgICAgICAgICAgeD0iMzEzLjY5MTI1IgogICAgICAgICAgIHk9IjE2OC4yODE3NyIKICAgICAgICAgICByeT0iNDEuNjY1NDA1IgogICAgICAgICAgIHJ4PSI0NC4xNjU0MjEiIC8+CiAgICAgICAgPHRleHQKICAgICAgICAgICB4bWw6c3BhY2U9InByZXNlcnZlIgogICAgICAgICAgIHN0eWxlPSJmb250LXN0eWxlOm5vcm1hbDtmb250LXdlaWdodDpub3JtYWw7Zm9udC1zaXplOjQwcHg7bGluZS1oZWlnaHQ6MTI1JTtmb250LWZhbWlseTpzYW5zLXNlcmlmO2xldHRlci1zcGFjaW5nOjBweDt3b3JkLXNwYWNpbmc6MHB4O2ZpbGw6IzAwMDAwMDtmaWxsLW9wYWNpdHk6MTtzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MXB4O3N0cm9rZS1saW5lY2FwOmJ1dHQ7c3Ryb2tlLWxpbmVqb2luOm1pdGVyO3N0cm9rZS1vcGFjaXR5OjEiCiAgICAgICAgICAgeD0iMzI1LjcxNDI5IgogICAgICAgICAgIHk9IjIyMi4zNjIyIgogICAgICAgICAgIGlkPSJ0ZXh0MzM0NyIKICAgICAgICAgICBzb2RpcG9kaTpsaW5lc3BhY2luZz0iMTI1JSI+PHRzcGFuCiAgICAgICAgICAgICBzb2RpcG9kaTpyb2xlPSJsaW5lIgogICAgICAgICAgICAgaWQ9InRzcGFuMzM0OSIKICAgICAgICAgICAgIHg9IjMyNS43MTQyOSIKICAgICAgICAgICAgIHk9IjIyMi4zNjIyIj5Ub3A8L3RzcGFuPjwvdGV4dD4KICAgICAgPC9nPgogICAgPC9nPgogIDwvZz4KPC9zdmc+Cg==\">";}#else end#移到最上面的icon div#函式說明:#<span>區塊,裡面可以指定css的class樣式,可以指定提示文字,若要使用移動的css樣式,請改用divSection函數.#$result["status"],字串,執行否正常,"true"代表正常,"false"代表不正常.#$result["functin"],字串,當前函數的名稱.#$result["error"],陣列,錯訊訊息.#$result["content"],字串,含有<span>標籤的內容.#必填參數:#$conf["contentArray"],字串陣列,要放入的內容陣列.$conf["css::spanSection"]["contentArray"]=array($data["content"]);#可省略參數#$conf["id"],字串,span元素的id.$conf["css::spanSection"]["id"]=$conf["id"];#$conf["styleAttr"],字串陣列,給div區段要套用的style樣式屬性.$conf["css::spanSection"]["styleAttr"]=array("position","bottom","right","display");#$conf["styleVal"],字串陣列,給div區段要套用的style樣式數值.$conf["css::spanSection"]["styleVal"]=array("fixed",$conf["bottom"],$conf["right"],"none");#$conf["class"],字串,span區段要套用的css樣式.#$conf["class"]="";#$conf["title"],陣列,滑鼠移到上面時要顯示的內容,每個元素代表一列內容#$conf["title"]=array();#$conf["data"],字串陣列,每個data屬性名稱為數值內容,例如array("a"=>"A","b"=>"B")#$conf["data"]=array();$spanSection=css::spanSection($conf["css::spanSection"]);unset($conf["css::spanSection"]);#如果建立 span section 失敗if($spanSection["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$spanSection;#回傳結果return $result;}#if end#儲存 top span$result["content"]=$result["content"].$spanSection["content"];#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//get topspanvar topSpan=document.getElementById('".$conf["id"]."');//scrolliv click eventtopSpan.addEventListener('click',function(e){//滑到頂端document.scrollingElement.scrollTop=0;});//topSpan addEventListener end//當滾軸滾動時觸發window.addEventListener('scroll', function(e){//get last scroll yvar last_known_scroll_position = window.scrollY;//get topspanvar topSpan=document.getElementById('".$conf["id"]."');//如果是在網頁頂端if(last_known_scroll_position===0){//隱藏往頂端的圖示topSpan.style.display='none';}//if end//反之else{//get topspan to showtopSpan.style.display='inline';}//else end});//window scroll event end";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立js失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存 top span$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#funcion goTopIcon end/*#函式說明:#透過ajax遞迴取得檔案的內容,類似tail指令的效果.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["argu"],使用的參數.#$result["content"],語法.#必填參數:#$conf["url"],字串,提供tail ajax的網址.$conf["url"]="";#可省略參數:#$conf["rootDivId"],字串,root div的id,預設為"tailRootDiv".#$conf["rootDivId"]="tailRootDiv";#參考資料:#無.#備註:#請跟fileAccess類別的tail函式搭配使用.*/public static function tail(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("url");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("rootDivId");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("rootDivId");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("tailRootDiv");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//initial window.tailif(window.tail===undefined){//初始化 window.tailwindow.tail={};//初始化繼續執行window.tail.continue=true;}//if end//create root divwindow.tail.rootDiv = document.createElement('div');window.tail.rootDiv.id = '".$conf["rootDivId"]."';document.body.appendChild(window.tail.rootDiv);//set tail urlwindow.tailUrl='".$conf["url"]."';//設置周期執行的涵式window.tail.ajax = function(line2start){xmlhttp=new XMLHttpRequest();xmlhttp.responseType='json';xmlhttp.timeout=60000;xmlhttp.open('POST',window.tailUrl,true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState===4 && xmlhttp.status===200){//get responseres=xmlhttp.response;//debugconsole.log(res);//針對每個輸出的行for(var i=0;i<xmlhttp.response.lines;i++){//set output linevar div=document.createElement('div');var text=document.createTextNode(xmlhttp.response.content[i]);div.appendChild(text);//debugconsole.log(div);//如果內容為空if(xmlhttp.response.content[i]===''){//建立<br>var br=document.createElement('br');//遷入<br>div.appendChild(br);}//show output linevar rootDiv=document.getElementById(window.tail.rootDiv.id);rootDiv.prepend(div);}//for end//遞迴window.tail.ajax.call(this,(res.lineNum)+1);}//if end}//function end//如果要繼續if(window.tail.continue){//繼續xmlhttp.send('line2start='+line2start);}//if end//反之要暫停else{//設置無限等待var intervalTail = window.setInterval(function(){//提示已經暫停console.log('paused');//如果要繼續了if(window.tail.continue){//清除無限等待clearInterval(intervalTail);//繼續xmlhttp.send('line2start='+line2start);}//if end},1000);}//else end}//function end//call tail ajaxwindow.tail.ajax.call(this,-1);";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立js失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存 top span$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function tail end/*#函式說明:#透過ajax產生亂數驗證碼,驗證亂數驗證碼與傳送表單#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["argu"],使用的參數.#$result["function"],當前執行的函數名稱.#$result["content"],json.#必填參數:#$conf["url"],字串,提供random code的網址.$conf["url"]="";#$conf["callBackUrls"],字串陣列,用來處理表單資訊的網址們,會傳送 obj 物件的 post 內容到第一個 callback url,之後都會將 json 回應傳送給下一個 callback url. 如果進行第2個含以上的 callback urls 時有回應含有 formObj 元素的 json 則會改傳送之.每次傳送給 callback url 的表單變數均為 $conf["sendedName"].$conf["callBackUrls"]=array();#可省略參數:#$conf["resDivId"],字串,輸入驗證碼的表單id,預設為"randomCode".#$conf["resDivId"]="randomCode";#$conf["names"],字串陣列,需要傳送的表單變數.#$conf["names"]=array();#$conf["sendedName"],字串,傳送的post變數名稱,預設的爲"formData".#$conf["sendedName"]="";#備註:#請跟 authenticate 類別的 verifyCodeAndFormData 函式搭配.#每次呼叫 callBackUrl 應該要驗證其所 post 的驗證碼是否正確,其對應的 post 變數為元素 id 為 $conf["resDivId"] 的 name 屬性數值;對應的session變數名稱則為 "authenticate.verifyCodeAndFormData.".元素 id 為 $conf["resDivId"] 的 name 屬性數值.例如 $_SESSION["authenticate.verifyCodeAndFormData.randomCode"]===$post->randomCode .#從 $conf["callBackUrls"] 取得的 json 回應,若有 msg 屬性,且 status 屬性爲 'true', 則會顯示提示訊息.#從 $conf["callBackUrls"] 取得的 json 回應,若有 error 屬性,且 status 屬性爲 'false', 則會顯示錯誤訊息.#從 $conf["callBackUrls"] 中的最後一個 callback url 取得的 json 回應,若有 href 屬性,則會轉址.#從 $conf["callBackUrls"] 中的最後一個 callback url 取得的 json 回應,若有 refresh 屬性,且爲 'true' 則會重新整理頁面.#參考資料:#無.#備註:#提示訊息的呈現改用 text area;#驗證失敗原因呈現改用 text area;*/public static function randomCode(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("url","callBackUrls");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("resDivId","names","sendedName");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("resDivId","names","sendedName");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("randomCode",null,"formData");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果未設置 $conf["names"]if(!isset($conf["names"])){#設置爲空$conf["names"]=array();}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//initial window.qbpwcfif(window.qbpwcf===undefined){window.qbpwcf={};}//if end//initial window.randomCodeif(window.qbpwcf.randomCode===undefined){window.qbpwcf.randomCode={};}//if end//set random code generate urlwindow.qbpwcf.randomCode.randomCodeUrl='".$conf["url"]."';//set 表單ID 陣列window.qbpwcf.randomCode.formDataIDs=".json_encode($conf["names"])."//設置傳送表單的涵式window.qbpwcf.randomCodeAjax = function(formObj){xmlhttp=new XMLHttpRequest();xmlhttp.responseType='json';xmlhttp.timeout=60000;xmlhttp.open('POST',window.qbpwcf.randomCode.randomCodeUrl,true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState===4 && xmlhttp.status===200){//get responseres=xmlhttp.response;//debugconsole.log(res);//debugconsole.log(res.status);//if error occurif(res.status==='false'){//debugconsole.log(res.error);//if no dataif(res.error==='no data'){//get random code base64 encoded stringvar randomCodeSrc=res.content.randomCodeSrc;//debugconsole.log(randomCodeSrc);//get random code lengthwindow.qbpwcf.randomCode.codeLength=res.content.randomCodeLength;//debugconsole.log(window.qbpwcf.randomCode.codeLength);//get code input elementvar codeInput=document.getElementById('".$conf["resDivId"]."');//create img elementvar img=document.createElement('img');//put src codeimg.src=randomCodeSrc;//create random code img idvar imgId='".$conf["resDivId"]."'+'Img';//若存在舊的驗證碼if(document.getElementById(imgId)!==null){//移除舊的驗證碼document.getElementById(imgId).remove();}//if end//set img idimg.id=imgId;//設置寬度img.width='200';//debugconsole.log(img);//place random code imgcodeInput.parentElement.prepend(img);}//if end//反之有其他錯誤else{//debugconsole.log(res.error);//alertalert(res.error);}//else end}//if end//如果驗證失敗if(res.passed==='false'){//debugconsole.log(res.error);//alertalert(res.error);}//if end//反之通過驗證else if(res.passed==='true'){//debugconsole.log(res.msg);//alert//alert(res.msg);//set callback urlswindow.qbpwcf.randomCode.callBackUrls=".json_encode($conf["callBackUrls"]).";//nested call callback urlswindow.qbpwcf.randomCode.callBackFunc.call(this,formObj,window.qbpwcf.randomCode.callBackUrls);}//else end}//if end}//function end//加密傳送資料xmlhttp.send('".$conf["sendedName"]."='+btoa(encodeURIComponent(JSON.stringify(formObj))));}//end window.qbpwcf.randomCodeAjax//initial call random code ajaxwindow.qbpwcf.randomCodeAjax({});//設置遞迴傳送表單的涵式window.qbpwcf.randomCode.callBackFunc = function(formObj,urls){xmlhttp=new XMLHttpRequest();xmlhttp.responseType='json';xmlhttp.timeout=60000;xmlhttp.open('POST',urls[0],true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState===4 && xmlhttp.status===200){//get responseres=xmlhttp.response;//如果沒有定義 res.statusif(res===null){//debugconsole.log('callback to '+urls[0]+' fails!');//show erroralert('callback to '+urls[0]+' fails!');//return & end process.return false;}//if end//debugconsole.log(res);//如果沒有定義 res.statusif(res.status===undefined){//debugconsole.log('callback to '+urls[0]+' fails!');//show erroralert('callback to '+urls[0]+' fails!');//return & end process.return false;}//if end//debugconsole.log(res.status);//如果執行不正常if(res.status!=='true'){//debugconsole.log('callback to '+urls[0]+' fails!');//show erroralert(res.error);//return & end process.return false;}//if end//執行正常//如果有訊息if(res.msg!==undefined){//顯示訊息alert(res.msg);}//if end//新的表單變數存在if(res.formObj!==undefined){//取代要傳送的表單變數res=res.formObj;}//else end//移除第一個已經callback的urlurls.splice(0, 1);//如果還有 callback urlsif(urls.length>0){//debugconsole.log('callback to:'+urls[0]);//nested call callback urlswindow.qbpwcf.randomCode.callBackFunc.call(this,res,urls);}//if end//反之else{//如果有 href 設定if(res.href!==undefined){//到指定頁面window.location.href=res.href;//結束執行return true;}//if end//如果有 refresh 設定if(res.refresh!==undefined){//如果要 refreshif(res.refresh==='true'){//重新整理頁面window.location.href=document.baseURI;//結束執行return true;}//if end}//if end}//else end}//if end}//function end//加密傳送資料xmlhttp.send('".$conf["sendedName"]."='+btoa(encodeURIComponent(JSON.stringify(formObj))));}//function end//get code input elementvar codeInput=document.getElementById('".$conf["resDivId"]."');//如果存在輸入驗證碼的表單if(codeInput!==null){//當輸入的驗證碼長度變化時、有按鍵放開時.codeInput.addEventListener('keyup',function(e){//debugconsole.log('keyup event occur');//debugconsole.log('放開的Key爲'+e.key);//expected 'Enter' Keyif( e.key!=='Enter' ){//debugconsole.log('ignore '+e.key);return false;}//if end//如果長度不一致if(codeInput.value.length!==window.qbpwcf.randomCode.codeLength){//結束執行return false;}//if end//長度一致//初始化 form ObjformObj={};//依照每個表單for(var i=0;i<window.qbpwcf.randomCode.formDataIDs.length;i++){//構成表單變數名稱var formName=window.qbpwcf.randomCode.formDataIDs[i];//debugconsole.log(formName);//取得表單內容formObj.formName=document.getElementById(window.qbpwcf.randomCode.formDataIDs[i]).value;}//for end//加入驗證碼表單內容formObj.".$conf["resDivId"]."=document.getElementById('".$conf["resDivId"]."').value;//傳送表單window.qbpwcf.randomCodeAjax.call(this,formObj);});//function end}//if end";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立js失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存 js 語法$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function randomCode end/*#函式說明:#$conf["countdownSec"]n秒後轉址#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["content"],js語法.#必填參數:#$conf["url"],字串,要導頁到哪邊.$conf["url"]="";#可省略參數:#$conf["countdownSec"],字串,幾秒後要導頁,預設不指定.#$conf["countdownSec"]="";#參考資料:#無.#備註:#無.*/public static function redirectUrl(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("url");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("countdownSec");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("countdownSec");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化不指定要幾秒後導頁$countdownSec="";#如果有設置 countdownSecif(isset($conf["countdownSec"])){#設置要幾秒後才導頁$countdownSec="params.countdownSec=".$conf["countdownSec"].";";}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="params={};params.url='".$conf["url"]."';".$countdownSec."window.redirectURL.call(this,params);";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果執行失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function redirectUrl end/*#函式說明:#傳遞識別數字進而取得連續的資料#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["content"],js語法.#必填參數:#$conf["params"],參數陣列,要傳遞的識別參數.$conf["params"]=array();#$conf["url"],字串,要從哪個頁面要求連續的資料.$conf["url"]="";#可省略參數:#$conf["method"],字串,資料傳輸的方式,有POST跟GET#$conf["method"]="";#$conf["responseDivId"],字串,放置取得資料div的id.#$conf["responseDivId"]="";#參考資料:#無.#備註:#無.*/public static function tailAny(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("params","url");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("method","responseDivId");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("method","responseDivId");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("POST","rootDiv");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="params=".json_encode($conf["params"])."var tailAny=new window.qbpwcf.tailAny.func(params,'".$conf["url"]."','".$conf["method"]."','".$conf["responseDivId"]."');";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果執行失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#funtion tailAny end/*#函式說明:#設置點擊元素後會傳遞data屬性為名稱與其數值為表單數值給特定url,進而取得連續的資料#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["content"],js語法.#必填參數:#$conf["elementJS"],字串,要用什麼js語法抓取要綁定事件的元素$conf["elementJS"]=""#$conf["url"],字串,要將表單資訊傳遞的哪個url.$conf["url"]="";#可省略參數:#$conf["method"],字串,資料傳輸的方式,有POST跟GET,預設為"POST".#$conf["method"]="";#$conf["resDiv"],字串,放置回應的div之id,預設為"rootDiv".#$conf["resDiv"]="";#參考資料:#無.#備註:#無.*/public static function postDataAttr(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("elementJS","url");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("method","resDiv");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("method","resDiv");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("POST","rootDiv");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="element=".$conf["elementJS"]."window.qbpwcf.postDataAttr.func.call(this,element,'".$conf["url"]."','".$conf["method"]."','".$conf["resDiv"]."');";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果執行失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function postDataAttr end/*#函式說明:#設置指定元素的數值長度為特定條件時,會傳遞data屬性為名稱與其數值為表單數值給特定url,進而取得連續的資料#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["content"],js語法.#必填參數:#$conf["elementJS"],字串,要用什麼js語法抓取要綁定事件的元素$conf["elementJS"]=""#$conf["length"],字串,數值長度為多少才傳送要求.$conf["length"]="";#$conf["paramsJS"],字串陣列要使用的js參數物件$conf["paramsJS"]="";#$conf["url"],字串,要將表單資訊傳遞的哪個url.$conf["url"]="";#可省略參數:#$conf["method"],字串,資料傳輸的方式,有POST跟GET,預設為"POST".#$conf["method"]="";#$conf["resDiv"],字串,放置回應的div之id,預設為"rootDiv".#$conf["resDiv"]="";#$conf["outFunc"],字串,重新定義用來將資料放到畫面上的函式,參數有兩個,第一個是得到的json回應,第二個為放置回應的div之id.#$conf["outFunc"]="function(res,id){console.log(res,id);}";#參考資料:#無.#備註:#無.*/public static function gatDataDynamic(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("elementJS","length","paramsJS","url");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("method","resDiv");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("method","resDiv","outFunc");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("POST","rootDiv",null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="var element=".$conf["elementJS"]."var params=".$conf["paramsJS"];#如果有設置 $conf["outFunc"]if(isset($conf["outFunc"])){#串接客制化的輸出函式$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."window.qbpwcf.tailAny.outputFunc=".$conf["outFunc"];}#if end//呼叫涵式$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."window.qbpwcf.gatDataDynamic.func.call(this,element,".$conf["length"].",params,'".$conf["url"]."','".$conf["method"]."','".$conf["resDiv"]."');";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果執行失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function end/*#函式說明:#設置點擊元素後會傳遞data屬性為名稱與其數值為表單數值給特定url,進而取得連續的資料#回傳結果:#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函式名稱.#$result["content"],js語法.#必填參數:#$conf["url"],字串,要將表單資訊傳遞的哪個url.$conf["url"]="";#$conf["name"],字串,變數名稱.$conf["name"]="";#$conf["callback"],陣列字串,要呼叫的涵式$conf["callback"]["name"]與參數$conf["callback"]["params"].$conf["callback"]=array();#可省略參數:#無#參考資料:#無.#備註:#無.*/public static function sequenceQuery(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#初始化內容$result["content"]="";#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("url","name","callback");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("method","resDiv");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("method","resDiv");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("POST","rootDiv");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="url='".$conf["url"]."';name='".$conf["name"]."';queue=[];callback=".json_encode($conf["callback"]).";window.qbpwcf.sequenceQuery.func.call(this,url,name,queue,callback);";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果執行失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得js語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function sequenceQuery end/*#函數說明#讓js變數確實存在.#回傳的結果#$result["status"],執行正常與否.#$result["content"],js語法.#$result[argu],使用的參數.#必填參數:#$conf["name"],js變數的名稱.$conf["name"]="";#可省略參數:#無#參考資料:#無.#備註:#無.*/public static function makeVarExist(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("name",);#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("method","resDiv");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("var","storeInArray","action");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("window.qbpwcf.readTable","true",null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化內容$result["content"]="";#用 "." 分割 $conf["var"]#函式說明:#將固定格式的字串分開,並回傳分開的結果。#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱.#$result["argu"],使用的參數.#$result["oriStr"],要分割的原始字串內容#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。#$result["dataCounts"],爲總共分成幾段#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.#必填參數:$conf["stringProcess::spiltString"]["stringIn"]=$conf["name"];#要處理的字串。$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割#可省略參數:#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";$spiltString=$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);unset($conf["stringProcess::spiltString"]);#如果檢查參數失敗if($spiltString["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$spiltString;#回傳結果return $result;}#if end#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="";#初始化 js 變數$jsVar="";#針對每個 js 變數的階層for($i=0;$i<$spiltString["dataCounts"];$i++){#取得片段 js 變數名稱$jsVarPart=$spiltString["dataArray"][$i];#如果不是第一層變數if($i!==0){#串接 js 變數名稱$jsVar=$jsVar.".".$jsVarPart;}#if end#反之else{#串接 js 變數名稱$jsVar=$jsVar.$jsVarPart;}#else end#串接 js 語法$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."//如果該階段變數不存在if(".$jsVar."===undefined){//初始化為空物件".$jsVar."={};}//if end";}#foreach end#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果檢查參數失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得 js 語法$result["content"]=$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#fucntion makeVarExist end/*#函數說明#讀取由table::div建立的資料表,依照欄位內容做不同的事情.#回傳的結果#$result["status"],執行正常與否.#$result["content"],js語法.#$result[argu],使用的參數.#必填參數:#$conf["table"],取得table的js.$conf["table"]="";#可省略參數:#$conf["var"],表格的資訊要儲在哪個js變數,預設為"window.qbpwcf.readTable"#$conf["var"]="window.qbpwcf.readTable";#$conf["storeInArray"],預設為儲存成陣列"true",反之儲存成單一變數"false".#$conf["storeInArray"]="true";#$conf["action"],字串陣列,讀到每個欄位要做什麼事情,預設選項為"save":僅儲存;"call,function name":呼叫call js funcion,欄位內容作為參數.#$conf["action"]=array();#參考資料:#無.#備註:#無.*/public static function readTable(&$conf=array()){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("table",);#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.#$conf["canNotBeEmpty"]=array();#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.#$conf["canBeEmpty"]=array();#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("method","resDiv");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("var","storeInArray","action");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","array");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("window.qbpwcf.readTable","true",null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["arrayCountEqualCheck"][]=array();#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果參數檢查不通過if($checkArguments["passed"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化內容$result["content"]="";#函數說明#讓js變數確實存在.#回傳的結果#$result["status"],執行正常與否.#$result["content"],js語法.#$result[argu],使用的參數.#必填參數:#$conf["name"],js變數的名稱.$conf["javaScript::makeVarExist"]["name"]=$conf["var"];#可省略參數:#無$makeVarExist=javaScript::makeVarExist($conf["javaScript::makeVarExist"]);unset($conf["javaScript::makeVarExist"]);#如果執行失敗if($makeVarExist["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$makeVarExist;#回傳結果return $result;}#if end#串接js語法$result["content"]=$result["content"].$makeVarExist["content"];#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//set debug modewindow.debug=true;//set paramsparams=".json_encode($conf).";//初始化變數存在noExist=true;//確認變數是否存在eval(noExist=('+params.var+'===undefined));//如果變數不存在if(noExist===false){//如果要儲存成陣列if(params.storeInArray==='true'){//初始化為空陣列eval(params.var+'=[]');}//if end//反之else{//初始化為空陣列eval(params.var+'={}');}//else end}//if end//initial empty table objectthisTable={};//get latest tablethisTable.target=".$conf["table"].";//如果有 thead,tbodyif(thisTable.target.children.length>1){//get theadthisTable.thead=thisTable.target.children[0];//get tbodythisTable.tbody=thisTable.target.children[1];}//if end//反之只有 tbodyelse{//empty theadthisTable.thead={};//get tbodythisTable.tbody=thisTable.target.children[1];}//if end//列數thisTable.rowsCount=thisTable.tbody.children.length;//欄數thisTable.colsCount=thisTable.tbody.children[1].children.length;//如果有標題欄位if(thisTable.thead!=={}){//debugif(window.debug){//提示有欄位標題console.log('There is title.');}//if end//取得每個欄位的標題thisTable.title=[];//debugif(window.debug){//提示欄位數目console.log('thisTable.colsCount='+thisTable.colsCount);}//if end//針對每個for(i=0;i<thisTable.colsCount;i++){//debugif(window.debug){//提示當前是第幾個欄位(從0開始)console.log('i='+i);}//if end//如果欄位存在if(thisTable.thead.children[0].children[i]!==undefined){//取得欄位標題thisTable.title.push(thisTable.thead.children[0].children[i].innerText);//debugif(window.debug){console.log('column title - start');console.log(thisTable.thead.children[0].children[i].innerText);console.log('column title - end');}//if end}//if end}//for end}//if end//反之else{//預設欄位標題為 A,B,C....Zconsole.log('尚未實作');exit;}//else end//暫存欄位的資料rowData=[];//debugif(window.debug){//提示資料筆數console.log('thisTable.rowsCount='+thisTable.rowsCount);}//if end//針對每筆資料for(i=1;i<thisTable.rowsCount;i++){//debugif(window.debug){//提示第幾筆資料console.log('i='+i);}//if end//取得列tr=thisTable.tbody.children[i];//debugif(window.debug){//提示第幾筆資料console.log('tr - start');console.log(tr);console.log('tr - end');}//if end//暫存欄位資料colData={};//debugif(window.debug){//提示欄位數量console.log('thisTable.rowsCount='+thisTable.rowsCount);}//if end//針對每個欄位for(j=0;j<thisTable.colsCount;j++){//debugif(window.debug){//提示欄位編號console.log('j='+j);}//if end//取得欄位內容td=tr.children[j].innerHTML;//debugif(window.debug){//提示欄位內容console.log('td='+td);}//if end//debugif(window.debug){//提示欄位原始名稱console.log('thisTable.title['+j+']='+thisTable.title[j]);}//if end//set temp title,replace ' ' to '_'.tempTitle=thisTable.title[j].replace(/ /i, '_');//debugif(window.debug){//提示欄位新名稱console.log('tempTitle='+tempTitle);}//if end//用欄位標題儲存欄位內容eval('colData.'+tempTitle+'=td');//如果有 action 參數if(params.action!==undefined){//如果 action 參數對應的欄位存在數值if(params.action[j]!==undefined){//get actionaction=params.action[j];//debugif(window.debug){//提示欄位新名稱console.log('action='+action);}//if end//如果動作不是 'save'if(action!=='save'){//debugif(window.debug){console.log('not only save, need extra action.');}//if end//用 ',' 分割 action 字串splitedStr=action.split(',');//debugif(window.debug){console.log('call '+splitedStr[1]+' function with param('+td+')');//call functino with paramseval(splitedStr[1]+'.call(this,td)');}//if end}//if end}//fie nd}//if end}//if end//儲存該筆資料的欄位資料rowData.push(colData);}//for end//儲存每筆資料的欄位資料thisTable.rowData=rowData;//如果要儲存成陣列if(params.storeInArray==='true'){//put table in arrayeval(params.var+'.push(thisTable)');}//if end//反之else{//put table in vareval(params.var+'.=thisTable');}//else end";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果檢查參數失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#取得 js 語法$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#funtion readTable end/*#函式說明:#提供tab頁簽,點選頁簽後顯示對應的內容.套用的element結構如下:#<div># <!-- data-tab-name 為頁籤要顯示名稱 --># <div data-tab-name="tab1" style="display:none;"># <!-- 頁籤對應的內容 --># tab1 content...# </div># <div data-tab-name="tab2" style="display:none;"># tab2 content...# </div># <div data-tab-name="tab3" style="display:none;"># tab3 content...# </div>#</div>#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["place"],字串,該功能區塊要在哪個元素裡面呈現,其區塊特徵為何?(請參閱javascript的querySelector函式).$conf["place"]="";#可省略參數:#$conf["height"],字串,tab選單+內容的高度,單位為px..#$conf["height"]="291";#參考資料:#無.#備註:#無.*/public static function tab(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("place");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("sec");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("height");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("tabsDisplayValue","tabsContent");#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查參數不通過if($checkArguments["passed"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//取得要放置投影片內容的區塊var displayArea=document.querySelector('".$conf["place"]."');//儲存頁籤的數量var tabsCount=displayArea.children.length;//初始化儲存頁籤的名稱var tabsName=[];//針對每個頁簽for(var i=0;i<tabsCount;i++){//隱藏頁籤displayArea.children[i].style.display='none';//初始化頁籤名稱var tabName='tab'+i;//如果有設置頁籤的名稱if(displayArea.children[i].dataset.tabName!==undefined){//更新頁籤名稱tabName=displayArea.children[i].dataset.tabName}//if end//儲存頁籤名稱tabsName.push(tabName);}//for end//建立存放頁籤選單的divvar tabsDiv=document.createElement('div');//針對每個頁簽for(var i=0;i<tabsCount;i++){//建立頁籤的divvar div=document.createElement('div');//設置儘量不換行div.style.display='inline-block';//設置間隔避免無法識別div.style.marginLeft='5px';div.style.marginRight='5px';//設置indexdiv.dataset.index=i+1;//放置頁籤的名稱div.appendChild(document.createTextNode(tabsName[i]));//放置頁籤tabsDiv.appendChild(div);//新增該頁籤的點擊事件div.addEventListener('click',function(event){//針對每個頁簽for(var j=1;j<tabsDiv.children.length+1;j++){//隱藏頁籤標題displayArea.children[0].children[j-1].style.borderBottom='unset';//隱藏頁籤與礦線displayArea.children[j].style.display='none';}//for end";#如果有設置高度if(isset($conf["height"])){#串接高度的設定$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."//設定tab內容區塊的高度displayArea.children[this.dataset.index].children[0].style.height=".$conf["height"]."-parseInt(getComputedStyle(displayArea.children[0]).height)+'px';";}#if end$conf["javaScript::toScript"]["script"]=$conf["javaScript::toScript"]["script"]."//顯示目標頁籤內容displayArea.children[this.dataset.index].style.display='inline-block';//提示當前選擇的頁籤displayArea.children[0].children[this.dataset.index-1].style.borderBottom='solid blue';});}//for end//放置標籤選單displayArea.prepend(tabsDiv);//預設顯示第一個頁簽displayArea.children[0].children[0].click();";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the#備註:#無.$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立 script 語法失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#function tab end/*#函式說明:#區塊輪播的效果,輪播內容支援影片播放結束後再換下一張.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["content"],語法.#必填參數:#$conf["place"],字串,輪播區塊要在哪個元素裡面呈現,其區塊特徵為何?(請參閱javascript的querySelector函式).$conf["place"]="";#$conf["slideHtml"],字串陣列,每個投影片的html語法,其生成結構必須為 html > body > div > anyTag(content to show).$conf["slideHtml"]=array("");#可省略參數:#$conf["sec"],字串,過幾秒就要置換成下一張投影片,預設為"3",代表每3秒就換一張投影片.#$conf["sec"]="3";#參考資料:#無.#備註:#無.*/public static function slideDivPlus(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif($conf===null){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end#檢查參數#函式說明:#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$reuslt["error"],執行不正常結束的錯訊息陣列.#$result["function"],當前執行的函式名稱.#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.#$result["argu"],字串陣列,目前輸入的參數名稱陣列.#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.#$result["notNeedVar"],字串陣列,多餘的參數名稱.#必填參數:#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。$conf["variableCheck::checkArguments"]["varInput"]=&$conf;#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("place","slideHtml");#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";#可以省略的參數:#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("sec");#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("sec");#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("3");#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("tabsDisplayValue","tabsContent");#參考資料來源:#array_keys=>http://php.net/manual/en/function.array-keys.php$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);unset($conf["variableCheck::checkArguments"]);#如果檢查參數失敗if($checkArguments["status"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#如果檢查參數不通過if($checkArguments["passed"]==="false"){#設置執行不正常$result["status"]="false";#設置執行錯誤$result["error"]=$checkArguments;#回傳結果return $result;}#if end#初始化要回傳的語法$result["content"]="";#函式說明:#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).#回傳結果:#$result["status"],執行是否正常,"true"為正常,"false"為不正常.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數名稱#$result["content"],要執行的javaScript語法#必填參數:#$conf["script"],字串,要執行的javaScript語法.$conf["javaScript::toScript"]["script"]="//設置要使用的投影片window.qbpwcf.slide.eles=".json_encode($conf["slideHtml"]).";//設置放置投影片的區塊特徵window.qbpwcf.slide.displayDivByQuerySelector='".$conf["place"]."';//初始化投影片的滯留時間,預設為3秒,時間到就換下一個投影片.window.qbpwcf.slide.showTime=".$conf["sec"].";//呈現投影片window.qbpwcf.slide.func();";#可省略參數:#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.#$conf["onReady"]="true";#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.#$conf["globalJs"]=array();#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.#$conf["jsFunciton"]=array();#參考資料:#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the#備註:#無.$toScript=javaScript::toScript($conf["javaScript::toScript"]);unset($conf["javaScript::toScript"]);#如果建立 script 語法失敗if($toScript["status"]==="false"){#設置執行失敗$result["status"]="false";#設置錯誤訊息$result["error"]=$toScript;#回傳結果return $result;}#if end#儲存內容$result["content"]=$result["content"].$toScript["content"];#設置執行正常$result["status"]="true";#回傳結果return $result;}#functino slideDivPlus end}#class javaScript end/*宣告變數 - start宣告變數請用var,若宣告在函式外面,則會變成全域變數.若不用var來宣告變數,則會被時為全域變數.函式多用會導致被最後一此呼叫的變數所覆蓋.var variable;參考資料:https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Statements/var宣告變數 - end//直接將選擇好的圖片檔案直接用來使用 - startinput=document.createElement('input');input.type='file';input.id='file';input.accept="image/*";input.style.display='none';input.addEventListener('change',function(event){event.preventDefault();event.stopPropagation();//置換成選取的照片document.getElementById('img').src=URL.createObjectURL(event.target.files[0]);//get selected file contentreader=new FileReader();reader.readAsBinaryString(event.target.files[0]);reader.onload=function(event){//base64 encodenewVal=btoa(event.target.result);//obj to savenewValObj={where:{id:'id', //識別要更新到哪一筆資料},col:'logo', //要儲存到資料表欄位val:newVal, //圖片的base64 encode}//encode post valueparams=btoa(encodeURIComponent(JSON.stringify(newValObj)));//如果服務端有回傳完成的狀態xmlhttp=new XMLHttpRequest();xmlhttp.temp={}; //要依照ajax的回應來編輯的內容請設置在此,透過window變數來修改是無效的.//xmlhttp.responseType='json';//xmlhttp.timeout=60000;xmlhttp.open('POST','update',false);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){}//function endxmlhttp.send('params='+params); //如果是post則要將參數加在這邊 'key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';};});input.click(); //觸發事件// 直接將選擇好的圖片檔案直接用來使用 - end//get new valuereader=new FileReader();reader.readAsBinaryString(event.target.files[0]);取得id為'bottom'的元素的上一層元素,將其儲存到變數bottomDiv裡面。var bottomDiv=document.getElementById('bottom').parentElement;取得id為'target'的元素可見高度document.getElementById('target').clientHeight;取得id為'bottom'的元素高度(含滾軸)document.getElementById('bottom').scrollHeight;#視窗的高度(含滾軸)document.scrollingElement.scrollHeight#視窗的高度拉到頂document.scrollingElement.scrollTop=0;#取得id為"ID"的元素位置與寬高var element = document.getElementById('ID');var domRect = element.getBoundingClientRect();output example => DOMRect { x: 404, y: 20, width: 155, height: 45, top: 20, right: 559, bottom: 65, left: 404 }#當視窗大小改變,要觸發myFunction,只會跑一次window.addEventListener("resize", myFunction);#當視窗大小改變,要觸發functionwindow.addEventListener("resize" function(){...});#當滾軸移動時觸發的事件window.addEventListener('scroll', function(e){//get last scroll y, 0 means top.var last_known_scroll_position = window.scrollY;});#建立物件函數,並透過addEventListener指定執行var someEvent=function(){...};window.addEventListener("resize",someEvent);//在 load event 之前的狀態與事件綁定//https://developer.mozilla.org/zh-TW/docs/Web/API/Document/readyStatedocument.onreadystatechange = function () {// alternative to DOMContentLoaded event//文件已經完成讀取和解析,但是其他的子資源,如「圖片樣式層次表」,仍然在讀取。這個狀態表示 DOMContentLoaded 事件已經被觸發。//可以開始使用 DOM 元素。if (document.readyState == "interactive"){initApplication();}// alternative to load event//文件及子資源都完成讀取。這個狀態表示 load 事件即將被觸發。else if (document.readyState == "complete"){initApplication();}}//所有內容跑完之後再執行的事件window.addEventListener('load',function(){...});//取消事件的預設效果document.getElementById("myCheckbox").addEventListener("click", function(event){event.preventDefault()});//將下拉式選單綁定'mousedown'事件,並取消預設的效果document.getElementById("myInputSelect").addEventListener("mousedown",function(event){//取消預設按下滑鼠的效果event.preventDefault();});//取消事件的預設效果與傳播document.getElementById("myCheckbox").addEventListener("click", function(event){//取消事件的預設效果event.preventDefault();//取消事件的傳播event.stopPropagation();});//參考資料//https://developer.mozilla.org/zh-TW/docs/Web/API/Event/stopPropagation//將事件解除綁定var x = document.getElementById("myDIV");if (x.removeEventListener) { // For all major browsers, except IE 8 and earlierx.removeEventListener("mousemove", myFunction);} else if (x.detachEvent) { // For IE 8 and earlier versionsx.detachEvent("onmousemove", myFunction);}#使用Date物件var myDate = new Date();#取得unixtimemyDate.getTime();#不宣告Dare物件也可取得unixtimeDate.parse(Date());#參考資料:#https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse#取得網頁body原始碼document.body.innerHTML;#取得網頁head原始碼document.head.innerHTML;#取得id為'bottom'的元素css stylevar bottomDiv=document.getElementById('bottom')window.getComputedStyle(bottomDiv,null);#取得id為'bottom'的元素css的height數值.var bottomDiv=document.getElementById('bottom');var bottomDivStyle=window.getComputedStyle(bottomDiv,null);var bottomDivH=bottomDivStyle['height'];#設置id為'bottom'的元素css的height數值為100pxvar bottomDiv=document.getElementById('bottom');bottomDiv.style.height='100px';#取得iframe內id為"run"的元素.var if1= document.getElementById('run');if1.contentDocument.getElementById('run');#設置過了3秒中後要做的事情.setTimeout(function(){do something...},3000);#新增網頁元素var node = document.createElement('li'); // Create a <li> nodevar textnode = document.createTextNode('Water'); // Create a text nodenode.appendChild(textnode); // Append the text to <li>document.getElementById("myList").appendChild(node); // Append <li> to <ul> with id="myList"#取得第一個子元素element=document.getElementById('target');element.firstChild;#取得下拉式選單的內容var inputSelect=下拉式選單元素;inputSelect.options.length; //取得選項數目inputSelect.options[0].value; //第1個選項傳送的數值inputSelect.options[0].innerHTML; //第1個選項的顯示內容#設置元素的類別var a=目標元素;a.className='className1 className2 ...'#取得所有含有 'className' 類別的元素var allOptions=document.getElementsByClassName('className');#取得id為targetDiv的div標籤的data-val屬性數值document.getElementById("targetDiv").attributes['data-val'].value;#移除id為targetDiv的div元素document.getElementById("targetDiv").remove();#移除id為targetDiv的div標籤的data-val屬性document.getElementById("targetDiv").removeAttribute('data-val');#若存在 scrollingListMiddleEvent 物件,則呼叫之.if(window.scrollingListMiddleEvent!==undefined){//debug//console.log('scrollingListMiddleEvent()');//方法1window.scrollingListMiddleEvent();//方法2,call()裡面可以覆寫物件.//參考資料:https://www.w3schools.com/js/js_function_call.aspwindow.scrollingListMiddleEvent.call();}#下拉式選單於Browser上選擇新的數值之後,所要取得新的數值與所選擇的選項應以<select></select>的value來判斷,而非透過<option></option>是否有selected屬性來判斷。var select=document.getElementById('selectID');var selectVal=document.getElementById('selectID').value;for(var i=0;i<select.options.length;i++){var opval=select.options[i].attributes['value'].value;if(opval===selectVal){var opName=select.options[i].innerHTML;}}#下拉式選單選擇了哪個options;var select=document.getElementById('selectID');var optionIndex=select.options.selectedIndex; //選擇的選項是第幾個var selectedOptions=select.options[select.options..selectedIndex]; 選擇的選項元素.#若用jquery取得元素,但想要透過原生js去存取,則其第一個元素就是接口.var nativeEleObject=$('#eleId')[0];#元素用"onClick"會停止event bubbling,點擊內部元素不會傳導到外部元素.<tag onClick="do something">#對元素進行變更,然後強迫瀏覽器刷新#change somethingvar btn=document.getElementById('top_up_submit');btn.setAttribute('data-lock',0);btn.removeAttribute('disabled');btn.innerHTML='Applying';#強迫刷新(不見得有效)var temp=document.createTextNode('');btn.appendChild(temp);var os=btn.style.display;btn.style.display='none';btn.style.display=os;btn.removeChild(temp);#如果要讓使用者輸入的數值或選擇的選項能夠反應到dom上則必須透過屬性設置的方式才能取得.#亦即透過 setAttribute 方法來設置這些內容element.setAttribute('attr','value');#取得所使用的html headerdocument.head.innerHTML;#取得所使用的hmtl bodydocument.body.innerHTML;#取得html所有dom物件document.all#this的應用window.qbpwcf.lib.init=function(){//等同印出 window,以及this指的是等號左邊的最上層變數.console.log(this);}#判斷不是數字var oriVal=parseInt($(this).val());//如果不是數字if(oriVal.toString()==='NaN'){//do something}//複製元素var copiedEle=element.cloneNode(true);//參考資料//https://developer.mozilla.org/zh-TW/docs/Web/API/Node/cloneNode//複製物件var obj = { a: 1 };var copy = Object.assign({}, obj);console.log(copy); // { a: 1 }//參考資料//https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Object/assign//深層複製物件var a = { b: {c:4} , d: { e: {f:1}} }var g = Object.assign({},a) // 淺層var h = JSON.parse(JSON.stringify(a)); // 深層//參考資料https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Object/assign//json to string//參考資料://https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringifyJSON.stringify(json);//jons string to jsonJSON.parse(jsonString);#設置周期執行的涵式var myVar = setInterval(function(){do something...}, 3000);#停止周期執行的程式clearInterval(myVar);#加解密中文var str='中文';var encodeStr=btoa(encodeURIComponent(str));var decodeStr=decodeURIComponent(atob(encodeStr));console.log(encodeStr);console.log(decodeStr);#呼叫由儲存在變數裡面的函數,可以藉此產生callback funcvar getPart=function(){console.log('test');}getPart.call(this);#設置 XMLHttpRequest 的回應為何種類型xmlhttp=new XMLHttpRequest();XMLHttpRequest.responseType='blob'; //設置為2元碼XMLHttpRequest.responseType='arraybuffer'; //針對2元碼內容,存成陣列,適合各別byte處理的需要.XMLHttpRequest.responseType='json'; //設置為jsonXMLHttpRequest.responseType='text'; //設為文字,此為defaultXMLHttpRequest.responseType='document'; //html, do not set to document when send a not async requesthttps://developer.mozilla.org/zh-TW/docs/Web/API/XMLHttpRequest/responseTypehttps://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#取得 XMLHttpRequest 回應的內容(可以非dom)xmlhttp=new XMLHttpRequest();xmlhttp.responseType='blob';//false 代表要同步,亦即會等待ajax完成後再執行.xmlhttp.open('GET','fileAccessT.php',false);xmlhttp.response;//如果服務端有回傳完成的狀態xmlhttp=new XMLHttpRequest();xmlhttp.temp={}; //要依照ajax的回應來編輯的內容請設置在此,透過window變數來修改是無效的.xmlhttp.responseType='json';xmlhttp.timeout=60000;xmlhttp.open('GET','fileAccessT.php',true);xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState==4 && xmlhttp.status==200){//將回應進行處理xmlhttp.response;//取得回應的內容res=xmlhttp.response;//取得回應的html並取代當前的內容,當xmlhttp.responseType='document'時 - start;//開新文件,要寫的內容類型為 'text/html' 繼承前頁面的資訊document.open('text/html',true);//清空文件,寫入取得的完整回應document.write(res.all[0].outerHTML);//結束輸出document.close();//取得回應的html並取代當前的內容,當xmlhttp.responseType='document'時 - end;}//if end}//function end//參數跟數值內容要用encodeURIComponent才不會有編碼的錯誤產生xmlhttp.send(); //如果是post則要將參數加在這邊 'encodeURIComponent(key1)=encodeURIComponent(val1)&encodeURIComponent(key2)=encodeURIComponent(val2)';//如果要在迴圈裏面執行異步的ajax,由於js是傳參考的語言,因此建議將每個ajax個別儲存在陣列裏面。 - start//初始化儲存xmlhttp的陣列xmlhttp=[];//針對每列for(i=0;i<rowCount;i++){//取得列tr=tbody.children[i];//取得燈號lightSta=tr.children[1].children[0];//取得gw idgwId=tr.children[0].innerText;url='area/device/getDeviceInfoInJSON/'+gwId;xmlhttp[i]=new XMLHttpRequest();xmlhttp[i].temp={}; //用於儲存額外的資訊給ajax function - startxmlhttp[i].temp.gwId=gwId;xmlhttp[i].temp.lightSta=lightSta; //用於儲存額外的資訊給ajax function - endxmlhttp[i].open('POST',url,true);xmlhttp[i].setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');xmlhttp[i].setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp[i].onreadystatechange=function(e){//debugif(window.debug){console.log('e - start');console.log(e);console.log(e.target); //xmlhttp[i] 自己console.log(e.target.response); //xmlhttp[i] 的回應console.log('e - end');}//get gw idgwId=e.target.temp.gwId;//response okif(e.target.readyState===4 && e.target.status===200){//do something,,,}}xmlhttp[i].send(null);}//for end//如果要在迴圈裏面執行異步的ajax,由於js是傳參考的語言,因此建議將每個ajax個別儲存在陣列裏面。 - end//所有內容跑完之後再執行的事件window.addEventListener('load',function(){//一段時間後再執行setTimeout(function(){//get divvar div=document.getElementById('test');//set div contentdiv.innerText='Loading...';xmlhttp=new XMLHttpRequest();xmlhttp.responseType='document';// do not set to document when send a not async requestxmlhttp.open('GET','javaScriptT/hang.php',true);xmlhttp.response;xmlhttp.onreadystatechange=function(){//如果狀態為4且response code為200if(xmlhttp.readyState==4 && xmlhttp.status==200){div.innerText='finish!';}//if end}//function endxmlhttp.send();//debugconsole.log(xmlhttp.response);//3 秒後再執行},3000)});//設定要求的屬性、目的、是否要異步//建議要異步,火狐以外的瀏覽器才會正常呈現 loading 效果xmlhttp.open('POST','".$conf["receivePage"]."',true);//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定 要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');#設置XMLHttpRequest等待回應的時間上限(毫秒)XMLHttpRequest.timeout=60000;//如果XMLHttpRequest等待回應逾時xmlhttp=new XMLHttpRequest();xmlhttp.addEventListener('timeout',function(){do something...})://如果XMLHttpRequest等待回應逾時xmlhttp=new XMLHttpRequest();xmlhttp.ontimeout=function(){do something...};#建立與傳送表單物件 - start//建立表單物件var formData = new FormData();//新增表單的名稱與對應的數值formData.append('username', 'Chris');//建立 XMLHttpRequest 物件xmlhttp=new XMLHttpRequest();//設置回傳的形態為 htmlxmlhttp.responseType='document';//設置 timeout 為 60 秒xmlhttp.timeout=60000;//設定 headerxmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');//設定 要求為ajax 的 headerxmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');//設置使用POST傳送到reveived pagerequest.open("POST", "received page");//傳送表單request.send(formData);參考資料https://developer.mozilla.org/en-US/docs/Web/API/FormDatahttps://developer.mozilla.org/en-US/docs/Web/API/FormData/FormDatahttps://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects#建立與傳送表單物件 - end#用\r\n'分割字串'abc\r\nABC'為陣列var testStr='abc\r\nABC';var splitedStr=testStr.split('\r\n');https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/String/split#字串轉成數字var stringInt='111';parseInt(stringInt);#透過 prototype 實做 append blob data 的 function#https://stackoverflow.com/questions/15970729/appending-blob-data//宣告 MyBlobBuilder 建構子var MyBlobBuilder = function() {this.parts = []; //建立屬性}//新增 MyBlobBuilder 的 append 方法MyBlobBuilder.prototype.append = function(part) {this.parts.push(part);this.blob = undefined; // Invalidate the blob};//新增 MyBlobBuilder 的 getBlob 方法MyBlobBuilder.prototype.getBlob = function(mimeType) {if(mimeType===''){mimeType="text/plain";}if (!this.blob) {this.blob = new Blob(this.parts, { type: mimeType });}return this.blob;};var myBlobBuilder = new MyBlobBuilder(); //實做物件 MyBlobBuildermyBlobBuilder.append("Hello world, 2"); //append 內容myBlobBuilder.append(",another data"); //append 內容var bb = myBlobBuilder.getBlob('application/zip'); //取得 append 完的內容,並設置 mimeType用FileReader讀取blob內容https://developer.mozilla.org/zh-TW/docs/Web/API/Blobhttps://developer.mozilla.org/zh-TW/docs/Web/API/FileReadervar reader = new FileReader(); //實做FileReaderreader.addEventListener("loadend", function() { //當讀取檔案結束後reader.result; //base64字串}reader.readAsDataURL(blob); //讀取blob物件要設定元素的class請用classListelement.classList=["classA classB ..."];新增元素的class,例如增加hide類別.element.classList.value=element.classList.value+' hide';新增元素的class,例如增加strong類別element.classList.add('strong');移除元素的class,例如移除strong類別element.classList.remove('strong');針對每個陣列元素做事情,不需要中斷.var testArray=[a,b,c,d,e];testArrayforEach.forEach(function(value,key){console.log('key:'+key+' val:'+value);});//參考資料://https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach針對每個陣列元素做事情,需要中斷.var testArray=['a','b','c','d','e'];testArray.find(function(key,value) // 回傳符合條件的數值內容{console.log('key:'+key+' val:'+value);if(key==='c'){return true;}});//參考資料://https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/find對於物件也適用,需要中斷.const obj = { a: 1, b: 2, c: 3 };for (const prop in obj) {console.log(`obj.${prop} = ${obj[prop]}`);}// Logs:// "obj.a = 1"// "obj.b = 2"// "obj.c = 3"//參考資料:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in#陣列操作,於尾端添加元素queue=[];queue.push('ele2add2tail');#陣列操作,於首端添加元素queue.unshift('ele2add2head');#陣列操作,移除尾端元素queue.pop('ele2delFromTail');//參考資料://https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/pop/*//針對特定元素做操作var myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];var removed = myFish.splice(2, 0, 'drum');// myFish 為 ["angel", "clown", "drum", "mandarin", "sturgeon"]// removed 為 [], 沒有元素被刪除var myFish = ['angel', 'clown', 'drum', 'mandarin', 'sturgeon'];var removed = myFish.splice(3, 1);// removed 為 ["mandarin"]// myFish 為 ["angel", "clown", "drum", "sturgeon"]var myFish = ['angel', 'clown', 'drum', 'sturgeon'];var removed = myFish.splice(2, 1, 'trumpet');// myFish 為 ["angel", "clown", "trumpet", "sturgeon"]// removed 為 ["drum"]*//*針對物件中的每個keyObject.keys(data.content).forEach(function(key){console.log('key');});//參考資料:https://stackoverflow.com/questions/921789/how-to-loop-through-a-plain-javascript-object-with-the-objects-as-members//參考資料://https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array/splice*//*物件長度temp0={0:'a',1:'b',2:'c',};Object.keys(temp0).length*//*存取複雜的物件屬性var object={"@attribute":"complex",};object["@attribute"];*//*萬用的取得物件屬性方法bit16toNoZeroHead=function(p){//範例物件table={a:A,b:B,c:C};//取得物件有多少keykeyCount=Object.keys(table).length;//針對物件每個keyfor(i=0;i<keyCount;i++){//如果物件的key等於參數pif(p===Object.keys(table)[i]){//取得該key指到的valuereturn Object.values(table)[i];}}}*//*desc:取得元素屬性的數值內容param:element,元素name,屬性名稱return:回傳屬性的數值function getAttrData(element,name){var attrs=element.attributes.length;for(i=0;i<attrs;i++){var attrName=element.attributes[i].name;var attrValue=element.attributes[i].value;if(attrName===name){return attrValue;}}}*//*desc:設置屬性的數值內容param:element,元素name,屬性名稱value,屬性的數值return:回傳屬性的名稱與數值function setAttrData(element,name,value){var attrs=element.attributes.length;for(i=0;i<attrs;i++){var attrName=element.attributes[i].name;var attrValue=element.attributes[i].value;if(attrName===name){element.attributes[i].value=value;return element.attributes[i];}}}*//*#取得屬性的列表與資訊#html:<span title="code" data-a="A" data-b="B">Fusion</span>#js console:spanStr=document.querySelector('span[title]');spanStr.dataset => DOMStringMap { a → "A", b → "B" }spanStr.dataset.a => "A"spanStr.dataset.b => "B"*//*#取得符合條件的第一個項目,選項的採用css的格式document.querySelector('span[title="code"]');*//*#取得每個符合的項目,選擇的方式採用css的格式#document.querySelectorAll('div > div._drags > span.img');*//*#用 inclues 來搜尋字串裡面有無對應的關鍵字.a="abc";a.includes('d'); //will be falsea.includes('a'); //will be true*//*解析string為dom字串parser = new DOMParser();doc = parser.parseFromString(stringContainingHTMLSource, "text/html");// returns a HTMLDocument, which also is a Document.https://developer.mozilla.org/en-US/docs/Web/API/DOMParser*//*#取得元素ID為eleID的下一個元素#document.getElementById('eleID').nextElementSibling;#取得元素ID為eleID的上一個元素#document.getElementById('eleID').preElementSibling;*//*//no use?stateObj={};//取得新 titletitle=res.title;//取得新 urlnewUrl=res.URL;//更新網頁標題與網址//參考資料:https://developer.mozilla.org/en-US/docs/Web/API/History_APIhistory.pushState(stateObj, title, newUrl);*//*#webSocket://設定webSocket的連線目標var conn = new WebSocket('wss://dns/wss/chatDemo');//狀態1代表正常可通訊conn.readyState=1;//建立與當連線成功後conn.onopen = function(e){}//當有收到訊息時conn.onmessage = function(e){//將訊息顯現在consoleconsole.log(e.data);//傳送訊息conn.send('mag');}//當連線斷開後, 每秒重新嘗試一次.conn.onclose = function(e){//指定1秒刷新一次setTimeout('window.webSock.connWebSock.call(this)',1000);}//所有內容跑完之後再執行的事件window.addEventListener('load',function(){//傳送訊息conn.send('mag');});eval(),將變數的數值印出.i=0;window.eval(i)='aa';window.0 //會印出 aa//定義物件的屬性 - start//初始化物件var object1 = {};Object.defineProperty(object1, 'property1', {value: 42,writable: false});object1.property1 = 77;// throws an error in strict modeconsole.log(object1.property1);// expected output: 42//參考資料//https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty//定義物件的屬性 - end//將圖片上下左右置中#over {position:relative; text-align:center;width:100%; height:100%; background:#CCC;}#over img{position: absolute;margin: auto;top: 0;left: 0;right: 0;bottom: 0;}//參考資料https://stackoverflow.com/questions/4888223/align-image-in-center-and-middle-within-div//override addEventListener(function(){Element.prototype._addEventListener = Element.prototype.addEventListener;Element.prototype.addEventListener = function(a,b,c){this._addEventListener(a,b,c);if(!this.eventListenerList) this.eventListenerList = {};if(!this.eventListenerList[a]) this.eventListenerList[a] = [];this.eventListenerList[a].push(b);};})();//access binded eventsvar clicks = someElement.eventListenerList.click;if(clicks) clicks.forEach(function(f) {alert("I listen to this function: "+f.toString());});//參考資料 https://stackoverflow.com/questions/446892/how-to-find-event-listeners-on-a-dom-node-when-debugging-or-from-the-javascript//get user agentnavigator.userAgent;//參考資料 https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/userAgent//判斷 user agent 是不是 windowsnavigator.userAgent.includes('Windows');//參考資料 https://www.w3schools.com/jsref/jsref_includes.asp//取得目前瀏覽的 hostnamewindow.location.hostname//參考資料 https://www.w3schools.com/jsref/prop_loc_hostname.asp//DOMParser,解析html字串為domparser = new DOMParser();doc = parser.parseFromString(stringContainingHTMLSource, "text/html");// returns a HTMLDocument, which also is a Document.//參考資料 https://developer.mozilla.org/zh-TW/docs/Web/API/DOMParser//寫入減貼簿,需要時使用者的操作。ele.addEventListener('click',function(event){navigator.clipboard.writeText('text write to clipboard');});//重複字串內容'a'.repeat(3)等於'aaa'//類似php的substr//-1代表找不到關鍵字的位置str='123456';str.indexOf('abc'); // -1str.indexOf('123'); // 0//參考資料 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf//reducevar tmpArray=[1,2,3,4,5,6,7,8,9];tmpArray.reduce(function(preValue,currentValue,currentIndex){return preValue+currentValue;});//參考資料 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce//joinvar tmpArray=['Fire', 'Air', 'Water'];tmpArray.join(",");//參考資料 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join//產生uuidcrypto.randomUUID();//參考資料 https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID*/?>