Files
rappaurio-sae501_502/app/node_modules/cejs/_documents/JsDoc/symbols/src/D__USB_cgi-bin_lib_JS_data_code_compatibility.origin.js.html
2023-09-25 13:27:24 +02:00

586 lines
76 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style>
.KEYW {color: #933;}
.COMM {color: #bbb; font-style: italic;}
.NUMB {color: #393;}
.STRN {color: #393;}
.REGX {color: #339;}
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
</style></head><body><pre><span class='line'> 1</span> <span class="TOKN"></span><span class="WHIT">
<span class='line'> 2</span> </span><span class="COMM">/**
<span class='line'> 3</span> * @name CeL function for compatibility
<span class='line'> 4</span> * @fileoverview
<span class='line'> 5</span> * 本檔案包含了相容性 test 專用的 functions。
<span class='line'> 6</span> * @since
<span class='line'> 7</span> * @see
<span class='line'> 8</span> * &lt;a href="http://msdn.microsoft.com/en-us/library/s4esdbwz%28v=VS.85%29.aspx" accessdate="2010/4/16 20:4">Version Information (Windows Scripting - JScript)&lt;/a>
<span class='line'> 9</span> */</span><span class="WHIT">
<span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="COMM">/*
<span class='line'> 12</span> http://www.comsharp.com/GetKnowledge/zh-CN/It_News_K875.aspx
<span class='line'> 13</span> 8進制數字表示被禁止 010 代表 10 而不是 8
<span class='line'> 14</span> 引入 JSON
<span class='line'> 15</span> Array 對象內置了一些標準函數,如 indexOf(), map(), filter(), reduce()
<span class='line'> 16</span> # Object.keys() 會列出對象中所有可以枚舉的屬性
<span class='line'> 17</span> # Object.getOwnPropertyNames() 會列出對象中所有可枚舉以及不可枚舉的屬性
<span class='line'> 18</span> # Object.getPrototypeof() 返回給定對象的原型
<span class='line'> 19</span>
<span class='line'> 20</span> http://jquerymobile.com/gbs/
<span class='line'> 21</span> */</span><span class="WHIT">
<span class='line'> 22</span>
<span class='line'> 23</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">CeL</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="NAME">CeL.setup_module</span><span class="PUNC">(</span><span class="STRN">'data.code.compatibility'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">library_namespace</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">load_arguments</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 26</span>
<span class='line'> 27</span> </span><span class="COMM">// no requiring</span><span class="WHIT">
<span class='line'> 28</span>
<span class='line'> 29</span>
<span class='line'> 30</span> </span><span class="COMM">/**
<span class='line'> 31</span> * null module constructor
<span class='line'> 32</span> * @class 相容性 test 專用的 functions
<span class='line'> 33</span> */</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="NAME">CeL.data.code.compatibility</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="COMM">// null module constructor</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span>
<span class='line'> 39</span> </span><span class="COMM">/**
<span class='line'> 40</span> * for JSDT: 有 prototype 才會將之當作 Class
<span class='line'> 41</span> */</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="NAME">CeL.data.code.compatibility</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="PUNC">.</span><span class="NAME">prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span>
<span class='line'> 46</span>
<span class='line'> 47</span>
<span class='line'> 48</span>
<span class='line'> 49</span>
<span class='line'> 50</span>
<span class='line'> 51</span> </span><span class="COMM">/* 對於舊版沒有Array.push()等函數時之判別及處置,舊版adapter
<span class='line'> 52</span> 從(typeof object.reverse=='function')可偵測object是否為Array
<span class='line'> 53</span> http://www.coolcode.cn/?p=126
<span class='line'> 54</span> */</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="COMM">//oldVadapter[generateCode.dLK]='*oldVadapter();';</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">oldVadapter</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="COMM">//var _Global=typeof window=='object'?window:this;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="COMM">// Global undefined variable</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="COMM">/*
<span class='line'> 60</span> if(typeof _Global=='undefined')window.undefined=_Global;
<span class='line'> 61</span> else _Global.undefined=_Global.undefined;
<span class='line'> 62</span> */</span><span class="WHIT">
<span class='line'> 63</span>
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Array.prototype.push</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Apush</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">Array.prototype.push</span><span class="PUNC">=</span><span class="NAME">Apush</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Array.prototype.pop</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Apop</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">Array.prototype.pop</span><span class="PUNC">=</span><span class="NAME">Apop</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Array.prototype.shift</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Ashift</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">Array.prototype.shift</span><span class="PUNC">=</span><span class="NAME">Ashift</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Array.prototype.unshift</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Aunshift</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">Array.prototype.unshift</span><span class="PUNC">=</span><span class="NAME">Aunshift</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="COMM">// apply & call: after ECMAScript 3rd Edition 不直接用undefined: for JS5</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Function.prototype.apply</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Fapply</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">Function.prototype.apply</span><span class="PUNC">=</span><span class="NAME">Fapply</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Function.prototype.call</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Fcall</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">Function.prototype.call</span><span class="PUNC">=</span><span class="NAME">Fcall</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof isNaN!='function'&&typeof NisNaN=='function')isNaN=NisNaN;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">encodeURI</span><span class="PUNC">!=</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">escape</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">encodeURI</span><span class="PUNC">=</span><span class="NAME">escape</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">decodeURI</span><span class="PUNC">!=</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">unescape</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">decodeURI</span><span class="PUNC">=</span><span class="NAME">unescape</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">!=</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">encodeURI</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">encodeURIComponent</span><span class="PUNC">=</span><span class="NAME">encodeURI</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">!=</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">decodeURI</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">decodeURIComponent</span><span class="PUNC">=</span><span class="NAME">decodeURI</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 77</span>
<span class='line'> 78</span> </span><span class="COMM">// 在 FF3 僅用 this[this.length]=o; 效率略好於 Array.push(),但 Chrome 6 相反。</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Apush</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">this.length</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">o</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.length</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="COMM">// 將 element_toPush 加入 array_pushTo 並篩選重複的(本來已經加入的並不會變更)</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="COMM">// array_reverse[value of element_toPush]=index of element_toPush</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">pushUnique</span><span class="PUNC">(</span><span class="NAME">array_pushTo</span><span class="PUNC">,</span><span class="NAME">element_toPush</span><span class="PUNC">,</span><span class="NAME">array_reverse</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">array_pushTo</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="NAME">element_toPush</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">array_pushTo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">array_reverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">array_reverse</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">array_pushTo</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="NAME">array_reverse</span><span class="PUNC">[</span><span class="NAME">array_pushTo</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span>
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">element_toPush</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">element_toPush</span><span class="PUNC">,</span><span class="NAME">element_toPush</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">,</span><span class="NAME">element_toPush.push</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span>
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">element_toPush</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">array_reverse</span><span class="PUNC">[</span><span class="NAME">element_toPush</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="COMM">//array_pushTo.push(element_toPush),array_reverse[element_toPush]=array_pushTo.length;</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="NAME">array_reverse</span><span class="PUNC">[</span><span class="NAME">array_pushTo</span><span class="PUNC">[</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">array_pushTo.length</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">element_toPush</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span>
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">array_pushTo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>100</span>
<span class='line'>101</span> </span><span class="COMM">// e.g., Array.prototype.concat does not change the existing arrays, it only returns a copy of the joined arrays.</span><span class="WHIT">
<span class='line'>102</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Aappend</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t.length</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>108</span>
<span class='line'>109</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Apop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.length</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">this.slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">this.length</span><span class="PUNC">--</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="COMM">//不能用return this[--this.length];</span><span class="WHIT">
<span class='line'>112</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>113</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Ashift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="COMM">//var t=this[0],s=this.join('\0');s=s.substr(s.indexOf('\0')+1);this.length=0;this.push(s.split('\0'));return t;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="NAME">this.value</span><span class="PUNC">=</span><span class="NAME">this.slice</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ECMAScript 不允許設定 this=</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>119</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Aunshift</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.length</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="COMM">//var t=this.join('\0');this.length=0;this.push(o);this.push(t.split('\0'));return this;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.value</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="NAME">o</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">concat</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ECMAScript 不允許設定 this=</span><span class="WHIT">
<span class='line'>123</span> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// 不能用t=this.valueOf(); .. this.push(t);</span><span class="WHIT">
<span class='line'>124</span> </span><span class="COMM">// 奇怪的是,這個版本(5.1版)尚不提供isNaN。(should be isNaN, NOT isNAN)</span><span class="WHIT">
<span class='line'>125</span> </span><span class="COMM">// 變數可以與其本身比較。如果比較結果不相等,則它會是 NaN。原因是 NaN 是唯一與其本身不相等的值。</span><span class="WHIT">
<span class='line'>126</span> </span><span class="COMM">//function NisNaN(v){var a=typeof v=='number'?v:parseInt(v);return /*typeof v=='number'&&*/a!=a;}//parseFloat(v) alert(typeof a+','+a+','+(a===a));</span><span class="WHIT">
<span class='line'>127</span> </span><span class="COMM">//oldVadapter();</span><span class="WHIT">
<span class='line'>128</span>
<span class='line'>129</span> </span><span class="COMM">/* http://www.cnblogs.com/sunwangji/archive/2007/06/26/791428.html http://www.cnblogs.com/sunwangji/archive/2006/08/21/482341.html
<span class='line'>130</span> http://msdn.microsoft.com/en-us/library/4zc42wh1(VS.85).aspx
<span class='line'>131</span> http://www.interq.or.jp/student/exeal/dss/ejs/3/1.html
<span class='line'>132</span> http://blog.mvpcn.net/fason/
<span class='line'>133</span> http://d.hatena.ne.jp/m-hiyama/20051017/1129510043
<span class='line'>134</span> http://noir.s7.xrea.com/archives/000203.html
<span class='line'>135</span>
<span class='line'>136</span> http://msdn.microsoft.com/en-us/library/4zc42wh1(VS.85).aspx
<span class='line'>137</span> 傳回某物件的方法,以另一個物件取代目前的物件。
<span class='line'>138</span> apply是將現在正在執行的function其this改成apply的引數。所有函數內部的this指針都會被賦值為oThis這可實現將函數作為另外一個對象的方法運行的目的
<span class='line'>139</span> xxx.apply(oThis,arrayArgs): 執行xxx執行時以oThis作為 thisarrayArgs作為 arguments
<span class='line'>140</span>
<span class='line'>141</span> http://www.tohoho-web.com/js/object.htm#inheritClass
<span class='line'>142</span> クラスを継承する 親のクラスが持っている機能をすべて使用することができます。
<span class='line'>143</span>
<span class='line'>144</span> to make classChild inheritance classParent: http://www.interq.or.jp/student/exeal/dss/ejs/3/2.html
<span class='line'>145</span> function classChild(_args1,_args2,..){
<span class='line'>146</span> 處理argumentsarguments.pop() or other way
<span class='line'>147</span>
<span class='line'>148</span> classParent.call(this,_args1,_args2,..); // way1
<span class='line'>149</span> classParent.apply(this,arguments); // way2
<span class='line'>150</span> //this.constructor=classChild; // maybe needless
<span class='line'>151</span>
<span class='line'>152</span> // ..
<span class='line'>153</span> }
<span class='line'>154</span> classChild.prototype=new classParent; // for (objChild instanceof objParent) 關鍵字: 繼承,原型
<span class='line'>155</span> classChild.prototype.methodOfParent=function(..){..}; // オーバーライド
<span class='line'>156</span>
<span class='line'>157</span> var objChild=new classChild(_args);
<span class='line'>158</span> classParent.prototype.methodOfParent.call(objChild, ..); // 基底プロトタイプのメソッドを呼び出す。ただしこの呼び出し自体は Programmer が Person を継承しているかどうかを何も考慮していません。
<span class='line'>159</span>
<span class='line'>160</span>
<span class='line'>161</span> 因 arguments 非instanceof Arrayarguments.join(sp) → Array.prototype.join.call(arguments,sp)
<span class='line'>162</span> */</span><span class="WHIT">
<span class='line'>163</span> </span><span class="COMM">/**
<span class='line'>164</span> * @ignore
<span class='line'>165</span> */</span><span class="WHIT">
<span class='line'>166</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>167</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Fapply</span><span class="PUNC">(</span><span class="COMM">/* object */</span><span class="WHIT"> </span><span class="NAME">oThis</span><span class="WHIT"> </span><span class="COMM">/* = null */</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/* Array */</span><span class="WHIT"> </span><span class="NAME">arrayArgs</span><span class="WHIT"> </span><span class="COMM">/* = null */</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">oThis</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">oThis</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// グローバルオブジェクトに適用</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">arrayArgs</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">arrayArgs</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">(</span><span class="NAME">arrayArgs</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">oThis</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Object</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 実際は throw TypeError();</span><span class="WHIT">
<span class='line'>172</span>
<span class='line'>173</span> </span><span class="WHIT"> </span><span class="NAME">oThis.$_funcTmp000</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>174</span>
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oReturn</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">arrayArgs</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">arrayArgs</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="NAME">oReturn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oThis.$_funcTmp000</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">arrayArgs</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">args</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">arrayArgs.length</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="STRN">'arrayArgs['</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">+</span><span class="STRN">']'</span><span class="PUNC">;</span><span class="COMM">//args.push('arrayArgs['+i+']');</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="NAME">oReturn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eval</span><span class="PUNC">(</span><span class="STRN">"oThis.$_funcTmp000("</span><span class="PUNC">+</span><span class="NAME">args.join</span><span class="PUNC">(</span><span class="STRN">","</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">");"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 因為arrayArgs[i]之type不固定故不能直接用arrayArgs.join(",")</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">//else{delete oThis.$_funcTmp000;throw TypeError();}</span><span class="WHIT">
<span class='line'>184</span>
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">oThis.$_funcTmp000</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">oReturn</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>188</span> </span><span class="COMM">/* http://msdn.microsoft.com/library/CHT/jscript7/html/jsmthcall.asp
<span class='line'>189</span> call 方法是用來呼叫代表另一個物件的方法。call 方法可讓您將函式的物件內容從原始內容變成由 thisObj 所指定的新物件。
<span class='line'>190</span> 如果未提供 thisObj 的話,將使用 global 物件作為 thisObj。
<span class='line'>191</span> */</span><span class="WHIT">
<span class='line'>192</span> </span><span class="COMM">/**
<span class='line'>193</span> * @ignore
<span class='line'>194</span> */</span><span class="WHIT">
<span class='line'>195</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>196</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Fcall</span><span class="PUNC">(</span><span class="COMM">/* object */</span><span class="WHIT"> </span><span class="NAME">oThis</span><span class="WHIT"> </span><span class="COMM">/* = null [, arg1[, arg2[, ... [, argN]]]]] */</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">argu</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="COMM">//Array.prototype.slice.call(arguments);</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">arguments.length</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="NAME">argu</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// argu.push(arguments[i]);</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.apply</span><span class="PUNC">(</span><span class="NAME">oThis</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">argu</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>202</span>
<span class='line'>203</span>
<span class='line'>204</span>
<span class='line'>205</span>
<span class='line'>206</span> </span><span class="NAME">CeL.data.code.compatibility</span><span class="WHIT">
<span class='line'>207</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>208</span> </span><span class="COMM">/**
<span class='line'>209</span> * Are we in a web environment?
<span class='line'>210</span> * @param W3CDOM Are we in a W3C DOM environment?
<span class='line'>211</span> * @return We're in a web environment.
<span class='line'>212</span> * @since 2009/12/29 19:18:53
<span class='line'>213</span> * @see
<span class='line'>214</span> * use lazy evaluation
<span class='line'>215</span> * @memberOf CeL.data.code.compatibility
<span class='line'>216</span> */</span><span class="WHIT">
<span class='line'>217</span> </span><span class="NAME">is_web</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">is_web</span><span class="PUNC">(</span><span class="NAME">W3CDOM</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">is_web</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">'web'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="NAME">_s.W3CDOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="NAME">_s.web</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">window</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">window.document</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">document</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="COMM">// 下兩個在 IE5.5 中都是 Object</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT"> </span><span class="COMM">//&& library_namespace.is_type(window, 'global')</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT"> </span><span class="COMM">//&& library_namespace.is_type(document, 'HTMLDocument')</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="COMM">// W3CDOM, type: Object @ IE5.5</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="COMM">// &&!!document.createElement</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="COMM">// type: Object @ IE5.5</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span>
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">W3CDOM</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_s.W3CDOM</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_s.web</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span>
<span class='line'>238</span>
<span class='line'>239</span> </span><span class="NAME">CeL.data.code.compatibility</span><span class="WHIT">
<span class='line'>240</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>241</span> </span><span class="COMM">/**
<span class='line'>242</span> * 判斷為 DOM。
<span class='line'>243</span> * @param name various name @ name-space window. e.g., document, location
<span class='line'>244</span> * @return {Boolean} various is object of window
<span class='line'>245</span> * @since 2010/1/14 22:04:37
<span class='line'>246</span> * @memberOf CeL.data.code.compatibility
<span class='line'>247</span> */</span><span class="WHIT">
<span class='line'>248</span> </span><span class="NAME">is_DOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.is_web</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">name</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>252</span>
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="COMM">// CeL.debug(CeL.is_type(window[name]));</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eval</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'===window.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>261</span>
<span class='line'>262</span>
<span class='line'>263</span> </span><span class="COMM">//is_HTA[generateCode.dLK]='is_web';</span><span class="WHIT">
<span class='line'>264</span> </span><span class="NAME">CeL.data.code.compatibility</span><span class="WHIT">
<span class='line'>265</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>266</span> </span><span class="COMM">/**
<span class='line'>267</span> * Are we run in HTA?&lt;br/>
<span class='line'>268</span> * ** HTA 中應該在 onload 中呼叫,否則 document.getElementsByTagName 不會有東西!
<span class='line'>269</span> * @param [id] HTA tag id (only used in low version that we have no document.getElementsByTagName)
<span class='line'>270</span> * @return We're in HTA
<span class='line'>271</span> * @require is_web
<span class='line'>272</span> * @since 2009/12/29 19:18:53
<span class='line'>273</span> * @memberOf CeL.data.code.compatibility
<span class='line'>274</span> * @see
<span class='line'>275</span> * http://msdn2.microsoft.com/en-us/library/ms536479.aspx
<span class='line'>276</span> * http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0420.mspx
<span class='line'>277</span> * http://www.msfn.org/board/lofiversion/index.php/t61847.html
<span class='line'>278</span> * lazy evaluation
<span class='line'>279</span> * http://peter.michaux.ca/articles/lazy-function-definition-pattern
<span class='line'>280</span> */</span><span class="WHIT">
<span class='line'>281</span> </span><span class="NAME">is_HTA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">is_HTA</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">is_HTA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'HTA'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_s.HTA</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>285</span>
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">is_web</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">'APPLICATION'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">is_web</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.all</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.all</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span>
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_s.HTA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span>
<span class='line'>295</span>
<span class='line'>296</span>
<span class='line'>297</span> </span><span class="COMM">// 版本檢查</span><span class="WHIT">
<span class='line'>298</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">checkVer</span><span class="PUNC">(</span><span class="NAME">ver</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">ver</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ver</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT"> </span><span class="NAME">ver</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// WScript.FullName,WScript.Path</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT"> </span><span class="KEYW">with</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">WScript</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Version</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">ver</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT"> </span><span class="KEYW">with</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">WshShell</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">promptTitle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Locale</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0x411</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'アップグレードしませんか?'</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'請升級'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">promptC</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Locale</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0x411</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"今使ってる "</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">WScript.Name</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" のバージョンは古過ぎるから、\nMicrosoft Windows スクリプト テクノロジ Web サイトより\nバージョン "</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Version</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" から "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ver</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" 以上にアップグレードしましょう。"</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"正使用的 "</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">WScript.Name</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" 版本過舊,\n請至 Microsoft Windows 網站將版本由 "</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Version</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" 升級到 "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ver</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" 以上。"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="COMM">/* Locale==0x411? */</span><span class="STRN">"http://www.microsoft.com/japan/developer/scripting/default.htm"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Popup</span><span class="PUNC">(</span><span class="NAME">promptC</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">promptTitle</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT"> </span><span class="NAME">Run</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT"> </span><span class="NAME">Quit</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>317</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>318</span>
<span class='line'>319</span>
<span class='line'>320</span>
<span class='line'>321</span>
<span class='line'>322</span>
<span class='line'>323</span>
<span class='line'>324</span>
<span class='line'>325</span> </span><span class="COMM">/* 2008/12/21 18:53:42
<span class='line'>326</span> value to json
<span class='line'>327</span> JavaScript Object Notation ECMA-262 3rd Edition
<span class='line'>328</span>
<span class='line'>329</span> http://stackoverflow.com/questions/1500745/how-to-pass-parameters-in-eval-in-an-object-form
<span class='line'>330</span> json={name:'~',values:..,description:'~'}
<span class='line'>331</span> window[json.name].apply(null, json.values)
<span class='line'>332</span>
<span class='line'>333</span>
<span class='line'>334</span> usage:
<span class='line'>335</span> json(value)
<span class='line'>336</span>
<span class='line'>337</span> parse:
<span class='line'>338</span> data=eval('('+data+')'); // 字串的前後記得要加上刮號 (),這是用來告知 Javascript Interpreter 這是個物件描述,不是要執行的 statement。
<span class='line'>339</span> eval('data='+data);
<span class='line'>340</span>
<span class='line'>341</span> TODO:
<span class='line'>342</span>
<span class='line'>343</span> useObj
<span class='line'>344</span> 加入function object成員.prototype可用with()。加入函數相依性(dependency)
<span class='line'>345</span>
<span class='line'>346</span> array用name:
<span class='line'>347</span> (function(){
<span class='line'>348</span> var o;
<span class='line'>349</span> o=[..];
<span class='line'>350</span> var i,v={..};
<span class='line'>351</span> for(i in v)o[i]=v[i];
<span class='line'>352</span> return o;
<span class='line'>353</span> })()
<span class='line'>354</span>
<span class='line'>355</span>
<span class='line'>356</span> recursion 循環參照
<span class='line'>357</span> (function(){
<span class='line'>358</span> var o;
<span class='line'>359</span> o={a:[]};
<span class='line'>360</span> o['b']=[o['a']],
<span class='line'>361</span> o['a'].push([o['b']]);
<span class='line'>362</span> return o;
<span class='line'>363</span> })()
<span class='line'>364</span>
<span class='line'>365</span>
<span class='line'>366</span>
<span class='line'>367</span> BUG:
<span class='line'>368</span> function 之名稱被清除掉了,這可能會產生問題!
<span class='line'>369</span> (function(){
<span class='line'>370</span> var f=function(){..};
<span class='line'>371</span> f.a=..;
<span class='line'>372</span> f.b=..;
<span class='line'>373</span> f.prototype={
<span class='line'>374</span> a:..,
<span class='line'>375</span> b:..
<span class='line'>376</span> }
<span class='line'>377</span> return f;
<span class='line'>378</span> })()
<span class='line'>379</span>
<span class='line'>380</span>
<span class='line'>381</span> */</span><span class="WHIT">
<span class='line'>382</span> </span><span class="COMM">//json[generateCode.dLK]='qNum,dQuote';</span><span class="WHIT">
<span class='line'>383</span>
<span class='line'>384</span>
<span class='line'>385</span>
<span class='line'>386</span> </span><span class="COMM">/*
<span class='line'>387</span> var a=[],b;a.push(b=[a]);json(a);
<span class='line'>388</span>
<span class='line'>389</span> test recursion 循環參照
<span class='line'>390</span> (function(){
<span class='line'>391</span> var o=[],_1=[o];
<span class='line'>392</span> o.push(_1);
<span class='line'>393</span> return o;
<span class='line'>394</span> })();
<span class='line'>395</span>
<span class='line'>396</span> */</span><span class="WHIT">
<span class='line'>397</span>
<span class='line'>398</span> </span><span class="COMM">/*
<span class='line'>399</span> 改用 window.JSON, jQuery.parseJSON
<span class='line'>400</span> 據說toJSONString跟parseJSON有可能成為ECMAScript第四版的標準
<span class='line'>401</span>
<span class='line'>402</span> 須判別來源是否為 String or Number!
<span class='line'>403</span>
<span class='line'>404</span>
<span class='line'>405</span> 九个PHP很有用的功能 | 酷壳 - CoolShell.cn
<span class='line'>406</span> http://coolshell.cn/?p=2394
<span class='line'>407</span> 你是否會把一個比較複雜的數據結構存到數據庫或是文件中你並不需要自己去寫自己的算法。PHP早已為你做好了其提供了兩個函數?serialize() 和 unserialize()
<span class='line'>408</span> JSON越來越流行所以在PHP5.2以後PHP開始支持JSON你可以使用 json_encode() 和 json_decode() 函數。但是對於一些非常複雜的數據結構,可能會造成數據丟失。
<span class='line'>409</span>
<span class='line'>410</span>
<span class='line'>411</span> json.dL='dependencyList'; // dependency List Key
<span class='line'>412</span> json.forceArray=1;
<span class='line'>413</span>
<span class='line'>414</span> json.indentString=' ';
<span class='line'>415</span> json.NewLine='\n';
<span class='line'>416</span> json.separator=' ';
<span class='line'>417</span> function json(val,name,type){ // type==2: inside object, treat undefined as ''
<span class='line'>418</span> var _f=json,expA=[],expC=[],vType=typeof val
<span class='line'>419</span> ,addE=function(o,l,n){
<span class='line'>420</span> if(l){
<span class='line'>421</span> o=_f(o,0,2);
<span class='line'>422</span> n=typeof n=='undefined'||n===''?''
<span class='line'>423</span> :(/^(\d{1,8})?(\.\d{1,8})?$/.test(n)||/^[a-z_][a-z_\d]{0,30}$/i.test(n)?n:dQuote(n))+':'+_f.separator;
<span class='line'>424</span> expA.push(n,o[1]);
<span class='line'>425</span>
<span class='line'>426</span> //expC.push(_f.indentString+n+o[0].join(_f.NewLine+_f.indentString)+',');
<span class='line'>427</span> o=o[0];
<span class='line'>428</span> o[0]=n+(typeof o[0]=='undefined'?'':o[0]);
<span class='line'>429</span> o[o.length-1]+=',';
<span class='line'>430</span> for(var i=0;i&lt;o.length;i++)
<span class='line'>431</span> o[i]=_f.indentString+(typeof o[i]=='undefined'?'':o[i]);
<span class='line'>432</span> expC=expC.concat(o);
<span class='line'>433</span> }else expA.push(o),expC.push(o);
<span class='line'>434</span> }
<span class='line'>435</span> // 去掉最後一組的 ',' 並作結
<span class='line'>436</span> ,closeB=function(c){
<span class='line'>437</span> var v=expC[expC.length-1];
<span class='line'>438</span> if(v.charAt(v.length-1)==',')
<span class='line'>439</span> expC[expC.length-1]=v.slice(0,v.length-1);
<span class='line'>440</span> addE(c);
<span class='line'>441</span> };
<span class='line'>442</span>
<span class='line'>443</span> switch(vType){
<span class='line'>444</span> case 'number':
<span class='line'>445</span> // http://msdn2.microsoft.com/zh-tw/library/y382995a(VS.80).aspx
<span class='line'>446</span> // isFinite(value) ? String(value)
<span class='line'>447</span> var k=0,m='MAX_VALUE,MIN_VALUE,NEGATIVE_INFINITY,POSITIVE_INFINITY,NaN'.split(','),t=0;
<span class='line'>448</span> if(val===NaN||val===Infinity||val===-Infinity)t=''+val;
<span class='line'>449</span> else for(;k&lt;m.length;k++)
<span class='line'>450</span> if(val===Number[m[k]]){t='Number.'+m[k];break;}
<span class='line'>451</span> if(!t){
<span class='line'>452</span> // http://msdn2.microsoft.com/zh-tw/library/shydc6ax(VS.80).aspx
<span class='line'>453</span> for(k=0,m='E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2'.split(',');k&lt;m.length;k++)
<span class='line'>454</span> if(val===Math[m[k]]){t='Math.'+m[k];break;}
<span class='line'>455</span> if(!t)
<span class='line'>456</span> if(k=(''+val).match(/^(-?\d*[1-9])(0{3,})$/))
<span class='line'>457</span> t=k[1]+'e'+k[2].length;
<span class='line'>458</span> else{
<span class='line'>459</span>
<span class='line'>460</span> // 有理數判別
<span class='line'>461</span> k=qNum(val);
<span class='line'>462</span>
<span class='line'>463</span> // 小數不以分數顯示. m==1:非分數
<span class='line'>464</span> m=k[1];
<span class='line'>465</span> while(m%2==0)m/=2;
<span class='line'>466</span> while(m%5==0)m/=5;
<span class='line'>467</span>
<span class='line'>468</span> t=k[2]==0 && m!=1?k[0]+'/'+k[1]:
<span class='line'>469</span> // TODO: 加速(?)
<span class='line'>470</span> (t=Math.floor(val))==val&&(''+t).length>(t='0x'+val.toString(16)).length?t:val;
<span class='line'>471</span> }
<span class='line'>472</span>
<span class='line'>473</span> }
<span class='line'>474</span> addE(t);
<span class='line'>475</span> break;
<span class='line'>476</span> case 'null':
<span class='line'>477</span> addE(''+val);
<span class='line'>478</span> break;
<span class='line'>479</span> case 'boolean':
<span class='line'>480</span> addE(val);
<span class='line'>481</span> break;
<span class='line'>482</span> case 'string':
<span class='line'>483</span> addE(dQuote(val));
<span class='line'>484</span> break;
<span class='line'>485</span> case 'undefined':
<span class='line'>486</span> addE(type==2?'':'undefined');
<span class='line'>487</span> break;
<span class='line'>488</span>
<span class='line'>489</span> case 'function':
<span class='line'>490</span> // 加入function object成員.prototype可用with()。加入函數相依性(dependency)
<span class='line'>491</span> var toS,f;
<span class='line'>492</span> // 這在多執行緒有機會出問題!
<span class='line'>493</span> if(typeof val.toString!='undefined'){toS=val.toString;delete val.toString;}
<span class='line'>494</span> f=''+val;
<span class='line'>495</span> if(typeof toS!='undefined')val.toString=toS;
<span class='line'>496</span>
<span class='line'>497</span> f=f.replace(/\r?\n/g,_f.NewLine); // function 才會產生 \r\n 問題,所以先處理掉
<span class='line'>498</span> var r=/^function\s+([^(\s]+)/,m=f.match(r),t;
<span class='line'>499</span> if(m)m=m[1],addE('// function ['+m+']'),t=f.replace(r,'function'+_f.separator);
<span class='line'>500</span> if(m&&t.indexOf(m)!=-1)alert('function ['+m+'] 之名稱被清除掉了,這可能會產生問題!');
<span class='line'>501</span> addE(t||f);
<span class='line'>502</span> // UNDO
<span class='line'>503</span> break;
<span class='line'>504</span>
<span class='line'>505</span> case 'object':
<span class='line'>506</span> try{
<span class='line'>507</span> if(val===null){addE(''+val);break;}
<span class='line'>508</span> var c=val.constructor;
<span class='line'>509</span> if(c==RegExp){
<span class='line'>510</span> addE(val);
<span class='line'>511</span> break;
<span class='line'>512</span> }
<span class='line'>513</span> if(c==Date || vType=='date'){ // typeof val.getTime=='function'
<span class='line'>514</span> // 與 now 相隔過短(&lt;1e7, 約3h)視為 now。但若是 new Date()+3 之類的會出現誤差!
<span class='line'>515</span> addE('new Date'+((val-new Date)>1e7?'('+val.getTime()+')':'')); // date被當作object
<span class='line'>516</span> break;
<span class='line'>517</span> }
<span class='line'>518</span> if((''+c).indexOf('Error')!=-1){
<span class='line'>519</span> addE('new Error'+(val.number||val.description?'('+(val.number||'')+(val.description?(val.number?',':'')+dQuote(val.description):'')+')':''));
<span class='line'>520</span> break;
<span class='line'>521</span> }
<span class='line'>522</span>
<span class='line'>523</span> var useObj=0;
<span class='line'>524</span> if(c==Array){
<span class='line'>525</span> var i,l=0;
<span class='line'>526</span> if(!_f.forceArray)for(i in val)
<span class='line'>527</span> if(isNaN(i)){useObj=1;break;}else l++;
<span class='line'>528</span>
<span class='line'>529</span> if(_f.forceArray || !useObj && l>val.length*.8){
<span class='line'>530</span> addE('[');
<span class='line'>531</span> for(i=0;i&lt;val.length;i++)
<span class='line'>532</span> addE(val[i],1);
<span class='line'>533</span> closeB(']');
<span class='line'>534</span> break;
<span class='line'>535</span> }else useObj=1;
<span class='line'>536</span> }
<span class='line'>537</span>
<span class='line'>538</span> if(useObj||c==Object){// instanceof
<span class='line'>539</span> addE('{');
<span class='line'>540</span> for(var i in val)
<span class='line'>541</span> addE(val[i],1,i);
<span class='line'>542</span> closeB('}');
<span class='line'>543</span> break;
<span class='line'>544</span> }
<span class='line'>545</span> addE(dQuote(val));
<span class='line'>546</span> break;
<span class='line'>547</span> }catch(e){
<span class='line'>548</span> if(28==(e.number&0xFFFF))
<span class='line'>549</span> alert('json: Too much recursion?\n循環參照');
<span class='line'>550</span> return;
<span class='line'>551</span> }
<span class='line'>552</span>
<span class='line'>553</span> case 'unknown': // sometimes we have this kind of type
<span class='line'>554</span> default:
<span class='line'>555</span> alert('Unknown type: ['+vType+'] (constructor: '+val.constructor+'), please contract me!\n'+val);
<span class='line'>556</span> break;
<span class='line'>557</span> //alert(vType);
<span class='line'>558</span> }
<span class='line'>559</span> return type?[expC,expA]:expC.join(_f.NewLine);
<span class='line'>560</span> }
<span class='line'>561</span>
<span class='line'>562</span> */</span><span class="WHIT">
<span class='line'>563</span>
<span class='line'>564</span>
<span class='line'>565</span>
<span class='line'>566</span>
<span class='line'>567</span>
<span class='line'>568</span>
<span class='line'>569</span>
<span class='line'>570</span>
<span class='line'>571</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>572</span> </span><span class="WHIT"> </span><span class="NAME">CeL.data.code.compatibility</span><span class="WHIT">
<span class='line'>573</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>574</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>575</span>
<span class='line'>576</span>
<span class='line'>577</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>578</span>
<span class='line'>579</span> </span></pre></body></html>