Subversion Repositories php-qbpwcf

Rev

Rev 200 | Rev 226 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 200 Rev 207
Line 9990... Line 9990...
9990
						//debug
9990
						//debug
9991
						console.log('beafore callback');
9991
						console.log('beafore callback');
9992
					
9992
					
9993
						//callback
9993
						//callback
9994
						params.callback.call(this,params.serviceBlock);
9994
						params.callback.call(this,params.serviceBlock);
9995
											
9995
						
9996
						}//if end
9996
						}//if end
9997
					
9997
					
9998
					}//if end
9998
					}//if end
9999
			
9999
			
10000
				},100);
10000
				},100);
Line 10007... Line 10007...
10007
		"
10007
		"
10008
		/*
10008
		/*
10009
		說明:
10009
		說明:
10010
		設置網頁要套用的字形.
10010
		設置網頁要套用的字形.
10011
		參數:
10011
		參數:
10012
		無.
10012
		window.qbpwcf.fonts.bufferArray,預設的字形檔案binary.
-
 
10013
		await window.qbpwcf.fonts.load(),將指定的字形套用在body.
10013
		參考資料:
10014
		參考資料:
10014
		https://developer.mozilla.org/en-US/docs/Web/API/FontFace
10015
		https://developer.mozilla.org/en-US/docs/Web/API/FontFace
10015
		https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace
10016
		https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace
10016
		https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face => 直接用 CSS 下載字形
10017
		https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face => 直接用 CSS 下載字形
10017
		https://fontlibrary.org/ => 免費字體下載
10018
		https://fontlibrary.org/ => 免費字體下載
10018
		https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet => CSS 樣式 in Javascript
10019
		https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet => CSS 樣式 in Javascript
10019
		https://developer.mozilla.org/en-US/docs/Web/API/Document/styleSheets => 取得 CSS 樣式集合
10020
		https://developer.mozilla.org/en-US/docs/Web/API/Document/styleSheets => 取得 CSS 樣式集合
10020
		https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet
10021
		https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet
10021
		https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet
10022
		https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet
10022
		https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule => 新增 css 樣式
10023
		https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule => 新增 css 樣式
-
 
10024
		https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer => ArrayBuffer
-
 
10025
		https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64 => bytes array from base64 encode string
-
 
10026
		#備註:
-
 
10027
		#server必須要有該字形.
10023
		*/
10028
		*/
10024
		window.qbpwcf.fonts={};
10029
		window.qbpwcf.fonts={};
10025
		
10030
		
10026
		//default font path
10031
		//default font binary
10027
		window.qbpwcf.fonts.path='liberation-mono/LiberationMono-Regular.ttf';
10032
		window.qbpwcf.fonts.bufferArray=new ArrayBuffer();
10028
		
10033
		
10029
		//load font function
10034
		//load font function
10030
		window.qbpwcf.fonts.load=async function()
10035
		window.qbpwcf.fonts.load=async function(){
10031
		{
10036
		
10032
			//建立font物件
10037
			//建立font物件
10033
			var font = new FontFace('qbpwcfFont', 'url(/qbpwcf/fonts/'+this.path+')');
10038
			var font = new FontFace('qbpwcfFont', window.qbpwcf.fonts.bufferArray);
10034
			
10039
			
10035
			//告訴瀏覽器載入字形,並等待其執行完再往下執行
10040
			//告訴瀏覽器載入字形,並等待其執行完再往下執行
10036
			//因為 FontFace 類別的 load 方法回傳為 Promise ,因此要等待其回傳結果所以要用 await 關鍵字.
10041
			//因為 FontFace 類別的 load 方法回傳為 Promise ,因此要等待其回傳結果所以要用 await 關鍵字.
10037
			await font.load();
10042
			await font.load();
10038
		
10043
		
Line 10045... Line 10050...
10045
			//避免重複新增class,先移除之
10050
			//避免重複新增class,先移除之
10046
			document.body.classList.remove('qbpwcfFont');
10051
			document.body.classList.remove('qbpwcfFont');
10047
			
10052
			
10048
			//套用字形
10053
			//套用字形
10049
			document.body.classList.add('qbpwcfFont');
10054
			document.body.classList.add('qbpwcfFont');
10050
		}
10055
		
-
 
10056
			}//function end
10051
		
10057
		
10052
		//list aviable fonts
10058
		//list aviable fonts
10053
		window.qbpwcf.fonts.list=function()
10059
		window.qbpwcf.fonts.list=function(){
10054
		{
10060
			
10055
			//開發中
10061
			//開發中
10056
			console.log('list fonts');
10062
			console.log('list fonts');
10057
		}
10063
	
-
 
10064
			}//function end
10058
 
10065
 
10059
		";
10066
		";
10060
		
10067
		
10061
		#js function
10068
		#js function
10062
		$conf["javaScript::toScript"]["jsFunciton"][]=
10069
		$conf["javaScript::toScript"]["jsFunciton"][]=
Line 16666... Line 16673...
16666
		#回傳結果
16673
		#回傳結果
16667
		return $result;
16674
		return $result;
16668
			
16675
			
16669
		}#functino slideDivPlus end
16676
		}#functino slideDivPlus end
16670
 
16677
 
-
 
16678
	/*
-
 
16679
	#函式說明:
-
 
16680
	#將指定的字形套用在body上.
-
 
16681
	#回傳結果:
-
 
16682
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
16683
	#$result["error"],錯誤訊息.
-
 
16684
	#$result["function"],當前執行的函數名稱.
-
 
16685
	#$result["content"],語法.
-
 
16686
	#必填參數:
-
 
16687
	#無.
-
 
16688
	#可省略參數:
-
 
16689
	#$conf["fontPath"],字串,字形檔案的位置,預設為"liberation-mono/LiberationMono-Regular.ttf".
-
 
16690
	$conf["fontPath"]="";
-
 
16691
	#參考資料:
-
 
16692
	#無.
-
 
16693
	#備註:
-
 
16694
	#無.
-
 
16695
	*/
-
 
16696
	public static function setBodyFont(&$conf){
-
 
16697
	
-
 
16698
		#初始化要回傳的結果
-
 
16699
		$result=array();
-
 
16700
 
-
 
16701
		#取得當前執行的函數名稱
-
 
16702
		$result["function"]=__FUNCTION__;
-
 
16703
 
-
 
16704
		#取得參數
-
 
16705
		$result["argu"]=$conf;
-
 
16706
 
-
 
16707
		#如果 $conf 不為陣列
-
 
16708
		if(gettype($conf)!="array"){
-
 
16709
 
-
 
16710
			#設置執行失敗
-
 
16711
			$result["status"]="false";
-
 
16712
 
-
 
16713
			#設置執行錯誤訊息
-
 
16714
			$result["error"][]="\$conf變數須為陣列形態";
-
 
16715
 
-
 
16716
			#如果傳入的參數為 null
-
 
16717
			if(is_null($conf)){
-
 
16718
 
-
 
16719
				#設置執行錯誤訊息
-
 
16720
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
16721
 
-
 
16722
				}#if end
-
 
16723
 
-
 
16724
			#回傳結果
-
 
16725
			return $result;
-
 
16726
 
-
 
16727
			}#if end
-
 
16728
	
-
 
16729
		#函式說明:
-
 
16730
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
-
 
16731
		#回傳結果:
-
 
16732
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
16733
		#$result["error"],執行不正常結束的錯訊息陣列.
-
 
16734
		#$result["simpleError"],簡單表示的錯誤訊息.
-
 
16735
		#$result["function"],當前執行的函式名稱.
-
 
16736
		#$result["argu"],設置給予的參數.
-
 
16737
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
16738
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
16739
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
16740
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
16741
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
16742
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
16743
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
16744
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
16745
		#必填參數:
-
 
16746
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
16747
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
16748
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
16749
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
16750
		#可省略參數:
-
 
16751
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
16752
		#$conf["mustBeFilledVariableName"]=array();
-
 
16753
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
-
 
16754
		#$conf["mustBeFilledVariableType"]=array();
-
 
16755
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
16756
		#$conf["canBeEmptyString"]="false";
-
 
16757
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
-
 
16758
		#$conf["canNotBeEmpty"]=array();
-
 
16759
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
-
 
16760
		#$conf["canBeEmpty"]=array();
-
 
16761
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
-
 
16762
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("fontPath","outsideFontUrl");
-
 
16763
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
16764
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fontPath","outsideFontUrl");
-
 
16765
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
16766
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
-
 
16767
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
16768
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("liberation-mono-fonts/LiberationMono-Regular.ttf",null);
-
 
16769
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
-
 
16770
		#$conf["disallowAllSkipableVarIsEmpty"]="";
-
 
16771
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
-
 
16772
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
-
 
16773
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
-
 
16774
		#$conf["disallowAllSkipableVarNotExist"]="";
-
 
16775
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
16776
		#$conf["arrayCountEqualCheck"][]=array();
-
 
16777
		#參考資料:
-
 
16778
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
16779
		#備註:
-
 
16780
		#無.
-
 
16781
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
16782
		unset($conf["variableCheck::checkArguments"]);
-
 
16783
	
-
 
16784
		#如果執行失敗
-
 
16785
		if($checkArguments["status"]==="false"){
-
 
16786
		
-
 
16787
			#設置執行異常
-
 
16788
			$result["status"]="false";
-
 
16789
		
-
 
16790
			#設置執行錯誤訊息
-
 
16791
			$result["error"]=$checkArguments;
-
 
16792
		
-
 
16793
			#回傳結果
-
 
16794
			return $result;
-
 
16795
		
-
 
16796
			}#if end
-
 
16797
			
-
 
16798
		#如果參數檢查不通過
-
 
16799
		if($checkArguments["passed"]==="false"){
-
 
16800
		
-
 
16801
			#設置執行異常
-
 
16802
			$result["status"]="false";
-
 
16803
		
-
 
16804
			#設置執行錯誤訊息
-
 
16805
			$result["error"]=$checkArguments;
-
 
16806
		
-
 
16807
			#回傳結果
-
 
16808
			return $result;
-
 
16809
		
-
 
16810
			}#if end
-
 
16811
		
-
 
16812
		#如果有設置 outsideFontUrl
-
 
16813
		if(isset($conf["outsideFontUrl"])){
-
 
16814
		
-
 
16815
			#設置字形是從 url 取得
-
 
16816
			$isWeb="true";
-
 
16817
		
-
 
16818
			#設置字形url
-
 
16819
			$fontsPath=$conf["outsideFontUrl"];
-
 
16820
		
-
 
16821
			}#if end
-
 
16822
			
-
 
16823
		#反之
-
 
16824
		else{
-
 
16825
		
-
 
16826
			#設置字形是從本地取得
-
 
16827
			$isWeb="false";
-
 
16828
			
-
 
16829
			#取得存在字形的根目錄
-
 
16830
			$fontsPath=pathinfo(__FILE__)["dirname"]."/fonts/".$conf["fontPath"];
-
 
16831
		
-
 
16832
			}#else end
-
 
16833
 
-
 
16834
		#取得font檔案內容
-
 
16835
		#函式說明:
-
 
16836
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
16837
		#回傳的變數說明:
-
 
16838
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
16839
		#$result["error"],錯誤訊息提示.
-
 
16840
		#$result["warning"],警告訊息.
-
 
16841
		#$result["function"],當前執行的函數名稱.
-
 
16842
		#$result["fileContent"],爲檔案的內容陣列.
-
 
16843
		#$result["lineCount"],爲檔案內容總共的行數.
-
 
16844
		#$result["fullContent"],為檔案的完整內容.
-
 
16845
		#$result["base64dataOnly"],檔案的base64data.
-
 
16846
		#$result["base64data"],為在網頁上給予src參數的數值.
-
 
16847
		#$result["mimeType"],為檔案的mime type.
-
 
16848
		#必填參數:
-
 
16849
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
16850
		$conf["fileAccess::getFileContent"]["filePositionAndName"]=$fontsPath;
-
 
16851
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
16852
		$conf["fileAccess::getFileContent"]["fileArgu"]=__FILE__;
-
 
16853
		#可省略參數:
-
 
16854
		#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
16855
		$conf["fileAccess::getFileContent"]["web"]=$isWeb;
-
 
16856
		#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
16857
		#$conf["createIfnotExist"]="false";
-
 
16858
		#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
16859
		#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
16860
		#參考資料:
-
 
16861
		#file(),取得檔案內容的行數.
-
 
16862
		#file=>http:#php.net/manual/en/function.file.php
-
 
16863
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
16864
		#filesize=>http://php.net/manual/en/function.filesize.php
-
 
16865
		#參考資料:
-
 
16866
		#無.
-
 
16867
		#備註:
-
 
16868
		#無.
-
 
16869
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
-
 
16870
		unset($conf["fileAccess::getFileContent"]);
-
 
16871
	
-
 
16872
		#如果執行異常
-
 
16873
		if($getFileContent["status"]==="false"){
-
 
16874
		
-
 
16875
			#設置執行異常
-
 
16876
			$result["status"]="false";
-
 
16877
		
-
 
16878
			#設置執行錯誤訊息
-
 
16879
			$result["error"]=$getFileContent;
-
 
16880
		
-
 
16881
			#回傳結果
-
 
16882
			return $result;
-
 
16883
		
-
 
16884
			}#if end
-
 
16885
		
-
 
16886
		#set custom font path
-
 
16887
		$setFontPart=
-
 
16888
		"
-
 
16889
			//store font file in base64 encode string
-
 
16890
			window.qbpwcf.fonts.base64='".$getFileContent["base64dataOnly"]."';
-
 
16891
			
-
 
16892
			//store font file in bufferArray 
-
 
16893
			window.qbpwcf.fonts.bufferArray=Uint8Array.fromBase64(window.qbpwcf.fonts.base64).buffer;
-
 
16894
		
-
 
16895
		";
-
 
16896
	
-
 
16897
		#函式說明:
-
 
16898
		#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
-
 
16899
		#回傳結果:
-
 
16900
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
-
 
16901
		#$result["error"],錯誤訊息陣列
-
 
16902
		#$result["function"],當前執行的函數名稱
-
 
16903
		#$result["content"],要執行的javaScript語法
-
 
16904
		#必填參數:
-
 
16905
		#$conf["script"],字串,要執行的javaScript語法.
-
 
16906
		$conf["javaScript::toScript"]["script"]=$setFontPart.
-
 
16907
		"
-
 
16908
			//load font function
-
 
16909
			await window.qbpwcf.fonts.load();
-
 
16910
		";
-
 
16911
		#可省略參數:
-
 
16912
		#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
-
 
16913
		#$conf["onReady"]="true";
-
 
16914
		#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
-
 
16915
		#$conf["globalJs"]=array();
-
 
16916
		#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
-
 
16917
		#$conf["jsFunciton"]=array();
-
 
16918
		#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
-
 
16919
		#$conf["noScriptTag"]="false";
-
 
16920
		#參考資料:
-
 
16921
		#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
-
 
16922
		#備註:
-
 
16923
		#無.
-
 
16924
		$toScript=javaScript::toScript($conf["javaScript::toScript"]);
-
 
16925
		unset($conf["javaScript::toScript"]);
-
 
16926
	
-
 
16927
		#儲存html(javascript)語法
-
 
16928
		$result["content"]=$toScript["content"];
-
 
16929
		
-
 
16930
		#設置執行正常
-
 
16931
		$result["status"]="true";
-
 
16932
		
-
 
16933
		#回傳結果
-
 
16934
		return $result;
-
 
16935
	
-
 
16936
		}#function setBodyFont end
-
 
16937
 
16671
	}#class javaScript end
16938
	}#class javaScript end
16672
 
16939
 
16673
/*
16940
/*
16674
 
16941
 
16675
宣告變數 - start
16942
宣告變數 - start
Line 16712... Line 16979...
16712
			{
16979
			{
16713
				id:'id', //識別要更新到哪一筆資料
16980
				id:'id', //識別要更新到哪一筆資料
16714
			},
16981
			},
16715
			col:'logo', //要儲存到資料表欄位
16982
			col:'logo', //要儲存到資料表欄位
16716
			val:newVal, //圖片的base64 encode
16983
			val:newVal, //圖片的base64 encode
16717
		}				
16984
		}
16718
 
16985
 
16719
		//encode post value
16986
		//encode post value
16720
		params=btoa(encodeURIComponent(JSON.stringify(newValObj)));
16987
		params=btoa(encodeURIComponent(JSON.stringify(newValObj)));
16721
 
16988
 
16722
		//如果服務端有回傳完成的狀態
16989
		//如果服務端有回傳完成的狀態
Line 16736... Line 17003...
16736
 
17003
 
16737
//get new value
17004
//get new value
16738
reader=new FileReader();
17005
reader=new FileReader();
16739
reader.readAsBinaryString(event.target.files[0]);
17006
reader.readAsBinaryString(event.target.files[0]);
16740
 
17007
 
16741
 
-
 
16742
取得id為'bottom'的元素的上一層元素,將其儲存到變數bottomDiv裡面。
17008
取得id為'bottom'的元素的上一層元素,將其儲存到變數bottomDiv裡面。
16743
var bottomDiv=document.getElementById('bottom').parentElement;
17009
var bottomDiv=document.getElementById('bottom').parentElement;
16744
 
17010
 
16745
取得id為'target'的元素可見高度
17011
取得id為'target'的元素可見高度
16746
document.getElementById('target').clientHeight;
17012
document.getElementById('target').clientHeight;
Line 17092... Line 17358...
17092
//參數跟數值內容要用encodeURIComponent才不會有編碼的錯誤產生
17358
//參數跟數值內容要用encodeURIComponent才不會有編碼的錯誤產生
17093
xmlhttp.send(); //如果是post則要將參數加在這邊 'encodeURIComponent(key1)=encodeURIComponent(val1)&encodeURIComponent(key2)=encodeURIComponent(val2)';
17359
xmlhttp.send(); //如果是post則要將參數加在這邊 'encodeURIComponent(key1)=encodeURIComponent(val1)&encodeURIComponent(key2)=encodeURIComponent(val2)';
17094
 
17360
 
17095
//如果要在迴圈裏面執行異步的ajax,由於js是傳參考的語言,因此建議將每個ajax個別儲存在陣列裏面。 - start 
17361
//如果要在迴圈裏面執行異步的ajax,由於js是傳參考的語言,因此建議將每個ajax個別儲存在陣列裏面。 - start 
17096
 
17362
 
17097
//初始化儲存xmlhttp的陣列			
17363
//初始化儲存xmlhttp的陣列
17098
xmlhttp=[];
17364
xmlhttp=[];
17099
 
17365
 
17100
//針對每列
17366
//針對每列
17101
for(i=0;i<rowCount;i++)
17367
for(i=0;i<rowCount;i++)
17102
{
17368
{
17103
	//取得列
17369
	//取得列
17104
	tr=tbody.children[i];
17370
	tr=tbody.children[i];
17105
 
17371
 
17106
	//取得燈號
17372
	//取得燈狀態
17107
	lightSta=tr.children[1].children[0];	
17373
	lightSta=tr.children[1].children[0];
17108
	
17374
	
17109
	//取得gw id
17375
	//取得gw id
17110
	gwId=tr.children[0].innerText;
17376
	gwId=tr.children[0].innerText;
17111
 
17377
 
17112
	url='area/device/getDeviceInfoInJSON/'+gwId;
17378
	url='area/device/getDeviceInfoInJSON/'+gwId;
Line 17117... Line 17383...
17117
	xmlhttp[i].open('POST',url,true);
17383
	xmlhttp[i].open('POST',url,true);
17118
	xmlhttp[i].setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');
17384
	xmlhttp[i].setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');
17119
	xmlhttp[i].setRequestHeader('X-Requested-With','XMLHttpRequest');
17385
	xmlhttp[i].setRequestHeader('X-Requested-With','XMLHttpRequest');
17120
	xmlhttp[i].onreadystatechange=function(e)
17386
	xmlhttp[i].onreadystatechange=function(e)
17121
	{	
17387
	{	
17122
		//debug					
17388
		//debug	
17123
		if(window.debug)
17389
		if(window.debug)
17124
		{
17390
		{
17125
			console.log('e - start');
17391
			console.log('e - start');
17126
			console.log(e);
17392
			console.log(e);
17127
			console.log(e.target); //xmlhttp[i] 自己
17393
			console.log(e.target); //xmlhttp[i] 自己
17128
			console.log(e.target.response); //xmlhttp[i] 的回應
17394
			console.log(e.target.response); //xmlhttp[i] 的回應
17129
			console.log('e - end');
17395
			console.log('e - end');
17130
		}					
17396
		}
17131
		
17397
		
17132
		//get gw id
17398
		//get gw id
17133
		gwId=e.target.temp.gwId;				
17399
		gwId=e.target.temp.gwId;
17134
 
17400
 
17135
		//response ok
17401
		//response ok
17136
		if(e.target.readyState===4 && e.target.status===200)
17402
		if(e.target.readyState===4 && e.target.status===200)
17137
		{
17403
		{
17138
			//do something,,,
17404
			//do something,,,