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

4032 lines
748 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="COMM">//&lt;![CDATA[</span><span class="WHIT">
<span class='line'> 2</span>
<span class='line'> 3</span>
<span class='line'> 4</span> </span><span class="COMM">/**
<span class='line'> 5</span> * @name Colorless echo JavaScript kit/library base framework
<span class='line'> 6</span> * @fileoverview
<span class='line'> 7</span> * 本檔案包含了呼叫其他 library 需要用到的 function以及常用 base functions。&lt;br/>
<span class='line'> 8</span> * &lt;br/>
<span class='line'> 9</span> * Copyright (C) 2002-, kanashimi &lt;kanasimi@gmail.com>. All Rights Reserved.&lt;br/>
<span class='line'> 10</span> * &lt;br/>
<span class='line'> 11</span> * This file is in tab wide of 4 chars, documentation with JsDoc Toolkit (&lt;a href="http://code.google.com/p/jsdoc-toolkit/wiki/TagReference">tags&lt;/a>).&lt;br/>
<span class='line'> 12</span> * &lt;br/>
<span class='line'> 13</span> * &lt;br/>Please visit &lt;a href="http://lyrics.meicho.com.tw/program/">Colorless echo program room&lt;/a> for more informations.
<span class='line'> 14</span> * @since 自 function.js 0.2 改寫
<span class='line'> 15</span> * @since JavaScript 1.2
<span class='line'> 16</span> * @since 2009/11/17 01:02:36
<span class='line'> 17</span> * @author kanasimi@gmail.com
<span class='line'> 18</span> * @version $Id: ce.js,v 0.2 2009/11/26 18:37:11 kanashimi Exp $
<span class='line'> 19</span> */</span><span class="WHIT">
<span class='line'> 20</span>
<span class='line'> 21</span>
<span class='line'> 22</span> </span><span class="COMM">/*
<span class='line'> 23</span> 引用:參照
<span class='line'> 24</span> function addCode
<span class='line'> 25</span>
<span class='line'> 26</span> 單一JS引用
<span class='line'> 27</span> // [function.js]_iF
<span class='line'> 28</span> function _iF(){}_iF.p='HKCU\\Software\\Colorless echo\\function.js.path';if(typeof WScript=="object")try{eval(getU((new ActiveXObject("WScript.Shell")).RegRead(_iF.p)));}catch(e){}
<span class='line'> 29</span> function getU(p,enc){var o;try{o=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){o=new XMLHttpRequest();}if(o)with(o){open('GET',p,false);if(enc&&o.overrideMimeType)overrideMimeType('text/xml;charset='+enc);send(null);return responseText;}}
<span class='line'> 30</span> // [function.js]End
<span class='line'> 31</span>
<span class='line'> 32</span>
<span class='line'> 33</span> 初始化:參照
<span class='line'> 34</span> initialization of function.js
<span class='line'> 35</span>
<span class='line'> 36</span> &lt;script type="text/javascript" src="path/to/function.js">&lt;/script>
<span class='line'> 37</span> &lt;script type="application/javascript;version=1.7" src="path/to/function.js">&lt;/script>
<span class='line'> 38</span>
<span class='line'> 39</span>
<span class='line'> 40</span> */</span><span class="WHIT">
<span class='line'> 41</span>
<span class='line'> 42</span>
<span class='line'> 43</span> </span><span class="COMM">//try{</span><span class="WHIT">
<span class='line'> 44</span>
<span class='line'> 45</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'> 46</span> </span><span class="COMM">//void(</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 48</span>
<span class='line'> 49</span> </span><span class="KEYW">var</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 51</span> * debug level
<span class='line'> 52</span> * @ignore
<span class='line'> 53</span> */</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="NAME">debug</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT">
<span class='line'> 55</span>
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">global</span><span class="WHIT">
<span class='line'> 57</span>
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="COMM">//,window</span><span class="WHIT">
<span class='line'> 59</span>
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 61</span> * Will speed up references to undefined, and allows redefining its name. (from jQuery)
<span class='line'> 62</span> * 用在 return undefined
<span class='line'> 63</span> */</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="COMM">//,undefined</span><span class="WHIT">
<span class='line'> 65</span>
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">_CeL</span><span class="WHIT">
<span class='line'> 67</span>
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">CeL</span><span class="WHIT">
<span class='line'> 69</span>
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">loaded_module</span><span class="WHIT">
<span class='line'> 71</span>
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="COMM">//,_base_function_to_extend</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span>
<span class='line'> 75</span>
<span class='line'> 76</span> </span><span class="COMM">// members of library -----------------------------------------------</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span>
<span class='line'> 79</span>
<span class='line'> 80</span> </span><span class="COMM">/**
<span class='line'> 81</span> * Global Scope object&lt;br/>
<span class='line'> 82</span> * 於 CeL.eval 使用
<span class='line'> 83</span> * @ignore
<span class='line'> 84</span> */</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="NAME">global</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="COMM">// isWeb()?window:this;</span><span class="WHIT">
<span class='line'> 86</span>
<span class='line'> 87</span>
<span class='line'> 88</span> </span><span class="COMM">/*
<span class='line'> 89</span> var _Global=(function(){return this;})();
<span class='line'> 90</span> _Global.JustANumber=2; // var _GlobalPrototype=_Global.constructor.prototype;_GlobalPrototype.JustANumber=2;
<span class='line'> 91</span> if(typeof _Global=='undefined')_Global=this;
<span class='line'> 92</span> for(i in _Global)alert(i);
<span class='line'> 93</span> */</span><span class="WHIT">
<span class='line'> 94</span>
<span class='line'> 95</span> </span><span class="COMM">// 若已經定義過,跳過。</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">global.CeL</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span>
<span class='line'> 99</span>
<span class='line'>100</span> </span><span class="COMM">/**
<span class='line'>101</span> * Will speed up references to DOM: window, and allows redefining its name. (from jQuery)
<span class='line'>102</span> * @ignore
<span class='line'>103</span> */</span><span class="WHIT">
<span class='line'>104</span> </span><span class="COMM">//window = this;</span><span class="WHIT">
<span class='line'>105</span>
<span class='line'>106</span>
<span class='line'>107</span> </span><span class="COMM">/**
<span class='line'>108</span> * 本 JavaScript framework 的框架基本宣告&lt;br/>
<span class='line'>109</span> * base name-space declaration of JavaScript library framework
<span class='line'>110</span> * @example
<span class='line'>111</span> * // 判別是否已經 load 過
<span class='line'>112</span> * if(typeof CeL !== 'function' || CeL.Class !== 'CeL')
<span class='line'>113</span> * ; // CeL has not been loaded
<span class='line'>114</span> * @name CeL
<span class='line'>115</span> * @class Colorless echo JavaScript kit/library: base name-space declaration
<span class='line'>116</span> */</span><span class="WHIT">
<span class='line'>117</span> </span><span class="NAME">CeL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="COMM">// function CeL // declaration for debug</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="COMM">//this.global = arguments[0] || arguments.callee.ce_doc;</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.callee.init.apply</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span>
<span class='line'>123</span> </span><span class="COMM">/**
<span class='line'>124</span> * JavaScript library framework main class name.
<span class='line'>125</span> * @see &lt;a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMA-262&lt;/a>: Class: A string value indicating the kind of this object.
<span class='line'>126</span> * @constant
<span class='line'>127</span> */</span><span class="WHIT">
<span class='line'>128</span> </span><span class="NAME">CeL.Class</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'CeL'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span>
<span class='line'>130</span>
<span class='line'>131</span> </span><span class="COMM">/**
<span class='line'>132</span> * Map over main name-space in case of overwrite (from jQuery)
<span class='line'>133</span> * @ignore
<span class='line'>134</span> */</span><span class="WHIT">
<span class='line'>135</span> </span><span class="NAME">_CeL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">global.CeL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="NAME">global</span><span class="PUNC">[</span><span class="NAME">CeL.Class</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CeL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span>
<span class='line'>138</span>
<span class='line'>139</span> </span><span class="COMM">/**
<span class='line'>140</span> * framework main prototype definition
<span class='line'>141</span> * for JSDT: 有 prototype 才會將之當作 Class
<span class='line'>142</span> */</span><span class="WHIT">
<span class='line'>143</span> </span><span class="NAME">CeL.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>144</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span>
<span class='line'>146</span>
<span class='line'>147</span>
<span class='line'>148</span>
<span class='line'>149</span> </span><span class="COMM">// 取得執行script之path,在.hta中取代 WScript.ScriptFullName%20的部分最好再加其他的…</span><span class="WHIT">
<span class='line'>150</span> </span><span class="NAME">CeL.get_script_full_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">WScript.ScriptFullName</span><span class="WHIT">
<span class='line'>152</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">location</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">unescape</span><span class="PUNC">(</span><span class="NAME">location.pathname</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>153</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 class='line'>154</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="COMM">// 取得執行script之名稱</span><span class="WHIT">
<span class='line'>156</span> </span><span class="NAME">CeL.get_script_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span>
<span class='line'>159</span> </span><span class="WHIT"> </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">WScript</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript.ScriptName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">==</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">n</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">n.slice</span><span class="PUNC">(</span><span class="NUMB">0</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'>163</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>164</span>
<span class='line'>165</span> </span><span class="WHIT"> </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">location</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">unescape</span><span class="PUNC">(</span><span class="NAME">location.pathname</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</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="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'\\'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// location.pathname在.hta中會回傳'\'形式的path</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">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">n.slice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">n.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>171</span>
<span class='line'>172</span> </span><span class="WHIT"> </span><span class="KEYW">return</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><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">document.title</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 class='line'>173</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>174</span>
<span class='line'>175</span>
<span class='line'>176</span>
<span class='line'>177</span>
<span class='line'>178</span> </span><span class="COMM">/**
<span class='line'>179</span> * 取得/設定環境變數 enumeration&lt;br/>
<span class='line'>180</span> * (雖然不喜歡另開 namespace但以 2009 當下的 JsDoc Toolkit 來說,似乎沒辦法創造 enumeration。
<span class='line'>181</span> * @class 環境變數 (environment variables) 與程式會用到的 library 相關變數。
<span class='line'>182</span> * @param name 環境變數名稱
<span class='line'>183</span> * @param value 環境變數之值
<span class='line'>184</span> * @return 舊環境變數之值
<span class='line'>185</span> */</span><span class="WHIT">
<span class='line'>186</span> </span><span class="NAME">CeL.env</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="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>187</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">name</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>188</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 class='line'>189</span>
<span class='line'>190</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">arguments.callee</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="NAME">_s</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><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</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">v</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span>
<span class='line'>196</span> </span><span class="COMM">/**
<span class='line'>197</span> * Setup environment variables
<span class='line'>198</span> * @param {string}[OS_type] type of OS
<span class='line'>199</span> * @return environment variables set
<span class='line'>200</span> */</span><span class="WHIT">
<span class='line'>201</span> </span><span class="NAME">CeL.initial_env</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">OS_type</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="COMM">//this.env = {};</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">OS</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">env</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.env</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span>
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>206</span> * library main file base name&lt;br/>
<span class='line'>207</span> * full path: {@link CeL.env.registry_path} + {@link CeL.env.main_script}
<span class='line'>208</span> * @name CeL.env.main_script
<span class='line'>209</span> */</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="NAME">env.main_script</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'ce.js'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span>
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>213</span> * module 中的這 member 定義了哪些 member 不被 extend
<span class='line'>214</span> * @name CeL.env.not_to_extend_keyword
<span class='line'>215</span> */</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="NAME">env.not_to_extend_keyword</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'no_extend'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span>
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>219</span> * 本 library source 檔案使用之 encoding&lt;br/>
<span class='line'>220</span> * 不使用會產生語法錯誤
<span class='line'>221</span> * @name CeL.env.source_encoding
<span class='line'>222</span> */</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT"> </span><span class="NAME">env.source_encoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'UTF-16'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span>
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>226</span> * default global object
<span class='line'>227</span> * @name CeL.env.global
<span class='line'>228</span> */</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="NAME">env.global</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">global</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span>
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>232</span> * creator group
<span class='line'>233</span> * @name CeL.env.company
<span class='line'>234</span> */</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT"> </span><span class="NAME">env.company</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'Colorless echo'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT"> </span><span class="NAME">env.registry_key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'HKCU\\Software\\'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">env.company</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">this.Class</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.path'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof WScript==='object')</span><span class="WHIT">
<span class='line'>239</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'>240</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>241</span> * 存放在 registry 中的 path
<span class='line'>242</span> * @name CeL.env.registry_path
<span class='line'>243</span> */</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT"> </span><span class="NAME">env.registry_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">WScript.CreateObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Shell"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">RegRead</span><span class="PUNC">(</span><span class="NAME">env.registry_key</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[^\\\/]+$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="COMM">// this.log(env.registry_path);</span><span class="WHIT">
<span class='line'>247</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'>248</span> </span><span class="WHIT"> </span><span class="COMM">// this.log(e.message);</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>250</span>
<span class='line'>251</span>
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="COMM">//條件式編譯(条件コンパイル) for version>=4, 用 /*@ and @*/ to 判別</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="COMM">/*@cc_on
<span class='line'>254</span> @if(@_PowerPC||@_mac)
<span class='line'>255</span> OS='Mac';
<span class='line'>256</span> @else
<span class='line'>257</span> @if(@_win32||@_win64||@_win16)
<span class='line'>258</span> OS='DOS';
<span class='line'>259</span> @else
<span class='line'>260</span> OS='unix'; // unknown
<span class='line'>261</span> @end
<span class='line'>262</span> @end@*/</span><span class="WHIT">
<span class='line'>263</span>
<span class='line'>264</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>265</span> * 本次執行所在 OS 平台
<span class='line'>266</span> * @name CeL.env.OS
<span class='line'>267</span> */</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT"> </span><span class="NAME">env.OS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">OS</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">OS_type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">OS_type</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="COMM">// 假如未設定則取預設值</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">OS</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'unix'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span>
<span class='line'>272</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>273</span> * 文件預設 new line
<span class='line'>274</span> * @name CeL.env.new_line
<span class='line'>275</span> */</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT"> </span><span class="NAME">env.new_line</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">OS</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'unix'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">OS</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Mac'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'\r'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\r\n'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// in VB: vbCrLf</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>278</span> * file system 預設 path separator&lt;br/>
<span class='line'>279</span> * platform-dependent path separator character, 決定目錄(directory)分隔
<span class='line'>280</span> * @name CeL.env.path_separator
<span class='line'>281</span> */</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="NAME">env.path_separator</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">OS</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'unix'</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="STRN">'\\'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>284</span> * 預設 module name separator
<span class='line'>285</span> * @name CeL.env.module_name_separator
<span class='line'>286</span> */</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="NAME">env.module_name_separator</span><span class="PUNC">=</span><span class="STRN">'.'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>289</span> * path_separator in 通用(regular)運算式
<span class='line'>290</span> * @name CeL.env.path_separator_RegExp
<span class='line'>291</span> */</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT"> </span><span class="NAME">env.path_separator_RegExp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.to_RegExp_pattern</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">to_RegExp_pattern</span><span class="PUNC">(</span><span class="NAME">env.path_separator</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">env.path_separator</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="STRN">'\\'</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="PUNC">+</span><span class="WHIT"> </span><span class="NAME">env.path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>296</span> * 預設語系
<span class='line'>297</span> * 0x404:中文-台灣,0x0411:日文-日本
<span class='line'>298</span> * @name CeL.env.locale
<span class='line'>299</span> * @see &lt;a href="http://msdn.microsoft.com/zh-tw/library/system.globalization.cultureinfo(VS.80).aspx">CultureInfo 類別&lt;/a>
<span class='line'>300</span> */</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT"> </span><span class="NAME">env.locale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x404</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span>
<span class='line'>303</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>304</span> * script name
<span class='line'>305</span> * @name CeL.env.script_name
<span class='line'>306</span> */</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT"> </span><span class="NAME">env.script_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.get_script_name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>309</span> * base path of library
<span class='line'>310</span> * @name CeL.env.library_base_path
<span class='line'>311</span> */</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT"> </span><span class="NAME">env.library_base_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.get_script_full_name</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 以reg代替</span><span class="WHIT">
<span class='line'>313</span>
<span class='line'>314</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">env</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span>
<span class='line'>317</span>
<span class='line'>318</span>
<span class='line'>319</span>
<span class='line'>320</span> </span><span class="COMM">/**
<span class='line'>321</span> * Tell if it's now debugging.
<span class='line'>322</span> * @param {int}[debug_level] if it's now in this debug level.
<span class='line'>323</span> * @type boolean
<span class='line'>324</span> * @return It's now debugging or in specified debug level.
<span class='line'>325</span> */</span><span class="WHIT">
<span class='line'>326</span> </span><span class="NAME">CeL.is_debug</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">debug_level</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">debug_level</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">debug</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">debug</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">debug_level</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>329</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>330</span>
<span class='line'>331</span> </span><span class="COMM">/**
<span class='line'>332</span> * Set debug level
<span class='line'>333</span> * @param {int}[debug_level] The debug level to set.
<span class='line'>334</span> * @type int
<span class='line'>335</span> * @return debug level now
<span class='line'>336</span> */</span><span class="WHIT">
<span class='line'>337</span> </span><span class="NAME">CeL.set_debug</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">debug_level</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>338</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">debug_level</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT"> </span><span class="NAME">debug_level</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>340</span>
<span class='line'>341</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">debug_level</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT"> </span><span class="NAME">debug</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">debug_level</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>343</span>
<span class='line'>344</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">debug</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>345</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>346</span>
<span class='line'>347</span>
<span class='line'>348</span> </span><span class="COMM">/*
<span class='line'>349</span> CeL.extend(function f_name(){}, object || string, initial arguments);
<span class='line'>350</span> CeL.extend({name:function(){},.. }, object || string);
<span class='line'>351</span> CeL.extend([function1,function12,..], object || string);
<span class='line'>352</span>
<span class='line'>353</span> set .name
<span class='line'>354</span> */</span><span class="WHIT">
<span class='line'>355</span>
<span class='line'>356</span> </span><span class="COMM">/**
<span class='line'>357</span> * 延展物件 (learned from jQuery)
<span class='line'>358</span> * @since 2009/11/25 21:17:44
<span class='line'>359</span> * @param variable_set variable set
<span class='line'>360</span> * @param namespace extend to what namespace
<span class='line'>361</span> * @param from_namespace When inputing function names, we need a base namespace to search these functions.
<span class='line'>362</span> * @return CeL
<span class='line'>363</span> * @see &lt;a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2009/03/01/jquery-extend.aspx" accessdate="2009/11/17 1:24" title="jQuery.extend的用法 - 黑暗執行緒">jQuery.extend的用法&lt;/a>
<span class='line'>364</span> */</span><span class="WHIT">
<span class='line'>365</span> </span><span class="NAME">CeL.extend</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">variable_set</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from_namespace</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>366</span> </span><span class="COMM">/*
<span class='line'>367</span> if(this.is_debug())
<span class='line'>368</span> throw new Error(1, 'UNDO');
<span class='line'>369</span> */</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>371</span>
<span class='line'>372</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">namespace</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT"> </span><span class="NAME">namespace</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'>374</span>
<span class='line'>375</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">from_namespace</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT"> </span><span class="NAME">from_namespace</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'>377</span>
<span class='line'>378</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">variable_set</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.parse_function</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="STRN">'Warning: Please include '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.Class</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.parse_function() first!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>383</span>
<span class='line'>384</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</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">variable_set</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">namespace</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">from_namespace</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</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">variable_set</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">from_namespace</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT"> </span><span class="COMM">//CeL.log('CeL.extend:\nextend (' + (typeof variable_set) + ') ' + variable_set + '\n=' + from_namespace[variable_set] + '\n\nto:\n' + namespace);</span><span class="WHIT">
<span class='line'>389</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">variable_set</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">from_namespace</span><span class="PUNC">[</span><span class="NAME">variable_set</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">variable_set</span><span class="PUNC">]</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">variable_set</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT"> </span><span class="COMM">//CeL.log('CeL.extend:\n' + variable_set + ' = ' + namespace[variable_set]);</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="STRN">'CeL.extend:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>397</span>
<span class='line'>398</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">variable_set</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'>399</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">arguments.callee</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">variable_set.length</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><span class="PUNC">{</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">(</span><span class="NAME">variable_set</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from_namespace</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>402</span>
<span class='line'>403</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">variable_set</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'>404</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">variable_set</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</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">variable_set</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>408</span>
<span class='line'>409</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>410</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>411</span>
<span class='line'>412</span>
<span class='line'>413</span> </span><span class="COMM">/**
<span class='line'>414</span> * Get file resource&lt;br/>
<span class='line'>415</span> * 用於 include JavaScript 檔之類需求時,取得檔案內容之輕量級函數。&lt;br/>
<span class='line'>416</span> * 除 Ajax本函數亦可用在 CScript 執行中。
<span class='line'>417</span> * @example
<span class='line'>418</span> * // get contents of [path/to/file]:
<span class='line'>419</span> * var file_contents = CeL.get_file('path/to/file');
<span class='line'>420</span> * @param {String} path URI / full path. &lt;em style="text-decoration:line-through;">不能用相對path&lt;/em>
<span class='line'>421</span> * @param {String} [encoding] file encoding
<span class='line'>422</span> * @return {String} data content of path
<span class='line'>423</span> * @return {undefined} when error occurred: no Ajax function, ..
<span class='line'>424</span> * @throws uncaught exception @ Firefox: 0x80520012 (NS_ERROR_FILE_NOT_FOUND), &lt;a href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/#exceptions">NETWORK_ERR&lt;/a> exception
<span class='line'>425</span> * @throws 'Access to restricted URI denied' 當 access 到上一層目錄時
<span class='line'>426</span> * @see
<span class='line'>427</span> * &lt;a href=http://blog.joycode.com/saucer/archive/2006/10/03/84572.aspx">Cross Site AJAX&lt;/a>&lt;br/>
<span class='line'>428</span> * &lt;a href="http://domscripting.com/blog/display/91">Cross-domain Ajax&lt;/a>
<span class='line'>429</span> */</span><span class="WHIT">
<span class='line'>430</span> </span><span class="NAME">CeL.get_file</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">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encoding</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT"> </span><span class="COMM">//with(typeof window.XMLHttpRequest=='undefined'?new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest()){</span><span class="WHIT">
<span class='line'>432</span>
<span class='line'>433</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>434</span> * XMLHttpRequest object
<span class='line'>435</span> */</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span>
<span class='line'>438</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">'Microsoft.XMLHTTP'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">XMLHttpRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>443</span>
<span class='line'>444</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="KEYW">with</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT"> </span><span class="NAME">open</span><span class="PUNC">(</span><span class="STRN">'GET'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>446</span>
<span class='line'>447</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">encoding</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">o.overrideMimeType</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>449</span> * old: overrideMimeType('text/xml;charset='+encoding);
<span class='line'>450</span> * 但這樣會被當作 XML 解析,產生語法錯誤。
<span class='line'>451</span> */</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT"> </span><span class="NAME">overrideMimeType</span><span class="PUNC">(</span><span class="STRN">'application/json;charset='</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">encoding</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>453</span>
<span class='line'>454</span>
<span class='line'>455</span> </span><span class="WHIT"> </span><span class="NAME">send</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>457</span> try {
<span class='line'>458</span> send(null);
<span class='line'>459</span> } catch (e) {
<span class='line'>460</span> // file not found
<span class='line'>461</span> // uncaught exception @ Firefox: 0x80520012 (NS_ERROR_FILE_NOT_FOUND)
<span class='line'>462</span> return undefined;
<span class='line'>463</span> }
<span class='line'>464</span> */</span><span class="WHIT">
<span class='line'>465</span>
<span class='line'>466</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">responseText</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">// else: This browser does not support XMLHttpRequest.</span><span class="WHIT">
<span class='line'>468</span>
<span class='line'>469</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">// This function must return a result of type any</span><span class="WHIT">
<span class='line'>470</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>471</span>
<span class='line'>472</span> </span><span class="COMM">/**
<span class='line'>473</span> * 本 library 專用之 evaluate()
<span class='line'>474</span> * @param code code to eval
<span class='line'>475</span> * @return value that eval() returned
<span class='line'>476</span> */</span><span class="WHIT">
<span class='line'>477</span> </span><span class="NAME">CeL.eval</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">code</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>479</span> JSC eval() takes an optional second argument which can be 'unsafe'.
<span class='line'>480</span> Mozilla/SpiderMonkey eval() takes an optional second argument which is the scope object for new symbols.
<span class='line'>481</span>
<span class='line'>482</span> use window.execScript(code,"JavaScript") in IE: window.execScript()將直接使用全局上下文環境因此execScript(Str)中的字符串Str可以影響全局變量。——也包括聲明全局變量、函數以及對象構造器。
<span class='line'>483</span> */</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(global.eval);</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(global && global.eval && global.eval !== arguments.callee);</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT"> </span><span class="COMM">//global.eval(code);</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">global</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">global.eval</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">global.eval</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">arguments.callee</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">global.eval.call</span><span class="PUNC">(</span><span class="NAME">global</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code</span><span class="PUNC">)</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">code</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>488</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>489</span>
<span class='line'>490</span> </span><span class="COMM">/* 得知相對basePath
<span class='line'>491</span> &lt;script type="text/javascript" src="../baseFunc.js">&lt;/script>
<span class='line'>492</span> var basePath=getBasePath('baseFunc.js'); // 引數為本.js檔名 若是更改.js檔名亦需要同步更動此值
<span class='line'>493</span> */</span><span class="WHIT">
<span class='line'>494</span> </span><span class="NAME">CeL.get_base_path</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">JSFN</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">JSFN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">WScript.ScriptFullName</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">location.href</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[^\/\\]+$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>500</span>
<span class='line'>501</span> </span><span class="WHIT"> </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">document</span><span class="PUNC">!==</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span>
<span class='line'>504</span> </span><span class="WHIT"> </span><span class="COMM">// form dojo: d.config.baseUrl = src.substring(0, m.index);</span><span class="WHIT">
<span class='line'>505</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><span class="NAME">j</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o</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">'script'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>506</span>
<span class='line'>507</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">o</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>508</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'>509</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getAttribute</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">j.indexOf</span><span class="PUNC">(</span><span class="NAME">JSFN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">j.slice</span><span class="PUNC">(</span><span class="NUMB">0</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'>513</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'>514</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>515</span>
<span class='line'>516</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b</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="COMM">// this.log()</span><span class="WHIT">
<span class='line'>517</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>518</span>
<span class='line'>519</span>
<span class='line'>520</span> </span><span class="COMM">/**
<span class='line'>521</span> * get the path of specified module
<span class='line'>522</span> * @param {String} module_name module name
<span class='line'>523</span> * @return {String} module path
<span class='line'>524</span> */</span><span class="WHIT">
<span class='line'>525</span> </span><span class="NAME">CeL.get_module_path</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">module_name</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>528</span>
<span class='line'>529</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(this.Class+'.get_module_path: load ['+module_name+']');</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">module_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.env.registry_path</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.get_base_path</span><span class="PUNC">(</span><span class="NAME">this.env.main_script</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.get_base_path</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT"> </span><span class="NAME">module_path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.split_module_name</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="REGX">/\//</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">module_path</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="STRN">'/'</span><span class="PUNC">:</span><span class="STRN">'\\'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.js'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(module_path);</span><span class="WHIT">
<span class='line'>536</span>
<span class='line'>537</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.getFP</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.getFP</span><span class="PUNC">(</span><span class="NAME">module_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>539</span>
<span class='line'>540</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(module_name+': '+module_path);</span><span class="WHIT">
<span class='line'>541</span>
<span class='line'>542</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">module_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>543</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>544</span>
<span class='line'>545</span>
<span class='line'>546</span> </span><span class="COMM">/*
<span class='line'>547</span> sample to test:
<span class='line'>548</span>
<span class='line'>549</span> ./a/b
<span class='line'>550</span> ./a/b/
<span class='line'>551</span> ../a/b
<span class='line'>552</span> ../a/b/
<span class='line'>553</span> a/../b ./b
<span class='line'>554</span> a/./b a/b
<span class='line'>555</span> /../a/b /a/b
<span class='line'>556</span> /./a/b /a/b
<span class='line'>557</span> /a/./b /a/b
<span class='line'>558</span> /a/../b /b
<span class='line'>559</span> /a/../../../b /b
<span class='line'>560</span> /a/b/.. /a
<span class='line'>561</span> /a/b/../ /a/
<span class='line'>562</span> a/b/.. a
<span class='line'>563</span> a/b/../ a/
<span class='line'>564</span> a/.. .
<span class='line'>565</span> ./a/b/../../../a.b/../c ../c
<span class='line'>566</span> ../../../a.b/../c ../../../c
<span class='line'>567</span>
<span class='line'>568</span> */</span><span class="WHIT">
<span class='line'>569</span>
<span class='line'>570</span> </span><span class="COMM">// 2009/11/23 22:12:5</span><span class="WHIT">
<span class='line'>571</span> </span><span class="NAME">CeL.deprecated_simplify_path</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">path</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>572</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">path</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>573</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path.replace</span><span class="PUNC">(</span><span class="REGX">/\s+$|^\s+/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\/\/+/g</span><span class="PUNC">,</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>574</span>
<span class='line'>575</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">is_absolute</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">path.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>576</span>
<span class='line'>577</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">path.replace</span><span class="PUNC">(</span><span class="REGX">/\/\.(\/|$)/g</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">$0</span><span class="PUNC">,</span><span class="NAME">$1</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$1</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>578</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>579</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="STRN">'1. '</span><span class="PUNC">+</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>580</span>
<span class='line'>581</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">path.replace</span><span class="PUNC">(</span><span class="REGX">/\/([^\/]+)\/\.\.(\/|$)/g</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">$0</span><span class="PUNC">,</span><span class="NAME">$1</span><span class="PUNC">,</span><span class="NAME">$2</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">$0</span><span class="PUNC">,</span><span class="NAME">$1</span><span class="PUNC">,</span><span class="NAME">$2</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$1</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">$0</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$2</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>582</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="STRN">'2. '</span><span class="PUNC">+</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>584</span>
<span class='line'>585</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">is_absolute</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>586</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path.replace</span><span class="PUNC">(</span><span class="REGX">/^(\/\.\.)+/g</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path.replace</span><span class="PUNC">(</span><span class="REGX">/^(\.\/)+/g</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>589</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="STRN">'3. '</span><span class="PUNC">+</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>590</span>
<span class='line'>591</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>592</span> </span><span class="WHIT"> </span><span class="NAME">path</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 class='line'>593</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>594</span>
<span class='line'>595</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>596</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>597</span>
<span class='line'>598</span> </span><span class="COMM">/**
<span class='line'>599</span> * 轉化所有 /., /.., //
<span class='line'>600</span> * @since 2009/11/23 22:32:52
<span class='line'>601</span> * @param {string} path 欲轉化之 path
<span class='line'>602</span> * @return {string} path
<span class='line'>603</span> */</span><span class="WHIT">
<span class='line'>604</span> </span><span class="NAME">CeL.simplify_path</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">path</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>605</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">path</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>606</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><span class="NAME">j</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">is_absolute</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">head</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>607</span>
<span class='line'>608</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT">
<span class='line'>609</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/^[\w\d\-]+:\/\//</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">$0</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">head</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>610</span> </span><span class="WHIT"> </span><span class="COMM">//.replace(/\s+$|^\s+/g,'')</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT"> </span><span class="COMM">//.replace(/\/\/+/g,'/')</span><span class="WHIT">
<span class='line'>612</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>613</span>
<span class='line'>614</span> </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 class='line'>615</span> </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">path.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>616</span> </span><span class="WHIT"> </span><span class="NAME">is_absolute</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>617</span>
<span class='line'>618</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">l</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</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 class='line'>620</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</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 class='line'>621</span>
<span class='line'>622</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">path</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'..'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">></span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">[</span><span class="PUNC">--</span><span class="NAME">j</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">[</span><span class="NAME">j</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 class='line'>626</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">[</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">path</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</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="COMM">// 相消</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>630</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>631</span>
<span class='line'>632</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">is_absolute</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</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 class='line'>634</span>
<span class='line'>635</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path.join</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>636</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\/\/+/g</span><span class="PUNC">,</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="NAME">is_absolute</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="REGX">/^(\/\.\.)+/g</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="REGX">/^(\.\/)+/g</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>638</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>639</span>
<span class='line'>640</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>641</span> </span><span class="WHIT"> </span><span class="NAME">path</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 class='line'>642</span>
<span class='line'>643</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">head</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>644</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">head</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>645</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>646</span>
<span class='line'>647</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>648</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>649</span>
<span class='line'>650</span>
<span class='line'>651</span>
<span class='line'>652</span>
<span class='line'>653</span>
<span class='line'>654</span> </span><span class="COMM">/**
<span class='line'>655</span> * 已經 include 之函式或 class
<span class='line'>656</span> * @inner
<span class='line'>657</span> * @ignore
<span class='line'>658</span> */</span><span class="WHIT">
<span class='line'>659</span> </span><span class="NAME">loaded_module</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>660</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>661</span>
<span class='line'>662</span> </span><span class="COMM">/**
<span class='line'>663</span> * Include specified module&lt;br/>
<span class='line'>664</span> * 注意:以下的 code 中CeL.warn 不一定會被執行(可能會、可能不會),因為執行時 code.log 尚未被 include。&lt;br/>
<span class='line'>665</span> * 此時應該改用 CeL.use('code.log', callback);&lt;br/>
<span class='line'>666</span> * code in head/script/:
<span class='line'>667</span> * &lt;pre>
<span class='line'>668</span> * CeL.use('code.log');
<span class='line'>669</span> * CeL.warn('a WARNING');
<span class='line'>670</span> * &lt;/pre>
<span class='line'>671</span> * ** 在指定 callback 時 namespace 無效!
<span class='line'>672</span> * @param {String} module module name
<span class='line'>673</span> * @param {Function} [callback] callback function
<span class='line'>674</span> * @param {Object, Boolean} [extend_to] extend to which namespace&lt;br/>
<span class='line'>675</span> * false: just load, don't extend to CeL&lt;br/>
<span class='line'>676</span> * this: extend to global&lt;br/>
<span class='line'>677</span> * object: extend to specified namespace that you can use [namespace]._func_ to run it&lt;br/>
<span class='line'>678</span> * (others, including undefined): extend to root of this library. e.g., call CeL._function_name_ and we can get the specified function.
<span class='line'>679</span> * @return error object or null(no error, OK)
<span class='line'>680</span> * @example
<span class='line'>681</span> * CeL.use('code.log', function(){..});
<span class='line'>682</span> * CeL.use(['code.log', 'code.debug']);
<span class='line'>683</span> */</span><span class="WHIT">
<span class='line'>684</span> </span><span class="NAME">CeL.use</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">module</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">extend_to</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>685</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><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">module_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>686</span>
<span class='line'>687</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">module</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>689</span>
<span class='line'>690</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>691</span> if (arguments.length > 3) {
<span class='line'>692</span> l = arguments.length;
<span class='line'>693</span> namespace = arguments[--l];
<span class='line'>694</span> callback = arguments[--l];
<span class='line'>695</span> --l;
<span class='line'>696</span> for (i = 0; i &lt; l; i++)
<span class='line'>697</span> this.use(arguments[i], callback, namespace);
<span class='line'>698</span> return;
<span class='line'>699</span> }
<span class='line'>700</span> */</span><span class="WHIT">
<span class='line'>701</span>
<span class='line'>702</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">module</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="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>703</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">error</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>704</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</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="PUNC">=</span><span class="NAME">module.length</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'>705</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">error</span><span class="PUNC">=</span><span class="NAME">this.use</span><span class="PUNC">(</span><span class="NAME">module</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">extend_to</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">error</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>708</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>709</span>
<span class='line'>710</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="NAME">module_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.get_module_path</span><span class="PUNC">(</span><span class="NAME">module</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.is_loaded</span><span class="PUNC">(</span><span class="NAME">module</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>711</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>712</span>
<span class='line'>713</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(this.Class+'.use ['+module+']:\ntry to load ['+module_path+'].');</span><span class="WHIT">
<span class='line'>714</span>
<span class='line'>715</span> </span><span class="WHIT"> </span><span class="COMM">// including code</span><span class="WHIT">
<span class='line'>716</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'>717</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</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">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: 在指定 callback 時使 namespace 依然有效。</span><span class="WHIT">
<span class='line'>719</span> </span><span class="WHIT"> </span><span class="NAME">this.include_resource</span><span class="PUNC">(</span><span class="NAME">module_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>720</span> </span><span class="WHIT"> </span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">module</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT"> </span><span class="NAME">global</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>725</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'>726</span> </span><span class="WHIT"> </span><span class="COMM">// this.log('load ['+module_path+']'),</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT"> </span><span class="COMM">// this.log('load</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT"> </span><span class="COMM">// ['+module_path+']:\n'+this.get_file(module_path,</span><span class="WHIT">
<span class='line'>729</span> </span><span class="WHIT"> </span><span class="COMM">// this.env.source_encoding)),</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT"> </span><span class="NAME">this.eval</span><span class="PUNC">(</span><span class="NAME">this.get_file</span><span class="PUNC">(</span><span class="NAME">module_path</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT"> </span><span class="NAME">this.env.source_encoding</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>732</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'>733</span> </span><span class="WHIT"> </span><span class="COMM">// http://www.w3.org/TR/DOM-Level-2-Core/ecma-script-binding.html</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT"> </span><span class="COMM">// http://reference.sitepoint.com/javascript/DOMException</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.constructor</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'[object DOMException]'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">e.code</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1012</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT"> </span><span class="NAME">this.log</span><span class="PUNC">(</span><span class="NAME">this.Class</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.use:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.message</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">module_path</span><span class="WHIT">
<span class='line'>738</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n\n程式可能呼叫了一個不存在的或是繞經上層目錄的檔案\n請嘗試使用相對路徑或 '</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.Class</span><span class="WHIT">
<span class='line'>740</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.use(module, callback function, namespace)'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>741</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">e</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">)</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="PUNC">{</span><span class="WHIT">
<span class='line'>742</span> </span><span class="WHIT"> </span><span class="NAME">this.log</span><span class="PUNC">(</span><span class="NAME">this.Class</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.use: 檔案可能不存在?\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">module_path</span><span class="WHIT">
<span class='line'>743</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>744</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'>745</span> </span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">log</span><span class="PUNC">(</span><span class="NAME">this.Class</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.use: Cannot load ['</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">module</span><span class="WHIT">
<span class='line'>749</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']!\n['</span><span class="WHIT">
<span class='line'>750</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.constructor</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>751</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] '</span><span class="WHIT">
<span class='line'>752</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">e.code</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>753</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">': '</span><span class="WHIT">
<span class='line'>754</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.message</span><span class="WHIT">
<span class='line'>755</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n抱歉在載入其他網頁時發生錯誤有些功能可能失常。\n重新讀取(reload),或是過段時間再嘗試或許可以解決問題。'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>756</span> </span><span class="WHIT"> </span><span class="COMM">//this.log('Cannot load [' + module + ']!', this.log.ERROR, e);</span><span class="WHIT">
<span class='line'>757</span>
<span class='line'>758</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>759</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>760</span>
<span class='line'>761</span>
<span class='line'>762</span> </span><span class="WHIT"> </span><span class="COMM">// 處理 extend to namespace</span><span class="WHIT">
<span class='line'>763</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">extend_to</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">extend_to</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT">
<span class='line'>764</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">namespace</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT">
<span class='line'>765</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">extend_to</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'>766</span> </span><span class="WHIT"> </span><span class="NAME">extend_to</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'>767</span>
<span class='line'>768</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">extend_to</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.get_module</span><span class="PUNC">(</span><span class="NAME">module</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">kw</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.env.not_to_extend_keyword</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">no_extend</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT"> </span><span class="COMM">// this.log(this.Class + '.use [' + module + ']:\nextend\n' + ns);</span><span class="WHIT">
<span class='line'>771</span>
<span class='line'>772</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">kw</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>773</span> </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">ns</span><span class="PUNC">[</span><span class="NAME">kw</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>774</span> </span><span class="WHIT"> </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">l</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT"> </span><span class="NAME">no_extend</span><span class="PUNC">[</span><span class="NAME">l</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</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="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">l</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT"> </span><span class="NAME">no_extend</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</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="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT"> </span><span class="NAME">no_extend</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'>781</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT"> </span><span class="NAME">no_extend</span><span class="PUNC">[</span><span class="NAME">kw</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>784</span>
<span class='line'>785</span> </span><span class="WHIT"> </span><span class="COMM">// '*': 完全不 extend</span><span class="WHIT">
<span class='line'>786</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">no_extend</span><span class="PUNC">[</span><span class="STRN">'*'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>787</span> </span><span class="WHIT"> </span><span class="NAME">no_extend.Class</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>788</span> </span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>789</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">ns</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>790</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="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">no_extend</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>791</span> </span><span class="WHIT"> </span><span class="NAME">l.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'>792</span>
<span class='line'>793</span> </span><span class="WHIT"> </span><span class="COMM">//this.log(this.Class + '.use [' + module + ']:\nextend\n' + l + '\n\nto:\n' + (extend_to.Class || extend_to));</span><span class="WHIT">
<span class='line'>794</span> </span><span class="WHIT"> </span><span class="NAME">this.extend</span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">extend_to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>795</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>796</span>
<span class='line'>797</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>798</span>
<span class='line'>799</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>800</span>
<span class='line'>801</span>
<span class='line'>802</span> </span><span class="COMM">/*
<span class='line'>803</span> bad: sometimes doesn't work. e.g. Google Maps API in IE
<span class='line'>804</span> push inside window.onload:
<span class='line'>805</span> window.onload=function(){
<span class='line'>806</span> include_resource(p);
<span class='line'>807</span> setTimeout('init();',2000);
<span class='line'>808</span> };
<span class='line'>809</span>
<span class='line'>810</span> way 3: ref. dojo.provide();, dojo.require();
<span class='line'>811</span> document.write('&lt;script type="text/javascript" src="'+encodeURI(p)+'">&lt;\/script>');
<span class='line'>812</span>
<span class='line'>813</span> TODO:
<span class='line'>814</span> encode
<span class='line'>815</span>
<span class='line'>816</span> */</span><span class="WHIT">
<span class='line'>817</span> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>818</span> </span><span class="COMM">/**
<span class='line'>819</span> * include other JavaScript/CSS files
<span class='line'>820</span> * @param {String} resource path
<span class='line'>821</span> * @param {Function, Object} callback callback function / {callback: callback function, module: module name, global: global object when run callback}
<span class='line'>822</span> * @param {Boolean} [use_write] use document.write() instead of insert a element
<span class='line'>823</span> * @param {Boolean} [is_css] is a .css file
<span class='line'>824</span> */</span><span class="WHIT">
<span class='line'>825</span> </span><span class="NAME">CeL.include_resource</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">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">use_write</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">is_css</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>826</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">arguments.callee</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>827</span> </span><span class="WHIT"> </span><span class="COMM">//if(!_f.loaded)_f.loaded={},_f.count=0;</span><span class="WHIT">
<span class='line'>828</span>
<span class='line'>829</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">path</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="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</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">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>831</span> </span><span class="WHIT"> </span><span class="NAME">_f</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">[</span><span class="NAME">s</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">use_write</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">is_css</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>832</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>833</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>834</span>
<span class='line'>835</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">path</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">_s.loaded</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>836</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>837</span>
<span class='line'>838</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">c</span><span class="PUNC">===</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT"> </span><span class="NAME">is_css</span><span class="PUNC">=</span><span class="REGX">/\.css$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>840</span>
<span class='line'>841</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="STRN">'text/'</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">is_css</span><span class="PUNC">?</span><span class="STRN">'css'</span><span class="PUNC">:</span><span class="STRN">'javascript'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>842</span> </span><span class="COMM">/*@cc_on
<span class='line'>843</span> w=1; // IE hack
<span class='line'>844</span> @*/</span><span class="WHIT">
<span class='line'>845</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">use_write</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>846</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'>847</span> </span><span class="WHIT"> </span><span class="COMM">// Dynamic Loading</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT"> </span><span class="COMM">// http://code.google.com/apis/ajax/documentation/#Dynamic</span><span class="WHIT">
<span class='line'>849</span> </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">document.createElement</span><span class="PUNC">(</span><span class="NAME">is_css</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'link'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'script'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>850</span> </span><span class="WHIT"> </span><span class="NAME">s.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>851</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">is_css</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>852</span> </span><span class="WHIT"> </span><span class="NAME">s.href</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s.rel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'stylesheet'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT"> </span><span class="NAME">s.src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>855</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">'head'</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">document.body.parentNode</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">appendChild</span><span class="PUNC">(</span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">'head'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">appendChild</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT"> </span><span class="COMM">//this.log('include_resource: HTML:\n' + document.getElementsByTagName('html')[0].innerHTML);</span><span class="WHIT">
<span class='line'>859</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'>860</span> </span><span class="WHIT"> </span><span class="NAME">use_write</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>862</span>
<span class='line'>863</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">use_write</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>864</span> </span><span class="WHIT"> </span><span class="NAME">document.write</span><span class="PUNC">(</span><span class="NAME">is_css</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'&lt;link type="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT">
<span class='line'>865</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'" rel="stylesheet" href="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'">&lt;\/link>'</span><span class="WHIT">
<span class='line'>866</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;script type="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'" src="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT">
<span class='line'>867</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'">&lt;\/script>'</span><span class="WHIT"> </span><span class="COMM">// language="JScript"</span><span class="WHIT">
<span class='line'>868</span> </span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>869</span>
<span class='line'>870</span> </span><span class="WHIT"> </span><span class="NAME">_s.loaded</span><span class="PUNC">[</span><span class="NAME">path</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s.count</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>871</span>
<span class='line'>872</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>873</span> </span><span class="WHIT"> </span><span class="NAME">_s.wait_to_call</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>874</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>875</span>
<span class='line'>876</span> </span><span class="COMM">/**
<span class='line'>877</span> * 已經 include_resource 了哪些 JavaScript 檔(存有其路徑)
<span class='line'>878</span> * loaded{路徑} = count
<span class='line'>879</span> */</span><span class="WHIT">
<span class='line'>880</span> </span><span class="NAME">CeL.include_resource.loaded</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>881</span>
<span class='line'>882</span> </span><span class="COMM">/**
<span class='line'>883</span> * 已經 include_resource 了多少個 JavaScript 檔
<span class='line'>884</span> * @type Number
<span class='line'>885</span> */</span><span class="WHIT">
<span class='line'>886</span> </span><span class="NAME">CeL.include_resource.count</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'>887</span>
<span class='line'>888</span> </span><span class="NAME">CeL.include_resource.wait_to_call</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">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT"> </span><span class="COMM">//alert('include_resource.wait_to_call:\n' + CeL.to_module_name(callback.module));</span><span class="WHIT">
<span class='line'>890</span>
<span class='line'>891</span> </span><span class="WHIT"> </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">callback</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'>892</span> </span><span class="WHIT"> </span><span class="COMM">// 不是 module僅僅為指定 function 的話,直接等一下再看看。</span><span class="WHIT">
<span class='line'>893</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: 等太久時 error handle</span><span class="WHIT">
<span class='line'>894</span> </span><span class="WHIT"> </span><span class="NAME">window.setTimeout</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">200</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>895</span>
<span class='line'>896</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback.global.is_loaded</span><span class="PUNC">(</span><span class="NAME">callback.module</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>897</span> </span><span class="WHIT"> </span><span class="NAME">callback.callback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>898</span>
<span class='line'>899</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>900</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>901</span> * the function it self, not 'this'.
<span class='line'>902</span> * @inner
<span class='line'>903</span> * @ignore
<span class='line'>904</span> */</span><span class="WHIT">
<span class='line'>905</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">arguments.callee</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>906</span> </span><span class="WHIT"> </span><span class="NAME">window.setTimeout</span><span class="PUNC">(</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'>907</span> </span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>908</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>909</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>910</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>911</span>
<span class='line'>912</span> </span><span class="NAME">CeL.get_module</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">module_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.split_module_name</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>914</span>
<span class='line'>915</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: test module_name.length</span><span class="WHIT">
<span class='line'>916</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>917</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>918</span>
<span class='line'>919</span> </span><span class="WHIT"> </span><span class="KEYW">var</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">module_name.length</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">namespace</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'>920</span> </span><span class="WHIT"> </span><span class="COMM">// 一層一層 call namespace</span><span class="WHIT">
<span class='line'>921</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</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 class='line'>922</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'>923</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">module_name</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>924</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'>925</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>926</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>927</span>
<span class='line'>928</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>929</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>930</span>
<span class='line'>931</span> </span><span class="COMM">/**
<span class='line'>932</span> * 預先準備好下層 module 定義時的環境。&lt;br/>
<span class='line'>933</span> * 請盡量先 call 上層 namespace 再定義下層的。
<span class='line'>934</span> * @param {String} module_name module name
<span class='line'>935</span> * @param {Function} code_for_including 若欲 include 整個 module 時,需囊括之 code。
<span class='line'>936</span> * @return null invalid module
<span class='line'>937</span> * @return {Object} 下層 module 之 namespace
<span class='line'>938</span> */</span><span class="WHIT">
<span class='line'>939</span> </span><span class="NAME">CeL.setup_module</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">module_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.split_module_name</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>941</span>
<span class='line'>942</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: test module_name.length</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>944</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>945</span>
<span class='line'>946</span> </span><span class="WHIT"> </span><span class="KEYW">var</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">module_name.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">namespace</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">name</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>947</span> </span><span class="WHIT"> </span><span class="COMM">// 一層一層準備好 namespace</span><span class="WHIT">
<span class='line'>948</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><span class="PUNC">{</span><span class="WHIT">
<span class='line'>949</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">namespace</span><span class="PUNC">[</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>950</span> </span><span class="WHIT"> </span><span class="NAME">namespace</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><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Function</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>951</span> </span><span class="WHIT"> </span><span class="STRN">'// module namespace of '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>952</span> </span><span class="WHIT"> </span><span class="NAME">this.to_module_name</span><span class="PUNC">(</span><span class="NAME">module_name.slice</span><span class="PUNC">(</span><span class="NUMB">0</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">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>953</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>954</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>955</span> </span><span class="WHIT"> </span><span class="COMM">// namespace 這時是 modele 的 parent modele。</span><span class="WHIT">
<span class='line'>956</span>
<span class='line'>957</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>958</span> </span><span class="WHIT"> </span><span class="COMM">// 尚未被定義或宣告過</span><span class="WHIT">
<span class='line'>959</span> </span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="PUNC">[</span><span class="NAME">l</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT"> </span><span class="COMM">// 可能是之前簡單定義過,例如被上面處理過。這時重新定義,並把原先的 member 搬過來。</span><span class="WHIT">
<span class='line'>961</span> </span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">Class</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>962</span>
<span class='line'>963</span> </span><span class="WHIT"> </span><span class="COMM">// 保留原先的 namespacefor 重新定義</span><span class="WHIT">
<span class='line'>964</span> </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">namespace</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>965</span>
<span class='line'>966</span> </span><span class="WHIT"> </span><span class="COMM">// extend code, 起始 namespace</span><span class="WHIT">
<span class='line'>967</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: code_for_including(this, load_arguments)</span><span class="WHIT">
<span class='line'>968</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">namespace</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><span class="NAME">code_for_including</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>969</span>
<span class='line'>970</span> </span><span class="WHIT"> </span><span class="COMM">// 把原先的 member 搬過來</span><span class="WHIT">
<span class='line'>971</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>972</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">l.Class</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>973</span> </span><span class="WHIT"> </span><span class="COMM">// may use: this.extend() </span><span class="WHIT">
<span class='line'>974</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">l</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>975</span> </span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</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">l</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>976</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>977</span> </span><span class="WHIT"> </span><span class="NAME">namespace.Class</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.to_module_name</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>978</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>979</span>
<span class='line'>980</span> </span><span class="COMM">/*
<span class='line'>981</span> l=[];
<span class='line'>982</span> for(i in namespace)
<span class='line'>983</span> l.push(i);
<span class='line'>984</span> WScript.Echo('Get members:\n'+l.join(', '));
<span class='line'>985</span> */</span><span class="WHIT">
<span class='line'>986</span>
<span class='line'>987</span> </span><span class="WHIT"> </span><span class="NAME">this.set_loaded</span><span class="PUNC">(</span><span class="NAME">namespace.Class</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>988</span>
<span class='line'>989</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>990</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>991</span>
<span class='line'>992</span>
<span class='line'>993</span> </span><span class="COMM">// 並沒有對 module 做完善的審核!</span><span class="WHIT">
<span class='line'>994</span> </span><span class="NAME">CeL.split_module_name</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">module_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>995</span> </span><span class="WHIT"> </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">module_name</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>996</span> </span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">module_name.replace</span><span class="PUNC">(</span><span class="REGX">/\.\.+|\\\\+|\/\/+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="REGX">/\.|\\|\/|::/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>997</span>
<span class='line'>998</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">module_name</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="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT"> </span><span class="COMM">// 去除 library name</span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">module_name.length</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">this.Class</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT"> </span><span class="NAME">module_name.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1003</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'>1004</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1006</span>
<span class='line'>1007</span>
<span class='line'>1008</span> </span><span class="NAME">CeL.to_module_name</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">module</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">separator</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="WHIT"> </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">module</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'>1010</span> </span><span class="WHIT"> </span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">module.Class</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1011</span>
<span class='line'>1012</span> </span><span class="WHIT"> </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">module</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1013</span> </span><span class="WHIT"> </span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.split_module_name</span><span class="PUNC">(</span><span class="NAME">module</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1014</span>
<span class='line'>1015</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</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 class='line'>1016</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">module</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="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1017</span> </span><span class="WHIT"> </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">separator</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT"> </span><span class="NAME">separator</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.env.module_name_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1019</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">module</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">this.Class</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1020</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.Class</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1021</span> </span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">module.join</span><span class="PUNC">(</span><span class="NAME">separator</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1022</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1023</span>
<span class='line'>1024</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1025</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1026</span>
<span class='line'>1027</span> </span><span class="COMM">// TODO</span><span class="WHIT">
<span class='line'>1028</span> </span><span class="NAME">CeL.unload</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">module</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1029</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1030</span>
<span class='line'>1031</span>
<span class='line'>1032</span> </span><span class="COMM">/**
<span class='line'>1033</span> * 判斷 module 是否存在,以及是否破損。
<span class='line'>1034</span> * @param {String} module_name module name
<span class='line'>1035</span> * @return {Boolean} module 是否存在以及良好。
<span class='line'>1036</span> */</span><span class="WHIT">
<span class='line'>1037</span> </span><span class="NAME">CeL.is_loaded</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">module_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1038</span> </span><span class="WHIT"> </span><span class="COMM">// var _s = arguments.callee;</span><span class="WHIT">
<span class='line'>1039</span> </span><span class="WHIT"> </span><span class="COMM">//this.log('is_loaded: test ' + this.to_module_name(module_name));</span><span class="WHIT">
<span class='line'>1040</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">loaded_module</span><span class="PUNC">[</span><span class="NAME">this.to_module_name</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>1041</span> </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'>1042</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1043</span>
<span class='line'>1044</span>
<span class='line'>1045</span>
<span class='line'>1046</span> </span><span class="NAME">CeL.set_loaded</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">module_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT"> </span><span class="COMM">//this.log('set_loaded: ' + this.to_module_name(module_name));</span><span class="WHIT">
<span class='line'>1048</span> </span><span class="WHIT"> </span><span class="NAME">loaded_module</span><span class="PUNC">[</span><span class="NAME">this.to_module_name</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1049</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1050</span>
<span class='line'>1051</span>
<span class='line'>1052</span>
<span class='line'>1053</span> </span><span class="COMM">// initial</span><span class="WHIT">
<span class='line'>1054</span>
<span class='line'>1055</span> </span><span class="COMM">//temporary decoration incase we call for nothing</span><span class="WHIT">
<span class='line'>1056</span> </span><span class="NAME">CeL.log</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1057</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">debug</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1058</span> </span><span class="WHIT"> </span><span class="COMM">//arguments.callee.function_to_call.apply(null,arguments);</span><span class="WHIT">
<span class='line'>1059</span> </span><span class="WHIT"> </span><span class="NAME">arguments.callee.function_to_call.apply</span><span class="PUNC">(</span><span class="NAME">global</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1060</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1061</span>
<span class='line'>1062</span>
<span class='line'>1063</span> </span><span class="NAME">CeL.log.function_to_call</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>1064</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">JSalert</span><span class="PUNC">===</span><span class="STRN">'function'</span><span class="PUNC">?</span><span class="NAME">JSalert</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1065</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="PUNC">===</span><span class="STRN">'object'</span><span class="PUNC">?</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">m</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">+</span><span class="NAME">m</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">m.length</span><span class="PUNC">></span><span class="NUMB">2000</span><span class="PUNC">)</span><span class="NAME">m</span><span class="PUNC">=</span><span class="NAME">m.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">'\n\n..\n\n'</span><span class="PUNC">+</span><span class="NAME">m.slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">WScript.Echo</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1066</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">===</span><span class="STRN">'object'</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">alert</span><span class="PUNC">===</span><span class="STRN">'function'</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">m</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">+</span><span class="NAME">m</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">m.length</span><span class="PUNC">></span><span class="NUMB">2000</span><span class="PUNC">)</span><span class="NAME">m</span><span class="PUNC">=</span><span class="NAME">m.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">'\n\n..\n\n'</span><span class="PUNC">+</span><span class="NAME">m.slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1067</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1068</span>
<span class='line'>1069</span> </span><span class="NAME">CeL.initial_env</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1070</span>
<span class='line'>1071</span>
<span class='line'>1072</span> </span><span class="COMM">/*
<span class='line'>1073</span> var test_obj=CeL(2,'test: initial');
<span class='line'>1074</span>
<span class='line'>1075</span> test_obj.test_print('OK!');
<span class='line'>1076</span> */</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1078</span>
<span class='line'>1079</span>
<span class='line'>1080</span>
<span class='line'>1081</span> </span><span class="COMM">//setTool(),oldVadapter(); // 當用此檔debug時請執行此行</span><span class="WHIT">
<span class='line'>1082</span> </span><span class="COMM">//alert(ScriptEngine()+' '+ScriptEngineMajorVersion()+'.'+ScriptEngineMinorVersion()+'.'+ScriptEngineBuildVersion());</span><span class="WHIT">
<span class='line'>1083</span>
<span class='line'>1084</span>
<span class='line'>1085</span>
<span class='line'>1086</span> </span><span class="COMM">/* initialization of function.js
<span class='line'>1087</span> 僅僅執行此檔時欲執行的程序。
<span class='line'>1088</span>
<span class='line'>1089</span> setTool(),oldVadapter(); // 當用此檔debug時請執行此行
<span class='line'>1090</span>
<span class='line'>1091</span> 利用.js加上此段與init(),以及.hta&lt;script type="text/javascript" src="~.js">&lt;/script>可造出GUI/none GUI兩種可選擇之介面。
<span class='line'>1092</span> if(typeof args=='object')init();else window.onload=init;
<span class='line'>1093</span> */</span><span class="WHIT">
<span class='line'>1094</span> </span><span class="COMM">//args=args.concat(['turnCode.js']);</span><span class="WHIT">
<span class='line'>1095</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_library_onload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1096</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">_library_onload</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1097</span> </span><span class="WHIT"> </span><span class="NAME">_library_onload</span><span class="WHIT"> </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'>1098</span> </span><span class="WHIT"> </span><span class="COMM">//WScript.Echo(CeL.env.ScriptName);</span><span class="WHIT">
<span class='line'>1099</span> </span><span class="WHIT"> </span><span class="COMM">//CeL.log(CeL.env.ScriptName);</span><span class="WHIT">
<span class='line'>1100</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">CeL.env.ScriptName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'ce'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1101</span> </span><span class="WHIT"> </span><span class="COMM">//WScript.Echo(CeL.env.ScriptName);</span><span class="WHIT">
<span class='line'>1102</span> </span><span class="WHIT"> </span><span class="NAME">CeL.use</span><span class="PUNC">(</span><span class="STRN">'OS.Windows.registry'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1103</span> </span><span class="WHIT"> </span><span class="COMM">//CeL.log(CeL.registryF);</span><span class="WHIT">
<span class='line'>1104</span>
<span class='line'>1105</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CeL.registryF.getValue</span><span class="PUNC">(</span><span class="NAME">CeL._iF.p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'(null)'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_p</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">CeL.env.library_base_path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="PUNC">(</span><span class="STRN">'Change path of ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">CeL.env.ScriptName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] from:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n to\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">CeL.env.library_base_path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">CeL._iF.p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT"> </span><span class="NAME">CeL.registryF.setValue.cid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1110</span> </span><span class="WHIT"> </span><span class="NAME">CeL.registryF.setValue</span><span class="PUNC">(</span><span class="NAME">CeL._iF.p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">CeL.env.library_base_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT"> </span><span class="NAME">CeL.registryF.setValue.cid</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'>1112</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1113</span>
<span class='line'>1114</span> </span><span class="WHIT"> </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">args</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="COMM">// args instanceof Array</span><span class="WHIT">
<span class='line'>1115</span> </span><span class="WHIT"> </span><span class="COMM">// getEnvironment();</span><span class="WHIT">
<span class='line'>1116</span> </span><span class="WHIT"> </span><span class="COMM">// alert('Get arguments ['+args.length+']\n'+args.join('\n'));</span><span class="WHIT">
<span class='line'>1117</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">args.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1118</span> </span><span class="WHIT"> </span><span class="KEYW">var</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">p</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">enc</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">backupDir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dBasePath</span><span class="PUNC">(</span><span class="STRN">'kanashimi\\www\\cgi-bin\\program\\log\\'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1119</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">fso.FolderExists</span><span class="PUNC">(</span><span class="NAME">backupDir</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1120</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'>1121</span> </span><span class="WHIT"> </span><span class="NAME">fso.CreateFolder</span><span class="PUNC">(</span><span class="NAME">backupDir</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1122</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'>1123</span> </span><span class="WHIT"> </span><span class="NAME">backupDir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dBasePath</span><span class="PUNC">(</span><span class="STRN">'kanashimi\\www\\cgi-bin\\game\\log\\'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1124</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1125</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">fso.FolderExists</span><span class="PUNC">(</span><span class="NAME">backupDir</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1126</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'>1127</span> </span><span class="WHIT"> </span><span class="NAME">fso.CreateFolder</span><span class="PUNC">(</span><span class="NAME">backupDir</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1128</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'>1129</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1130</span> </span><span class="WHIT"> </span><span class="STRN">'無法建立備份資料夾['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">backupDir</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']\n接下來的操作將不會備份'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1131</span> </span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</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'>1132</span> </span><span class="WHIT"> </span><span class="NAME">WScript.Quit</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="WHIT"> </span><span class="NAME">backupDir</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 class='line'>1134</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1135</span> </span><span class="WHIT"> </span><span class="COMM">// addCode.report=true; // 是否加入報告</span><span class="WHIT">
<span class='line'>1136</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">args.length</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'>1137</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">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dealShortcut</span><span class="PUNC">(</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="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1138</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/\.(js|vbs|hta|s?html?|txt|wsf|pac)$/i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1139</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">isFile</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1140</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1141</span> </span><span class="WHIT"> </span><span class="STRN">'是否以預設編碼['</span><span class="WHIT">
<span class='line'>1142</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">enc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</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">simpleFileDformat</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="WHIT">
<span class='line'>1143</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">enc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']處理下面檔案?\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1144</span> </span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1145</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1146</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1147</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1148</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">backupDir</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1149</span> </span><span class="WHIT"> </span><span class="NAME">fso.CopyFile</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">backupDir</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">getFN</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1150</span> </span><span class="WHIT"> </span><span class="NAME">addCode</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1151</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1152</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1153</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</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">alert</span><span class="PUNC">(</span><span class="STRN">'We will generate a reduced ['</span><span class="WHIT">
<span class='line'>1154</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">CeL.env.ScriptName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']\n to ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">CeL.env.ScriptName</span><span class="WHIT">
<span class='line'>1155</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.reduced.js].\nBut it takes several time.'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1156</span> </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">32</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1157</span> </span><span class="WHIT"> </span><span class="NAME">reduceScript</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">CeL.env.ScriptName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'.reduced.js'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1158</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">//else window.onload=init;</span><span class="WHIT">
<span class='line'>1159</span>
<span class='line'>1160</span> </span><span class="WHIT"> </span><span class="COMM">//CeL._iF=undefined;</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// if(1&&CeL.env.ScriptName==='function'){</span><span class="WHIT">
<span class='line'>1162</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// _library_onload</span><span class="WHIT">
<span class='line'>1163</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1164</span>
<span class='line'>1165</span>
<span class='line'>1166</span>
<span class='line'>1167</span> </span><span class="COMM">/*
<span class='line'>1168</span>
<span class='line'>1169</span> // test WinShell http://msdn.microsoft.com/en-us/library/bb787810(VS.85).aspx
<span class='line'>1170</span> if (0) {
<span class='line'>1171</span> alert(WinShell.Windows().Item(0).FullName);
<span class='line'>1172</span>
<span class='line'>1173</span> var i, cmd, t = '', objFolder = WinShell.NameSpace(0xa), objFolderItem = objFolder
<span class='line'>1174</span> .Items().Item(), colVerbs = objFolderItem.Verbs(); // 假如出意外objFolder==null
<span class='line'>1175</span> for (i = 0; i &lt; colVerbs.Count; i++) {
<span class='line'>1176</span> t += colVerbs.Item(i) + '\n';
<span class='line'>1177</span> if (('' + colVerbs.Item(i)).indexOf('&R') != -1)
<span class='line'>1178</span> cmd = colVerbs.Item(i);
<span class='line'>1179</span> }
<span class='line'>1180</span> objFolderItem.InvokeVerb('' + cmd);
<span class='line'>1181</span> alert('Commands:\n' + t);
<span class='line'>1182</span>
<span class='line'>1183</span> // objShell.NameSpace(FolderFrom).CopyHere(FolderTo,0); // copy folder
<span class='line'>1184</span> // objFolderItem=objShell.NameSpace(FolderFrom).ParseName("clock.avi");objFolderItem.Items().Item().InvokeVerb([動作]);
<span class='line'>1185</span> // objShell.NameSpace(FolderFromPath).Items.Item(mName).InvokeVerb();
<span class='line'>1186</span>
<span class='line'>1187</span> // Sets or gets the date and time that a file was last modified.
<span class='line'>1188</span> // http://msdn.microsoft.com/en-us/library/bb787825(VS.85).aspx
<span class='line'>1189</span> // objFolderItem.ModifyDate = "01/01/1900 6:05:00 PM";
<span class='line'>1190</span> // objShell.NameSpace("C:\Temp").ParseName("Test.Txt").ModifyDate =
<span class='line'>1191</span> // DateAdd("d", -1, Now()) CDate("19 October 2007")
<span class='line'>1192</span>
<span class='line'>1193</span> // Touch displays or sets the created, access, and modified times of one or
<span class='line'>1194</span> // more files. http://www.stevemiller.net/apps/
<span class='line'>1195</span> }
<span class='line'>1196</span>
<span class='line'>1197</span> // 測試可寫入的字元:0-128,最好用1-127因為許多編輯器會將\0轉成' '\128又不確定
<span class='line'>1198</span> if (0) {
<span class='line'>1199</span> var t = '', f = 'try.js', i = 0;
<span class='line'>1200</span> for (; i &lt; 128; i++)
<span class='line'>1201</span> t += String.fromCharCode(i);
<span class='line'>1202</span> if (simpleWrite(f, t))
<span class='line'>1203</span> alert('Write error!\n有此local無法相容的字元?');
<span class='line'>1204</span> else if (simpleRead(f) != t)
<span class='line'>1205</span> alert('內容不同!');
<span class='line'>1206</span> else if (simpleWrite(f, dQuote(t) + ';'))
<span class='line'>1207</span> alert('Write error 2!\n有此local無法相容的字元?');
<span class='line'>1208</span> else if (eval(simpleRead(f)) != t)
<span class='line'>1209</span> alert('eval內容不同!');
<span class='line'>1210</span> else
<span class='line'>1211</span> alert('OK!');
<span class='line'>1212</span> }
<span class='line'>1213</span> */</span><span class="WHIT">
<span class='line'>1214</span>
<span class='line'>1215</span>
<span class='line'>1216</span> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_library_onload</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT"> </span><span class="NAME">_library_onload</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1218</span>
<span class='line'>1219</span>
<span class='line'>1220</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// (function(){</span><span class="WHIT">
<span class='line'>1221</span> </span><span class="COMM">//) // void(</span><span class="WHIT">
<span class='line'>1222</span> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1223</span>
<span class='line'>1224</span>
<span class='line'>1225</span> </span><span class="COMM">//}catch(e){WScript.Echo('There are some error in function.js!\n'+e.message);throw e;}</span><span class="WHIT">
<span class='line'>1226</span>
<span class='line'>1227</span>
<span class='line'>1228</span>
<span class='line'>1229</span>
<span class='line'>1230</span>
<span class='line'>1231</span> </span><span class="COMM">//CeL.use('code.log');</span><span class="WHIT">
<span class='line'>1232</span> </span><span class="COMM">//CeL.warn('test_print: ' + CeL.code.log.Class);</span><span class="WHIT">
<span class='line'>1233</span>
<span class='line'>1234</span> </span><span class="COMM">//]]></span><span class="WHIT">
<span class='line'>1235</span>
<span class='line'>1236</span>
<span class='line'>1237</span>
<span class='line'>1238</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="PUNC">{</span><span class="WHIT">
<span class='line'>1239</span>
<span class='line'>1240</span> </span><span class="COMM">/**
<span class='line'>1241</span> * 本 module 之 name(id)&lt;span style="text-decoration:line-through;">不設定時會從呼叫時之 path 取得&lt;/span>。
<span class='line'>1242</span> * @type String
<span class='line'>1243</span> * @constant
<span class='line'>1244</span> * @inner
<span class='line'>1245</span> * @ignore
<span class='line'>1246</span> */</span><span class="WHIT">
<span class='line'>1247</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'IO.Windows.file'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1248</span>
<span class='line'>1249</span> </span><span class="COMM">//===================================================</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="COMM">/**
<span class='line'>1251</span> * 若欲 include 整個 module 時,需囊括之 code。
<span class='line'>1252</span> * @type Function
<span class='line'>1253</span> * @param {Function} library_namespace namespace of library
<span class='line'>1254</span> * @param load_arguments 呼叫時之 argument(s)
<span class='line'>1255</span> * @return
<span class='line'>1256</span> * @name CeL.IO.Windows.file
<span class='line'>1257</span> * @constant
<span class='line'>1258</span> * @inner
<span class='line'>1259</span> * @ignore
<span class='line'>1260</span> */</span><span class="WHIT">
<span class='line'>1261</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">code_for_including</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">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'>1262</span>
<span class='line'>1263</span>
<span class='line'>1264</span> </span><span class="COMM">/**
<span class='line'>1265</span> * null module constructor
<span class='line'>1266</span> * @class Windows 下,檔案操作相關之 function。
<span class='line'>1267</span> */</span><span class="WHIT">
<span class='line'>1268</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1269</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'>1270</span> </span><span class="WHIT"> </span><span class="COMM">// null module constructor</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1272</span>
<span class='line'>1273</span> </span><span class="COMM">/**
<span class='line'>1274</span> * for JSDT: 有 prototype 才會將之當作 Class
<span class='line'>1275</span> */</span><span class="WHIT">
<span class='line'>1276</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1277</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'>1278</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1279</span>
<span class='line'>1280</span>
<span class='line'>1281</span>
<span class='line'>1282</span> </span><span class="COMM">/*
<span class='line'>1283</span> JScript only -------------------------------------------------------
<span class='line'>1284</span> */</span><span class="WHIT">
<span class='line'>1285</span>
<span class='line'>1286</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1287</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1288</span> </span><span class="COMM">/**
<span class='line'>1289</span> * FileSystemObject Object I/O mode enumeration
<span class='line'>1290</span> * @see &lt;a href="http://msdn.microsoft.com/en-us/library/314cz14s%28VS.85%29.aspx" accessdate="2009/11/28 17:42" title="OpenTextFile Method">OpenTextFile Method&lt;/a>
<span class='line'>1291</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1292</span> */</span><span class="WHIT">
<span class='line'>1293</span> </span><span class="NAME">iomode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1294</span> </span><span class="WHIT"> </span><span class="COMM">// * @_description &lt;a href="#.iomode">iomode&lt;/a>: Open a file for reading only. You can't write to this file.</span><span class="WHIT">
<span class='line'>1295</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1296</span> * Open a file for reading only. You can't write to this file.
<span class='line'>1297</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1298</span> */</span><span class="WHIT">
<span class='line'>1299</span> </span><span class="WHIT"> </span><span class="NAME">ForReading</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1300</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1301</span> * Open a file for writing.
<span class='line'>1302</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1303</span> */</span><span class="WHIT">
<span class='line'>1304</span> </span><span class="WHIT"> </span><span class="NAME">ForWriting</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1305</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1306</span> * Open a file and write to the end of the file.
<span class='line'>1307</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1308</span> */</span><span class="WHIT">
<span class='line'>1309</span> </span><span class="WHIT"> </span><span class="NAME">ForAppending</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT">
<span class='line'>1310</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1311</span>
<span class='line'>1312</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1313</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1314</span> </span><span class="COMM">/**
<span class='line'>1315</span> * FileSystemObject Object file open format enumeration
<span class='line'>1316</span> * @see &lt;a href="http://msdn.microsoft.com/en-us/library/314cz14s%28VS.85%29.aspx" accessdate="2009/11/28 17:42" title="OpenTextFile Method">OpenTextFile Method&lt;/a>
<span class='line'>1317</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1318</span> */</span><span class="WHIT">
<span class='line'>1319</span> </span><span class="NAME">open_format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1320</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1321</span> * Opens the file using the system default.
<span class='line'>1322</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1323</span> */</span><span class="WHIT">
<span class='line'>1324</span> </span><span class="WHIT"> </span><span class="NAME">TristateUseDefault</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1325</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1326</span> * Opens the file as Unicode.
<span class='line'>1327</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1328</span> */</span><span class="WHIT">
<span class='line'>1329</span> </span><span class="WHIT"> </span><span class="NAME">TristateTrue</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1330</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1331</span> * Opens the file as ASCII.
<span class='line'>1332</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1333</span> */</span><span class="WHIT">
<span class='line'>1334</span> </span><span class="WHIT"> </span><span class="NAME">TristateFalse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>1335</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1336</span>
<span class='line'>1337</span>
<span class='line'>1338</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.path_separator</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">path_separator_RegExp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.path_separator_RegExp</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.new_line</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1339</span> </span><span class="COMM">/**
<span class='line'>1340</span> * FileSystemObject
<span class='line'>1341</span> */</span><span class="WHIT">
<span class='line'>1342</span> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript.CreateObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1343</span> </span><span class="COMM">// XMLHttp,</span><span class="WHIT">
<span class='line'>1344</span> </span><span class="NAME">WinShell</span><span class="WHIT"> </span><span class="COMM">// initWScriptObj</span><span class="WHIT">
<span class='line'>1345</span> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ScriptHost</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1346</span>
<span class='line'>1347</span>
<span class='line'>1348</span> </span><span class="COMM">/* ↑JScript only -------------------------------------------------------
<span class='line'>1349</span> */</span><span class="WHIT">
<span class='line'>1350</span>
<span class='line'>1351</span>
<span class='line'>1352</span>
<span class='line'>1353</span>
<span class='line'>1354</span> </span><span class="COMM">/*
<span class='line'>1355</span>
<span class='line'>1356</span> return {Object} report
<span class='line'>1357</span> .list files matched
<span class='line'>1358</span> .succeed success items
<span class='line'>1359</span> .failed failed items
<span class='line'>1360</span> .log log text
<span class='line'>1361</span> .undo undo data
<span class='line'>1362</span>
<span class='line'>1363</span> usage example:
<span class='line'>1364</span> move_file() get file list array of current dir.
<span class='line'>1365</span> move_file(0,0,'dir') get file list array of dir.
<span class='line'>1366</span> move_file('*.*','*.jpg','dir') Error! Please use RegExp('.*\..*') or turnWildcardToRegExp('*.*')
<span class='line'>1367</span> move_file(/file(\d+).jpg/,0,'dir') get file list array of dir/file(\d+).jpg
<span class='line'>1368</span> move_file(f1,move_file.f.remove) delete f1
<span class='line'>1369</span> move_file('f1','f2') [f1]->[f2]
<span class='line'>1370</span> move_file('f1','f2','.',move_file.f.copy|move_file.f.reverse) copy [./f2] to [./f1]
<span class='line'>1371</span> move_file(/file(\d+).jpg/,/file ($1).jpg/,'dir') [dir/file(\d+).jpg]->[dir/file ($1).jpg] can't use fuzzy or reverse in this time
<span class='line'>1372</span>
<span class='line'>1373</span> prog example:
<span class='line'>1374</span> function move_file_filter(fn){var n=fn.match(/0000(\d+)\(\d\)\.pdf/);if(!n)return true;n=n[1];if(n!=0&&n!=1&&n!=7&&n!=10&&n!=13&&n!=15&&n!=26&&n!=28)return true;try{n=fn.match(/(\d+)\(\d\)\.pdf/);FileSystemObject.MoveFile(n[1]+'('+(n[1]?vol-1:vol-2)+').pdf',n[1]+'.pdf');}catch(e){}return;}
<span class='line'>1375</span> var vol=11,doMove=move_file(new RegExp('(\\d+)\\('+vol+'\\)\\.pdf'),'$1.pdf');
<span class='line'>1376</span> write_to_file('move.log','-'.x(60)+new_line+doMove.log,open_format.TristateTrue,ForAppending);
<span class='line'>1377</span> write_to_file('move.undo.'+vol+'.txt',doMove.undo,open_format.TristateTrue),write_to_file('move.undo.'+vol+'.bat',doMove.undo);//bat不能用open_format.TristateTrue
<span class='line'>1378</span> alert('Done '+doMove.succeed+'/'+doMove.list.length);
<span class='line'>1379</span>
<span class='line'>1380</span> for Win98, turn lower case:
<span class='line'>1381</span> move_file(/^[A-Z\d.]+$/,function($0){return '_mv_tmp_'+$0.toLowerCase();},'.',move_file.f.include_folder|move_file.f.include_subfolder);
<span class='line'>1382</span> alert(move_file(/^_mv_tmp_/,'','.',move_file.f.include_folder|move_file.f.include_subfolder).log);
<span class='line'>1383</span>
<span class='line'>1384</span>
<span class='line'>1385</span> for(var i=0,j,n,m;i&lt;40;i++)
<span class='line'>1386</span> if(!fso.FileExists(n='0000'+(i>9?'':'0')+i+'.pdf'))for(j=0;j&lt;25;j++)
<span class='line'>1387</span> if(fso.FileExists(m='0000'+(i>9?'':'0')+i+'('+j+').pdf')){try{fso.MoveFile(m,n);}catch(e){}break;}
<span class='line'>1388</span>
<span class='line'>1389</span> TODO:
<span class='line'>1390</span> move newer 把新檔移到目的地,舊檔移到 bak。
<span class='line'>1391</span>
<span class='line'>1392</span> */</span><span class="WHIT">
<span class='line'>1393</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1394</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1395</span> </span><span class="COMM">/**
<span class='line'>1396</span> * move/rename files, ** use RegExp, but no global flag **&lt;br/>
<span class='line'>1397</span> * 可用 move_file_filter() 來排除不要的&lt;br/>
<span class='line'>1398</span> * 本函數可能暫時改變目前工作目錄!
<span class='line'>1399</span> * @param from
<span class='line'>1400</span> * @param to
<span class='line'>1401</span> * @param base_path
<span class='line'>1402</span> * @param flag
<span class='line'>1403</span> * @param {Function} filter 可用 filter() 來排除不要的
<span class='line'>1404</span> * @return {Object} report
<span class='line'>1405</span> * @since 2004/4/12 17:25
<span class='line'>1406</span> * @requires path_separator,fso,WshShell,new_line,Enumerator
<span class='line'>1407</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1408</span> */</span><span class="WHIT">
<span class='line'>1409</span> </span><span class="NAME">move_file</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">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1410</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">arguments.callee</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s.f</span><span class="WHIT">
<span class='line'>1411</span> </span><span class="WHIT"> </span><span class="COMM">// '.?': 一定會match</span><span class="WHIT">
<span class='line'>1412</span> </span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'.?'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1413</span> </span><span class="WHIT"> </span><span class="COMM">// alert(typeof from+','+from.constructor);</span><span class="WHIT">
<span class='line'>1414</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.reverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1415</span> </span><span class="WHIT"> </span><span class="COMM">//flag-=_f.reverse,</span><span class="WHIT">
<span class='line'>1416</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1417</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">from</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1418</span> </span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1419</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </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">from</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT">
<span class='line'>1420</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">from</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1421</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">from</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">from</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1422</span> </span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1423</span> </span><span class="WHIT"> </span><span class="NAME">report.list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report.succeed</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">report.failed</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'>1424</span> </span><span class="WHIT"> </span><span class="NAME">report.undo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">report.log</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 class='line'>1425</span>
<span class='line'>1426</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">base_path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1427</span> </span><span class="WHIT"> </span><span class="NAME">base_path</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">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1428</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </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">get_folder</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'>1429</span> </span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1430</span>
<span class='line'>1431</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">base_path</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">base_path</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1432</span> </span><span class="WHIT"> </span><span class="COMM">// -1, or try: base_path.length-path_separator.length</span><span class="WHIT">
<span class='line'>1433</span> </span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1434</span> </span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1435</span>
<span class='line'>1436</span> </span><span class="WHIT"> </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">fso</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1437</span> </span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1438</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </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">fso</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1439</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'fso was already seted!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1440</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'>1441</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1442</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'>1443</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1444</span> </span><span class="WHIT"> </span><span class="STRN">'move_file(): 基準路徑不存在\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1445</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1446</span>
<span class='line'>1447</span> </span><span class="WHIT"> </span><span class="COMM">// TODO: 對from不存在與為folder之處裡:fuzzy</span><span class="WHIT">
<span class='line'>1448</span>
<span class='line'>1449</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.include_subfolder</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1450</span> </span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WshShell.CurrentDirectory</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1451</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.SubFolders</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">i.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT">
<span class='line'>1452</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1453</span> </span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1454</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1455</span> </span><span class="WHIT"> </span><span class="COMM">// 改變目前工作目錄</span><span class="WHIT">
<span class='line'>1456</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.CurrentDirectory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">base_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1457</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1458</span> </span><span class="WHIT"> </span><span class="COMM">// if(flag&_f.include_folder){}</span><span class="WHIT">
<span class='line'>1459</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><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.Files</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">use_exact</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">from</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT">
<span class='line'>1460</span> </span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.overwrite</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">not_test</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.Test</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT">
<span class='line'>1461</span> </span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.copy</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'copy'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">_f.remove</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.remove</span><span class="WHIT">
<span class='line'>1462</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'delete'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'move'</span><span class="WHIT">
<span class='line'>1463</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'list'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1464</span> </span><span class="WHIT"> </span><span class="COMM">// if(func=='delete')to=_f.remove; // 反正不是用這個判別的</span><span class="WHIT">
<span class='line'>1465</span> </span><span class="WHIT"> </span><span class="COMM">//alert('use_exact: '+use_exact+'\nbase_path: '+base_path+'\nfrom: '+from);</span><span class="WHIT">
<span class='line'>1466</span> </span><span class="WHIT"> </span><span class="COMM">// BUG: 這樣順序會亂掉,使得 traverse (遍歷)不完全</span><span class="WHIT">
<span class='line'>1467</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="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1468</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">use_exact</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">i.Name</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">use_exact</span><span class="WHIT">
<span class='line'>1469</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">from.test</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1470</span> </span><span class="WHIT"> </span><span class="NAME">report.list.push</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1471</span>
<span class='line'>1472</span> </span><span class="WHIT"> </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">filter</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">filter</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1473</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1474</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'copy'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'move'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">i.Name.replace</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1475</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">to.source</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">)</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 class='line'>1476</span>
<span class='line'>1477</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1478</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'>1479</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">func</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">i.Name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="WHIT">
<span class='line'>1480</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">' to ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</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="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1481</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u</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 class='line'>1482</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">base_path</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">default_from</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">base_path</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 class='line'>1483</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1484</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'delete'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1485</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">not_test</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1486</span> </span><span class="WHIT"> </span><span class="NAME">i.Delete</span><span class="PUNC">(</span><span class="NAME">overwrite</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1487</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</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">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1488</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">not_test</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1489</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1490</span> </span><span class="WHIT"> </span><span class="NAME">fso.DeleteFile</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1491</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'copy'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1492</span> </span><span class="WHIT"> </span><span class="COMM">// Copy() 用的是 FileSystemObject.CopyFile or FileSystemObject.CopyFolder, 亦可用萬用字元(wildcard characters)</span><span class="WHIT">
<span class='line'>1493</span> </span><span class="WHIT"> </span><span class="NAME">i.Copy</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1494</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1495</span> </span><span class="WHIT"> </span><span class="NAME">i.Move</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1496</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1497</span> </span><span class="WHIT"> </span><span class="NAME">u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'move '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">t</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">i.Name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1498</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1499</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">': target existing, '</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1500</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1501</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1502</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'succeed.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1503</span> </span><span class="WHIT"> </span><span class="NAME">report.undo</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report.succeed</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1504</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'>1505</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'failed.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">report.failed</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1506</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1507</span> </span><span class="WHIT"> </span><span class="COMM">//alert(i.Name+','+t);</span><span class="WHIT">
<span class='line'>1508</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1509</span>
<span class='line'>1510</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.include_subfolder</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1511</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.CurrentDirectory</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CurrentDirectory</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1512</span> </span><span class="WHIT"> </span><span class="NAME">report.log</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">not_test</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="STRN">'(test)'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' ['</span><span class="WHIT">
<span class='line'>1513</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] to ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">to</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">new_line</span><span class="WHIT">
<span class='line'>1514</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">gDate</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">gDate</span><span class="PUNC">(</span><span class="PUNC">)</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="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1515</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'done '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">report.succeed</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">report.list.length</span><span class="WHIT">
<span class='line'>1516</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">new_line</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1517</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">report</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1518</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1519</span>
<span class='line'>1520</span> </span><span class="COMM">//var move_file.f;</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="COMM">//setObjValue('move_file.f','none=0,overwrite=1,fuzzy=2,reverse=4,include_folder=8,include_subfolder=16,Test=32,copy=64,remove=128','int');</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1523</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1524</span> </span><span class="COMM">/**
<span class='line'>1525</span> * &lt;a href="#.move_file">move_file&lt;/a> 的 flag enumeration
<span class='line'>1526</span> * @constant
<span class='line'>1527</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1528</span> */</span><span class="WHIT">
<span class='line'>1529</span> </span><span class="NAME">move_file.f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1530</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1531</span> * null flag
<span class='line'>1532</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1533</span> */</span><span class="WHIT">
<span class='line'>1534</span> </span><span class="WHIT"> </span><span class="NAME">none</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'>1535</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1536</span> * overwrite target
<span class='line'>1537</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1538</span> */</span><span class="WHIT">
<span class='line'>1539</span> </span><span class="WHIT"> </span><span class="NAME">overwrite</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1540</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1541</span> * If source don't exist but target exist, than reverse.
<span class='line'>1542</span> * @deprecated TODO
<span class='line'>1543</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1544</span> */</span><span class="WHIT">
<span class='line'>1545</span> </span><span class="WHIT"> </span><span class="NAME">fuzzy</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1546</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1547</span> * reverse source and target
<span class='line'>1548</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1549</span> */</span><span class="WHIT">
<span class='line'>1550</span> </span><span class="WHIT"> </span><span class="NAME">reverse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1551</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1552</span> * include folder
<span class='line'>1553</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1554</span> */</span><span class="WHIT">
<span class='line'>1555</span> </span><span class="WHIT"> </span><span class="NAME">include_folder</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1556</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1557</span> * include sub-folder
<span class='line'>1558</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1559</span> */</span><span class="WHIT">
<span class='line'>1560</span> </span><span class="WHIT"> </span><span class="NAME">include_subfolder</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1561</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1562</span> * Just do a test
<span class='line'>1563</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1564</span> */</span><span class="WHIT">
<span class='line'>1565</span> </span><span class="WHIT"> </span><span class="NAME">Test</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1566</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1567</span> * copy, instead of move the file
<span class='line'>1568</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1569</span> */</span><span class="WHIT">
<span class='line'>1570</span> </span><span class="WHIT"> </span><span class="NAME">copy</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1571</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1572</span> * 當 target 指定此 flag或包含此 flag 而未指定 target 時remove the source。
<span class='line'>1573</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1574</span> */</span><span class="WHIT">
<span class='line'>1575</span> </span><span class="WHIT"> </span><span class="NAME">remove</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">128</span><span class="WHIT">
<span class='line'>1576</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1577</span>
<span class='line'>1578</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1579</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1580</span> </span><span class="COMM">/**
<span class='line'>1581</span> * move file
<span class='line'>1582</span> * @requires fso,get_folder,getFN,initWScriptObj
<span class='line'>1583</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1584</span> */</span><span class="WHIT">
<span class='line'>1585</span> </span><span class="NAME">mv</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">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">onlyFN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reverse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1586</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">from</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1587</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'filename error.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1588</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1589</span> </span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="PUNC">(</span><span class="NAME">dir</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1590</span>
<span class='line'>1591</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">reverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1592</span> </span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">from</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">to</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1593</span> </span><span class="WHIT"> </span><span class="NAME">e</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">_i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1594</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fso.FileExists</span><span class="PUNC">(</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">_i</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="WHIT">
<span class='line'>1595</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">onlyFN</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">getFN</span><span class="PUNC">(</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">_i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1596</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1597</span>
<span class='line'>1598</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'>1599</span> </span><span class="WHIT"> </span><span class="COMM">// alert('mv():\n'+dir+'\n\n'+e(from)+'\n→\n'+e(to));</span><span class="WHIT">
<span class='line'>1600</span> </span><span class="WHIT"> </span><span class="NAME">fso.MoveFile</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">(</span><span class="NAME">from</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">(</span><span class="NAME">to</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1601</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1602</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'>1603</span> </span><span class="WHIT"> </span><span class="NAME">e.message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'mv():\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">from</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n→\n'</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>1604</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">to</span><span class="COMM">// +'\n\n'+e.message</span><span class="WHIT">
<span class='line'>1605</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1606</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1607</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1608</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1609</span>
<span class='line'>1610</span>
<span class='line'>1611</span> </span><span class="COMM">/*
<span class='line'>1612</span> function mv(from,to,dir,onlyFN,reverse){
<span class='line'>1613</span> var e,_f,_t;
<span class='line'>1614</span> dir=get_folder(dir);
<span class='line'>1615</span>
<span class='line'>1616</span> if(reverse)e=from,from=to,to=e;
<span class='line'>1617</span> _f=from;
<span class='line'>1618</span> _t=to;
<span class='line'>1619</span> to=0;
<span class='line'>1620</span> e=function(_i){
<span class='line'>1621</span> return fso.FileExists(_i)?_i:dir&&fso.FileExists(_i=dir+(onlyFN?getFN(_i):_i))?_i:0;
<span class='line'>1622</span> };
<span class='line'>1623</span>
<span class='line'>1624</span> try{
<span class='line'>1625</span> if(!(_f=e(_f)))to=1;else if(!(_t=e(_t)))to=2;
<span class='line'>1626</span> else{
<span class='line'>1627</span> alert('mv():\n'+dir+'\n\n'+_f+'\n→\n'+_t);
<span class='line'>1628</span> fso.MoveFile(_f,_t);
<span class='line'>1629</span> return;
<span class='line'>1630</span> }
<span class='line'>1631</span> }catch(e){return e;}
<span class='line'>1632</span> return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t);
<span class='line'>1633</span> }
<span class='line'>1634</span>
<span class='line'>1635</span>
<span class='line'>1636</span> function mv(from,to,dir,onlyFN,reverse){
<span class='line'>1637</span> var e,_f,_t;
<span class='line'>1638</span> dir=get_folder(dir);
<span class='line'>1639</span>
<span class='line'>1640</span> if(reverse)e=from,from=to,to=e;
<span class='line'>1641</span> _f=from,_t=to,to=e=0;
<span class='line'>1642</span>
<span class='line'>1643</span> try{
<span class='line'>1644</span> if(!fso.FileExists(_f)&&(!dir||!fso.FileExists(_f=dir+(onlyFN?getFN(_f):_f))))to=1;
<span class='line'>1645</span> else if(fso.FileExists(_t)&&(!dir||fso.FileExists(_t=dir+(onlyFN?getFN(_t):_t))))to=2;
<span class='line'>1646</span> else{
<span class='line'>1647</span> alert('mv():\n'+dir+'\n'+_f+'\n→\n'+_t);
<span class='line'>1648</span> //fso.MoveFile(_f,_t);
<span class='line'>1649</span> return;
<span class='line'>1650</span> }
<span class='line'>1651</span> }catch(e){}
<span class='line'>1652</span> return e||new Error(to,(to==1?'移動するファイルは存在しない':'移動先が既存した')+':\n'+_f+'\n→\n'+_t);
<span class='line'>1653</span> }
<span class='line'>1654</span>
<span class='line'>1655</span> */</span><span class="WHIT">
<span class='line'>1656</span>
<span class='line'>1657</span>
<span class='line'>1658</span> </span><span class="COMM">/*
<span class='line'>1659</span>
<span class='line'>1660</span> 下面一行調到檔案頭
<span class='line'>1661</span> var get_file_details_items,get_file_details_get_object=-62.262;
<span class='line'>1662</span> */</span><span class="WHIT">
<span class='line'>1663</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1664</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1665</span> </span><span class="COMM">/**
<span class='line'>1666</span> * get file details (readonly)
<span class='line'>1667</span> * @example
<span class='line'>1668</span> * get_file_details('path');
<span class='line'>1669</span> * get_file_details('file/folder name',parentDir);
<span class='line'>1670</span> * get_file_details('path',get_file_details_get_object);
<span class='line'>1671</span> * @see &lt;a href="http://msdn.microsoft.com/en-us/library/bb787870%28VS.85%29.aspx" accessdate="2009/11/29 22:52" title="GetDetailsOf Method (Folder)">GetDetailsOf Method (Folder)&lt;/a>
<span class='line'>1672</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1673</span> */</span><span class="WHIT">
<span class='line'>1674</span> </span><span class="NAME">get_file_details</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">fileObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1675</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><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT"> </span><span class="COMM">// WinShell=new ActiveXObject("Shell.Application");</span><span class="WHIT">
<span class='line'>1677</span> </span><span class="WHIT"> </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">WinShell</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fileObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1679</span>
<span class='line'>1680</span> </span><span class="WHIT"> </span><span class="COMM">// deal with fileObj & parentDirObj</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">get_file_details_get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1682</span> </span><span class="WHIT"> </span><span class="NAME">parentDirObj</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">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1683</span> </span><span class="WHIT"> </span><span class="COMM">// else n='';</span><span class="WHIT">
<span class='line'>1684</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">parentDirObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1685</span> </span><span class="WHIT"> </span><span class="COMM">// fileObj is path</span><span class="WHIT">
<span class='line'>1686</span> </span><span class="WHIT"> </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">fileObj</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1687</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fileObj.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fileObj.slice</span><span class="PUNC">(</span><span class="NUMB">0</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">1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT">
<span class='line'>1690</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1691</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1692</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1693</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1694</span> </span><span class="WHIT"> </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">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1695</span> </span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WinShell.NameSpace</span><span class="PUNC">(</span><span class="NAME">parentDirObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1696</span> </span><span class="WHIT"> </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">fileObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1697</span> </span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parentDirObj.ParseName</span><span class="PUNC">(</span><span class="NAME">fileObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1698</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1699</span> </span><span class="WHIT"> </span><span class="COMM">// just get [(object)parentDirObj,(object)fileObj]</span><span class="WHIT">
<span class='line'>1700</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">parentDirObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fileObj</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1701</span>
<span class='line'>1702</span> </span><span class="WHIT"> </span><span class="COMM">// get item name</span><span class="WHIT">
<span class='line'>1703</span> </span><span class="WHIT"> </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">get_file_details_items</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1704</span> </span><span class="WHIT"> </span><span class="NAME">get_file_details_items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1705</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</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">j</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="NUMB">99</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'>1706</span> </span><span class="WHIT"> </span><span class="COMM">// scan cols</span><span class="WHIT">
<span class='line'>1707</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WinShell.NameSpace</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">GetDetailsOf</span><span class="PUNC">(</span><span class="KEYW">null</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'>1708</span> </span><span class="WHIT"> </span><span class="NAME">get_file_details_items</span><span class="PUNC">[</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">n</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1709</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1710</span>
<span class='line'>1711</span> </span><span class="WHIT"> </span><span class="COMM">// main process</span><span class="WHIT">
<span class='line'>1712</span> </span><span class="WHIT"> </span><span class="COMM">//for(i=0,r=[];i&lt;get_file_details_items.length;i++)</span><span class="WHIT">
<span class='line'>1713</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="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1714</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">get_file_details_items</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1715</span> </span><span class="WHIT"> </span><span class="COMM">//if(get_file_details_items[i])</span><span class="WHIT">
<span class='line'>1716</span> </span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">[</span><span class="NAME">get_file_details_items</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">r</span><span class="PUNC">[</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">parentDirObj</span><span class="WHIT">
<span class='line'>1717</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">GetDetailsOf</span><span class="PUNC">(</span><span class="NAME">fileObj</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'>1718</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1719</span>
<span class='line'>1720</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'>1721</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1722</span>
<span class='line'>1723</span>
<span class='line'>1724</span>
<span class='line'>1725</span>
<span class='line'>1726</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1727</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1728</span> </span><span class="COMM">/*
<span class='line'>1729</span> TODO
<span class='line'>1730</span> 未來change_attributes(path,'-ReadOnly&-Hidden&-System')
<span class='line'>1731</span>
<span class='line'>1732</span> 下面調到檔案頭
<span class='line'>1733</span> setObjValue('Attribute','Normal=0,none=0,ReadOnly=1,Hidden=2,System=4,Volume=8,Directory=16,Archive=32,Alias=64,Compressed=128','int');
<span class='line'>1734</span> setObjValue('AttributeV','0=Normal,1=ReadOnly,2=Hidden,4=System,8=Volume,16=Directory,32=Archive,64=Alias,128=Compressed');
<span class='line'>1735</span> */</span><span class="WHIT">
<span class='line'>1736</span> </span><span class="COMM">/**
<span class='line'>1737</span> * 改變檔案之屬性
<span class='line'>1738</span> * @param F file path
<span class='line'>1739</span> * @param A attributes, 屬性
<span class='line'>1740</span> * @example
<span class='line'>1741</span> * change_attributes(path,'-ReadOnly');
<span class='line'>1742</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1743</span> */</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="NAME">change_attributes</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">F</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">A</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1745</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">F</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1747</span> </span><span class="WHIT"> </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">F</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1748</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'>1749</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">F</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1750</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'>1751</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1752</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1753</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1754</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'>1755</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">F.Attributes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1756</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'>1757</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1758</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1759</span> </span><span class="WHIT"> </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">A</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1760</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="PUNC">;</span><span class="WHIT">
<span class='line'>1761</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</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">A</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Archive'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1762</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="NUMB">32</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1763</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Normal'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1764</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="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1765</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">A</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1766</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'x'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">A.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</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 class='line'>1767</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">Attribute</span><span class="PUNC">[</span><span class="NAME">A.substr</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">]</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</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1768</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</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1769</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1770</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="PUNC">;</span><span class="WHIT">
<span class='line'>1771</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Attribute</span><span class="PUNC">[</span><span class="NAME">A</span><span class="PUNC">]</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</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</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'>1772</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</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1773</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1774</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="PUNC">;</span><span class="WHIT">
<span class='line'>1775</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">AttributeV</span><span class="PUNC">[</span><span class="NAME">A</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1776</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</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'>1777</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</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1778</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1779</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="PUNC">;</span><span class="WHIT">
<span class='line'>1780</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">AttributeV</span><span class="PUNC">[</span><span class="PUNC">-</span><span class="NAME">A</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1781</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">A</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1782</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</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1783</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>1784</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="PUNC">;</span><span class="WHIT">
<span class='line'>1785</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</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="PUNC">)</span><span class="WHIT">
<span class='line'>1786</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'>1787</span> </span><span class="WHIT"> </span><span class="NAME">F.Attributes</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'>1788</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'>1789</span> </span><span class="WHIT"> </span><span class="NAME">popErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1790</span> </span><span class="WHIT"> </span><span class="COMM">// 70防寫沒有使用權限</span><span class="WHIT">
<span class='line'>1791</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">70</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">8</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">9</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1792</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1793</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">F.Attributes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1794</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1795</span>
<span class='line'>1796</span>
<span class='line'>1797</span>
<span class='line'>1798</span>
<span class='line'>1799</span>
<span class='line'>1800</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1801</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1802</span> </span><span class="COMM">/**
<span class='line'>1803</span> * 開檔處理&lt;br/>
<span class='line'>1804</span> * 測試是否已開啟資料檔之測試與重新開啟資料檔
<span class='line'>1805</span> * @param FN file name
<span class='line'>1806</span> * @param NOTexist if NOT need exist
<span class='line'>1807</span> * @param io_mode IO mode
<span class='line'>1808</span> * @return
<span class='line'>1809</span> * @requires fso,WshShell,iomode
<span class='line'>1810</span> * @memberOf CeL.IO.Windows.file
<span class='line'>1811</span> */</span><span class="WHIT">
<span class='line'>1812</span> </span><span class="NAME">openDataTest</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">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NOTexist</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1813</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">FN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1814</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1815</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">NOTexist</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1816</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1817</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">io_mode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1818</span> </span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForAppending</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1819</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="PUNC">;</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1820</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'>1821</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ForAppending</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1822</span> </span><span class="WHIT"> </span><span class="NAME">Fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1823</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1824</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'>1825</span> </span><span class="WHIT"> </span><span class="COMM">// 對執行時檔案已經開啟之處理</span><span class="WHIT">
<span class='line'>1826</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof e=='object'&&e.number&&(e.number&0xFFFF)==70)</span><span class="WHIT">
<span class='line'>1827</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">e.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">70</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1828</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1829</span> </span><span class="WHIT"> </span><span class="STRN">'開啟資料檔 [&lt;green>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'&lt;\/>] 時發生錯誤!'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1830</span> </span><span class="WHIT"> </span><span class="NUMB">6</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1831</span> </span><span class="WHIT"> </span><span class="STRN">'開啟資料檔 ['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']時發生不明錯誤,\n 是否中止執行?'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1832</span> </span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ScriptName</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 class='line'>1833</span> </span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">)</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="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1834</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1835</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">WshShell.Popup</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1836</span> </span><span class="WHIT"> </span><span class="STRN">'★資料檔:\n\ '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n 無法寫入!\n\n可能原因與解決方法\n ①資料檔已被開啟。執行程式前請勿以其他程式開啟資料檔!\n ②資料檔被設成唯讀,請取消唯讀屬性。'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1837</span> </span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ScriptName</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="NUMB">5</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'>1838</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1839</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1840</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1841</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1842</span>
<span class='line'>1843</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>1844</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>1845</span> </span><span class="COMM">/**
<span class='line'>1846</span> *
<span class='line'>1847</span> * @param FN
<span class='line'>1848</span> * @param format
<span class='line'>1849</span> * @param io_mode
<span class='line'>1850</span> * @return
<span class='line'>1851</span> */</span><span class="WHIT">
<span class='line'>1852</span> </span><span class="NAME">open_template</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">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1853</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1854</span> * file
<span class='line'>1855</span> * @inner
<span class='line'>1856</span> * @ignore
<span class='line'>1857</span> */</span><span class="WHIT">
<span class='line'>1858</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1859</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>1860</span> * file streams
<span class='line'>1861</span> * @inner
<span class='line'>1862</span> * @ignore
<span class='line'>1863</span> */</span><span class="WHIT">
<span class='line'>1864</span> </span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1865</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">io_mode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1866</span> </span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1867</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">format</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1868</span> </span><span class="WHIT"> </span><span class="COMM">//format=autodetectEncode(FN);</span><span class="WHIT">
<span class='line'>1869</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">;</span><span class="COMM">// TristateTrue</span><span class="WHIT">
<span class='line'>1870</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'>1871</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1872</span> </span><span class="WHIT"> </span><span class="COMM">//Fs=_.open_file(FN,format,io_mode);</span><span class="WHIT">
<span class='line'>1873</span> </span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">F.OpenAsTextStream</span><span class="PUNC">(</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1874</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'>1875</span> </span><span class="WHIT"> </span><span class="COMM">// 指定的檔案不存在?</span><span class="WHIT">
<span class='line'>1876</span> </span><span class="WHIT"> </span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1877</span> </span><span class="WHIT"> </span><span class="COMM">// quit();</span><span class="WHIT">
<span class='line'>1878</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1879</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1880</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1881</span>
<span class='line'>1882</span> </span><span class="COMM">//var openOut.f; // default format</span><span class="WHIT">
<span class='line'>1883</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">openOut</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1884</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">OUT</span><span class="PUNC">,</span><span class="NAME">OUTs</span><span class="PUNC">,</span><span class="NAME">_f</span><span class="PUNC">=</span><span class="NAME">arguments.callee.f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1885</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="NAME">io_mode</span><span class="PUNC">=</span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1886</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">format</span><span class="PUNC">)</span><span class="NAME">format</span><span class="PUNC">=</span><span class="NAME">_f</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">&&</span><span class="NAME">_f</span><span class="PUNC">?</span><span class="NAME">_f</span><span class="PUNC">:</span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1887</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1888</span> </span><span class="WHIT"> </span><span class="NAME">OUT</span><span class="PUNC">=</span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1889</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1890</span> </span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1891</span> </span><span class="WHIT"> </span><span class="COMM">//指定的檔案不存在</span><span class="WHIT">
<span class='line'>1892</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="PUNC">=</span><span class="NAME">fso.CreateTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1893</span> </span><span class="WHIT"> </span><span class="NAME">tmp.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1894</span> </span><span class="WHIT"> </span><span class="NAME">OUT</span><span class="PUNC">=</span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1895</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1896</span>
<span class='line'>1897</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">OUTs</span><span class="PUNC">=</span><span class="NAME">OUT.OpenAsTextStream</span><span class="PUNC">(</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">pErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1898</span>
<span class='line'>1899</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">OUTs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1900</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1901</span>
<span class='line'>1902</span>
<span class='line'>1903</span>
<span class='line'>1904</span>
<span class='line'>1905</span>
<span class='line'>1906</span>
<span class='line'>1907</span>
<span class='line'>1908</span> </span><span class="COMM">// 2007/5/31 21:5:16</span><span class="WHIT">
<span class='line'>1909</span> </span><span class="NAME">compressF.tool</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1910</span> </span><span class="WHIT"> </span><span class="NAME">WinRAR</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">path</span><span class="PUNC">:</span><span class="STRN">'"%ProgramFiles%\\WinRAR\\WinRAR.exe"'</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">:</span><span class="STRN">'rar'</span><span class="WHIT">
<span class='line'>1911</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $s $archive -- $files'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'a'</span><span class="WHIT"> </span><span class="COMM">// cL:command line, c:compress, s:switch</span><span class="WHIT">
<span class='line'>1912</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">:</span><span class="STRN">'-u -dh -m5 -os -r -ts'</span><span class="WHIT"> </span><span class="COMM">// -rr1p -s&lt;N> -ap -as -ep1 -tl -x&lt;f> -x@&lt;lf> -z&lt;f> -p[p] -hp[p] // rar等</span><span class="WHIT">
<span class='line'>1913</span> </span><span class="WHIT"> </span><span class="COMM">//,l:'-ilog logFN'</span><span class="WHIT">
<span class='line'>1914</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1915</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">u</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive $eF $eTo'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'e'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// uncompress</span><span class="WHIT">
<span class='line'>1916</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'t'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// test</span><span class="WHIT">
<span class='line'>1917</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1918</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="STRN">'7-Zip'</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">path</span><span class="PUNC">:</span><span class="STRN">'"%ProgramFiles%\\7-Zip\\7zg.exe"'</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">:</span><span class="STRN">'7z'</span><span class="WHIT">
<span class='line'>1919</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $s $archive $files'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'u'</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">:</span><span class="STRN">'-mx9 -ms -mhe -mmt -uy2'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// compress</span><span class="WHIT">
<span class='line'>1920</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">u</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive $eF $_e'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'e'</span><span class="PUNC">,</span><span class="NAME">_e</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fO.eTo</span><span class="PUNC">?</span><span class="STRN">'-o'</span><span class="PUNC">+</span><span class="NAME">fO.eTo</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// uncompress</span><span class="WHIT">
<span class='line'>1921</span> </span><span class="WHIT"> </span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">:</span><span class="PUNC">{</span><span class="NAME">cL</span><span class="PUNC">:</span><span class="STRN">'$path $cmd $archive'</span><span class="PUNC">,</span><span class="NAME">cmd</span><span class="PUNC">:</span><span class="STRN">'t'</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// test</span><span class="WHIT">
<span class='line'>1922</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1923</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1924</span> </span><span class="COMM">/*
<span class='line'>1925</span> test:
<span class='line'>1926</span> var base='C:\\kanashimi\\www\\cgi-bin\\program\\misc\\';
<span class='line'>1927</span> compress(base+'jit','_jit.htm',{tool:'7-Zip',s:''});
<span class='line'>1928</span> uncompress(base+'jit',base,{tool:'7-Zip'});
<span class='line'>1929</span>
<span class='line'>1930</span>
<span class='line'>1931</span> fO={
<span class='line'>1932</span> tool:'WinRAR' // or '7-Zip'
<span class='line'>1933</span> ,m:'c' // method
<span class='line'>1934</span> ,s:'' // switch
<span class='line'>1935</span> ,archive:'' // archive file
<span class='line'>1936</span> ,files='' // what to compress
<span class='line'>1937</span> ,eTo='' // where to uncompress
<span class='line'>1938</span> ,eF='' // what to uncompress
<span class='line'>1939</span> ,rcL=1 // rebuild command line
<span class='line'>1940</span> }
<span class='line'>1941</span> */</span><span class="WHIT">
<span class='line'>1942</span> </span><span class="COMM">// solid, overwrite, compressLevel, password</span><span class="WHIT">
<span class='line'>1943</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">compressF</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// flags object</span><span class="WHIT">
<span class='line'>1944</span> </span><span class="WHIT"> </span><span class="COMM">// 參數檢查: 未完全</span><span class="WHIT">
<span class='line'>1945</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="NAME">fO</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1946</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">fO</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1947</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.tool</span><span class="PUNC">)</span><span class="NAME">fO.tool</span><span class="PUNC">=</span><span class="STRN">'WinRAR'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1948</span> </span><span class="WHIT"> </span><span class="COMM">//if(!fO.m)fO.m='c';//method</span><span class="WHIT">
<span class='line'>1949</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.m</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="NAME">fO.archive</span><span class="PUNC">&&</span><span class="PUNC">(</span><span class="NAME">fO.m</span><span class="PUNC">!=</span><span class="STRN">'c'</span><span class="PUNC">||</span><span class="NAME">fO.m</span><span class="PUNC">==</span><span class="STRN">'c'</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">fO.files</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1950</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fO.m</span><span class="PUNC">==</span><span class="STRN">'c'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1951</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">fO.files</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">fO.files</span><span class="PUNC">=</span><span class="NAME">fO.files</span><span class="PUNC">?</span><span class="PUNC">[</span><span class="NAME">fO.files</span><span class="PUNC">]</span><span class="PUNC">:</span><span class="NAME">fO.archive.replace</span><span class="PUNC">(</span><span class="REGX">/\..+$/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1952</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.archive</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="NAME">fO.files</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[\\\/]$/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="NAME">_t.ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1953</span> </span><span class="WHIT"> </span><span class="NAME">fO.files</span><span class="PUNC">=</span><span class="STRN">'"'</span><span class="PUNC">+</span><span class="NAME">fO.files.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="WHIT">
<span class='line'>1954</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1955</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="NAME">_t</span><span class="PUNC">=</span><span class="NAME">compressF.tool</span><span class="PUNC">[</span><span class="NAME">fO.tool</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="NAME">_m</span><span class="PUNC">,</span><span class="NAME">_c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1956</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">_t</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">_m</span><span class="PUNC">=</span><span class="NAME">_t</span><span class="PUNC">[</span><span class="NAME">fO.m</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1957</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="PUNC">!</span><span class="REGX">/\.[a-z]+$/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">fO.archive</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="STRN">'.'</span><span class="PUNC">+</span><span class="NAME">_t.ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1958</span> </span><span class="WHIT"> </span><span class="COMM">//if(fO.bD)fO.archive=fO.bD+(/[\\\/]$/.test(fO.bD)?'':'\\')+fO.archive; // base directory, work directory, base folder</span><span class="WHIT">
<span class='line'>1959</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="REGX">/["']/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">fO.archive</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="STRN">'"'</span><span class="PUNC">+</span><span class="NAME">fO.archive</span><span class="PUNC">+</span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1960</span> </span><span class="WHIT"> </span><span class="COMM">//alert('compressF(): check OK.');</span><span class="WHIT">
<span class='line'>1961</span> </span><span class="WHIT"> </span><span class="COMM">// 構築 command line</span><span class="WHIT">
<span class='line'>1962</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_m._cL</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">fO.rcL</span><span class="PUNC">)</span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_m._cL</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// rebuild command line</span><span class="WHIT">
<span class='line'>1963</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1964</span> </span><span class="WHIT"> </span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_m.cL.replace</span><span class="PUNC">(</span><span class="REGX">/\$path/</span><span class="PUNC">,</span><span class="NAME">_t.path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1965</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">_m</span><span class="PUNC">)</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">fO</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_c.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'\\$'</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">_m</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">?</span><span class="NAME">_m</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NAME">_m</span><span class="PUNC">[</span><span class="NAME">i</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 class='line'>1966</span> </span><span class="WHIT"> </span><span class="NAME">_m._cL</span><span class="PUNC">=</span><span class="NAME">_c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1967</span> </span><span class="WHIT"> </span><span class="COMM">//alert('compressF():\n'+_c);</span><span class="WHIT">
<span class='line'>1968</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1969</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">fO</span><span class="PUNC">)</span><span class="NAME">_c</span><span class="PUNC">=</span><span class="NAME">_c.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'\\$'</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">fO</span><span class="PUNC">[</span><span class="NAME">i</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 class='line'>1970</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_c.indexOf</span><span class="PUNC">(</span><span class="STRN">'$'</span><span class="PUNC">)</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">alert</span><span class="PUNC">(</span><span class="STRN">'compressF() error:\n'</span><span class="PUNC">+</span><span class="NAME">_c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1971</span> </span><span class="WHIT"> </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">'compressF() '</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">_c.indexOf</span><span class="PUNC">(</span><span class="STRN">'$'</span><span class="PUNC">)</span><span class="PUNC">==</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">?</span><span class="STRN">'run'</span><span class="PUNC">:</span><span class="STRN">'error'</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">':\n'</span><span class="PUNC">+</span><span class="NAME">_c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1972</span> </span><span class="WHIT"> </span><span class="COMM">// run</span><span class="WHIT">
<span class='line'>1973</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.Run</span><span class="PUNC">(</span><span class="NAME">_c</span><span class="PUNC">,</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1974</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1975</span> </span><span class="COMM">//compress[generateCode.dLK]='compressF';</span><span class="WHIT">
<span class='line'>1976</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">compress</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">,</span><span class="NAME">files</span><span class="PUNC">,</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// compress file path, what to compress, flags object</span><span class="WHIT">
<span class='line'>1977</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="NAME">fO</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="KEYW">else</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">fO</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1978</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.m</span><span class="PUNC">)</span><span class="NAME">fO.m</span><span class="PUNC">=</span><span class="STRN">'c'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1979</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="NAME">archive</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1980</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">files</span><span class="PUNC">)</span><span class="NAME">fO.files</span><span class="PUNC">=</span><span class="NAME">files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1981</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">compressF</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1982</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1983</span> </span><span class="COMM">//uncompress[generateCode.dLK]='uncompressF';</span><span class="WHIT">
<span class='line'>1984</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">uncompress</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">,</span><span class="NAME">eTo</span><span class="PUNC">,</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// compress file path, where to uncompress, flags object</span><span class="WHIT">
<span class='line'>1985</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="NAME">fO</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="KEYW">else</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">fO</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1986</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.m</span><span class="PUNC">)</span><span class="NAME">fO.m</span><span class="PUNC">=</span><span class="STRN">'u'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1987</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fO.eF</span><span class="PUNC">)</span><span class="NAME">fO.eF</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1988</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">archive</span><span class="PUNC">)</span><span class="NAME">fO.archive</span><span class="PUNC">=</span><span class="NAME">archive</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1989</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">eTo</span><span class="PUNC">)</span><span class="NAME">fO.eTo</span><span class="PUNC">=</span><span class="NAME">eTo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1990</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">compressF</span><span class="PUNC">(</span><span class="NAME">fO</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1991</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1992</span>
<span class='line'>1993</span>
<span class='line'>1994</span>
<span class='line'>1995</span>
<span class='line'>1996</span>
<span class='line'>1997</span>
<span class='line'>1998</span>
<span class='line'>1999</span> </span><span class="COMM">/*
<span class='line'>2000</span> 轉換捷徑, 傳回shortcut的Object. true path
<span class='line'>2001</span> http://msdn2.microsoft.com/en-us/library/xk6kst2k.aspx
<span class='line'>2002</span> http://yuriken.hp.infoseek.co.jp/index3.html
<span class='line'>2003</span> */</span><span class="WHIT">
<span class='line'>2004</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2005</span> </span><span class="COMM">//dealShortcut[generateCode.dLK]='initWScriptObj';//,parseINI</span><span class="WHIT">
<span class='line'>2006</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">dealShortcut</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="NAME">rtPath</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2007</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">path</span><span class="PUNC">!=</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="NAME">path</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2008</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="REGX">/\.(lnk|url)$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2009</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sc</span><span class="PUNC">=</span><span class="NAME">WshShell.CreateShortcut</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">sc.TargetPath</span><span class="PUNC">,</span><span class="NAME">_i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2010</span> </span><span class="WHIT"> </span><span class="COMM">// 檔名有可能是不被容許的字元(不一定總是有'?'),這時只有.url以文字儲存還讀得到。</span><span class="WHIT">
<span class='line'>2011</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="COMM">/*(''+sc).indexOf('?')!=-1*/</span><span class="PUNC">!</span><span class="NAME">p</span><span class="PUNC">&&</span><span class="REGX">/\.url$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">parseINI</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2012</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">parseINI</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">,</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2013</span> </span><span class="WHIT"> </span><span class="NAME">sc</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="NAME">_emu</span><span class="PUNC">:</span><span class="NAME">p</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2014</span> </span><span class="WHIT"> </span><span class="NAME">sc.TargetPath</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">p.InternetShortcut</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">URL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2015</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">p</span><span class="PUNC">)</span><span class="NAME">sc</span><span class="PUNC">[</span><span class="NAME">_i</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">_i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2016</span> </span><span class="COMM">/*
<span class='line'>2017</span> URL File Format (.url) http://www.cyanwerks.com/file-format-url.html
<span class='line'>2018</span> [DEFAULT]
<span class='line'>2019</span> BASEURL=http://so.7walker.net/guide.php
<span class='line'>2020</span> [DOC#n(#n#n#n…)]
<span class='line'>2021</span> [DOC#4#5]
<span class='line'>2022</span> BASEURL=http://www.someaddress.com/frame2.html
<span class='line'>2023</span> [DOC_adjustiframe]
<span class='line'>2024</span> BASEURL=http://so.7walker.net/guide.php
<span class='line'>2025</span> ORIGURL=http://so.7walker.net/guide.php
<span class='line'>2026</span> [InternetShortcut]
<span class='line'>2027</span> URL=http://so.7walker.net/guide.php
<span class='line'>2028</span> Modified=50A8FD7702D1C60106
<span class='line'>2029</span> WorkingDirectory=C:\WINDOWS\
<span class='line'>2030</span> ShowCommand= // 規定Internet Explorer啟動後窗口的初始狀態7表示最小化3表示最大化如果沒有ShowCommand這一項的話則表示正常大小。
<span class='line'>2031</span> IconIndex=1 // IconFile和IconIndex用來為Internet快捷方式指定圖標
<span class='line'>2032</span> IconFile=C:\WINDOWS\SYSTEM\url.dll
<span class='line'>2033</span> Hotkey=1601
<span class='line'>2034</span>
<span class='line'>2035</span> Hotkey:
<span class='line'>2036</span> 下面加起來: Fn 單獨 || (Fn || base) 擇一 + additional 擇2~3
<span class='line'>2037</span> base:
<span class='line'>2038</span> 0=0x30(ASCII)
<span class='line'>2039</span> 9=0x39(ASCII)
<span class='line'>2040</span> A=0x41(ASCII)
<span class='line'>2041</span> Z=0x5a(ASCII)
<span class='line'>2042</span> ;=0xba
<span class='line'>2043</span> =
<span class='line'>2044</span> ,
<span class='line'>2045</span> -
<span class='line'>2046</span> .
<span class='line'>2047</span> /
<span class='line'>2048</span> `=0xc0
<span class='line'>2049</span> [=0xdb
<span class='line'>2050</span> \
<span class='line'>2051</span> ]
<span class='line'>2052</span> '=0xde
<span class='line'>2053</span>
<span class='line'>2054</span> Fn:
<span class='line'>2055</span> F1=0x70
<span class='line'>2056</span> ..
<span class='line'>2057</span> F12=0x7b
<span class='line'>2058</span>
<span class='line'>2059</span> additional:
<span class='line'>2060</span> Shift=0x100
<span class='line'>2061</span> Ctrl=0x200
<span class='line'>2062</span> Alt=0x400
<span class='line'>2063</span>
<span class='line'>2064</span> */</span><span class="WHIT">
<span class='line'>2065</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">p.URL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2066</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2067</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">rtPath</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sc</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2068</span> </span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">=</span><span class="REGX">/^file:/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">p.replace</span><span class="PUNC">(</span><span class="REGX">/^[^:]+:\/+/</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/[\/]/g</span><span class="PUNC">,</span><span class="STRN">'\\'</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// /\.url$/i.test(path)?'':p;</span><span class="WHIT">
<span class='line'>2069</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2070</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">rtPath</span><span class="PUNC">?</span><span class="NAME">path</span><span class="PUNC">:</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2071</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2072</span>
<span class='line'>2073</span> </span><span class="COMM">//filepath=OpenFileDialog(); 基於安全IE無法指定初始值或型態</span><span class="WHIT">
<span class='line'>2074</span> </span><span class="COMM">//OpenFileDialog[generateCode.dLK]='IEA';</span><span class="WHIT">
<span class='line'>2075</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">OpenFileDialog</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2076</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">IE</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">IEA</span><span class="PUNC">,</span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2077</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">IE.OK</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2078</span> </span><span class="WHIT"> </span><span class="NAME">IE.write</span><span class="PUNC">(</span><span class="STRN">'&lt;input id="file" type="file"/>'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">// value="'+dP+'" useless</span><span class="WHIT">
<span class='line'>2079</span> </span><span class="WHIT"> </span><span class="KEYW">with</span><span class="PUNC">(</span><span class="NAME">IE.getE</span><span class="PUNC">(</span><span class="STRN">'file'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">focus</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">click</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">o</span><span class="PUNC">=</span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2080</span> </span><span class="WHIT"> </span><span class="COMM">//IE.setDialog(200,400).show(1);</span><span class="WHIT">
<span class='line'>2081</span> </span><span class="WHIT"> </span><span class="NAME">IE.quit</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2082</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">||</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2083</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2084</span>
<span class='line'>2085</span>
<span class='line'>2086</span> </span><span class="COMM">// 是否為檔案</span><span class="WHIT">
<span class='line'>2087</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isFile</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="COMM">//file path,create</span><span class="WHIT">
<span class='line'>2088</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">p</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2089</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">fso</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2090</span> </span><span class="WHIT"> </span><span class="NAME">fso</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2091</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2092</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2093</span>
<span class='line'>2094</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">getFN</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2095</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">c</span><span class="PUNC">=</span><span class="NAME">fso.CreateTextFile</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">,</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">c.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2096</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2097</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2098</span> </span><span class="COMM">// 是否為目錄</span><span class="WHIT">
<span class='line'>2099</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isFolder</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">p</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="COMM">//path,create return 0:not,1:absolute,2:relative path</span><span class="WHIT">
<span class='line'>2100</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fso.FolderExists</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">=</span><span class="NAME">turnToPath</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">isAbsPath</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NUMB">1</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2101</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fso.CreateFolder</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">isAbsPath</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NUMB">1</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2102</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2103</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2104</span> </span><span class="COMM">// get directory name of a path</span><span class="WHIT">
<span class='line'>2105</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">get_folder</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">,</span><span class="NAME">mode</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// mode=0:path,1:filename</span><span class="WHIT">
<span class='line'>2106</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">FP</span><span class="PUNC">==</span><span class="STRN">'object'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">FP.Path</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2107</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">FP.IsRootFolder</span><span class="PUNC">!=</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">FP.Path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2108</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">FP</span><span class="PUNC">=</span><span class="NAME">FP.Path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2109</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">FP</span><span class="PUNC">!=</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2110</span> </span><span class="WHIT"> </span><span class="COMM">//else if(/^[a-z]$/i.test(FP))FP+=':\\';</span><span class="WHIT">
<span class='line'>2111</span> </span><span class="WHIT"> </span><span class="COMM">//if(FP.slice(-1)!='\\')FP+='\\';</span><span class="WHIT">
<span class='line'>2112</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="NAME">FP.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'\\'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2113</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">==</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">FP.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2114</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">==</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">?</span><span class="NAME">FP</span><span class="PUNC">:</span><span class="NAME">mode</span><span class="PUNC">?</span><span class="NAME">FP.substr</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">FP.slice</span><span class="PUNC">(</span><span class="NUMB">0</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="WHIT">
<span class='line'>2115</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2116</span>
<span class='line'>2117</span>
<span class='line'>2118</span>
<span class='line'>2119</span> </span><span class="COMM">// 取得下一個序號的檔名如輸入pp\aa.txt將嘗試pp\aa.txt→pp\aa[pattern].txt</span><span class="WHIT">
<span class='line'>2120</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getNextSerialFN</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">,</span><span class="NAME">bs</span><span class="PUNC">,</span><span class="NAME">pattern</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// FP:file path,bs:begin serial,pattern:增添主檔名的模式包含Ser的部分將被轉換為序號</span><span class="WHIT">
<span class='line'>2121</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">bs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">FP</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">bs</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2122</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="NAME">FP.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">base</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">,</span><span class="NAME">Ser</span><span class="PUNC">=</span><span class="STRN">':s:'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2123</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">==</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="NAME">base</span><span class="PUNC">=</span><span class="NAME">FP</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">base</span><span class="PUNC">=</span><span class="NAME">FP.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">=</span><span class="NAME">FP.substr</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">//fso.GetBaseName(filespec);fso.GetExtensionName(path);fso.GetTempName();</span><span class="WHIT">
<span class='line'>2124</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">pattern</span><span class="PUNC">)</span><span class="NAME">pattern</span><span class="PUNC">=</span><span class="STRN">'_'</span><span class="PUNC">+</span><span class="NAME">Ser</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">pattern.indexOf</span><span class="PUNC">(</span><span class="NAME">Ser</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2125</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">==</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="NAME">base</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">pattern</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">base</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">pattern.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">ext</span><span class="PUNC">=</span><span class="NAME">pattern.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">+</span><span class="NAME">Ser.length</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="NAME">ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2126</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">bs</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="NUMB">999</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">base</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">+</span><span class="NAME">ext</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">base</span><span class="PUNC">+</span><span class="NAME">i</span><span class="PUNC">+</span><span class="NAME">ext</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2127</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2128</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2129</span>
<span class='line'>2130</span>
<span class='line'>2131</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2132</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2133</span> </span><span class="COMM">/**
<span class='line'>2134</span> * 轉換以 adTypeBinary 讀到的資料
<span class='line'>2135</span> * @example
<span class='line'>2136</span> * // 較安全的讀檔:
<span class='line'>2137</span> * t=translate_AdoStream_binary_data(read_all_file(FP,'binary'));
<span class='line'>2138</span> * write_to_file(FP,t,'iso-8859-1');
<span class='line'>2139</span> * @see
<span class='line'>2140</span> * &lt;a href="http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html">Hawk&apos;s W3 Laboratory : Disposable WSH : 番外編文字エンコーディングとADODB.Stream&lt;/a>
<span class='line'>2141</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2142</span> */</span><span class="WHIT">
<span class='line'>2143</span> </span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="NAME">len</span><span class="PUNC">,</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2144</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">arguments.callee</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">charArray</span><span class="PUNC">,</span><span class="NAME">val</span><span class="PUNC">,</span><span class="NAME">DOM</span><span class="PUNC">=</span><span class="NAME">_s.XMLDOM</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="NAME">txt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2145</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">DOM</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2146</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2147</span> </span><span class="WHIT"> </span><span class="NAME">DOM</span><span class="PUNC">=</span><span class="NAME">_s.XMLDOM</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Microsoft.XMLDOM"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'tmp'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 要素名は何でも良い</span><span class="WHIT">
<span class='line'>2148</span> </span><span class="WHIT"> </span><span class="NAME">DOM.dataType</span><span class="PUNC">=</span><span class="STRN">'bin.hex'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2149</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2150</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">!==</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="NAME">DOM.nodeTypedValue</span><span class="PUNC">=</span><span class="NAME">data</span><span class="PUNC">,</span><span class="NAME">txt</span><span class="PUNC">=</span><span class="NAME">DOM.text</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="COMM">//binary data</span><span class="WHIT">
<span class='line'>2151</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">=</span><span class="NAME">_s.pos</span><span class="PUNC">,</span><span class="NAME">txt</span><span class="PUNC">=</span><span class="NAME">_s.text</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2152</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">||</span><span class="NAME">len</span><span class="PUNC">></span><span class="NAME">txt.length</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="NAME">len</span><span class="PUNC">=</span><span class="NAME">txt.length</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2153</span>
<span class='line'>2154</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2155</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">val</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">len</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="NAME">val</span><span class="PUNC">=</span><span class="NUMB">0x100</span><span class="PUNC">*</span><span class="NAME">val</span><span class="PUNC">+</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">txt.substr</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2156</span> </span><span class="WHIT"> </span><span class="NAME">_s.pos</span><span class="PUNC">=</span><span class="NAME">pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2157</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2158</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2159</span>
<span class='line'>2160</span> </span><span class="COMM">/*
<span class='line'>2161</span> if(!(len>0)||len!=parseInt(len))
<span class='line'>2162</span> alert(pos+','+_i+'==0~len='+len+','+txt.slice(0,8));
<span class='line'>2163</span> */</span><span class="WHIT">
<span class='line'>2164</span> </span><span class="WHIT"> </span><span class="NAME">charArray</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">parseInt</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// Error 5029 [RangeError] (facility code 10): 陣列長度必須是一有限的正整數</span><span class="WHIT">
<span class='line'>2165</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">len</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">// 極慢用charString+=更慢。</span><span class="WHIT">
<span class='line'>2166</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2167</span> </span><span class="WHIT"> </span><span class="COMM">//if(_i%100000==0)alert(i);</span><span class="WHIT">
<span class='line'>2168</span> </span><span class="WHIT"> </span><span class="COMM">//if(_i==40)alert(String.fromCharCode(parseInt(txt.substr(pos,2),16))+'\n'+charArray.join(''));</span><span class="WHIT">
<span class='line'>2169</span> </span><span class="WHIT"> </span><span class="NAME">charArray.push</span><span class="PUNC">(</span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">txt.substr</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2170</span> </span><span class="WHIT"> </span><span class="COMM">//charArray[_i]=String.fromCharCode((t.charCodeAt(_i&lt;&lt;1)&lt;&lt;8)+t.charCodeAt((_i&lt;&lt;1)+1));</span><span class="WHIT">
<span class='line'>2171</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2172</span> </span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">=</span><span class="STRN">'translate_AdoStream_binary_data: 輸入了錯誤的資料:\n'</span><span class="PUNC">+</span><span class="NAME">e.description</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2173</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2174</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2175</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data</span><span class="PUNC">)</span><span class="NAME">_s.pos</span><span class="PUNC">=</span><span class="NAME">pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2176</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">charArray.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2177</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2178</span>
<span class='line'>2179</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2180</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2181</span> </span><span class="COMM">/**
<span class='line'>2182</span> * 轉換以 adTypeBinary 讀到的資料
<span class='line'>2183</span> * @param data 以 adTypeBinary 讀到的資料
<span class='line'>2184</span> * @param pos position
<span class='line'>2185</span> * @since 2007/9/19 20:58:26
<span class='line'>2186</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2187</span> */</span><span class="WHIT">
<span class='line'>2188</span> </span><span class="NAME">Ado_binary</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">data</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2189</span> </span><span class="WHIT"> </span><span class="NAME">this.newDOM</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2190</span>
<span class='line'>2191</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">data</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2192</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">=</span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2193</span> </span><span class="WHIT"> </span><span class="NAME">this.newFS</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2194</span> </span><span class="WHIT"> </span><span class="NAME">this.setPos</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">||</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2195</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">this.setData</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="NAME">pos</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2196</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2197</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2198</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2199</span> </span><span class="COMM">/**
<span class='line'>2200</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2201</span> */</span><span class="WHIT">
<span class='line'>2202</span> </span><span class="NAME">Ado_binary.prototype</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2203</span> </span><span class="COMM">/**
<span class='line'>2204</span> * 設定 data
<span class='line'>2205</span> *
<span class='line'>2206</span> * @param data binary data
<span class='line'>2207</span> * @param pos
<span class='line'>2208</span> * @return
<span class='line'>2209</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2210</span> */</span><span class="WHIT">
<span class='line'>2211</span> </span><span class="NAME">setData</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">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2212</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM.nodeTypedValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="COMM">// binary data</span><span class="WHIT">
<span class='line'>2213</span> </span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.DOM.text</span><span class="PUNC">;</span><span class="COMM">// binary text</span><span class="WHIT">
<span class='line'>2214</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">this.AdoS</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2215</span> </span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bt.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2216</span> </span><span class="WHIT"> </span><span class="NAME">this.setPos</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2217</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2218</span> </span><span class="NAME">setPos</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">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2219</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">isNaN</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2220</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2221</span> </span><span class="WHIT"> </span><span class="NAME">p</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'>2222</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2223</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2224</span> </span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2225</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2226</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2227</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2228</span> </span><span class="NAME">testLen</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">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2229</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">len</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2230</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2231</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2232</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2233</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2234</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2235</span> </span><span class="COMM">/**
<span class='line'>2236</span> * read data
<span class='line'>2237</span> * @private
<span class='line'>2238</span> * @param len length
<span class='line'>2239</span> * @return
<span class='line'>2240</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2241</span> */</span><span class="WHIT">
<span class='line'>2242</span> </span><span class="NAME">readData</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">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2243</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.Position</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2244</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Read</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2245</span> </span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>2246</span> </span><span class="WHIT"> </span><span class="NAME">this.setData</span><span class="PUNC">(</span><span class="NAME">_data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Position</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2247</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2248</span> </span><span class="NAME">read</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">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2249</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.testLen</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</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">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2250</span> </span><span class="WHIT"> </span><span class="NAME">this.readData</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2251</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">len</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'>2252</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'>2253</span> </span><span class="WHIT"> </span><span class="NAME">charArray.push</span><span class="PUNC">(</span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">this.bt</span><span class="WHIT">
<span class='line'>2254</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">substr</span><span class="PUNC">(</span><span class="NUMB">2</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="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2255</span> </span><span class="WHIT"> </span><span class="COMM">// charArray[i]=String.fromCharCode((t.charCodeAt(i&lt;&lt;1)&lt;&lt;8)+t.charCodeAt((i&lt;&lt;1)+1));</span><span class="WHIT">
<span class='line'>2256</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'>2257</span> </span><span class="WHIT"> </span><span class="NAME">this.retErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2258</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2259</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">charArray.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2260</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2261</span> </span><span class="NAME">readNum</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">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2262</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.testLen</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2263</span> </span><span class="WHIT"> </span><span class="NAME">this.readData</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2264</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">val</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">_i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2265</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">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2266</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'>2267</span> </span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x100</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT">
<span class='line'>2268</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">this.bt.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">--</span><span class="NAME">_i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2269</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'>2270</span> </span><span class="WHIT"> </span><span class="NAME">this.retErr</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2271</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2272</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2273</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2274</span> </span><span class="NAME">readHEX</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">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2275</span> </span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.testLen</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2276</span> </span><span class="WHIT"> </span><span class="NAME">this.readData</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2277</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2278</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2279</span> </span><span class="NAME">retErr</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">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2280</span> </span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'translate_AdoStream_binary_data: 輸入了錯誤的資料:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2281</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2282</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2283</span> </span><span class="COMM">/**
<span class='line'>2284</span> * @private
<span class='line'>2285</span> * @return
<span class='line'>2286</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2287</span> */</span><span class="WHIT">
<span class='line'>2288</span> </span><span class="NAME">newDOM</span><span class="WHIT"> </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'>2289</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2290</span> </span><span class="WHIT"> </span><span class="COMM">// try{</span><span class="WHIT">
<span class='line'>2291</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Microsoft.XMLDOM"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2292</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'tmp'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 要素名は何でも良い</span><span class="WHIT">
<span class='line'>2293</span> </span><span class="WHIT"> </span><span class="COMM">// }catch(e){return;}</span><span class="WHIT">
<span class='line'>2294</span> </span><span class="WHIT"> </span><span class="NAME">this.DOM.dataType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'bin.hex'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2295</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2296</span> </span><span class="COMM">/**
<span class='line'>2297</span> * @private
<span class='line'>2298</span> * @param FP
<span class='line'>2299</span> * @return
<span class='line'>2300</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2301</span> */</span><span class="WHIT">
<span class='line'>2302</span> </span><span class="NAME">newFS</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">FP</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2303</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2304</span> </span><span class="WHIT"> </span><span class="NAME">this.FP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FP</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2305</span> </span><span class="WHIT"> </span><span class="KEYW">else</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="NAME">FP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.FP</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2306</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2307</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_file.returnADO</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2308</span> </span><span class="WHIT"> </span><span class="NAME">_.open_file.returnADO</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2309</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'binary'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2310</span> </span><span class="WHIT"> </span><span class="NAME">_.open_file.returnADO</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 class='line'>2311</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">this.AdoS</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2312</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2313</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.LoadFromFile</span><span class="PUNC">(</span><span class="NAME">FP</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2314</span> </span><span class="WHIT"> </span><span class="NAME">this.len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2315</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2316</span> </span><span class="COMM">/**
<span class='line'>2317</span> * 實際上沒多大效用。實用解決法:少用 AdoStream.Write()
<span class='line'>2318</span> * @return
<span class='line'>2319</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2320</span> */</span><span class="WHIT">
<span class='line'>2321</span> </span><span class="NAME">renew</span><span class="WHIT"> </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'>2322</span> </span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.data</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'>2323</span> </span><span class="WHIT"> </span><span class="NAME">this.newDOM</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2324</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.FP</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2325</span> </span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.AdoS.Position</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2326</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2327</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2328</span> </span><span class="WHIT"> </span><span class="NAME">this.newFS</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2329</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2330</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2331</span> </span><span class="NAME">destory</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">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2332</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.AdoS</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2333</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2334</span> </span><span class="WHIT"> </span><span class="NAME">this.AdoS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.data</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'>2335</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2336</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// Ado_binary.prototype={</span><span class="WHIT">
<span class='line'>2337</span>
<span class='line'>2338</span>
<span class='line'>2339</span> </span><span class="COMM">/*
<span class='line'>2340</span> // 速度過慢,放棄。
<span class='line'>2341</span> //_.open_file.returnADO=true;
<span class='line'>2342</span> function dealBinary(FP,func,interval){
<span class='line'>2343</span> var t,fs=_.open_file(FP,'binary',ForReading);
<span class='line'>2344</span> if(!fs)return;
<span class='line'>2345</span> AdoStream.LoadFromFile(FP);
<span class='line'>2346</span> if(!interval)interval=1;
<span class='line'>2347</span> //alert(fs.size)
<span class='line'>2348</span> while(!fs.EOS)
<span class='line'>2349</span> if(func(translate_AdoStream_binary_data(fs.Read(interval))))return;
<span class='line'>2350</span> func();
<span class='line'>2351</span> fs.Close();
<span class='line'>2352</span> }
<span class='line'>2353</span> */</span><span class="WHIT">
<span class='line'>2354</span>
<span class='line'>2355</span> </span><span class="COMM">/* 配合simple系列使用
<span class='line'>2356</span> http://thor.prohosting.com/~mktaka/html/utf8.html
<span class='line'>2357</span> http://www.andrewu.co.uk/webtech/comment/?703
<span class='line'>2358</span> http://www.blueidea.com/bbs/NewsDetail.asp?id=1488978
<span class='line'>2359</span> http://www.blueidea.com/bbs/NewsDetail.asp?GroupName=WAP+%BC%BC%CA%F5%D7%A8%C0%B8&DaysPrune=5&lp=1&id=1524739
<span class='line'>2360</span> C# http://www.gotdotnet.com/team/clr/bcl/TechArticles/TechArticles/IOFAQ/FAQ.aspx
<span class='line'>2361</span> http://www.sqlxml.org/faqs.aspx?faq=2
<span class='line'>2362</span> http://www.imasy.or.jp/~hir/hir/tech/js_tips.html
<span class='line'>2363</span>
<span class='line'>2364</span> ADODB.Stream 最大問題不能append
<span class='line'>2365</span> http://msdn2.microsoft.com/en-us/library/ms808792.aspx
<span class='line'>2366</span> http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp
<span class='line'>2367</span> http://study.99net.net/study/web/asp/1067048121.html http://www.6to23.com/s11/s11d5/20031222114950.htm
<span class='line'>2368</span> http://blog.csdn.net/dfmz007/archive/2004/07/23/49373.aspx
<span class='line'>2369</span> */</span><span class="WHIT">
<span class='line'>2370</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">,</span><span class="NAME">AdoEnums</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ADO Enumerated Constants http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp</span><span class="WHIT">
<span class='line'>2371</span> </span><span class="COMM">/* 搬到前面
<span class='line'>2372</span> setObjValue('AdoEnums','adTypeBinary=1,adTypeText=2' // StreamTypeEnum
<span class='line'>2373</span> +',adReadAll=-1,adReadLine=-2' // StreamReadEnum http://msdn2.microsoft.com/en-us/library/ms806462.aspx
<span class='line'>2374</span> +',adSaveCreateNotExist=1,adSaveCreateOverWrite=2' // SaveOptionsEnum
<span class='line'>2375</span> +',adCR=13,adCRLF=-1,adLF=10' // LineSeparatorsEnum
<span class='line'>2376</span> ,'int');
<span class='line'>2377</span> */</span><span class="WHIT">
<span class='line'>2378</span> </span><span class="NAME">AdoEnums</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2379</span> </span><span class="WHIT"> </span><span class="NAME">adTypeBinary</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2380</span> </span><span class="WHIT"> </span><span class="NAME">adTypeText</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2381</span> </span><span class="WHIT"> </span><span class="NAME">adReadAll</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2382</span> </span><span class="WHIT"> </span><span class="NAME">adReadLine</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2383</span> </span><span class="WHIT"> </span><span class="NAME">adSaveCreateNotExist</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2384</span> </span><span class="WHIT"> </span><span class="NAME">adSaveCreateOverWrite</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2385</span> </span><span class="WHIT"> </span><span class="NAME">adCR</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">13</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2386</span> </span><span class="WHIT"> </span><span class="NAME">adCRLF</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2387</span> </span><span class="WHIT"> </span><span class="NAME">adLF</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="WHIT">
<span class='line'>2388</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2389</span>
<span class='line'>2390</span>
<span class='line'>2391</span> </span><span class="COMM">//_.open_file[generateCode.dLK]='AdoEnums,simpleFileErr,ForReading,ForWriting,ForAppending,TristateUseDefault';//AdoStream</span><span class="WHIT">
<span class='line'>2392</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2393</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2394</span> </span><span class="COMM">/**
<span class='line'>2395</span> * 提供給 &lt;a href="#.read_all_file">read_all_file&lt;/a>, &lt;a href="#.write_to_file">write_to_file&lt;/a> 使用的簡易開檔函數
<span class='line'>2396</span> * @param FN file path
<span class='line'>2397</span> * @param format open format, e.g., open_format.TristateUseDefault
<span class='line'>2398</span> * @param io_mode open mode, e.g., iomode.ForWriting
<span class='line'>2399</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2400</span> */</span><span class="WHIT">
<span class='line'>2401</span> </span><span class="NAME">open_file</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2402</span> </span><span class="WHIT"> </span><span class="COMM">//if(!FN||typeof isAbsPath=='function'&&typeof getFN=='function'&&!isAbsPath(FN)&&!(FN=getFN(FN)))return;</span><span class="WHIT">
<span class='line'>2403</span> </span><span class="WHIT"> </span><span class="COMM">//if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;</span><span class="WHIT">
<span class='line'>2404</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">arguments.callee</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2405</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">format</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2406</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">_s.returnADO</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">!=</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2407</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2408</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2409</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"ADODB.Stream"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">//var objStream=Server.CreateObject("ADODB.Stream"); // ASPの場合,Err.Number=-2147221005表不支援</span><span class="WHIT">
<span class='line'>2410</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2411</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2412</span> </span><span class="WHIT"> </span><span class="COMM">//AdoStream.Mode=3; // read write</span><span class="WHIT">
<span class='line'>2413</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">format</span><span class="PUNC">==</span><span class="STRN">'binary'</span><span class="PUNC">)</span><span class="NAME">AdoStream.Type</span><span class="PUNC">=</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 以二進位方式操作</span><span class="WHIT">
<span class='line'>2414</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2415</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Type</span><span class="PUNC">=</span><span class="NAME">AdoEnums.adTypeText</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2416</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Charset</span><span class="PUNC">=</span><span class="NAME">format</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="PUNC">,</span><span class="STRN">'open_file: Error format:\n ('</span><span class="PUNC">+</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">+</span><span class="STRN">') ['</span><span class="PUNC">+</span><span class="NAME">format</span><span class="PUNC">+</span><span class="STRN">']\n'</span><span class="PUNC">+</span><span class="NAME">e.description</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// UTF-8,unicode,shift_jis,Big5,GB2312,ascii=iso-8859-1,_autodetect,_autodetect_all.. HKEY_CLASSES_ROOT\MIME\Database\Charset</span><span class="WHIT">
<span class='line'>2417</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2418</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Open</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2419</span> </span><span class="WHIT"> </span><span class="COMM">//AdoStream.Position=0,AdoStream.LineSeparator=AdoEnums.adLF;</span><span class="WHIT">
<span class='line'>2420</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_s.returnADO</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_A</span><span class="PUNC">=</span><span class="NAME">AdoStream</span><span class="PUNC">;</span><span class="NAME">AdoStream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_A</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2421</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2422</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2423</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2424</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2425</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2426</span> </span><span class="WHIT"> </span><span class="COMM">// 使用某些防毒軟體(如諾頓 Norton)時,.OpenTextFile() 可能會被攔截,因而延宕。</span><span class="WHIT">
<span class='line'>2427</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2428</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">io_mode</span><span class="PUNC">==</span><span class="NAME">_.iomode.ForAppending</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">fso.FileExists</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">io_mode</span><span class="PUNC">=</span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 無此檔時改 writing</span><span class="WHIT">
<span class='line'>2429</span> </span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">=</span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">||</span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">==</span><span class="NAME">_.iomode.ForWriting</span><span class="COMM">/*create*/</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">||</span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2430</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2431</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2432</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2433</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2434</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2435</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2436</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2437</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2438</span> </span><span class="PUNC">.</span><span class="NAME">open_file.returnADO</span><span class="PUNC">=</span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2439</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2440</span> </span><span class="PUNC">.</span><span class="NAME">open_file.error</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2441</span>
<span class='line'>2442</span> </span><span class="COMM">// 若是僅使用普通的開檔方法_.open_format.TristateTrue/_.open_format.TristateFalse等不使用ADODB.Stream直接引用下兩函數與fso段定義即可。否則還需要引入_.open_file(),setObjValue(),dQuote()</span><span class="WHIT">
<span class='line'>2443</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">,</span><span class="NAME">simpleFileAutodetectEncode</span><span class="PUNC">=</span><span class="PUNC">-</span><span class="NUMB">5.4</span><span class="PUNC">,</span><span class="NAME">simpleFileDformat</span><span class="PUNC">=</span><span class="NAME">_.open_format.TristateUseDefault</span><span class="PUNC">;</span><span class="COMM">//_autodetect autodetectEncode(file)</span><span class="WHIT">
<span class='line'>2444</span> </span><span class="COMM">//_.read_all_file[generateCode.dLK]=_.write_to_file[generateCode.dLK]='simpleFileErr,simpleFileAutodetectEncode,simpleFileDformat,initWScriptObj';//_.open_file,autodetectEncode,getFP,_.open_format.TristateUseDefault</span><span class="WHIT">
<span class='line'>2445</span> </span><span class="COMM">//_.read_all_file[generateCode.dLK]+=',ForReading';_.write_to_file[generateCode.dLK]+=',ForWriting';</span><span class="WHIT">
<span class='line'>2446</span> </span><span class="COMM">//_.read_all_file[generateCode.dLK]+=',translate_AdoStream_binary_data'; // for _.read_all_file(FP,'binary')</span><span class="WHIT">
<span class='line'>2447</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2448</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2449</span> </span><span class="COMM">/**
<span class='line'>2450</span> * 讀取檔案
<span class='line'>2451</span> * @param FN file path
<span class='line'>2452</span> * @param format open encode = simpleFileDformat
<span class='line'>2453</span> * @param io_mode open IO mode = ForReading
<span class='line'>2454</span> * @param func do this function per line, or [func, maxsize] (TODO)
<span class='line'>2455</span> * @return {String} 檔案內容
<span class='line'>2456</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2457</span> */</span><span class="WHIT">
<span class='line'>2458</span> </span><span class="NAME">read_all_file</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">func</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2459</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">format</span><span class="PUNC">==</span><span class="NAME">simpleFileAutodetectEncode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2460</span> </span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">=</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">?</span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2461</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">FN</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">=</span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2462</span> </span><span class="WHIT"> </span><span class="COMM">//var a,fs;try{fs=fso.OpenTextFile(FN,io_mode||_.iomode.ForReading,false,format||simpleFileDformat),a=fs.ReadAll(),fs.Close();}catch(e){simpleFileErr=e;return;}</span><span class="WHIT">
<span class='line'>2463</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">,</span><span class="NAME">fs</span><span class="PUNC">;</span><span class="COMM">//,i,s=0,t;</span><span class="WHIT">
<span class='line'>2464</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">_.open_file</span><span class="PUNC">!=</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2465</span> </span><span class="WHIT"> </span><span class="COMM">//{if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return;</span><span class="WHIT">
<span class='line'>2466</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fs</span><span class="PUNC">=</span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">||</span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">,</span><span class="KEYW">false</span><span class="COMM">/*create*/</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2467</span> </span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2468</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">fs</span><span class="PUNC">=</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">||</span><span class="NAME">_.iomode.ForReading</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">fs</span><span class="PUNC">===</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2469</span>
<span class='line'>2470</span> </span><span class="WHIT"> </span><span class="COMM">//if(func instanceof Array)s=func[1],func=func[0];</span><span class="WHIT">
<span class='line'>2471</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">fs</span><span class="PUNC">!==</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2472</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2473</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fs.AtEndOfStream</span><span class="PUNC">)</span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">fs.ReadLine</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2474</span> </span><span class="COMM">/*
<span class='line'>2475</span> while(!fs.AtEndOfStream){
<span class='line'>2476</span> for(t='',i=0;!fs.AtEndOfStream&&(!t||i&lt;s);i++)
<span class='line'>2477</span> t+=fs.ReadLine();
<span class='line'>2478</span> a+=func(t);
<span class='line'>2479</span> }
<span class='line'>2480</span> */</span><span class="WHIT">
<span class='line'>2481</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">fs.ReadAll</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2482</span> </span><span class="WHIT"> </span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2483</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2484</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="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">!=</span><span class="STRN">'undefined'</span><span class="PUNC">&&</span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2485</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2486</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.LoadFromFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2487</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="PUNC">==</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2488</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">AdoStream.Read</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadAll</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>2489</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_.read_all_file.turnBinToStr</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">==</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2490</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2491</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">AdoStream.EOS</span><span class="PUNC">)</span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadLine</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2492</span> </span><span class="COMM">/*
<span class='line'>2493</span> while(!AdoStream.EOS){
<span class='line'>2494</span> for(t='',i=0;!AdoStream.AtEndOfStream&&(!t||i&lt;s);i++)
<span class='line'>2495</span> t+=AdoStream.ReadText(AdoEnums.adReadLine);
<span class='line'>2496</span> a+=func(t);
<span class='line'>2497</span> }
<span class='line'>2498</span> */</span><span class="WHIT">
<span class='line'>2499</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadAll</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2500</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2501</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2502</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2503</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2504</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2505</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2506</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="STRN">'unknown error!'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">simpleFileErr.name</span><span class="PUNC">=</span><span class="STRN">'unknownError'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2507</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2508</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2509</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2510</span> </span><span class="PUNC">.</span><span class="NAME">read_all_file.turnBinToStr</span><span class="PUNC">=</span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2511</span>
<span class='line'>2512</span>
<span class='line'>2513</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2514</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2515</span> </span><span class="COMM">/**
<span class='line'>2516</span> * 將 content 寫入 file
<span class='line'>2517</span> * ** ADODB.Stream does not support appending!
<span class='line'>2518</span> * @param FN file path
<span class='line'>2519</span> * @param content content to write
<span class='line'>2520</span> * @param format open format = simpleFileDformat
<span class='line'>2521</span> * @param io_mode write mode = ForWriting, e.g., ForAppending
<span class='line'>2522</span> * @param N_O DO NOT overwrite
<span class='line'>2523</span> * @return error No.
<span class='line'>2524</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2525</span> */</span><span class="WHIT">
<span class='line'>2526</span> </span><span class="NAME">write_to_file</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">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">content</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">N_O</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2527</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</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'>2528</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">simpleFileAutodetectEncode</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2529</span> </span><span class="WHIT"> </span><span class="NAME">format</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">autodetectEncode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2530</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2531</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">FN</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">getFP</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2532</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2533</span> </span><span class="WHIT"> </span><span class="COMM">//var fs;try{fs=fso.OpenTextFile(FN,iomode||ForWriting,true,format||TristateUseDefault);}catch(e){return 2;}if(!fs)return 3;</span><span class="WHIT">
<span class='line'>2534</span> </span><span class="WHIT"> </span><span class="COMM">//try{fs.Write(content);}catch(e){return e.number&0xFFFF==5?5:4;} // 5:content中有此local無法相容的字元例如在中文中寫入日文假名</span><span class="WHIT">
<span class='line'>2535</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2536</span> </span><span class="WHIT"> </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">_.open_file</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'>2537</span> </span><span class="WHIT"> </span><span class="COMM">// {if(!FN||typeof getFP=='function'&&!(FN=getFP(FN)))return 2;</span><span class="WHIT">
<span class='line'>2538</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'>2539</span> </span><span class="WHIT"> </span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2540</span> </span><span class="WHIT"> </span><span class="KEYW">true</span><span class="COMM">/* create */</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2541</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">fs</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2542</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2543</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'>2544</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2545</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2546</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2547</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT">
<span class='line'>2548</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_.iomode.ForWriting</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fs</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2549</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2550</span> </span><span class="WHIT"> </span><span class="KEYW">else</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">fs</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">fs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2551</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2552</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fs</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'>2553</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'>2554</span> </span><span class="WHIT"> </span><span class="NAME">fs.Write</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2555</span> </span><span class="WHIT"> </span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2556</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'>2557</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2558</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'>2559</span> </span><span class="WHIT"> </span><span class="NAME">fs.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2560</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'>2561</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2562</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">simpleFileErr.number</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xFFFF</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2563</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2564</span> </span><span class="WHIT"> </span><span class="COMM">// AdoStream.SaveToFile()需在AdoStream.Write之後</span><span class="WHIT">
<span class='line'>2565</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </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">AdoStream</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2566</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'>2567</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">AdoEnums.adTypeText</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2568</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.WriteText</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2569</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>2570</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Write</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2571</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.SaveToFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">io_mode</span><span class="WHIT">
<span class='line'>2572</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">AdoEnums.adSaveCreateOverWrite</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2573</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2574</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'>2575</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2576</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'>2577</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2578</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'>2579</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2580</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2581</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2582</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2583</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'unknown error!'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2584</span> </span><span class="WHIT"> </span><span class="NAME">simpleFileErr.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'unknownError'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2585</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2586</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2587</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2588</span>
<span class='line'>2589</span> </span><span class="COMM">// TODO: unfinished</span><span class="WHIT">
<span class='line'>2590</span> </span><span class="COMM">//simpleDealFile[generateCode.dLK]='autodetectEncode,_.read_all_file,_.write_to_file';</span><span class="WHIT">
<span class='line'>2591</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2592</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2593</span> </span><span class="NAME">simpleDealFile</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">inFN</span><span class="PUNC">,</span><span class="NAME">func</span><span class="PUNC">,</span><span class="NAME">outFN</span><span class="PUNC">,</span><span class="NAME">format</span><span class="PUNC">,</span><span class="NAME">io_mode</span><span class="PUNC">,</span><span class="NAME">N_O</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2594</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">inFN</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2595</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">outFN</span><span class="PUNC">)</span><span class="NAME">outFN</span><span class="PUNC">=</span><span class="NAME">inFN</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2596</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">=</span><span class="NAME">autodetectEncode</span><span class="PUNC">(</span><span class="NAME">inFN</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">_.read_all_file</span><span class="PUNC">(</span><span class="NAME">inFN</span><span class="PUNC">,</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">o</span><span class="PUNC">=</span><span class="NAME">_.read_all_file</span><span class="PUNC">(</span><span class="NAME">outFN</span><span class="PUNC">,</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">inFN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2597</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">t</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">&&</span><span class="NAME">o</span><span class="PUNC">!=</span><span class="NAME">t</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_.write_to_file</span><span class="PUNC">(</span><span class="NAME">outFN</span><span class="PUNC">,</span><span class="NAME">t</span><span class="PUNC">,</span><span class="NAME">e</span><span class="PUNC">,</span><span class="NAME">N_O</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2598</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2599</span>
<span class='line'>2600</span> </span><span class="COMM">/*
<span class='line'>2601</span> var autodetectEncodeSP,autodetectEncodeCode; // 特殊字元,各種編碼及判別所需最短長度
<span class='line'>2602</span> setObjValue('autodetectEncodeSP','3005=J,3006=J,3402=J,3447=C,3468=J,3473=C,359e=C,360e=C,361a=C,3918=C,396e=C,39cf=C,39d0=C,39df=C,3a73=C,3b4e=C,3b77=J,3c6e=C,3ce0=C,3f57=J,4056=C,415f=C,42c6=J,4302=J,4337=C,43ac=C,43b1=C,43dd=C,44be=J,44d4=J,44d6=C,464c=C,4661=C,4723=C,4729=C,477c=C,478d=C,4947=C,497a=C,497d=C,'
<span class='line'>2603</span> +'4982=C,4983=C,4985=C,4986=C,499b=C,499f=C,49b0=J,49b6=C,49b7=C,4c77=C,4c9f=C,4ca0=C,4ca1=C,4ca2=C,4ca3=C,4d13=C,4d14=C,4d15=C,4d16=C,4d17=C,4d18=C,4d19=C,4dae=C,4e12=J,4e13=C,4e1a=C,4e1b=C,4e1c=C,4e1d=C,4e24=C,4e25=C,4e27=C,4e28=J,4e2a=C,4e34=C,4e3a=C,4e3c=J,4e3d=C,4e3e=C,4e49=C,'
<span class='line'>2604</span> +'4e4c=C,4e50=C,4e54=C,4e60=C,4e61=C,4e62=J,4e66=C,4e70=C,4e71=C,4e8f=C,4e9a=C,4ea7=C,4ea9=C,4eb2=C,4eb5=C,4ebf=C,4ec5=C,4ece=C,4ed0=J,4ed1=C,4ed3=C,4eea=C,4eec=C,4f17=C,4f1b=C,4f1d=J,4f1e=C,4f1f=C,4f20=C,4f24=C,4f25=C,4f26=C,4f27=C,4f2a=C,4f65=C,4f66=J,4fa0=C,4fa1=J,4fa4=J,4fa5=C,'
<span class='line'>2605</span> +'4fa6=C,4fa7=C,4fa8=C,4fa9=C,4faa=C,4fac=C,4fb0=J,4fe3=J,4fe4=J,4fe5=J,4fe6=C,4fe7=J,4fe8=C,4fe9=C,4fea=C,4fed=C,5039=J,503a=C,503b=J,503e=C,5051=J,507b=C,507e=C,507f=C,50a5=C,50a7=C,50a8=C,50a9=C,50cd=J,50de=C,50f2=J,5170=C,5173=C,5174=C,517b=C,517d=C,5181=C,5188=C,5199=C,519b=C,'
<span class='line'>2606</span> +'519c=C,51af=C,51b2=C,51bb=C,51e4=C,51e7=J,51e9=J,51ea=J,51eb=C,51ed=C,51ee=J,51ef=C,51fb=C,51ff=C,520d=C,5218=C,5219=C,521a=C,521b=C,522b=C,522c=C,522d=C,523d=C,523f=C,5240=C,5242=C,5250=C,5251=C,5257=C,5267=C,5273=C,529d=C,529e=C,52a1=C,52a8=C,52b1=C,52b2=C,52b3=C,52bf=C,52cb=C,'
<span class='line'>2607</span> +'52da=C,5301=J,5302=J,5307=J,5326=C,532e=C,533b=C,534e=C,534f=C,5355=C,5356=C,5362=C,5364=C,536b=C,5385=C,5386=C,5389=C,538b=C,538c=C,538d=C,5395=C,53a0=C,53a3=C,53bf=C,53c2=C,53c6=C,53c7=C,53cc=C,53d1=C,53d8=C,53f6=C,53f7=C,53f9=C,53fa=J,53fd=C,540b=J,5413=C,5417=C,542f=C,544e=J,'
<span class='line'>2608</span> +'544f=J,5452=C,5453=C,5455=C,5456=C,5457=C,5458=C,545b=C,545c=C,5484=J,5491=J,5499=C,549b=C,549c=J,549d=C,54cd=C,54d1=C,54d2=C,54d3=C,54d4=C,54d5=C,54d7=C,54d8=J,54d9=C,54dd=C,54df=C,54e9=J,5500=J,551b=C,551d=C,5520=C,5521=C,5522=C,5553=C,5567=C,556c=C,556d=C,556e=C,5570=C,5578=C,'
<span class='line'>2609</span> +'55b0=J,55b7=C,55bd=C,55be=C,55eb=C,55f3=C,5624=C,5631=C,565c=C,565d=C,5678=J,567a=J,56a3=C,56c9=J,56ce=J,56e2=C,56ed=C,56f2=J,56f4=C,56f5=C,56fe=C,5706=C,5715=J,5726=J,5737=J,5738=J,5739=C,573a=C,5746=J,5757=C,575a=C,575b=C,575c=C,575d=C,575e=C,575f=C,5760=C,5784=C,5786=C,5788=J,'
<span class='line'>2610</span> +'5789=J,5792=C,57a4=J,57a6=C,57a9=C,57ab=C,57ac=J,57ad=C,57b0=J,57b2=C,57b3=J,57d6=J,57d8=C,57d9=C,57da=C,5811=C,5815=C,5840=J,5870=J,5899=C,58b8=J,58b9=J,58d7=J,58e5=J,58ee=C,58f0=C,58f3=C,58f6=C,58f8=C,5904=C,5907=C,5934=C,5939=C,593a=C,5941=C,594b=C,5956=C,5986=C,5987=C,5988=C,'
<span class='line'>2611</span> +'598b=J,599b=J,59a9=C,59aa=C,59ab=C,59c9=J,5a04=C,5a05=C,5a06=C,5a07=C,5a08=C,5a32=C,5a34=C,5a47=J,5a72=J,5a73=C,5a74=C,5a75=C,5a76=C,5aac=J,5ad2=C,5ad4=C,5af1=C,5b00=C,5b36=J,5b59=C,5b66=C,5b6a=C,5b93=J,5b9e=C,5ba0=C,5ba1=C,5baa=C,5bbd=C,5bbe=C,5bc9=J,5bdd=C,5bf9=C,5bfb=C,5bfc=C,'
<span class='line'>2612</span> +'5bff=C,5c06=C,5c14=C,5c18=C,5c1d=C,5c27=C,5c34=C,5c3d=C,5c42=C,5c5e=C,5c61=C,5c66=C,5c76=J,5c7f=C,5c81=C,5c82=C,5c96=C,5c97=C,5c98=C,5c9a=C,5c9b=C,5cbc=J,5cbd=C,5cbe=J,5cbf=C,5cc3=C,5cc4=C,5cc5=J,5ce0=J,5ce1=C,5ce3=C,5ce4=C,5ce6=C,5d02=C,5d03=C,5d10=C,5d2c=C,5d2d=C,5d58=C,5d59=J,'
<span class='line'>2613</span> +'5d5a=C,5d5d=C,5d76=J,5dc5=C,5de9=C,5def=C,5e01=C,5e05=C,5e08=C,5e0f=C,5e10=C,5e1c=C,5e26=C,5e27=C,5e2e=C,5e3b=C,5e3c=C,5e7f=C,5e83=J,5e86=C,5e90=C,5e91=C,5e93=C,5e94=C,5e99=C,5e9e=C,5e9f=C,5ebc=C,5f00=C,5f03=C,5f16=J,5f20=C,5f25=C,5f2f=C,5f39=C,5f41=J,5f45=J,5f52=C,5f53=C,5f55=C,'
<span class='line'>2614</span> +'5f7b=C,5f84=C,5f95=C,5fa4=J,5fc6=C,5fdc=J,5fe7=C,5ff0=J,5ffe=C,6001=C,6002=C,6003=C,6004=C,6005=C,6006=C,603a=J,603b=C,603c=C,603f=C,604b=C,6073=C,6076=C,6077=J,6078=C,6079=C,607a=C,607b=C,607c=C,607d=C,60ab=C,60ac=C,60ad=C,60af=C,60e7=C,60e8=C,60e9=C,60eb=C,60ec=C,60ed=C,60ee=C,'
<span class='line'>2615</span> +'60ef=C,6124=C,6126=C,6151=C,6164=C,61d1=C,61d2=C,6206=C,620b=C,620f=C,6217=C,6218=C,6256=J,6267=C,6268=J,6269=C,626a=C,626b=C,626c=C,629a=C,629f=C,62a0=C,62a1=C,62a2=C,62a4=C,62a5=C,62c5=C,62df=C,62e2=C,62e3=C,62e5=C,62e6=C,62e7=C,62e8=C,62e9=C,630a=J,6317=J,6318=J,631a=C,631b=C,'
<span class='line'>2616</span> +'631c=C,631d=C,631e=C,631f=C,6320=C,6321=C,6322=C,6324=C,6325=C,6326=C,6327=J,635e=C,635f=C,6361=C,6363=C,6364=J,6386=C,63b3=C,63b4=C,63b5=J,63b7=C,63b8=C,63ba=C,63bc=C,63fd=C,63ff=C,6400=C,6401=C,6402=C,6405=C,643e=J,6444=C,6445=C,6446=C,6448=C,644a=C,6484=C,64b5=C,64b7=C,64ba=C,'
<span class='line'>2617</span> +'64d3=C,64de=C,6512=C,654c=C,655b=C,6570=C,658b=C,6593=C,65a9=C,65ad=C,65e0=C,65e7=C,65f6=C,65f7=C,65f8=C,6619=C,663c=C,663d=C,663e=C,6653=C,6654=C,6655=C,6682=C,6683=J,66a7=C,66fb=J,6722=J,672f=C,6740=C,6741=J,6742=C,6743=C,6761=C,6762=J,6763=J,6764=J,6765=C,6766=J,6768=C,678c=J,'
<span class='line'>2618</span> +'679e=C,67a0=J,67a1=J,67a2=C,67a3=C,67a5=C,67a6=J,67a7=C,67a8=C,67a9=J,67aa=C,67ab=C,67ad=C,67d5=J,67e0=C,67fd=C,67fe=J,6802=J,6803=J,6807=C,6808=C,6809=C,680a=C,680b=C,680c=C,680d=J,680e=C,680f=C,6811=C,682c=J,6837=C,683e=C,685b=J,685c=J,685d=J,6861=C,6862=C,6863=C,6864=C,6865=C,'
<span class='line'>2619</span> +'6866=C,6867=C,6868=C,6869=C,6898=C,68a6=C,68ba=J,68bb=J,68c0=C,68c2=C,6917=J,6919=J,691a=J,691b=J,691f=C,6920=C,6921=J,6923=J,6924=C,6925=J,6926=J,6928=J,692a=J,692d=C,693f=J,697c=C,697e=J,697f=J,6980=J,6981=J,6984=C,6987=C,6988=C,6989=C,698a=J,69c7=J,69da=C,69db=C,69dd=J,69df=C,'
<span class='line'>2620</span> +'69e0=C,6a2b=J,6a2e=J,6a2f=C,6a30=J,6a31=C,6a3b=J,6a67=J,6a72=J,6a73=J,6a78=J,6a79=C,6a7c=C,6ab0=J,6ae4=J,6b1f=J,6b22=C,6b24=C,6b27=C,6b7c=C,6b87=C,6b8b=C,6b92=C,6b93=C,6b9a=C,6ba1=C,6ba8=C,6bb4=C,6bbb=C,6bc2=C,6bd5=C,6bd9=C,6bdf=J,6be1=C,6bee=J,6bf5=C,6c07=C,6c17=J,6c22=C,6c29=C,'
<span class='line'>2621</span> +'6c47=C,6c49=C,6c62=J,6c64=C,6c9f=C,6ca3=C,6ca4=C,6ca5=C,6ca6=C,6ca7=C,6ca8=C,6ca9=C,6caa=C,6cea=C,6cf7=C,6cf8=C,6cfa=C,6cfb=C,6cfc=C,6cfd=C,6cfe=C,6d43=C,6d45=C,6d46=C,6d47=C,6d48=C,6d49=C,6d4a=C,6d4b=C,6d4d=C,6d4e=C,6d4f=C,6d50=C,6d51=C,6d52=C,6d53=C,6d54=C,6d55=C,6d9b=C,6d9c=J,'
<span class='line'>2622</span> +'6d9d=C,6d9e=C,6d9f=C,6da0=C,6da1=C,6da2=C,6da4=C,6da6=C,6da7=C,6da8=C,6da9=C,6e0a=C,6e0d=C,6e0e=C,6e10=C,6e11=C,6e14=C,6e17=C,6e7e=C,6e7f=C,6e82=J,6e83=C,6e85=C,6e87=C,6ed7=C,6ede=C,6edf=C,6ee0=C,6ee1=C,6ee4=C,6ee5=C,6ee6=C,6ee8=C,6ee9=C,6eea=C,6f47=C,6f4b=C,6f4d=C,6f57=J,6f59=C,'
<span class='line'>2623</span> +'6f76=J,6f9c=C,6fbe=C,6fd1=C,6fd2=C,6ff9=J,704f=C,7067=C,706d=C,706f=C,7075=C,707e=C,707f=C,7080=C,7089=C,709c=C,709d=C,70b9=C,70bb=J,70bc=C,70bd=C,70c1=C,70c2=C,70c3=C,70db=C,70e6=C,70e7=C,70e8=C,70e9=C,70eb=C,70ec=C,70ed=C,7116=C,7118=C,7144=J,7173=J,7194=J,7195=J,71f5=J,7231=C,'
<span class='line'>2624</span> +'7232=C,7237=C,7240=C,724d=C,7275=C,727a=C,728a=C,72b6=C,72b7=C,72b8=C,72b9=C,72c6=J,72c8=C,72de=C,72ec=C,72ed=C,72ee=C,72ef=C,72f1=C,72f2=C,7303=C,730e=C,7315=C,7321=C,732b=C,732e=C,7341=C,736d=C,7391=C,739b=C,73ae=C,73af=C,73b0=C,73b1=C,73ba=C,73c6=J,73d1=C,73f2=C,740e=C,740f=C,'
<span class='line'>2625</span> +'7410=C,7411=J,743c=C,7443=J,7477=C,748e=C,74d2=C,74e7=J,74e9=J,74ea=J,74ef=C,74f0=J,74f1=J,74f2=J,74f8=J,74fc=J,7505=J,7523=C,7535=C,753b=C,753c=J,7545=C,7551=J,7560=J,7569=J,7573=J,7574=C,757d=J,7596=C,7597=C,759f=C,75a0=C,75a1=C,75ac=C,75ae=C,75af=C,75c7=J,75c8=C,75c9=C,75e8=C,'
<span class='line'>2626</span> +'75eb=C,7605=C,7606=C,7617=C,7618=C,762a=C,762b=C,762e=C,763b=C,763e=C,763f=C,764c=J,765e=C,7663=C,7667=C,766a=J,766b=C,7691=C,76b1=C,76b2=C,76cf=C,76d0=C,76d1=C,76d6=C,76d8=C,770d=C,7750=C,7751=C,7792=C,7798=C,77a9=C,77eb=C,77f6=C,77fe=C,77ff=C,7800=C,7801=C,7816=C,7817=C,781a=C,'
<span class='line'>2627</span> +'781c=C,783a=C,783b=C,783e=C,7840=C,7855=C,7856=C,7857=C,7859=C,785a=C,7872=J,7874=J,7877=C,788d=C,7897=J,789b=C,789c=C,78b5=J,78b8=C,7935=J,793c=C,794e=C,7962=C,796f=C,7977=C,7978=C,7985=C,79ef=C,79f0=C,79fd=C,7a23=C,7a2d=C,7a33=C,7a43=J,7a51=C,7a5d=J,7a77=C,7a83=C,7a8d=C,7a8e=C,'
<span class='line'>2628</span> +'7a9c=C,7a9d=C,7aa5=C,7aa6=C,7aad=C,7ac8=C,7acd=J,7acf=J,7ad3=J,7ad5=J,7ad6=C,7ade=C,7ae1=J,7aea=C,7af0=J,7b02=J,7b03=C,7b0b=C,7b14=C,7b15=C,7b39=J,7b3a=C,7b3c=C,7b3d=J,7b3e=C,7b5a=C,7b5b=C,7b79=C,7b7e=C,7b80=C,7b93=C,7ba5=J,7ba6=C,7ba7=C,7ba8=C,7ba9=C,7baa=C,7bab=C,7bcf=J,7bd1=C,'
<span class='line'>2629</span> +'7bd3=C,7bee=C,7c13=J,7c16=C,7c17=J,7c31=J,7c41=C,7c4f=J,7c74=C,7c75=J,7c7b=C,7c7e=J,7c81=J,7c82=J,7c8d=J,7c8f=J,7c90=J,7c9c=C,7c9d=C,7ca0=J,7ca8=J,7caa=C,7cab=J,7cad=J,7cae=C,7cc0=J,7cc1=C,7cce=J,7cd8=J,7d25=C,7d26=J,7d27=C,7d5d=C,7d76=C,7d77=C,7d89=C,7d9b=J,7dab=C,7db3=C,7dd1=C,'
<span class='line'>2630</span> +'7dd5=J,7dfc=C,7e05=J,7e27=C,7e28=J,7e4a=J,7e67=J,7e6e=C,7e83=J,7e90=J,7ea0=C,7ea1=C,7ea2=C,7ea3=C,7ea4=C,7ea5=C,7ea6=C,7ea7=C,7ea8=C,7ea9=C,7eaa=C,7eab=C,7eac=C,7ead=C,7eaf=C,7eb0=C,7eb1=C,7eb2=C,7eb3=C,7eb4=C,7eb5=C,7eb6=C,7eb7=C,7eb8=C,7eb9=C,7eba=C,7ebc=C,7ebd=C,7ebe=C,7ebf=C,'
<span class='line'>2631</span> +'7ec0=C,7ec1=C,7ec2=C,7ec3=C,7ec4=C,7ec5=C,7ec6=C,7ec7=C,7ec8=C,7ec9=C,7eca=C,7ecb=C,7ecc=C,7ecd=C,7ece=C,7ecf=C,7ed0=C,7ed1=C,7ed2=C,7ed3=C,7ed4=C,7ed5=C,7ed6=C,7ed7=C,7ed8=C,7ed9=C,7eda=C,7edb=C,7edc=C,7edd=C,7ede=C,7edf=C,7ee0=C,7ee1=C,7ee2=C,7ee3=C,7ee5=C,7ee6=C,7ee7=C,7ee8=C,'
<span class='line'>2632</span> +'7ee9=C,7eea=C,7eeb=C,7eed=C,7eee=C,7eef=C,7ef0=C,7ef2=C,7ef3=C,7ef4=C,7ef5=C,7ef6=C,7ef7=C,7ef8=C,7efa=C,7efb=C,7efc=C,7efd=C,7efe=C,7eff=C,7f00=C,7f01=C,7f02=C,7f03=C,7f04=C,7f05=C,7f06=C,7f07=C,7f08=C,7f09=C,7f0a=C,7f0c=C,7f0e=C,7f11=C,7f12=C,7f13=C,7f14=C,7f15=C,7f16=C,7f17=C,'
<span class='line'>2633</span> +'7f18=C,7f19=C,7f1a=C,7f1b=C,7f1c=C,7f1d=C,7f1e=C,7f1f=C,7f20=C,7f21=C,7f22=C,7f23=C,7f24=C,7f25=C,7f26=C,7f27=C,7f28=C,7f29=C,7f2a=C,7f2b=C,7f2c=C,7f2d=C,7f2e=C,7f2f=C,7f30=C,7f31=C,7f32=C,7f33=C,7f34=C,7f35=C,7f3c=J,7f42=C,7f4e=C,7f57=C,7f5a=C,7f62=C,7f74=C,7f81=C,7f9f=C,7faa=J,'
<span class='line'>2634</span> +'7fd8=C,7fda=C,8022=C,8027=C,802e=C,8038=C,8042=C,804b=C,804c=C,804d=C,8054=C,8062=J,8069=C,806a=C,8083=C,80a0=C,80a4=C,80be=C,80bf=C,80c0=C,80c1=C,80c6=C,80e7=C,80e8=C,80ea=C,80eb=C,80f1=J,80f6=C,8109=C,810d=C,810f=C,8110=C,8111=C,8113=C,8114=C,8135=J,8136=C,8138=C,8156=C,8158=C,'
<span class='line'>2635</span> +'817a=J,817b=C,817e=C,8191=C,81a4=J,81b5=J,81cd=J,81dc=C,8206=C,8220=J,822e=J,8230=C,8231=C,823b=C,8249=J,825d=J,8260=J,8270=C,8273=C,827a=C,8282=C,8297=C,829c=C,82a6=C,82c1=C,82c5=J,82c7=C,82c8=C,82cb=C,82cd=C,82cf=C,830e=C,830f=C,8311=C,8314=C,8315=C,834e=J,835a=C,835b=C,835c=C,'
<span class='line'>2636</span> +'835e=C,835f=C,8360=C,8361=C,8363=C,8364=C,8365=C,8366=C,8367=C,8368=C,8369=C,836a=C,836b=C,836c=C,836d=C,836e=C,836f=C,83b1=C,83b2=C,83b3=C,83b4=C,83b7=C,83b8=C,83b9=C,83ba=C,83bc=C,8419=J,841a=C,841d=C,8421=J,8422=J,8424=C,8425=C,8426=C,8427=C,8428=C,8429=J,8464=C,8485=J,8487=C,'
<span class='line'>2637</span> +'8489=C,848b=C,848c=C,8493=C,84d9=J,84da=J,84dc=J,84dd=C,84df=C,84e3=C,84e6=C,8534=C,8536=J,8537=C,8539=C,853a=C,853c=C,8552=C,8572=C,8574=C,85ae=C,85d3=C,85f4=C,8612=J,8630=J,8645=J,864f=C,8651=C,8672=J,867d=C,867e=C,867f=C,8680=C,8681=C,8682=C,86ab=J,86ac=C,86ca=C,86ce=C,86cf=C,'
<span class='line'>2638</span> +'86ee=C,86ef=J,86f0=C,86f1=C,86f2=C,86f3=C,86f4=C,8717=C,8747=C,8748=C,8749=C,877c=C,877e=C,87a7=J,87a8=C,87a9=J,87cf=C,87d0=J,87f5=J,8845=C,8846=C,8854=C,8865=C,886c=C,8884=C,8885=C,889c=C,88ad=C,88b0=J,88c3=J,88c4=J,88c5=C,88c6=C,88e2=C,88e3=C,88e4=C,88e5=C,8902=J,8904=J,891b=C,'
<span class='line'>2639</span> +'891c=J,8934=C,8947=C,8977=J,898e=C,89c1=C,89c2=C,89c3=C,89c4=C,89c5=C,89c6=C,89c7=C,89c8=C,89c9=C,89ca=C,89cb=C,89cc=C,89ce=C,89cf=C,89d0=C,89d1=C,89de=C,8a29=C,8a33=J,8a5f=C,8a89=C,8a8a=C,8aac=C,8aad=J,8aae=J,8ada=J,8b21=C,8b2d=C,8ba1=C,8ba2=C,8ba3=C,8ba4=C,8ba5=C,8ba6=C,8ba7=C,'
<span class='line'>2640</span> +'8ba8=C,8ba9=C,8baa=C,8bab=C,8bad=C,8bae=C,8baf=C,8bb0=C,8bb2=C,8bb3=C,8bb4=C,8bb5=C,8bb6=C,8bb7=C,8bb8=C,8bb9=C,8bba=C,8bbb=C,8bbc=C,8bbd=C,8bbe=C,8bbf=C,8bc0=C,8bc1=C,8bc2=C,8bc3=C,8bc4=C,8bc5=C,8bc6=C,8bc7=C,8bc8=C,8bc9=C,8bca=C,8bcb=C,8bcc=C,8bcd=C,8bce=C,8bcf=C,8bd1=C,8bd2=C,'
<span class='line'>2641</span> +'8bd3=C,8bd4=C,8bd5=C,8bd6=C,8bd7=C,8bd8=C,8bd9=C,8bda=C,8bdb=C,8bdd=C,8bde=C,8bdf=C,8be0=C,8be1=C,8be2=C,8be3=C,8be4=C,8be5=C,8be6=C,8be7=C,8be8=C,8be9=C,8beb=C,8bec=C,8bed=C,8bee=C,8bef=C,8bf0=C,8bf1=C,8bf2=C,8bf3=C,8bf4=C,8bf5=C,8bf6=C,8bf7=C,8bf8=C,8bf9=C,8bfa=C,8bfb=C,8bfc=C,'
<span class='line'>2642</span> +'8bfd=C,8bfe=C,8bff=C,8c00=C,8c01=C,8c02=C,8c03=C,8c04=C,8c05=C,8c06=C,8c07=C,8c08=C,8c09=C,8c0a=C,8c0b=C,8c0c=C,8c0d=C,8c0e=C,8c0f=C,8c10=C,8c11=C,8c12=C,8c13=C,8c14=C,8c15=C,8c16=C,8c17=C,8c18=C,8c19=C,8c1a=C,8c1b=C,8c1c=C,8c1d=C,8c1e=C,8c1f=C,8c20=C,8c21=C,8c22=C,8c23=C,8c24=C,'
<span class='line'>2643</span> +'8c25=C,8c26=C,8c27=C,8c28=C,8c29=C,8c2a=C,8c2b=C,8c2c=C,8c2d=C,8c2e=C,8c2f=C,8c30=C,8c31=C,8c32=C,8c33=C,8c34=C,8c35=C,8c36=C,8c6e=C,8cae=J,8ceb=C,8cec=J,8d0b=C,8d1c=C,8d1d=C,8d1e=C,8d1f=C,8d21=C,8d22=C,8d23=C,8d24=C,8d25=C,8d26=C,8d27=C,8d28=C,8d29=C,8d2a=C,8d2b=C,8d2c=C,8d2d=C,'
<span class='line'>2644</span> +'8d2e=C,8d2f=C,8d30=C,8d31=C,8d32=C,8d33=C,8d34=C,8d35=C,8d36=C,8d37=C,8d38=C,8d39=C,8d3a=C,8d3b=C,8d3c=C,8d3d=C,8d3e=C,8d3f=C,8d41=C,8d42=C,8d43=C,8d44=C,8d45=C,8d46=C,8d48=C,8d49=C,8d4a=C,8d4b=C,8d4c=C,8d4d=C,8d4e=C,8d4f=C,8d50=C,8d52=C,8d53=C,8d54=C,8d55=C,8d56=C,8d57=C,8d58=C,'
<span class='line'>2645</span> +'8d59=C,8d5a=C,8d5b=C,8d5c=C,8d5d=C,8d5e=C,8d60=C,8d61=C,8d62=C,8d63=C,8d6a=C,8d71=J,8d75=C,8d8b=C,8db1=C,8db8=C,8dc3=C,8dc4=C,8def=J,8df4=J,8df5=C,8df7=C,8df8=C,8df9=C,8dfb=C,8e0c=C,8e2c=C,8e2f=C,8e51=C,8e52=C,8e7f=C,8e8f=C,8e9c=C,8eae=J,8eaf=C,8eb5=J,8ebb=J,8ebe=J,8ec5=J,8ec8=J,'
<span class='line'>2646</span> +'8ee4=C,8ef2=C,8f4c=J,8f66=C,8f67=C,8f68=C,8f69=C,8f6b=C,8f6c=C,8f6d=C,8f6e=C,8f6f=C,8f70=C,8f71=C,8f72=C,8f73=C,8f74=C,8f76=C,8f77=C,8f78=C,8f79=C,8f7a=C,8f7b=C,8f7c=C,8f7d=C,8f7e=C,8f7f=C,8f82=C,8f83=C,8f84=C,8f85=C,8f86=C,8f87=C,8f88=C,8f89=C,8f8a=C,8f8b=C,8f8d=C,8f8e=C,8f8f=C,'
<span class='line'>2647</span> +'8f90=C,8f91=C,8f93=C,8f94=C,8f95=C,8f96=C,8f97=C,8f98=C,8f99=C,8f9a=C,8f9e=C,8fa9=C,8fab=C,8fb7=J,8fb9=C,8fbb=J,8fbc=J,8fbd=C,8fbe=C,8fc1=C,8fc7=C,8fc8=C,8fd0=C,8fd8=C,8fd9=C,8fda=J,8fdb=C,8fdc=C,8fdd=C,8fde=C,8fdf=C,8fe9=C,8ff9=C,9009=C,900a=C,9012=C,9026=C,9027=J,903b=C,9056=J,'
<span class='line'>2648</span> +'9057=C,9093=C,909d=C,90ac=C,90ae=C,90b9=C,90ba=C,90bb=C,90cf=C,90d0=C,90d1=C,90d2=J,90d3=C,90e6=C,90e7=C,90f8=C,915b=J,915d=C,9171=C,917d=C,917e=C,917f=C,9196=C,91ca=C,91d7=J,91fa=C,91fb=J,91fe=C,9208=C,920e=C,9225=J,9226=J,9228=J,9229=J,922c=J,9239=J,923e=J,9255=C,9262=C,926b=J,'
<span class='line'>2649</span> +'9274=C,9286=J,92ab=J,92ae=C,92af=J,92b1=C,92c5=J,92e5=C,92ed=C,92f2=J,9307=C,9332=C,9335=J,933a=J,933e=C,9340=C,9341=C,9344=J,9369=C,9384=C,9386=J,9387=C,93b8=C,93b9=J,93bf=C,93e5=J,93f0=C,941d=C,9420=J,9421=J,9426=C,9427=C,942f=C,9453=J,9454=C,9465=C,9479=C,9486=C,9487=C,9488=C,'
<span class='line'>2650</span> +'9489=C,948a=C,948b=C,948c=C,948d=C,948e=C,948f=C,9490=C,9492=C,9493=C,9494=C,9495=C,9496=C,9497=C,9498=C,9499=C,949a=C,949b=C,949d=C,949e=C,949f=C,94a0=C,94a1=C,94a2=C,94a4=C,94a5=C,94a6=C,94a7=C,94a8=C,94a9=C,94aa=C,94ab=C,94ac=C,94ad=C,94ae=C,94af=C,94b0=C,94b1=C,94b2=C,94b3=C,'
<span class='line'>2651</span> +'94b4=C,94b5=C,94b6=C,94b7=C,94b9=C,94ba=C,94bb=C,94bc=C,94bd=C,94be=C,94bf=C,94c0=C,94c1=C,94c2=C,94c3=C,94c4=C,94c5=C,94c6=C,94c8=C,94c9=C,94ca=C,94cb=C,94cc=C,94cd=C,94ce=C,94cf=C,94d0=C,94d1=C,94d2=C,94d3=C,94d5=C,94d7=C,94d9=C,94db=C,94dc=C,94dd=C,94de=C,94df=C,94e0=C,94e1=C,'
<span class='line'>2652</span> +'94e2=C,94e3=C,94e4=C,94e5=C,94e7=C,94e8=C,94e9=C,94ea=C,94eb=C,94ec=C,94ed=C,94ee=C,94ef=C,94f0=C,94f1=C,94f2=C,94f3=C,94f5=C,94f6=C,94f7=C,94f8=C,94f9=C,94fa=C,94fc=C,94fd=C,94fe=C,94ff=C,9500=C,9501=C,9502=C,9503=C,9504=C,9505=C,9506=C,9507=C,9508=C,9509=C,950b=C,950c=C,950e=C,'
<span class='line'>2653</span> +'950f=C,9510=C,9511=C,9512=C,9513=C,9514=C,9515=C,9517=C,9518=C,9519=C,951a=C,951b=C,951d=C,951e=C,951f=C,9521=C,9522=C,9523=C,9524=C,9525=C,9526=C,9527=C,9528=C,952b=C,952d=C,952e=C,952f=C,9530=C,9531=C,9532=C,9534=C,9535=C,9536=C,9537=C,9538=C,9539=C,953b=C,953c=C,953e=C,953f=C,'
<span class='line'>2654</span> +'9540=C,9541=C,9542=C,9543=C,9544=C,9545=C,9547=C,9549=C,954a=C,954b=C,954c=C,954d=C,954e=C,954f=C,9550=C,9551=C,9552=C,9553=C,9554=C,9556=C,9557=C,9558=C,955a=C,955b=C,955c=C,955d=C,955e=C,9562=C,9563=C,9564=C,9565=C,9566=C,9567=C,9568=C,9569=C,956a=C,956b=C,956c=C,956d=C,956e=C,'
<span class='line'>2655</span> +'956f=C,9570=C,9571=C,9572=C,9573=C,9574=C,9576=C,957f=C,9584=J,9587=J,958a=J,9596=J,95a0=J,95a7=C,95aa=J,95b2=C,95b8=J,95e6=J,95e8=C,95e9=C,95ea=C,95ed=C,95ee=C,95ef=C,95f0=C,95f1=C,95f2=C,95f4=C,95f5=C,95f7=C,95f8=C,95f9=C,95fa=C,95fb=C,95fc=C,95fd=C,95fe=C,95ff=C,9600=C,9601=C,'
<span class='line'>2656</span> +'9602=C,9603=C,9604=C,9605=C,9606=C,9608=C,9609=C,960a=C,960b=C,960c=C,960d=C,960e=C,960f=C,9610=C,9611=C,9612=C,9614=C,9615=C,9616=C,9617=C,9619=C,961a=C,961f=C,9633=C,9634=C,9635=C,9636=C,9645=C,9646=C,9647=C,9648=C,9649=C,9655=C,9668=C,9669=C,968f=C,9690=C,96b6=C,96be=C,96cf=C,'
<span class='line'>2657</span> +'96e0=C,96eb=J,96f3=C,96fe=C,9701=C,972d=C,974d=J,974e=J,974f=J,9753=C,9765=C,9779=J,9786=J,9790=J,9791=C,9792=C,979c=J,97af=C,97bd=C,97e6=C,97e7=C,97e8=C,97e9=C,97ea=C,97eb=C,97ec=C,97f5=C,983d=C,9854=C,986c=C,9875=C,9876=C,9877=C,9878=C,9879=C,987a=C,987b=C,987c=C,987d=C,987e=C,'
<span class='line'>2658</span> +'987f=C,9880=C,9881=C,9882=C,9883=C,9884=C,9885=C,9886=C,9887=C,9888=C,9889=C,988a=C,988b=C,988c=C,988d=C,988f=C,9890=C,9891=C,9893=C,9894=C,9896=C,9897=C,9898=C,9899=C,989b=C,989c=C,989d=C,989e=C,989f=C,98a0=C,98a1=C,98a2=C,98a4=C,98a5=C,98a6=C,98a7=C,98aa=J,98ce=C,98d2=C,98d3=C,'
<span class='line'>2659</span> +'98d4=C,98d5=C,98d7=C,98d8=C,98d9=C,98de=C,98e8=C,98ff=C,9904=C,990d=C,990e=C,990f=C,9919=J,991c=C,9936=C,9937=C,9942=J,994a=C,9962=C,9965=C,9966=C,9967=C,9968=C,9969=C,996a=C,996b=C,996c=C,996d=C,996e=C,996f=C,9970=C,9971=C,9972=C,9973=C,9974=C,9975=C,9976=C,9977=C,9978=C,9979=C,'
<span class='line'>2660</span> +'997a=C,997b=C,997c=C,997d=C,997f=C,9981=C,9983=C,9984=C,9985=C,9986=C,9987=C,9988=C,9989=C,998a=C,998b=C,998d=C,998e=C,998f=C,9990=C,9991=C,9992=C,9993=C,9994=C,9995=C,99e1=C,99f2=J,9a6b=J,9a6c=C,9a6d=C,9a6e=C,9a6f=C,9a70=C,9a71=C,9a73=C,9a74=C,9a75=C,9a76=C,9a77=C,9a78=C,9a79=C,'
<span class='line'>2661</span> +'9a7a=C,9a7b=C,9a7c=C,9a7d=C,9a7e=C,9a7f=C,9a80=C,9a81=C,9a82=C,9a84=C,9a85=C,9a86=C,9a87=C,9a88=C,9a8a=C,9a8b=C,9a8c=C,9a8e=C,9a8f=C,9a90=C,9a91=C,9a92=C,9a93=C,9a96=C,9a97=C,9a98=C,9a9a=C,9a9b=C,9a9c=C,9a9d=C,9a9e=C,9a9f=C,9aa0=C,9aa1=C,9aa2=C,9aa4=C,9aa5=C,9aa7=C,9ac5=C,9acb=C,'
<span class='line'>2662</span> +'9acc=C,9aea=J,9b13=C,9b47=C,9b49=C,9b5d=J,9b5e=J,9b6c=J,9b74=J,9b78=J,9b79=J,9b81=C,9b84=J,9b8d=C,9b8e=C,9b95=J,9b96=J,9b97=J,9b98=J,9b9d=C,9b9f=J,9ba3=C,9bb1=J,9bb4=J,9bba=C,9bce=J,9bcf=J,9bd0=J,9bd1=J,9bd2=J,9be1=J,9bf0=J,9bf1=J,9bf2=J,9bf3=J,9bff=C,9c02=C,9c04=J,9c0c=C,9c10=C,'
<span class='line'>2663</span> +'9c12=J,9c18=J,9c1f=C,9c21=J,9c27=C,9c2e=J,9c2f=J,9c30=J,9c35=C,9c39=J,9c45=C,9c47=J,9c48=J,9c5a=J,9c69=J,9c6a=J,9c6b=J,9c70=J,9c7c=C,9c7d=C,9c7f=C,9c81=C,9c82=C,9c85=C,9c86=C,9c87=C,9c88=C,9c8a=C,9c8b=C,9c8d=C,9c8e=C,9c8f=C,9c90=C,9c91=C,9c92=C,9c94=C,9c96=C,9c97=C,9c99=C,9c9a=C,'
<span class='line'>2664</span> +'9c9b=C,9c9c=C,9c9d=C,9c9e=C,9c9f=C,9ca0=C,9ca1=C,9ca2=C,9ca3=C,9ca4=C,9ca5=C,9ca6=C,9ca7=C,9ca8=C,9ca9=C,9cab=C,9cad=C,9cae=C,9cb0=C,9cb1=C,9cb2=C,9cb3=C,9cb5=C,9cb6=C,9cb7=C,9cb8=C,9cbb=C,9cbd=C,9cbf=C,9cc1=C,9cc3=C,9cc4=C,9cc5=C,9cc6=C,9cc7=C,9cca=C,9ccc=C,9ccd=C,9cce=C,9ccf=C,'
<span class='line'>2665</span> +'9cd1=C,9cd2=C,9cd3=C,9cd4=C,9cd5=C,9cd6=C,9cd7=C,9cd8=C,9cd9=C,9cdb=C,9cdc=C,9cdd=C,9cde=C,9cdf=C,9ce2=C,9ce3=C,9cec=C,9cf0=J,9cfe=C,9d2b=J,9d30=J,9d34=C,9d46=J,9d47=J,9d48=J,9d64=J,9d6e=C,9d93=C,9da5=C,9dab=J,9dc0=C,9dc4=C,9dc9=C,9e0a=C,9e1f=C,9e20=C,9e21=C,9e22=C,9e23=C,9e25=C,'
<span class='line'>2666</span> +'9e26=C,9e27=C,9e28=C,9e29=C,9e2a=C,9e2b=C,9e2c=C,9e2d=C,9e2e=C,9e2f=C,9e30=C,9e31=C,9e32=C,9e33=C,9e35=C,9e36=C,9e37=C,9e38=C,9e39=C,9e3a=C,9e3b=C,9e3c=C,9e3d=C,9e3e=C,9e3f=C,9e41=C,9e42=C,9e43=C,9e44=C,9e45=C,9e46=C,9e47=C,9e48=C,9e49=C,9e4a=C,9e4b=C,9e4c=C,9e4f=C,9e50=C,9e51=C,'
<span class='line'>2667</span> +'9e52=C,9e55=C,9e56=C,9e57=C,9e58=C,9e59=C,9e5a=C,9e5b=C,9e5c=C,9e5e=C,9e61=C,9e63=C,9e64=C,9e65=C,9e66=C,9e67=C,9e68=C,9e69=C,9e6a=C,9e6b=C,9e6c=C,9e6d=C,9e6f=C,9e70=C,9e73=C,9e7e=C,9e91=J,9ea6=C,9eaf=C,9eb8=C,9ebd=C,9ebf=J,9ec9=C,9ee1=C,9ee9=C,9efe=C,9f0b=C,9f0d=C,9f21=J,9f50=C,'
<span class='line'>2668</span> +'9f51=C,9f7f=C,9f80=C,9f83=C,9f84=C,9f85=C,9f86=C,9f87=C,9f88=C,9f89=C,9f8a=C,9f8b=C,9f8c=C,9f99=C,9f9a=C,9f9b=C,9f9f=C,fa0f=J,fa13=J,fa20=J,fa21=J,fa24=J,fa29=J',1,16);
<span class='line'>2669</span> // HKEY_CLASSES_ROOT\MIME\Database\Charset
<span class='line'>2670</span> // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字Big5常用字卻常常是gb中奇怪字碼與罕用字
<span class='line'>2671</span> setObjValue('autodetectEncodeCode','GB2312=3000,Big5=3000,shift_jis=900,iso-8859-1=2000',1);
<span class='line'>2672</span>
<span class='line'>2673</span>
<span class='line'>2674</span> TODO:
<span class='line'>2675</span> 只檢測常用的幾個字,無法判別才廣泛測試。
<span class='line'>2676</span> */</span><span class="WHIT">
<span class='line'>2677</span> </span><span class="COMM">//var FN='I:\\Documents and Settings\\kanashimi\\My Documents\\kanashimi\\www\\cgi-bin\\game\\sjis.txt',enc=autodetectEncode(FN);alert('['+enc+'] '+FN+'\n'+_.read_all_file(FN,enc).slice(0,900));</span><span class="WHIT">
<span class='line'>2678</span> </span><span class="COMM">/* 自動判別檔案(或字串)之編碼 文字エンコーディング判定を行う
<span class='line'>2679</span> http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html
<span class='line'>2680</span> http://www.ericphelps.com/q193998/
<span class='line'>2681</span> http://hp.vector.co.jp/authors/VA003334/ado/adostream.htm
<span class='line'>2682</span> */</span><span class="WHIT">
<span class='line'>2683</span> </span><span class="COMM">//autodetectEncode[generateCode.dLK]='isFile,simpleFileDformat,_.open_file,autodetectStringEncode,autodetectHTMLEncode';</span><span class="WHIT">
<span class='line'>2684</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2685</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2686</span> </span><span class="NAME">autodetectEncode</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="NAME">isHTML</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2687</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">code</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2688</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">ActiveXObject</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"autodetectEncode: Can't find ActiveXObject!"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2689</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof autodetectHTMLEncode!='function')isHTML=false;</span><span class="WHIT">
<span class='line'>2690</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">FN.length</span><span class="PUNC">&lt;</span><span class="NUMB">64</span><span class="PUNC">?</span><span class="NAME">simpleFileDformat</span><span class="PUNC">:</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">autodetectStringEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">t</span><span class="PUNC">:</span><span class="PUNC">(</span><span class="NAME">isHTML</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">isHTML</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">&&</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">autodetectHTMLEncode</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">t</span><span class="PUNC">:</span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2691</span> </span><span class="WHIT"> </span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>2692</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">AdoEnums</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="NAME">AdoStream</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2693</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.LoadFromFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2694</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">//Read(3);//</span><span class="WHIT">
<span class='line'>2695</span> </span><span class="WHIT"> </span><span class="COMM">//alert(FN+'\n'+t.charCodeAt(0)+','+t.charCodeAt(1)+','+t.charCodeAt(2));</span><span class="WHIT">
<span class='line'>2696</span>
<span class='line'>2697</span> </span><span class="WHIT"> </span><span class="COMM">//if(typeof t!='string')return simpleFileDformat;//t=''+t; // 此時type通常是unknown不能用+=</span><span class="WHIT">
<span class='line'>2698</span> </span><span class="WHIT"> </span><span class="COMM">// Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏它是以FF-FE這兩個bytes表達在BE(big endian)裏是FEFF。而在UTF-8裏它是以EF-BB-BF這三個bytes表達。</span><span class="WHIT">
<span class='line'>2699</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">==</span><span class="STRN">'\xFF\xFE'</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="STRN">'unicodeFFFE'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2700</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">t.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">==</span><span class="STRN">'\xFE\xFF'</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="STRN">'unicode'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2701</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">t</span><span class="PUNC">==</span><span class="STRN">'\xEF\xBB\xBF'</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="STRN">'UTF-8'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2702</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2703</span> </span><span class="WHIT"> </span><span class="COMM">// 即使是用OpenTextFile(_.open_format.TristateFalse)UTF-8還是會被轉換而判別不出來。</span><span class="WHIT">
<span class='line'>2704</span> </span><span class="WHIT"> </span><span class="COMM">// from http://www.hawk.34sp.com/stdpls/dwsh/charset_adodb.html</span><span class="WHIT">
<span class='line'>2705</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="NAME">codes</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">reg</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">stream</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"ADODB.Stream"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2706</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="STRN">'[\\x09\\x0a\\x0d\\x20-\\x7e]'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2707</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'big5'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2708</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xa4-\\xc6\\xc9-\\xf9][\\x40-\\xfe]'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://www.cns11643.gov.tw/web/word/big5/index.html</span><span class="WHIT">
<span class='line'>2709</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'shift_jis'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2710</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\x81-\\x9f\\xe0-\\xef\\xfa-\\xfc][\\x40-\\x7e\\x80-\\xfc]|[\\xa1-\\xdf]'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://hp.vector.co.jp/authors/VA013241/misc/shiftjis.html</span><span class="WHIT">
<span class='line'>2711</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'euc-jp'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2712</span> </span><span class="WHIT"> </span><span class="STRN">'|\\x8f[\\xa1-\\xfe][\\xa1-\\xfe]|[\\xa1-\\xfe][\\xa1-\\xfe]|\\x8e[\\xa1-\\xdf]'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2713</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'utf-8'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2714</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xc0-\\xdf][\\x80-\\xbf]|[\\xe0-\\xef][\\x80-\\xbf]{2}|[\\xf0-\\xf7][\\x80-\\xbf]{3}'</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2715</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xf8-\\xfb][\\x80-\\xbf]{4}|[\\xfc-\\xfd][\\x80-\\xbf]{5}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2716</span> </span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'gb2312'</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="COMM">// GBK</span><span class="WHIT">
<span class='line'>2717</span> </span><span class="WHIT"> </span><span class="STRN">'|[\\xa1-\\xf7][\\xa1-\\xfe]'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// http://zh.wikipedia.org/wiki/GB_18030 http://zh.wikipedia.org/wiki/GB_2312</span><span class="WHIT">
<span class='line'>2718</span>
<span class='line'>2719</span> </span><span class="WHIT"> </span><span class="NAME">stream.type</span><span class="PUNC">=</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2720</span> </span><span class="WHIT"> </span><span class="NAME">stream.open</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2721</span> </span><span class="WHIT"> </span><span class="NAME">stream.loadFromFile</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2722</span> </span><span class="WHIT"> </span><span class="NAME">stream.position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2723</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">stream.read</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2724</span> </span><span class="WHIT"> </span><span class="NAME">stream.close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2725</span> </span><span class="WHIT"> </span><span class="NAME">stream</span><span class="PUNC">=</span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2726</span>
<span class='line'>2727</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">translate_AdoStream_binary_data</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="NUMB">4</span><span class="NAME">e3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2728</span>
<span class='line'>2729</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">_e</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">codes</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2730</span> </span><span class="WHIT"> </span><span class="NAME">reg</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'^(?:'</span><span class="PUNC">+</span><span class="NAME">codes</span><span class="PUNC">[</span><span class="NAME">_e</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 class='line'>2731</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="NUMB">0</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2732</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">!=</span><span class="NAME">s.length</span><span class="PUNC">)</span><span class="NAME">l</span><span class="PUNC">=</span><span class="NAME">s.length</span><span class="PUNC">,</span><span class="NAME">s</span><span class="PUNC">=</span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="NAME">reg</span><span class="PUNC">,</span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2733</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">==</span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">code</span><span class="PUNC">=</span><span class="NAME">_e</span><span class="PUNC">;</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2734</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2735</span>
<span class='line'>2736</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2737</span> </span><span class="WHIT"> </span><span class="COMM">//sl('autodetectEncode: coding: ['+code+'] in parse 1.');</span><span class="WHIT">
<span class='line'>2738</span>
<span class='line'>2739</span> </span><span class="WHIT"> </span><span class="COMM">// 假如是HTML檔判斷是否有charset設定。這個判別放在unicode之後其他自動判別之前。</span><span class="WHIT">
<span class='line'>2740</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">isHTML</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">isHTML</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">&&</span><span class="REGX">/\.s?html?$/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2741</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="PUNC">==</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">)</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2742</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">AdoStream.Charset</span><span class="PUNC">=</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 讀 binary data 用 'iso-8859-1' 會 error encoding.</span><span class="WHIT">
<span class='line'>2743</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">autodetectHTMLEncode</span><span class="PUNC">(</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="NAME">e3</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="NAME">code</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2744</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2745</span> </span><span class="WHIT"> </span><span class="COMM">//sl('autodetectEncode: coding: ['+code+'] in parse 2.');</span><span class="WHIT">
<span class='line'>2746</span>
<span class='line'>2747</span> </span><span class="WHIT"> </span><span class="COMM">//autodetectEncodeCode.GB2312=900000; // 4 test</span><span class="WHIT">
<span class='line'>2748</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">code</span><span class="PUNC">)</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="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">autodetectEncodeCode</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2749</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Type</span><span class="PUNC">==</span><span class="NAME">AdoEnums.adTypeBinary</span><span class="PUNC">)</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NAME">FN</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2750</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">AdoStream.Position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">i</span><span class="PUNC">==</span><span class="NAME">autodetectStringEncode</span><span class="PUNC">(</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">autodetectEncodeCode</span><span class="PUNC">[</span><span class="NAME">AdoStream.Charset</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">code</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">;</span><span class="KEYW">break</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2751</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2752</span>
<span class='line'>2753</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2754</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">code</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// ascii=iso-8859-1,_autodetect,_autodetect_all</span><span class="WHIT">
<span class='line'>2755</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2756</span>
<span class='line'>2757</span> </span><span class="COMM">// 判斷HTML檔是否有charset設定</span><span class="WHIT">
<span class='line'>2758</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">autodetectHTMLEncode</span><span class="PUNC">(</span><span class="NAME">fc</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// file contents</span><span class="WHIT">
<span class='line'>2759</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="WHIT">
<span class='line'>2760</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">fc.match</span><span class="PUNC">(</span><span class="REGX">/&lt;\s*meta\s+([^>]+)>/i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2761</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">RegExp.$1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/content="([^"]+)"/i</span><span class="PUNC">)</span><span class="PUNC">||</span><span class="NAME">t.match</span><span class="PUNC">(</span><span class="REGX">/content=([^\w]+)/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2762</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">RegExp.$1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/charset=([\w-]{2,})/i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2763</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">fc.match</span><span class="PUNC">(</span><span class="REGX">/&lt;\?\s*xml\s[^>]+\sencoding\s*=\s*["']([a-z\d\-]+)["']/i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2764</span> </span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2765</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">RegExp.$1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2766</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2767</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2768</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2769</span> </span><span class="COMM">/**
<span class='line'>2770</span> * 靠常用字自動判別字串之編碼 string,預設編碼
<span class='line'>2771</span> */</span><span class="WHIT">
<span class='line'>2772</span> </span><span class="NAME">autodetectStringEncode</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2773</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">str</span><span class="PUNC">!=</span><span class="STRN">'string'</span><span class="PUNC">||</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">=</span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/g</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2774</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">=</span><span class="NAME">str.length</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">c</span><span class="PUNC">,</span><span class="NAME">a</span><span class="PUNC">,</span><span class="NAME">kana</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">jianhuazi</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">halfwidthKatakana</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">Hangul</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">ascii</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">asciiHigh</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">kanji</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">kokuji</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">symbol</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">unknown</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2775</span> </span><span class="WHIT"> </span><span class="COMM">//if(len>9000)len=9000;</span><span class="WHIT">
<span class='line'>2776</span> </span><span class="WHIT"> </span><span class="COMM">//var unknownC='';</span><span class="WHIT">
<span class='line'>2777</span>
<span class='line'>2778</span> </span><span class="WHIT"> </span><span class="COMM">// char分類</span><span class="WHIT">
<span class='line'>2779</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">len</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2780</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">=</span><span class="NAME">str.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x80</span><span class="PUNC">)</span><span class="NAME">ascii</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2781</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">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x100</span><span class="PUNC">)</span><span class="NAME">asciiHigh</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2782</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">c</span><span class="PUNC">></span><span class="NUMB">0x3040</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x30ff</span><span class="PUNC">)</span><span class="NAME">kana</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2783</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">c</span><span class="PUNC">==</span><span class="NUMB">0x30fb</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0xff65</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xff9e</span><span class="PUNC">)</span><span class="NAME">halfwidthKatakana</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2784</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">c</span><span class="PUNC">>=</span><span class="NUMB">0x1100</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x11fa</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0xac00</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xad00</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0xd700</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xd7a4</span><span class="PUNC">)</span><span class="NAME">Hangul</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2785</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">c</span><span class="PUNC">></span><span class="NUMB">0x4dff</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x9fa6</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">kanji</span><span class="PUNC">++</span><span class="PUNC">,</span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">autodetectEncodeSP</span><span class="PUNC">[</span><span class="NAME">c</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">==</span><span class="STRN">'C'</span><span class="PUNC">)</span><span class="NAME">jianhuazi</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">==</span><span class="STRN">'J'</span><span class="PUNC">)</span><span class="NAME">kokuji</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2786</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">c</span><span class="PUNC">></span><span class="NUMB">0xfa00</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xfa6b</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">autodetectEncodeSP</span><span class="PUNC">[</span><span class="NAME">c</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'J'</span><span class="PUNC">)</span><span class="NAME">kokuji</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2787</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">c</span><span class="PUNC">></span><span class="NUMB">0x2010</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x2610</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">>=</span><span class="NUMB">0xfe30</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xfe70</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0xff00</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0xff5f</span><span class="PUNC">)</span><span class="NAME">symbol</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2788</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">c</span><span class="PUNC">>=</span><span class="NUMB">0x3000</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x3400</span><span class="PUNC">||</span><span class="NAME">c</span><span class="PUNC">></span><span class="NUMB">0x33ff</span><span class="PUNC">&&</span><span class="NAME">c</span><span class="PUNC">&lt;</span><span class="NUMB">0x4db6</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2789</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">autodetectEncodeSP</span><span class="PUNC">[</span><span class="NAME">c</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'J'</span><span class="PUNC">)</span><span class="NAME">kokuji</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">symbol</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2790</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">unknown</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="COMM">//,unknownC+=str.charAt(i);</span><span class="WHIT">
<span class='line'>2791</span>
<span class='line'>2792</span> </span><span class="WHIT"> </span><span class="COMM">//alert('len='+len+'\nkana='+kana+'\nkokuji='+kokuji+'\njianhuazi='+jianhuazi+'\nhalfwidthKatakana='+halfwidthKatakana+'\nHangul='+Hangul+'\nascii='+ascii+'\nasciiHigh='+asciiHigh+'\nkanji='+kanji+'\nsymbol='+symbol+'\nunknown='+unknown);</span><span class="WHIT">
<span class='line'>2793</span> </span><span class="WHIT"> </span><span class="COMM">//if(unknownC)alert('unknown:\n'+unknownC.slice(0,200));//alert(unknownC.slice(0,200)+'\n'+str.slice(0,1000));</span><span class="WHIT">
<span class='line'>2794</span> </span><span class="WHIT"> </span><span class="COMM">// 依各種常用字母之條件判別</span><span class="WHIT">
<span class='line'>2795</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ascii</span><span class="PUNC">+</span><span class="NAME">asciiHigh</span><span class="PUNC">==</span><span class="NAME">len</span><span class="PUNC">?</span><span class="STRN">'iso-8859-1'</span><span class="WHIT">
<span class='line'>2796</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">unknown</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">05</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="STRN">''</span><span class="COMM">//unicode // unknown不能太多</span><span class="WHIT">
<span class='line'>2797</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">kana</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">2</span><span class="PUNC">*</span><span class="NAME">len</span><span class="PUNC">&&</span><span class="NAME">kanji</span><span class="PUNC">+</span><span class="NAME">kana</span><span class="PUNC">+</span><span class="NAME">symbol</span><span class="PUNC">></span><span class="NUMB">3</span><span class="PUNC">*</span><span class="NAME">halfwidthKatakana</span><span class="PUNC">?</span><span class="STRN">'shift_jis'</span><span class="WHIT">
<span class='line'>2798</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">kanji</span><span class="PUNC">+</span><span class="NAME">symbol</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">7</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">&&</span><span class="NAME">kana</span><span class="PUNC">&lt;</span><span class="PUNC">.</span><span class="NUMB">05</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">jianhuazi</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">1</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="STRN">'GB2312'</span><span class="PUNC">:</span><span class="STRN">'Big5'</span><span class="WHIT">
<span class='line'>2799</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">Hangul</span><span class="PUNC">+</span><span class="NAME">symbol</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">7</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="STRN">'korean'</span><span class="COMM">//ks_c_5601</span><span class="WHIT">
<span class='line'>2800</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="NAME">kanji</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">2</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">-</span><span class="NAME">ascii</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">jianhuazi</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">1</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="NAME">kokuji</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">02</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="STRN">'unicode'</span><span class="PUNC">:</span><span class="STRN">'GB2312'</span><span class="PUNC">:</span><span class="NAME">kokuji</span><span class="PUNC">></span><span class="PUNC">.</span><span class="NUMB">02</span><span class="PUNC">*</span><span class="NAME">kanji</span><span class="PUNC">?</span><span class="STRN">'shift_jis'</span><span class="PUNC">:</span><span class="STRN">'Big5'</span><span class="WHIT">
<span class='line'>2801</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">;</span><span class="COMM">//unicode</span><span class="WHIT">
<span class='line'>2802</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2803</span>
<span class='line'>2804</span> </span><span class="COMM">/*
<span class='line'>2805</span> http://bbs.ee.ntu.edu.tw/boards/Linux/7/9/58.html http://libai.math.ncu.edu.tw/~shann//Chinese/big5.html http://wiki.debian.org.tw/index.php/Big5Variants http://leoboard.cpatch.org/cgi-bin/topic.cgi?forum=20&topic=64&changemode=1
<span class='line'>2806</span> http://www.theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=F900&end=FAFF http://homepage1.nifty.com/nomenclator/unicode/normalization.htm
<span class='line'>2807</span>
<span class='line'>2808</span> Unicode的漢字大致是以康熙部首排序不過間中有部分字排錯部首筆劃
<span class='line'>2809</span> 第一批在1993年加進Unicode的
<span class='line'>2810</span> 於中國內地、台灣、南韓及日本已有字集的漢字,
<span class='line'>2811</span> 編碼於U+4E00至U+9FA5
<span class='line'>2812</span> 亦有部分南韓重覆漢字被編到U+F900至U+FA0B、
<span class='line'>2813</span> 兩個Big-5重覆漢字被編到U+FA0C至U+FA0D、
<span class='line'>2814</span> 日本廠商漢字被編到U+FA0E至U+FA2D
<span class='line'>2815</span>
<span class='line'>2816</span> 全形符號只限鍵盤上那94個位於U+FF01至U+FF5E
<span class='line'>2817</span> 中日韓專用符號放到了U+3000至U+33FF內
<span class='line'>2818</span> 其餘有部分符號放到了U+2XXX及U+FE30至U+FE6F
<span class='line'>2819</span>
<span class='line'>2820</span> 第二批在1999年加進Unicode的
<span class='line'>2821</span> 加進了新加坡用漢字、南韓PKS C 5700-2 1994、
<span class='line'>2822</span> 部分CNS11643第三、四、十五字面等用字、
<span class='line'>2823</span> 未包括在第一批字的數個GB字集用字
<span class='line'>2824</span> 被編入U+3400至U+4DB5
<span class='line'>2825</span>
<span class='line'>2826</span> 第三批在2001年加進Unicode的
<span class='line'>2827</span> 加進了CNS11643第三、四、五、六、七、十五字面所有字、
<span class='line'>2828</span> 香港增補字集用字、四庫全書、辭海、辭源、康熙字典、
<span class='line'>2829</span> 漢語大字典、漢語大詞典內的所有用字,
<span class='line'>2830</span> 被編入U+20000至U+2A6D6
<span class='line'>2831</span> JIS-X0213漢字被加到U+FA30至U+FA6A
<span class='line'>2832</span> CNS11643重覆漢字被加到U+2F800至U+2FA1D
<span class='line'>2833</span>
<span class='line'>2834</span> 简化字总表 http://cdns.twnic.net.tw/cjktable/ http://www.sxyw.cn/YuWenGongZuo/gfzs22.htm http://huayuqiao.org/articles/xieshiya/Simplified/6_XinJiaPoTiaoZhengJianTiZi-XP.htm http://www.hk-place.com/vp.php?board=2&id=333-9
<span class='line'>2835</span> 简化字分布似乎並無規範只好以array判斷:
<span class='line'>2836</span>
<span class='line'>2837</span> &lt;div id="dataGB">
<span class='line'>2838</span> http://cdns.twnic.net.tw/cjktable/simtab.html
<span class='line'>2839</span> 簡化字總表之 UNICODE 碼表
<span class='line'>2840</span> &lt;/div>
<span class='line'>2841</span> &lt;div id="dataJP">
<span class='line'>2842</span> http://homepage2.nifty.com/TAB01645/ohara/index_j2.htm
<span class='line'>2843</span> JIS区点索引
<span class='line'>2844</span> &lt;/div>
<span class='line'>2845</span>
<span class='line'>2846</span> &lt;script type="text/javascript">
<span class='line'>2847</span> var i=0,c=0,autodetectEncodeSP=[],m=document.getElementById('dataGB').innerHTML.match(/\([0-9A-F]{4},\w*\)/g),t="setObjValue('autodetectEncodeSP','";
<span class='line'>2848</span> for(;i&lt;m.length;i++)//if(m[i].indexOf('C')!=-1&&m[i].slice(m[i].indexOf(',')+1).indexOf('T')==-1)t+=m[i].substr(1,5);
<span class='line'>2849</span> if(m[i].indexOf('T')==-1)autodetectEncodeSP[parseInt(m[i].substr(1,4),16)]='C';
<span class='line'>2850</span> for(i=0,m=document.getElementById('dataJP').innerHTML.match(/【.】/g);i&lt;m.length;i++)
<span class='line'>2851</span> autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]=autodetectEncodeSP[parseInt(m[i].charCodeAt(1))]?0:'J';
<span class='line'>2852</span>
<span class='line'>2853</span> m=[];for(i in autodetectEncodeSP)m.push(parseInt(i));m.sort();
<span class='line'>2854</span> for(i=0;i&lt;m.length;i++)if(autodetectEncodeSP[m[i]]){t+=m[i].toString(16)+'='+autodetectEncodeSP[m[i]]+',',c++;if(c%40==0)t+="'&lt;br/>+'";}
<span class='line'>2855</span> alert(c+'字');
<span class='line'>2856</span> document.getElementById('dataJP').innerHTML='';
<span class='line'>2857</span> document.getElementById('dataGB').innerHTML=t.slice(0,-1)+"',1,16);";
<span class='line'>2858</span> &lt;/script>
<span class='line'>2859</span>
<span class='line'>2860</span>
<span class='line'>2861</span> 和製漢字(国字)は、和語(ヤマトコトバ)に相当する漢字が無い場合に新規につくられたもので、奈良時代から作られた。ほとんどは訓読みしかない。魚篇や木篇が多い。
<span class='line'>2862</span> http://homepage2.nifty.com/TAB01645/ohara/index.htm
<span class='line'>2863</span> http://zh.wiktionary.org/wiki/%E8%BE%BB
<span class='line'>2864</span> http://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=8fbb
<span class='line'>2865</span> http://jprs.jp/doc/rule/saisoku-1-wideusejp-furoku-4.html
<span class='line'>2866</span> http://m2000.idv.tw/informer/zhi/char-root.htm
<span class='line'>2867</span> http://www.ajisai.sakura.ne.jp/~dindi/chrc/ref/wincode2.txt
<span class='line'>2868</span> http://cs-people.bu.edu/butta1/personal/hkscs/hkscs-oct.html
<span class='line'>2869</span> http://www.nobi.or.jp/i/kotoba/kanji/wasei-kanji.html
<span class='line'>2870</span> http://www.melma.com/mag/52/m00011552/a00000066.html
<span class='line'>2871</span>
<span class='line'>2872</span>
<span class='line'>2873</span> 韓語字母/諺文
<span class='line'>2874</span> http://www.sinica.edu.tw/~cytseng/Korean%20reader/hangul.htm
<span class='line'>2875</span> http://www.unicode.org/charts/normalization/
<span class='line'>2876</span>
<span class='line'>2877</span> old:
<span class='line'>2878</span> // 自動判別檔案(或字串)之編碼
<span class='line'>2879</span> function autodetectEncode(FN){
<span class='line'>2880</span> if(!isFile(FN))return FN.length>64?autodetectStringEncode(FN):simpleFileDformat;
<span class='line'>2881</span> _.open_file(FN,'iso-8859-1');
<span class='line'>2882</span> if(!AdoEnums)return simpleFileDformat;
<span class='line'>2883</span> //AdoStream.Type=AdoEnums.adTypeBinary;
<span class='line'>2884</span> AdoStream.LoadFromFile(FN);
<span class='line'>2885</span> var t=AdoStream.ReadText(3),code;
<span class='line'>2886</span> // Unicode的Byte Order Mark(BOM)在UTF-16LE(little endian)裏它是以FF-FE這兩個bytes表達在BE(big endian)裏是FEFF。而在UTF-8裏它是以EF-BB-BF這三個bytes表達。
<span class='line'>2887</span> if(t.slice(0,2)=='\xFF\xFE')code='unicodeFFFE';
<span class='line'>2888</span> if(t.slice(0,2)=='\xFE\xFF')code='unicode';
<span class='line'>2889</span> if(t=='\xEF\xBB\xBF')code='UTF-8';
<span class='line'>2890</span> if(code){AdoStream.Close();return code;}
<span class='line'>2891</span>
<span class='line'>2892</span> if(!code)with(AdoStream){
<span class='line'>2893</span> // 將sjis排在gb與Big5前面是因為sjis常符合gb且sjis之判定相當嚴。
<span class='line'>2894</span> if(!code)Position=0,Charset='shift_jis',code=autodetectStringEncode(ReadText(900),Charset);
<span class='line'>2895</span> // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字Big5常用字卻常常是gb中奇怪字碼與罕用字
<span class='line'>2896</span> if(!code)Position=0,Charset='GB2312',code=autodetectStringEncode(ReadText(2000),Charset);
<span class='line'>2897</span> if(!code)Position=0,Charset='Big5',code=autodetectStringEncode(ReadText(2000),Charset);
<span class='line'>2898</span> }
<span class='line'>2899</span>
<span class='line'>2900</span> AdoStream.Close();
<span class='line'>2901</span> return code||simpleFileDformat; // ascii=iso-8859-1,_autodetect,_autodetect_all
<span class='line'>2902</span> }
<span class='line'>2903</span> // 靠常用字自動判別字串之編碼 string,預設編碼
<span class='line'>2904</span> function autodetectStringEncode(str,dcode){
<span class='line'>2905</span> var code;
<span class='line'>2906</span> if(str.length>9000)str=str.slice(0,9000);
<span class='line'>2907</span>
<span class='line'>2908</span> // 將sjis排在gb與Big5前面是因為sjis常符合gb且sjis之判定相當嚴。
<span class='line'>2909</span> if(dcode=='shift_jis'||!dcode&&!code){
<span class='line'>2910</span> // http://www.asahi-net.or.jp/~hc3j-tkg/unicode/ http://www.unicode.org/Public/UNIDATA/DerivedCoreProperties.txt
<span class='line'>2911</span> var i=0,c,k=0,u=0,h=0;//h_=u_=k_='';
<span class='line'>2912</span> for(;i&lt;str.length;i++)if(c=str.charCodeAt(i),c>0xFF)
<span class='line'>2913</span> if(c==0x30FB||c>0xFF65&&c&lt;0xFF9E)h++;//,h_+=str.charAt(i);//||c==0xE134 // HALFWIDTH KATAKANA LETTER等可能不是日文文件中會出現的char
<span class='line'>2914</span> else if(c>0x3040&&c&lt;0x30FF)k++;//,k_+=str.charAt(i); // kana
<span class='line'>2915</span> else u++;//,u_+=str.charAt(i); // unknown kanji
<span class='line'>2916</span> //alert(k+','+u+','+h+'\n*'+k_+'\n*'+u_+'\n*'+h_);//alert(u_.charCodeAt(2));
<span class='line'>2917</span> if(k+u>2*h)code='shift_jis'; // HALFWIDTH KATAKANA LETTER數目比漢字少時判別為shift_jis
<span class='line'>2918</span> }
<span class='line'>2919</span>
<span class='line'>2920</span> // 將gb排在Big5前面是因為gb常用字在Big5中常常是0x8000之後的常用字Big5常用字卻常常是gb中奇怪字碼與罕用字
<span class='line'>2921</span> if(dcode=='Big5'||dcode=='GB2312'||!dcode&&!code){
<span class='line'>2922</span> var i=0,c,k=0,u=0;//k_=u_='';
<span class='line'>2923</span> for(;i&lt;str.length;i++)if(c=str.charCodeAt(i),c>0xFF)
<span class='line'>2924</span> if(c>0x4DFF&&c&lt;0x9FA6||c>0xFF00&&c&lt;0xFF5F||c>0x33ff&&c&lt;0x4DB6||c==0x2605||c==0x2606)k++;//,k_+=str.charAt(i); // 2605,6:★☆
<span class='line'>2925</span> else u++;//,u_+=str.charAt(i);
<span class='line'>2926</span> //alert(k+','+u+'\n'+k_+'\n*'+u_);
<span class='line'>2927</span> if(k>5*u)code=dcode||'Big5'; // 漢字比不認識的字多時判定
<span class='line'>2928</span> }
<span class='line'>2929</span>
<span class='line'>2930</span> if(dcode=='iso-8859-1'||dcode=='ascii'||!dcode&&!code){
<span class='line'>2931</span> }
<span class='line'>2932</span>
<span class='line'>2933</span> return code;
<span class='line'>2934</span> }
<span class='line'>2935</span> */</span><span class="WHIT">
<span class='line'>2936</span>
<span class='line'>2937</span>
<span class='line'>2938</span> </span><span class="COMM">/* 將 iso-8859-1 轉成utf-8
<span class='line'>2939</span> To use:
<span class='line'>2940</span> ..
<span class='line'>2941</span> translated=turnBinStr(original);
<span class='line'>2942</span> ..
<span class='line'>2943</span> translated=turnBinStr(); // delete temp file
<span class='line'>2944</span> */</span><span class="WHIT">
<span class='line'>2945</span> </span><span class="NAME">turnBinStr.temp_file</span><span class="PUNC">=</span><span class="STRN">'turnBinStr.tmp'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// temp file name</span><span class="WHIT">
<span class='line'>2946</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">turnBinStr</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">,</span><span class="NAME">_enc</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2947</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">t</span><span class="PUNC">!=</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2948</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">)</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">=</span><span class="NAME">getFP</span><span class="PUNC">(</span><span class="NAME">turnBinStr.temp_file</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2949</span>
<span class='line'>2950</span> </span><span class="WHIT"> </span><span class="COMM">//t+='';</span><span class="WHIT">
<span class='line'>2951</span> </span><span class="WHIT"> </span><span class="COMM">//if(t.replace(/[^\x00-\x7f]+/g,''))return t;</span><span class="WHIT">
<span class='line'>2952</span> </span><span class="WHIT"> </span><span class="COMM">//var _q=t.replace(/[^?]+/g,'').length,_t,_j=0;</span><span class="WHIT">
<span class='line'>2953</span> </span><span class="WHIT"> </span><span class="NAME">_.write_to_file</span><span class="PUNC">(</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">,</span><span class="STRN">''</span><span class="PUNC">+</span><span class="NAME">t</span><span class="PUNC">,</span><span class="STRN">'iso-8859-1'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2954</span> </span><span class="WHIT"> </span><span class="COMM">//alert(turnBinStr.tmpF+'\n'+simpleFileErr.description+'\n'+t+'\n'+_.read_all_file(turnBinStr.tmpF,'utf-8'));</span><span class="WHIT">
<span class='line'>2955</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_.read_all_file</span><span class="PUNC">(</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">,</span><span class="STRN">'utf-8'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2956</span> </span><span class="COMM">/*
<span class='line'>2957</span> if(!_enc)_enc='utf-8,Big5,shift_jis,euc-jp,GB2312'.split(',');
<span class='line'>2958</span> else if(!(_enc instanceof Array))_enc=[_enc];
<span class='line'>2959</span> for(;_j&lt;_enc.length;_j++)
<span class='line'>2960</span> if((_t=_.read_all_file(turnBinStr.tmpF,_enc[_j])).replace(/[^?]+/g,'').length==_q)
<span class='line'>2961</span> return _t;//'['+_enc[_j]+']'+
<span class='line'>2962</span> return t;
<span class='line'>2963</span> */</span><span class="WHIT">
<span class='line'>2964</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2965</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">fso.DeleteFile</span><span class="PUNC">(</span><span class="NAME">turnBinStr.tmpF</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// 有時會出錯</span><span class="WHIT">
<span class='line'>2966</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2967</span>
<span class='line'>2968</span>
<span class='line'>2969</span>
<span class='line'>2970</span>
<span class='line'>2971</span>
<span class='line'>2972</span> </span><span class="COMM">//folder_info[generateCode.dLK]='initWScriptObj';</span><span class="WHIT">
<span class='line'>2973</span> </span><span class="COMM">// 需同時修改if(traverseSubDirectory==folder_info.f.noNewObj)段落之return!</span><span class="WHIT">
<span class='line'>2974</span>
<span class='line'>2975</span> </span><span class="COMM">//setObjValue('folder_info.f','noNewObj=-1,files,dirs,fsize,size,Tsize=3,Tfiles,Tdirs',1);</span><span class="WHIT">
<span class='line'>2976</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>2977</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>2978</span> </span><span class="COMM">/**
<span class='line'>2979</span> * Get the infomation of folder
<span class='line'>2980</span> * @param folder_path folder path
<span class='line'>2981</span> * @param file_filter
<span class='line'>2982</span> * @param traverseSubDirectory
<span class='line'>2983</span> * @return
<span class='line'>2984</span> * @example
<span class='line'>2985</span> * var finfo=new folder_info(path or folder object,extFilter,0/1);
<span class='line'>2986</span> * @deprecated 以 &lt;a href="#.traverse_file_system">traverse_file_system&lt;/a> 代替
<span class='line'>2987</span> * @memberOf CeL.IO.Windows.file
<span class='line'>2988</span> */</span><span class="WHIT">
<span class='line'>2989</span> </span><span class="NAME">folder_info</span><span class="PUNC">=</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">,</span><span class="NAME">file_filter</span><span class="PUNC">,</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2990</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dir</span><span class="PUNC">,</span><span class="NAME">filesCount</span><span class="PUNC">,</span><span class="NAME">subDirectorysCount</span><span class="PUNC">,</span><span class="NAME">total_size_of_files</span><span class="PUNC">,</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">,</span><span class="NAME">total_filesCount</span><span class="PUNC">,</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2991</span> </span><span class="WHIT"> </span><span class="NAME">filesCount</span><span class="PUNC">=</span><span class="NAME">subDirectorysCount</span><span class="PUNC">=</span><span class="NAME">total_size_of_files</span><span class="PUNC">=</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">=</span><span class="NAME">total_filesCount</span><span class="PUNC">=</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2992</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">traverseSubDirectory</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2993</span>
<span class='line'>2994</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">folder_path</span><span class="PUNC">==</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NAME">folder_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2995</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">folder_path</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2996</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">folder_path.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">path_separator</span><span class="PUNC">)</span><span class="NAME">folder_path</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2997</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2998</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2999</span>
<span class='line'>3000</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">dir</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3001</span> </span><span class="WHIT"> </span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">=</span><span class="NAME">subDirectorysCount</span><span class="PUNC">=</span><span class="NAME">dir.SubFolders.Count</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3002</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="NAME">t</span><span class="PUNC">,</span><span class="NAME">f</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.SubFolders</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3003</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">||</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">==</span><span class="NAME">folder_info.f.noNewObj</span><span class="PUNC">)</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3004</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3005</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">=</span><span class="NAME">folder_info</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">file_filter</span><span class="PUNC">,</span><span class="NAME">folder_info.f.noNewObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3006</span> </span><span class="WHIT"> </span><span class="COMM">//alert(i.path+'\n'+t[folder_info.f.size]+','+t[folder_info.f.Tfiles]+','+t[folder_info.f.Tdirs]);</span><span class="WHIT">
<span class='line'>3007</span> </span><span class="WHIT"> </span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">folder_info.f.size</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3008</span> </span><span class="WHIT"> </span><span class="NAME">total_filesCount</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tfiles</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3009</span> </span><span class="WHIT"> </span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">t</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tdirs</span><span class="PUNC">]</span><span class="PUNC">||</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3010</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3011</span>
<span class='line'>3012</span> </span><span class="WHIT"> </span><span class="COMM">//alert(dir.files.Count+'\n'+total_filesCount);</span><span class="WHIT">
<span class='line'>3013</span> </span><span class="WHIT"> </span><span class="NAME">total_filesCount</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">filesCount</span><span class="PUNC">=</span><span class="NAME">dir.files.Count</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3014</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.files</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3015</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3016</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3017</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">file_filter</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">file_filter.test</span><span class="PUNC">(</span><span class="NAME">i.name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3018</span> </span><span class="WHIT"> </span><span class="COMM">//if(traverseSubDirectory!=folder_info.f.noNewObj)alert(i.name+': '+i.size+' / '+total_size_of_files);</span><span class="WHIT">
<span class='line'>3019</span> </span><span class="WHIT"> </span><span class="NAME">total_size_of_files</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">i.size</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3020</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3021</span>
<span class='line'>3022</span> </span><span class="WHIT"> </span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">total_size_of_files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3023</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3024</span>
<span class='line'>3025</span> </span><span class="WHIT"> </span><span class="COMM">//alert(dir.path+'\nfile filter: '+file_filter+'\n'+filesCount+','+subDirectorysCount+','+total_size_of_files+','+total_size_of_this_folder+','+total_filesCount+','+total_subDirectorysCount);</span><span class="WHIT">
<span class='line'>3026</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">traverseSubDirectory</span><span class="PUNC">==</span><span class="NAME">folder_info.f.noNewObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3027</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">filesCount</span><span class="PUNC">,</span><span class="NAME">subDirectorysCount</span><span class="PUNC">,</span><span class="NAME">total_size_of_files</span><span class="PUNC">,</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">,</span><span class="NAME">total_filesCount</span><span class="PUNC">,</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3028</span>
<span class='line'>3029</span> </span><span class="WHIT"> </span><span class="NAME">this.files</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.files</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">filesCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3030</span> </span><span class="WHIT"> </span><span class="NAME">this.dirs</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.dirs</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">subDirectorysCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3031</span> </span><span class="WHIT"> </span><span class="NAME">this.fsize</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.fsize</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_size_of_files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3032</span> </span><span class="WHIT"> </span><span class="NAME">this.size</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.size</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_size_of_this_folder</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3033</span> </span><span class="WHIT"> </span><span class="NAME">this.Tfiles</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tfiles</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_filesCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3034</span> </span><span class="WHIT"> </span><span class="NAME">this.Tdirs</span><span class="PUNC">=</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">folder_info.f.Tdirs</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">total_subDirectorysCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3035</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3036</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3037</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>3038</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>3039</span> </span><span class="COMM">/**
<span class='line'>3040</span> * &lt;a href="#.folder_info">folder_info&lt;/a> 的 flag enumeration
<span class='line'>3041</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3042</span> * @constant
<span class='line'>3043</span> */</span><span class="WHIT">
<span class='line'>3044</span> </span><span class="NAME">folder_info.f</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3045</span> </span><span class="WHIT"> </span><span class="NAME">noNewObj</span><span class="PUNC">:</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3046</span> </span><span class="WHIT"> </span><span class="NAME">files</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3047</span> </span><span class="WHIT"> </span><span class="NAME">dirs</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3048</span> </span><span class="WHIT"> </span><span class="NAME">fsize</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3049</span> </span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">:</span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3050</span> </span><span class="WHIT"> </span><span class="NAME">Tsize</span><span class="PUNC">:</span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3051</span> </span><span class="WHIT"> </span><span class="NAME">Tfiles</span><span class="PUNC">:</span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3052</span> </span><span class="WHIT"> </span><span class="NAME">Tdirs</span><span class="PUNC">:</span><span class="NUMB">5</span><span class="WHIT">
<span class='line'>3053</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3054</span>
<span class='line'>3055</span>
<span class='line'>3056</span> </span><span class="COMM">/* list files of folder 改編自 folder_info()
<span class='line'>3057</span> var files=new listFile(path or folder object,extFilter,flag);
<span class='line'>3058</span>
<span class='line'>3059</span> */</span><span class="WHIT">
<span class='line'>3060</span> </span><span class="COMM">//listFile[generateCode.dLK]='initWScriptObj';</span><span class="WHIT">
<span class='line'>3061</span> </span><span class="COMM">// 需同時修改if(flag==listFile.f.noNewObj)段落之return!</span><span class="WHIT">
<span class='line'>3062</span>
<span class='line'>3063</span> </span><span class="COMM">//setObjValue('listFile.f','ignoreCase=1',1);</span><span class="WHIT">
<span class='line'>3064</span> </span><span class="NAME">listFile.f</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3065</span> </span><span class="WHIT"> </span><span class="NAME">ignoreCase</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="WHIT">
<span class='line'>3066</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3067</span>
<span class='line'>3068</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">listFile</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">,</span><span class="NAME">file_filter</span><span class="PUNC">,</span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3069</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">files</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3070</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">flag</span><span class="PUNC">==</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="NAME">flag</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3071</span>
<span class='line'>3072</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">folder_path</span><span class="PUNC">==</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NAME">folder_path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3073</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">folder_path</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3074</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">folder_path.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">path_separator</span><span class="PUNC">)</span><span class="NAME">folder_path</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">path_separator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3075</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">folder_path</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">dir</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3076</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3077</span>
<span class='line'>3078</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">dir</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3079</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="NAME">f</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">dir.files</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3080</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="PUNC">;</span><span class="PUNC">!</span><span class="NAME">f.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">f.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3081</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">f.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3082</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">file_filter</span><span class="PUNC">&&</span><span class="PUNC">!</span><span class="NAME">file_filter.test</span><span class="PUNC">(</span><span class="NAME">i.name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3083</span> </span><span class="WHIT"> </span><span class="NAME">files.push</span><span class="PUNC">(</span><span class="NAME">i.name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3084</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3085</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3086</span>
<span class='line'>3087</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">files</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3088</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3089</span>
<span class='line'>3090</span>
<span class='line'>3091</span>
<span class='line'>3092</span>
<span class='line'>3093</span>
<span class='line'>3094</span>
<span class='line'>3095</span> </span><span class="COMM">/*
<span class='line'>3096</span> in UNIX:
<span class='line'>3097</span> iconv -l
<span class='line'>3098</span> iconv -c -f UTF-16 -t BIG5-HKSCS function.js
<span class='line'>3099</span>
<span class='line'>3100</span> */</span><span class="WHIT">
<span class='line'>3101</span> </span><span class="COMM">/**
<span class='line'>3102</span> * 將編碼為fromCode之檔案fileName中所有不合編碼toCode之char以encodeFunction轉換
<span class='line'>3103</span> * @param fileName
<span class='line'>3104</span> * @param toCode
<span class='line'>3105</span> * @param fromCode
<span class='line'>3106</span> * @param encodeFunction
<span class='line'>3107</span> * @return
<span class='line'>3108</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3109</span> */</span><span class="WHIT">
<span class='line'>3110</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">iconv_file</span><span class="PUNC">(</span><span class="NAME">fileName</span><span class="PUNC">,</span><span class="NAME">toCode</span><span class="PUNC">,</span><span class="NAME">fromCode</span><span class="PUNC">,</span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3111</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">iconv</span><span class="PUNC">(</span><span class="NAME">_.read_all_file</span><span class="PUNC">(</span><span class="NAME">fileName</span><span class="PUNC">,</span><span class="NAME">fromCode</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">toCode</span><span class="PUNC">,</span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3112</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3113</span> </span><span class="COMM">/* 將string text中所有不合編碼toCode之char以encodeFunction轉換
<span class='line'>3114</span>
<span class='line'>3115</span> TODO:
<span class='line'>3116</span> 一次寫入多 bytes
<span class='line'>3117</span> */</span><span class="WHIT">
<span class='line'>3118</span> </span><span class="COMM">//var iconvError=[];</span><span class="WHIT">
<span class='line'>3119</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">iconv</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="NAME">toCode</span><span class="PUNC">,</span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3120</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">text</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3121</span> </span><span class="WHIT"> </span><span class="COMM">//alert('iconv: ['+toCode+']\n'+text.slice(0,200));</span><span class="WHIT">
<span class='line'>3122</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="REGX">/utf-?(8|16)/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">toCode</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3123</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">HTMLToUnicode</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3124</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_.open_file</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">toCode</span><span class="PUNC">||</span><span class="NAME">simpleFileDformat</span><span class="PUNC">)</span><span class="PUNC">!==</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3125</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3126</span> </span><span class="WHIT"> </span><span class="COMM">//AdoStream.Type=AdoEnums.adTypeText;</span><span class="WHIT">
<span class='line'>3127</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">encodeFunction</span><span class="PUNC">)</span><span class="NAME">encodeFunction</span><span class="PUNC">=</span><span class="NAME">toHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3128</span> </span><span class="WHIT"> </span><span class="COMM">//iconvError=[];</span><span class="WHIT">
<span class='line'>3129</span>
<span class='line'>3130</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charToSet</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">t</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3131</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">text.length</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3132</span> </span><span class="WHIT"> </span><span class="NAME">charToSet</span><span class="PUNC">=</span><span class="NAME">text.charAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3133</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">charToSet.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">&lt;</span><span class="NUMB">256</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">t</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">charToSet</span><span class="PUNC">;</span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// 對於過小的,直接匯入。</span><span class="WHIT">
<span class='line'>3134</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3135</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.WriteText</span><span class="PUNC">(</span><span class="NAME">charToSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3136</span> </span><span class="WHIT"> </span><span class="NAME">AdoStream.Position</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3137</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">charToSet</span><span class="PUNC">==</span><span class="NAME">AdoStream.ReadText</span><span class="PUNC">(</span><span class="NAME">AdoEnums.adReadAll</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">charToSet</span><span class="PUNC">:</span><span class="NAME">encodeFunction</span><span class="PUNC">(</span><span class="NAME">charToSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3138</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3139</span> </span><span class="WHIT"> </span><span class="COMM">//iconvError.push(e.description);</span><span class="WHIT">
<span class='line'>3140</span> </span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NAME">encodeFunction</span><span class="PUNC">(</span><span class="NAME">charToSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3141</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3142</span>
<span class='line'>3143</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">AdoStream.Close</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3144</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'>3145</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3146</span>
<span class='line'>3147</span>
<span class='line'>3148</span>
<span class='line'>3149</span> </span><span class="COMM">//---------------------------------------------------</span><span class="WHIT">
<span class='line'>3150</span>
<span class='line'>3151</span>
<span class='line'>3152</span> </span><span class="COMM">/*
<span class='line'>3153</span> var driverProperty,folderProperty,fileProperty;
<span class='line'>3154</span> setObjValue('driverProperty','AvailableSpace,DriveLetter,DriveType,FileSystem,FreeSpace,IsReady,Path,RootFolder,SerialNumber,ShareName,TotalSize,VolumeName',1,setObjValueFlag.array);
<span class='line'>3155</span> setObjValue('folderProperty','Attributes,DateCreated,DateLastAccessed,DateLastModified,Drive,Name,ParentFolder,Path,ShortName,ShortPath,Size,Type,Files,IsRootFolder,SubFolders',1,setObjValueFlag.array);//Files起為Folder property
<span class='line'>3156</span> fileProperty=folderProperty.slice(0,12);//folderProperty.sort();
<span class='line'>3157</span> */</span><span class="WHIT">
<span class='line'>3158</span>
<span class='line'>3159</span>
<span class='line'>3160</span> </span><span class="COMM">//var kkk='';_.traverse_file_system(function(fileItem,itemType){kkk+=(itemType==_.traverse_file_system.f.driver?fileItem.DriveLetter+':('+fileItem.VolumeName+')':fileItem.Name+(itemType==_.traverse_file_system.f.folder?path_separator:''))+'\n';},'I:\\Documents and Settings\\kanashimi\\My Documents\\kanashimi\\www\\cgi-bin\\program');_.write_to_file('tmp.txt',kkk,'unicode');</span><span class="WHIT">
<span class='line'>3161</span> </span><span class="COMM">/*
<span class='line'>3162</span>
<span class='line'>3163</span> _.traverse_file_system(FS_function_array) 省略path會當作所有Drives
<span class='line'>3164</span> _.traverse_file_system(FS_function_array,'c:') c:→c:\→sub dir of c:\
<span class='line'>3165</span> _.traverse_file_system(FS_function_array,'c:\\') c:\→sub dir of c:\
<span class='line'>3166</span> _.traverse_file_system(FS_function_array,'c:\\cc') c:\cc,cc為dir→sub dir of c:\cc\
<span class='line'>3167</span> _.traverse_file_system(FS_function_array,'c:\\cc\\') c:\cc\→sub dir of c:\cc\
<span class='line'>3168</span> _.traverse_file_system(FS_function_array,['c:\\cc\\','d:\\dd']) c:\cc\→sub dir of c:\cc\→d:\dd→sub dir of d:\dd
<span class='line'>3169</span> _.traverse_file_system([,folderFunction],'.');
<span class='line'>3170</span>
<span class='line'>3171</span>
<span class='line'>3172</span> _.traverse_file_system([,folderFunction],basePath);
<span class='line'>3173</span> function folderFunction(folderItem){
<span class='line'>3174</span> t=folderItem.Path.slice(same_length(basePath,folderItem.Path));
<span class='line'>3175</span> //if(t==folderItem.Name) // 僅單層subdir次目錄
<span class='line'>3176</span> //if(t.indexOf(path_separator)==t.lastIndexOf(path_separator)) // 僅單層及次層subdir次目錄
<span class='line'>3177</span> if(t.replace(new RegExp('[^'+path_separator_RegExp+']','g'),'').length&lt;3) // 僅3層subdir以下
<span class='line'>3178</span> ;
<span class='line'>3179</span> }
<span class='line'>3180</span>
<span class='line'>3181</span>
<span class='line'>3182</span> // itemType=0:file/1:folder/2:driver
<span class='line'>3183</span> function fsoFunction(fsi,itemType){if(!itemType){}}
<span class='line'>3184</span> function fileFunction(fileItem){}
<span class='line'>3185</span> function folderFunction(folderItem){}
<span class='line'>3186</span> function driverFunction(driverItem){}
<span class='line'>3187</span>
<span class='line'>3188</span> filter:
<span class='line'>3189</span> file_filter 僅單一 filter 時預設當作 file_filter, should has NO global flag.
<span class='line'>3190</span> [file_filter,folder_filter]
<span class='line'>3191</span> file_filter 篩選檔案, should has NO global flag.
<span class='line'>3192</span> folder_filter 篩選資料夾, should has NO global flag.
<span class='line'>3193</span>
<span class='line'>3194</span>
<span class='line'>3195</span> tip:
<span class='line'>3196</span> 使用相對路徑,如'..'開頭時需用getFP()調整過。
<span class='line'>3197</span> 用folder.Size==0可判別是否為empty folder
<span class='line'>3198</span>
<span class='line'>3199</span> TODO:
<span class='line'>3200</span> 限定traverse深度幾層,sort=8,preOrder=0,widthFirst=0,postOrder=16,depthFirst=16
<span class='line'>3201</span> */</span><span class="WHIT">
<span class='line'>3202</span> </span><span class="COMM">//_.traverse_file_system.stop=false;</span><span class="WHIT">
<span class='line'>3203</span>
<span class='line'>3204</span> </span><span class="COMM">//_.traverse_file_system[generateCode.dLK]='initWScriptObj';</span><span class="WHIT">
<span class='line'>3205</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>3206</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>3207</span> </span><span class="COMM">/**
<span class='line'>3208</span> * 巡覽 file system 的公用函數
<span class='line'>3209</span> * @param FS_function_array file system handle function array
<span class='line'>3210</span> * @param path target path
<span class='line'>3211</span> * @param filter filter
<span class='line'>3212</span> * @param flag see &lt;a href="#.traverse_file_system.f">flag&lt;/a>
<span class='line'>3213</span> * @return
<span class='line'>3214</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3215</span> * @see &lt;a href="http://msdn.microsoft.com/library/en-us/script56/html/0fa93e5b-b657-408d-9dd3-a43846037a0e.asp">FileSystemObject&lt;/a>
<span class='line'>3216</span> */</span><span class="WHIT">
<span class='line'>3217</span> </span><span class="NAME">traverse_file_system</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">FS_function_array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3218</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">arguments.callee</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s.f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3219</span>
<span class='line'>3220</span> </span><span class="WHIT"> </span><span class="COMM">// initial</span><span class="WHIT">
<span class='line'>3221</span> </span><span class="WHIT"> </span><span class="COMM">// 預設 flag</span><span class="WHIT">
<span class='line'>3222</span> </span><span class="WHIT"> </span><span class="COMM">// if(isNaN(flag))flag=_f.traverse;</span><span class="WHIT">
<span class='line'>3223</span>
<span class='line'>3224</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system:\n[' + path + ']');</span><span class="WHIT">
<span class='line'>3225</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3226</span> </span><span class="WHIT"> </span><span class="COMM">// or FS_function_array=[,,]: 可以使用 Array 常值中的空白元素來建立零星稀疏的陣列。</span><span class="WHIT">
<span class='line'>3227</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">_f.func_length</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3228</span> </span><span class="WHIT"> </span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3229</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3230</span> </span><span class="WHIT"> </span><span class="COMM">/*
<span class='line'>3231</span> if (FS_function_array instanceof Array && FS_function_array.length == 1)
<span class='line'>3232</span> FS_function_array = FS_function_array[0];
<span class='line'>3233</span> */</span><span class="WHIT">
<span class='line'>3234</span> </span><span class="WHIT"> </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">FS_function_array</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><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3235</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3236</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="WHIT"> </span><span class="PUNC">=</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="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3237</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3238</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3239</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system: fso:\n[' + fso + ']');</span><span class="WHIT">
<span class='line'>3240</span> </span><span class="WHIT"> </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">fso</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">FS_function_array</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="WHIT">
<span class='line'>3241</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">FS_function_array.length</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3242</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3243</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']');</span><span class="WHIT">
<span class='line'>3244</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">filter</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3245</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3246</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">filter</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3247</span> </span><span class="WHIT"> </span><span class="COMM">// filter=[filter,filter]; 通常我們輸入的只會指定 file filter</span><span class="WHIT">
<span class='line'>3248</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3249</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </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">filter</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3250</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3251</span>
<span class='line'>3252</span> </span><span class="WHIT"> </span><span class="COMM">//library_namespace.log('traverse_file_system: FS_function_array:\n[' + FS_function_array + ']');</span><span class="WHIT">
<span class='line'>3253</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">traverse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">_f.no_traverse</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">objBuf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">folder_filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">testFilter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>3254</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3255</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'>3256</span> </span><span class="WHIT"> </span><span class="COMM">// f instanceof RegExp</span><span class="WHIT">
<span class='line'>3257</span> </span><span class="WHIT"> </span><span class="NAME">f.test</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3258</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3259</span> </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'>3260</span> </span><span class="WHIT"> </span><span class="COMM">// throw new Error(e.number,'traverse_file_system: 錯誤的 filter:\n'+f+'\n'+e.description);</span><span class="WHIT">
<span class='line'>3261</span> </span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'traverse_file_system: 錯誤的 filter:\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT">
<span class='line'>3262</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">e.description</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3263</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3264</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3265</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3266</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3267</span> </span><span class="WHIT"> </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">filter</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3268</span> </span><span class="WHIT"> </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="NAME">filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3269</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>3270</span> </span><span class="WHIT"> </span><span class="NAME">testFilter</span><span class="PUNC">(</span><span class="NAME">filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3271</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">folder_filter</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3272</span> </span><span class="WHIT"> </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">folder_filter</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3273</span> </span><span class="WHIT"> </span><span class="NAME">folder_filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="NAME">folder_filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3274</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>3275</span> </span><span class="WHIT"> </span><span class="NAME">testFilter</span><span class="PUNC">(</span><span class="NAME">folder_filter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3276</span> </span><span class="WHIT"> </span><span class="COMM">// if(flag!=_f.get_object)alert(filter+'\n'+folder_filter);</span><span class="WHIT">
<span class='line'>3277</span> </span><span class="WHIT"> </span><span class="COMM">// 至此 filter 代表 file_filter, vs. folder_filter</span><span class="WHIT">
<span class='line'>3278</span>
<span class='line'>3279</span>
<span class='line'>3280</span> </span><span class="WHIT"> </span><span class="COMM">// 轉換輸入之各項成fso object</span><span class="WHIT">
<span class='line'>3281</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">path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// 取得各個driver code</span><span class="WHIT">
<span class='line'>3282</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3283</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3284</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">drivers</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">fso.Drives</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">drivers.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">drivers</span><span class="WHIT">
<span class='line'>3285</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3286</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">drivers.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>3287</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.driver</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3288</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3289</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </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">path</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3290</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">path.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3291</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</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">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">path.length</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'>3292</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">(</span><span class="NAME">_f.get_object</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3293</span> </span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">filter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flag</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3294</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3295</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3296</span> </span><span class="WHIT"> </span><span class="NAME">item</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">path.IsReady</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_f.driver</span><span class="WHIT">
<span class='line'>3297</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">path.IsRootFolder</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_f.folder</span><span class="WHIT">
<span class='line'>3298</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">path.Path</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_f.file</span><span class="WHIT">
<span class='line'>3299</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">_f.NULL</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3300</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_f.NULL</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3301</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3302</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3303</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3304</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// fault</span><span class="WHIT">
<span class='line'>3305</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3306</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'>3307</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">fso.GetFolder</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>3308</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.folder</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">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3309</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'>3310</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">// fso.FolderExists()</span><span class="WHIT">
<span class='line'>3311</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3312</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'>3313</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">fso.GetFile</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>3314</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.file</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">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3315</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'>3316</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">// fso.FileExists()</span><span class="WHIT">
<span class='line'>3317</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">fso.GetDriveName</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3318</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'>3319</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">fso.GetDrive</span><span class="PUNC">(</span><span class="NAME">path</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>3320</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.driver</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">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3321</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'>3322</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3323</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3324</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flag</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">_f.get_object</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3325</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">objBuf</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">objBuf</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">]</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'>3326</span>
<span class='line'>3327</span> </span><span class="WHIT"> </span><span class="COMM">// FS_function_array.length=_f.func_length;</span><span class="WHIT">
<span class='line'>3328</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</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">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">_f.func_length</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'>3329</span> </span><span class="WHIT"> </span><span class="COMM">// 可以安排僅對folder或是file作用之function</span><span class="WHIT">
<span class='line'>3330</span> </span><span class="WHIT"> </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">FS_function_array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</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'>3331</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </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="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3332</span> </span><span class="WHIT"> </span><span class="COMM">//alert(objBuf.length+','+typeBuf.length+'\n'+typeBuf);</span><span class="WHIT">
<span class='line'>3333</span> </span><span class="WHIT"> </span><span class="COMM">// main loop</span><span class="WHIT">
<span class='line'>3334</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">_s.stop</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">objBuf.length</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3335</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">objBuf.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">// fsoFunction執行途中可能將此項目刪除</span><span class="WHIT">
<span class='line'>3336</span> </span><span class="WHIT"> </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">iType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">typeBuf.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3337</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">_f.folder</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3338</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">folder_filter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">folder_filter.test</span><span class="PUNC">(</span><span class="NAME">item.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3339</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">iType</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3340</span> </span><span class="WHIT"> </span><span class="COMM">// if(traverse||traverse!==0){</span><span class="WHIT">
<span class='line'>3341</span> </span><span class="WHIT"> </span><span class="COMM">// if(!traverse)traverse=0; // 加上次一層: 會連這次一層之檔案都加上去。</span><span class="WHIT">
<span class='line'>3342</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">traverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3343</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">item.SubFolders</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fc.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT">
<span class='line'>3344</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3345</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fc.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">folder_filter</span><span class="WHIT">
<span class='line'>3346</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">folder_filter.test</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3347</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>3348</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.folder</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3349</span> </span><span class="WHIT"> </span><span class="COMM">// }</span><span class="WHIT">
<span class='line'>3350</span> </span><span class="WHIT"> </span><span class="COMM">// try 以防item已經被刪除</span><span class="WHIT">
<span class='line'>3351</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'>3352</span> </span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">item.Files</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3353</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'>3354</span> </span><span class="WHIT"> </span><span class="NAME">fc</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'>3355</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3356</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3357</span> </span><span class="WHIT"> </span><span class="COMM">// for(;!fc.atEnd();fc.moveNext())if(i=fc.item(),!filter||filter.test(i.Name))FS_function_array[_f.file](i,_f.file);</span><span class="WHIT">
<span class='line'>3358</span> </span><span class="WHIT"> </span><span class="COMM">// 因為檔案可能因改名等改變順序,因此用.moveNext()的方法可能有些重複,有些漏掉未處理。</span><span class="WHIT">
<span class='line'>3359</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fc.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">fc.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3360</span> </span><span class="WHIT"> </span><span class="NAME">item.push</span><span class="PUNC">(</span><span class="NAME">fc.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3361</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </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">item</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3362</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item</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="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">filter.test</span><span class="PUNC">(</span><span class="NAME">i.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3363</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">_f.file</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3364</span> </span><span class="WHIT"> </span><span class="NAME">_f.file</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3365</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3366</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3367</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">_f.file</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3368</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">filter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">filter.test</span><span class="PUNC">(</span><span class="NAME">item.Name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3369</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">iType</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3370</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3371</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">_f.driver</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3372</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">item.IsReady</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3373</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3374</span> </span><span class="WHIT"> </span><span class="NAME">FS_function_array</span><span class="PUNC">[</span><span class="NAME">iType</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3375</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">traverse</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3376</span> </span><span class="WHIT"> </span><span class="NAME">objBuf.push</span><span class="PUNC">(</span><span class="NAME">item.RootFolder</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">typeBuf</span><span class="WHIT">
<span class='line'>3377</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">_f.folder</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3378</span> </span><span class="WHIT"> </span><span class="COMM">// break;</span><span class="WHIT">
<span class='line'>3379</span> </span><span class="WHIT"> </span><span class="COMM">//default:break;</span><span class="WHIT">
<span class='line'>3380</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3381</span>
<span class='line'>3382</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3383</span>
<span class='line'>3384</span>
<span class='line'>3385</span> </span><span class="COMM">//setObjValue('traverse_file_system.f','get_object=-2,NULL=-1,file,folder,driver,func_length,traverse=0,no_traverse=4',1);//,sort=8,preOrder=0,widthFirst=0,postOrder=16,depthFirst=16</span><span class="WHIT">
<span class='line'>3386</span> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>3387</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>3388</span> </span><span class="COMM">/**
<span class='line'>3389</span> * &lt;a href="#.traverse_file_system">traverse_file_system&lt;/a> 的 flag enumeration
<span class='line'>3390</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3391</span> * @constant
<span class='line'>3392</span> */</span><span class="WHIT">
<span class='line'>3393</span> </span><span class="NAME">traverse_file_system.f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3394</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3395</span> * return object
<span class='line'>3396</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3397</span> */</span><span class="WHIT">
<span class='line'>3398</span> </span><span class="WHIT"> </span><span class="NAME">get_object</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3399</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3400</span> * null flag
<span class='line'>3401</span> * @private
<span class='line'>3402</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3403</span> */</span><span class="WHIT">
<span class='line'>3404</span> </span><span class="WHIT"> </span><span class="NAME">NULL</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3405</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3406</span> * 用於指示 file
<span class='line'>3407</span> * @private
<span class='line'>3408</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3409</span> */</span><span class="WHIT">
<span class='line'>3410</span> </span><span class="WHIT"> </span><span class="NAME">file</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'>3411</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3412</span> * 用於指示 folder
<span class='line'>3413</span> * @private
<span class='line'>3414</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3415</span> */</span><span class="WHIT">
<span class='line'>3416</span> </span><span class="WHIT"> </span><span class="NAME">folder</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3417</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3418</span> * 用於指示 driver
<span class='line'>3419</span> * @private
<span class='line'>3420</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3421</span> */</span><span class="WHIT">
<span class='line'>3422</span> </span><span class="WHIT"> </span><span class="NAME">driver</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3423</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3424</span> * handle function 應有的長度
<span class='line'>3425</span> * @private
<span class='line'>3426</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3427</span> */</span><span class="WHIT">
<span class='line'>3428</span> </span><span class="WHIT"> </span><span class="NAME">func_length</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3429</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3430</span> * 深入下層子目錄及檔案
<span class='line'>3431</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3432</span> */</span><span class="WHIT">
<span class='line'>3433</span> </span><span class="WHIT"> </span><span class="NAME">traverse</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'>3434</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3435</span> * 不深入下層子目錄及檔案
<span class='line'>3436</span> * @memberOf CeL.IO.Windows.file
<span class='line'>3437</span> */</span><span class="WHIT">
<span class='line'>3438</span> </span><span class="WHIT"> </span><span class="NAME">no_traverse</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT">
<span class='line'>3439</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3440</span>
<span class='line'>3441</span>
<span class='line'>3442</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>3443</span> </span><span class="WHIT"> </span><span class="NAME">CeL.IO.Windows.file</span><span class="WHIT">
<span class='line'>3444</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3445</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3446</span>
<span class='line'>3447</span> </span><span class="COMM">//===================================================</span><span class="WHIT">
<span class='line'>3448</span>
<span class='line'>3449</span> </span><span class="NAME">CeL.setup_module</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3450</span>
<span class='line'>3451</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3452</span>
<span class='line'>3453</span>
<span class='line'>3454</span> </span><span class="COMM">//WScript.Echo(this.Class);</span><span class="WHIT">
<span class='line'>3455</span>
<span class='line'>3456</span> </span><span class="COMM">// 若 library base 尚未 load 或本 module 已經 loaded 則跳過。</span><span class="WHIT">
<span class='line'>3457</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="PUNC">{</span><span class="WHIT">
<span class='line'>3458</span>
<span class='line'>3459</span> </span><span class="COMM">/**
<span class='line'>3460</span> * 本 module 之 name(id)&lt;span style="text-decoration:line-through;">不設定時會從呼叫時之 path 取得&lt;/span>。
<span class='line'>3461</span> * @type String
<span class='line'>3462</span> * @constant
<span class='line'>3463</span> * @inner
<span class='line'>3464</span> * @ignore
<span class='line'>3465</span> */</span><span class="WHIT">
<span class='line'>3466</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'code.log'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3467</span>
<span class='line'>3468</span> </span><span class="COMM">//var do_before_including = function() {};</span><span class="WHIT">
<span class='line'>3469</span>
<span class='line'>3470</span> </span><span class="COMM">/* to include:
<span class='line'>3471</span> include code_for_including
<span class='line'>3472</span> &lt;div id="debug_panel">&lt;/div>
<span class='line'>3473</span> var SL=new Debug.log('debug_panel'),sl=function(){SL.log.apply(SL,arguments);},err=function(){SL.err.apply(SL,arguments);},warn=function(){SL.warn.apply(SL,arguments);};
<span class='line'>3474</span>
<span class='line'>3475</span> http://www.comsharp.com/GetKnowledge/zh-CN/TeamBlogTimothyPage_K742.aspx
<span class='line'>3476</span>
<span class='line'>3477</span> if possible, use Firebug Lite instead.
<span class='line'>3478</span> http://benalman.com/projects/javascript-debug-console-log/
<span class='line'>3479</span> */</span><span class="WHIT">
<span class='line'>3480</span>
<span class='line'>3481</span>
<span class='line'>3482</span> </span><span class="COMM">// ===================================================</span><span class="WHIT">
<span class='line'>3483</span> </span><span class="COMM">/**
<span class='line'>3484</span> * 若欲 include 整個 module 時,需囊括之 code。通常即 CeL。
<span class='line'>3485</span> * @type Function
<span class='line'>3486</span> * @param {Function} library_namespace namespace of library
<span class='line'>3487</span> * @param load_arguments 呼叫時之 argument(s)
<span class='line'>3488</span> * @return
<span class='line'>3489</span> * @constant
<span class='line'>3490</span> * @inner
<span class='line'>3491</span> * @ignore
<span class='line'>3492</span> */</span><span class="WHIT">
<span class='line'>3493</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">code_for_including</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">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'>3494</span> </span><span class="COMM">//WScript.Echo(this);</span><span class="WHIT">
<span class='line'>3495</span>
<span class='line'>3496</span> </span><span class="KEYW">var</span><span class="WHIT">
<span class='line'>3497</span>
<span class='line'>3498</span> </span><span class="COMM">// class private -----------------------------------</span><span class="WHIT">
<span class='line'>3499</span>
<span class='line'>3500</span> </span><span class="COMM">// class name, 需要用到這個都不是好方法。</span><span class="WHIT">
<span class='line'>3501</span> </span><span class="COMM">//cn='Debug.log',</span><span class="WHIT">
<span class='line'>3502</span>
<span class='line'>3503</span> </span><span class="COMM">/**
<span class='line'>3504</span> * private storage pool
<span class='line'>3505</span> * @ignore
<span class='line'>3506</span> */</span><span class="WHIT">
<span class='line'>3507</span> </span><span class="NAME">p</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3508</span>
<span class='line'>3509</span> </span><span class="COMM">/**
<span class='line'>3510</span> * default write/show log function
<span class='line'>3511</span> * @ignore
<span class='line'>3512</span> * @param {string} id element id
<span class='line'>3513</span> */</span><span class="WHIT">
<span class='line'>3514</span> </span><span class="NAME">w</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">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3515</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.instance</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3516</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3517</span> * buffer
<span class='line'>3518</span> */</span><span class="WHIT">
<span class='line'>3519</span> </span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.buf</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3520</span> </span><span class="WHIT"> </span><span class="NAME">B</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.board</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.do_function</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">level</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3521</span>
<span class='line'>3522</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_p.clean</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3523</span> </span><span class="WHIT"> </span><span class="NAME">_t.clear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_p.clean</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'>3524</span>
<span class='line'>3525</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">B</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">F</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3526</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3527</span>
<span class='line'>3528</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">b.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3529</span> </span><span class="WHIT"> </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 預防 MP 時重複顯示</span><span class="WHIT">
<span class='line'>3530</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">F</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3531</span> </span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3532</span>
<span class='line'>3533</span> </span><span class="WHIT"> </span><span class="NAME">c</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'>3534</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">m</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="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">m</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'>3535</span> </span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m.l</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">_t.className_set</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_t.className_set</span><span class="PUNC">[</span><span class="NAME">m.l</span><span class="PUNC">]</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'>3536</span> </span><span class="WHIT"> </span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m.m</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3537</span> </span><span class="WHIT"> </span><span class="NAME">_p.lbuf.push</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3538</span>
<span class='line'>3539</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">B</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// && typeof document==='object'</span><span class="WHIT">
<span class='line'>3540</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.instance.log_tag</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3541</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3542</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3543</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3544</span> </span><span class="WHIT"> </span><span class="NAME">o.className</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3545</span> </span><span class="WHIT"> </span><span class="NAME">o.innerHTML</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">m</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>3546</span> </span><span class="WHIT"> </span><span class="COMM">// for character (null)</span><span class="WHIT">
<span class='line'>3547</span> </span><span class="WHIT"> </span><span class="NAME">m.replace</span><span class="PUNC">(</span><span class="REGX">/\x00/g</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3548</span> </span><span class="WHIT"> </span><span class="STRN">'&lt;span class="control_character">\\x00&lt;/span>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3549</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3550</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'>3551</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createTextNode</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3552</span> </span><span class="WHIT"> </span><span class="NAME">B.appendChild</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3553</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3554</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3555</span>
<span class='line'>3556</span> </span><span class="WHIT"> </span><span class="COMM">//if(_t.auto_hide)B.style.display=B.innerHTML?'block':'none';</span><span class="WHIT">
<span class='line'>3557</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">B</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">_t.auto_scroll</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3558</span> </span><span class="WHIT"> </span><span class="KEYW">with</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">B</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3559</span> </span><span class="WHIT"> </span><span class="NAME">scrollTop</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scrollHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">clientHeight</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3560</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3561</span>
<span class='line'>3562</span>
<span class='line'>3563</span> </span><span class="COMM">/**
<span class='line'>3564</span> * save log
<span class='line'>3565</span> * @ignore
<span class='line'>3566</span> * @param m message
<span class='line'>3567</span> * @param {string} id element id
<span class='line'>3568</span> * @param force force to clean the message area
<span class='line'>3569</span> */</span><span class="WHIT">
<span class='line'>3570</span> </span><span class="NAME">s</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">m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">force</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3571</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.instance</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.logF</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.save_log</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3572</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">s</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">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">s</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3573</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3574</span>
<span class='line'>3575</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3576</span> </span><span class="WHIT"> </span><span class="NAME">_p.sbuf</span><span class="WHIT">
<span class='line'>3577</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">m</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_t.save_date</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">gDate</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">_t.save_new_line</span><span class="WHIT">
<span class='line'>3578</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">gDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">_t.save_new_line</span><span class="WHIT">
<span class='line'>3579</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 class='line'>3580</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3581</span>
<span class='line'>3582</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_t.flush</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_p.sbufL</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">_t.save_limit</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3583</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'>3584</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">f</span><span class="WHIT">
<span class='line'>3585</span> </span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_t.log_file</span><span class="WHIT">
<span class='line'>3586</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_p.logF</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fso.OpenTextFile</span><span class="PUNC">(</span><span class="NAME">_t.log_file</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3587</span> </span><span class="WHIT"> </span><span class="NUMB">8</span><span class="COMM">/* ForAppending */</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="COMM">/* create */</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3588</span> </span><span class="WHIT"> </span><span class="NAME">_t.log_encoding</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3589</span> </span><span class="WHIT"> </span><span class="NAME">f.Write</span><span class="PUNC">(</span><span class="NAME">_p.sbuf.join</span><span class="PUNC">(</span><span class="NAME">_t.save_new_line</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_p.sbuf</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3590</span> </span><span class="WHIT"> </span><span class="NAME">_p.sbufL</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">_t.error_message</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'>3591</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'>3592</span> </span><span class="WHIT"> </span><span class="NAME">_t.error_message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="COMM">// err(e);</span><span class="WHIT">
<span class='line'>3593</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3594</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3595</span> </span><span class="WHIT"> </span><span class="NAME">_p.sbufL</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3596</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3597</span>
<span class='line'>3598</span> </span><span class="COMM">// instance constructor ---------------------------</span><span class="WHIT">
<span class='line'>3599</span> </span><span class="COMM">// (document object)</span><span class="WHIT">
<span class='line'>3600</span> </span><span class="COMM">/*
<span class='line'>3601</span>
<span class='line'>3602</span> _=this
<span class='line'>3603</span>
<span class='line'>3604</span>
<span class='line'>3605</span> TODO:
<span class='line'>3606</span> set class in each input
<span class='line'>3607</span> input array
<span class='line'>3608</span> show file path & directory functional 可從 FSO operation.hta 移植
<span class='line'>3609</span> 增加 group 以便在多次輸入時亦可 trigger 或排版
<span class='line'>3610</span>
<span class='line'>3611</span> count
<span class='line'>3612</span> c.f.: GLog
<span class='line'>3613</span>
<span class='line'>3614</span> dependency:
<span class='line'>3615</span>
<span class='line'>3616</span> */</span><span class="WHIT">
<span class='line'>3617</span> </span><span class="COMM">/**
<span class='line'>3618</span> * initial a log tool's instance/object
<span class='line'>3619</span> * @class log function
<span class='line'>3620</span> * @see usage: &lt;a href="#.extend">CeL.code.log.extend&lt;/a>
<span class='line'>3621</span> * @since 2008/8/20 23:9:48
<span class='line'>3622</span> * @requires gDate(),NewLine,fso
<span class='line'>3623</span>
<span class='line'>3624</span> * @constructor
<span class='line'>3625</span> * @name CeL.code.log
<span class='line'>3626</span> * @param {String, object HTMLElement} obj message area element or id
<span class='line'>3627</span> */</span><span class="WHIT">
<span class='line'>3628</span> </span><span class="NAME">_tmp</span><span class="PUNC">;</span><span class="NAME">CeL.code.log</span><span class="WHIT">
<span class='line'>3629</span> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3630</span> </span><span class="WHIT"> </span><span class="COMM">// Initial instance object. You can set it yourself.</span><span class="WHIT">
<span class='line'>3631</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3632</span> * 表示是 warning/error message 之 className
<span class='line'>3633</span> * @name CeL.code.log.prototype.className_set
<span class='line'>3634</span> */</span><span class="WHIT">
<span class='line'>3635</span> </span><span class="WHIT"> </span><span class="NAME">this.className_set</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3636</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3637</span> * @description 當呼叫 {@link CeL.code.log.prototype.warn} 時使用的 className
<span class='line'>3638</span> * @name CeL.code.log.prototype.className_set.warn
<span class='line'>3639</span> */</span><span class="WHIT">
<span class='line'>3640</span> </span><span class="WHIT"> </span><span class="NAME">warn</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'debug_warn'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3641</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3642</span> * @description 當呼叫 {@link CeL.code.log.prototype.err} 時使用的 className
<span class='line'>3643</span> * @name CeL.code.log.prototype.className_set.err
<span class='line'>3644</span> */</span><span class="WHIT">
<span class='line'>3645</span> </span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'debug_err'</span><span class="WHIT">
<span class='line'>3646</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3647</span>
<span class='line'>3648</span> </span><span class="WHIT"> </span><span class="NAME">this.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">p.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3649</span> </span><span class="WHIT"> </span><span class="NAME">p.push</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3650</span> </span><span class="WHIT"> </span><span class="NAME">instance</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'>3651</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3652</span> * write buffer
<span class='line'>3653</span> */</span><span class="WHIT">
<span class='line'>3654</span> </span><span class="WHIT"> </span><span class="NAME">buf</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3655</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3656</span> * save buffer when we need to save the messages
<span class='line'>3657</span> */</span><span class="WHIT">
<span class='line'>3658</span> </span><span class="WHIT"> </span><span class="NAME">sbuf</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3659</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3660</span> * length of save buffer
<span class='line'>3661</span> */</span><span class="WHIT">
<span class='line'>3662</span> </span><span class="WHIT"> </span><span class="NAME">sbufL</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'>3663</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3664</span> * now logged buffer
<span class='line'>3665</span> */</span><span class="WHIT">
<span class='line'>3666</span> </span><span class="WHIT"> </span><span class="NAME">lbuf</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>3667</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>3668</span> </span><span class="WHIT"> </span><span class="NAME">this.set_board</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3669</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3670</span>
<span class='line'>3671</span>
<span class='line'>3672</span>
<span class='line'>3673</span> </span><span class="COMM">// class public interface ---------------------------</span><span class="WHIT">
<span class='line'>3674</span>
<span class='line'>3675</span> </span><span class="NAME">CeL.code.log</span><span class="WHIT">
<span class='line'>3676</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>3677</span> </span><span class="COMM">/**
<span class='line'>3678</span> * do the log action
<span class='line'>3679</span> * @memberOf CeL.code.log
<span class='line'>3680</span> * @private
<span class='line'>3681</span> */</span><span class="WHIT">
<span class='line'>3682</span> </span><span class="NAME">do_log</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">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3683</span> </span><span class="COMM">/* 這段應該只在 module namespace 重複定義時才會發生
<span class='line'>3684</span> var I=p[id];
<span class='line'>3685</span> if(!I){
<span class='line'>3686</span> alert('.do_log: not exist: ['+id+']');
<span class='line'>3687</span> return;
<span class='line'>3688</span> }
<span class='line'>3689</span> I=I.instance;
<span class='line'>3690</span> */</span><span class="WHIT">
<span class='line'>3691</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="NAME">p</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">instance</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3692</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">I.do_log</span><span class="PUNC">)</span><span class="NAME">I.do_log</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3693</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3694</span>
<span class='line'>3695</span>
<span class='line'>3696</span> </span><span class="NAME">CeL.code.log</span><span class="WHIT">
<span class='line'>3697</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>3698</span> </span><span class="COMM">/**
<span class='line'>3699</span> * new extend instance
<span class='line'>3700</span> * @param {String, object HTMLElement} [obj] message area element or id
<span class='line'>3701</span> * @return {Array} [ log function, warning function, error function, instance of this module ]
<span class='line'>3702</span> * @example
<span class='line'>3703</span> * // status logger
<span class='line'>3704</span> * var SL=new CeL.code.log('log'),sl=SL[1],warn=SL[2],err=SL[3];
<span class='line'>3705</span> * sl(msg);
<span class='line'>3706</span> * sl(msg,clear);
<span class='line'>3707</span> * @memberOf CeL.code.log
<span class='line'>3708</span> * @since 2009/8/24 20:15:31
<span class='line'>3709</span> */</span><span class="WHIT">
<span class='line'>3710</span> </span><span class="NAME">extend</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">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3711</span> </span><span class="WHIT"> </span><span class="COMM">//CeL.Log=new CeL.code.log(function(m){var F=typeof JSalert==='function'?JSalert:typeof alert==='function'?alert:WScript.Echo;F(typeof m==='object'?'['+m.l+'] '+m.m:m);});</span><span class="WHIT">
<span class='line'>3712</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>3713</span> * new instance
<span class='line'>3714</span> * @type CeL.code.log
<span class='line'>3715</span> * @inner
<span class='line'>3716</span> * @ignore
<span class='line'>3717</span> */</span><span class="WHIT">
<span class='line'>3718</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>3719</span> </span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>3720</span> </span><span class="WHIT"> </span><span class="COMM">// 預設以訊息框代替</span><span class="WHIT">
<span class='line'>3721</span> </span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Function</span><span class="PUNC">(</span><span class="STRN">'m'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3722</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">JSalert</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'JSalert'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3723</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'WScript.Echo'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3724</span> </span><span class="WHIT"> </span><span class="STRN">'alert'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>3725</span> </span><span class="WHIT"> </span><span class="STRN">"(typeof m==='object'?'['+m.l+'] '+m.m:m);"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3726</span>
<span class='line'>3727</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">o</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'>3728</span> </span><span class="WHIT"> </span><span class="NAME">o.log.apply</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3729</span> </span><span class="WHIT"> </span><span class="PUNC">}</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'>3730</span> </span><span class="WHIT"> </span><span class="NAME">o.warn.apply</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3731</span> </span><span class="WHIT"> </span><span class="PUNC">}</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'>3732</span> </span><span class="WHIT"> </span><span class="NAME">o.err.apply</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3733</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3734</span>
<span class='line'>3735</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3736</span>
<span class='line'>3737</span>
<span class='line'>3738</span>
<span class='line'>3739</span> </span><span class="COMM">/*
<span class='line'>3740</span> _.option_open=function(p){
<span class='line'>3741</span>
<span class='line'>3742</span> };
<span class='line'>3743</span>
<span class='line'>3744</span> _.option_file=function(p){
<span class='line'>3745</span> };
<span class='line'>3746</span>
<span class='line'>3747</span> _.option_folder=function(p){
<span class='line'>3748</span> };
<span class='line'>3749</span> */</span><span class="WHIT">
<span class='line'>3750</span>
<span class='line'>3751</span> </span><span class="COMM">// class constructor ---------------------------</span><span class="WHIT">
<span class='line'>3752</span>
<span class='line'>3753</span>
<span class='line'>3754</span> </span><span class="NAME">CeL.code.log</span><span class="WHIT">
<span class='line'>3755</span> </span><span class="PUNC">.</span><span class="NAME">prototype</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3756</span>
<span class='line'>3757</span> </span><span class="COMM">// instance public interface -------------------</span><span class="WHIT">
<span class='line'>3758</span>
<span class='line'>3759</span> </span><span class="COMM">/**
<span class='line'>3760</span> * 當執行寫檔案或任何錯誤發生時之錯誤訊息。&lt;br/>
<span class='line'>3761</span> * while error occurred.. should read only
<span class='line'>3762</span> * @name CeL.code.log.prototype.error_message
<span class='line'>3763</span> */</span><span class="WHIT">
<span class='line'>3764</span> </span><span class="NAME">error_message</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 class='line'>3765</span>
<span class='line'>3766</span> </span><span class="COMM">/**
<span class='line'>3767</span> * 超過這長度才 save。&lt;=0 表示 autoflash非數字則不紀錄。
<span class='line'>3768</span> * @name CeL.code.log.prototype.save_limit
<span class='line'>3769</span> * @type Number
<span class='line'>3770</span> */</span><span class="WHIT">
<span class='line'>3771</span> </span><span class="NAME">save_limit</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4000</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3772</span>
<span class='line'>3773</span> </span><span class="COMM">/**
<span class='line'>3774</span> * 在 log 結束時執行,相當於 VB 中 DoEvent() 或 。
<span class='line'>3775</span> * @name CeL.code.log.prototype.do_event
<span class='line'>3776</span> */</span><span class="WHIT">
<span class='line'>3777</span> </span><span class="NAME">do_event</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">library_namespace.DoNoting</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3778</span>
<span class='line'>3779</span>
<span class='line'>3780</span> </span><span class="COMM">/**
<span class='line'>3781</span> * log 時使用之 tagName, 可用 div / span 等。若不設定會用 document.createTextNode
<span class='line'>3782</span> * @name CeL.code.log.prototype.log_tag
<span class='line'>3783</span> */</span><span class="WHIT">
<span class='line'>3784</span> </span><span class="NAME">log_tag</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3785</span>
<span class='line'>3786</span>
<span class='line'>3787</span> </span><span class="COMM">/**
<span class='line'>3788</span> * boolean or function(message, log level) return save or not
<span class='line'>3789</span> * @name CeL.code.log.prototype.save_log
<span class='line'>3790</span> * @type Boolean
<span class='line'>3791</span> */</span><span class="WHIT">
<span class='line'>3792</span> </span><span class="NAME">save_log</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3793</span> </span><span class="COMM">/**
<span class='line'>3794</span> * save log to this file path
<span class='line'>3795</span> * @name CeL.code.log.prototype.log_file
<span class='line'>3796</span> * @type Boolean
<span class='line'>3797</span> */</span><span class="WHIT">
<span class='line'>3798</span> </span><span class="NAME">log_file</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3799</span> </span><span class="COMM">/**
<span class='line'>3800</span> * auto save log. 若未設定,記得在 onunload 時 .save()
<span class='line'>3801</span> * @name CeL.code.log.prototype.flush
<span class='line'>3802</span> * @type Boolean
<span class='line'>3803</span> */</span><span class="WHIT">
<span class='line'>3804</span> </span><span class="NAME">flush</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3805</span> </span><span class="COMM">/**
<span class='line'>3806</span> * 在 save log 時 add date
<span class='line'>3807</span> * @name CeL.code.log.prototype.save_date
<span class='line'>3808</span> * @type Boolean
<span class='line'>3809</span> */</span><span class="WHIT">
<span class='line'>3810</span> </span><span class="NAME">save_date</span><span class="PUNC">:</span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3811</span> </span><span class="COMM">/**
<span class='line'>3812</span> * 在 save log 時的換行
<span class='line'>3813</span> * @name CeL.code.log.prototype.save_new_line
<span class='line'>3814</span> * @type string
<span class='line'>3815</span> */</span><span class="WHIT">
<span class='line'>3816</span> </span><span class="NAME">save_new_line</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">library_namespace.env.new_line</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'\r\n'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3817</span> </span><span class="COMM">/**
<span class='line'>3818</span> * 在 save log 時的 encoding
<span class='line'>3819</span> * @name CeL.code.log.prototype.log_encoding
<span class='line'>3820</span> */</span><span class="WHIT">
<span class='line'>3821</span> </span><span class="NAME">log_encoding</span><span class="PUNC">:</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="COMM">//TristateTrue</span><span class="WHIT">
<span class='line'>3822</span>
<span class='line'>3823</span>
<span class='line'>3824</span> </span><span class="COMM">/**
<span class='line'>3825</span> * 自動捲動
<span class='line'>3826</span> * @name CeL.code.log.prototype.auto_scroll
<span class='line'>3827</span> * @type Boolean
<span class='line'>3828</span> */</span><span class="WHIT">
<span class='line'>3829</span> </span><span class="NAME">auto_scroll</span><span class="PUNC">:</span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3830</span> </span><span class="COMM">/**
<span class='line'>3831</span> * 沒有內容時自動隱藏
<span class='line'>3832</span> * @deprecated TODO
<span class='line'>3833</span> * @name CeL.code.log.prototype.auto_hide
<span class='line'>3834</span> * @type Boolean
<span class='line'>3835</span> */</span><span class="WHIT">
<span class='line'>3836</span> </span><span class="NAME">auto_hide</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3837</span>
<span class='line'>3838</span> </span><span class="COMM">/**
<span class='line'>3839</span> * 等待多久才顯示 log。若為 0 則直接顯示。&lt;br/>
<span class='line'>3840</span> * (WScript 沒有 setTimeout)
<span class='line'>3841</span> * @name CeL.code.log.prototype.interval
<span class='line'>3842</span> */</span><span class="WHIT">
<span class='line'>3843</span> </span><span class="NAME">interval</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">setTimeout</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3844</span>
<span class='line'>3845</span> </span><span class="COMM">/**
<span class='line'>3846</span> * log function (no delay)
<span class='line'>3847</span> * @name CeL.code.log.prototype.do_log
<span class='line'>3848</span> */</span><span class="WHIT">
<span class='line'>3849</span> </span><span class="NAME">do_log</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">level</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3850</span> </span><span class="WHIT"> </span><span class="COMM">//if(p[this.id].th)clearTimeout(p[this.id].th);</span><span class="WHIT">
<span class='line'>3851</span> </span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">this.id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">th</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// reset timeout handle</span><span class="WHIT">
<span class='line'>3852</span> </span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">(</span><span class="NAME">this.id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3853</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3854</span>
<span class='line'>3855</span> </span><span class="COMM">/**
<span class='line'>3856</span> * class 預設作 log 之 function, (String message, clean)
<span class='line'>3857</span> * @name CeL.code.log.prototype.
<span class='line'>3858</span> */</span><span class="WHIT">
<span class='line'>3859</span> </span><span class="NAME">log</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="NAME">clean</span><span class="PUNC">,</span><span class="NAME">level</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3860</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="NAME">_p</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">t.id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3861</span> </span><span class="WHIT"> </span><span class="COMM">//var msg_head=(arguments.callee.caller+'').match(/function\s([^\(]+)/);if(msg_head)msg_head=msg_head[1]+' ';</span><span class="WHIT">
<span class='line'>3862</span> </span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="NAME">t.id</span><span class="PUNC">,</span><span class="NAME">level</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3863</span>
<span class='line'>3864</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">level</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3865</span> </span><span class="WHIT"> </span><span class="NAME">m</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="NAME">m</span><span class="PUNC">:</span><span class="NAME">m</span><span class="PUNC">,</span><span class="NAME">l</span><span class="PUNC">:</span><span class="NAME">level</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3866</span>
<span class='line'>3867</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">clean</span><span class="PUNC">)</span><span class="NAME">_p.clean</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="NAME">_p.buf</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="NAME">m</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// clean log next time</span><span class="WHIT">
<span class='line'>3868</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">_p.buf.push</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3869</span> </span><span class="WHIT"> </span><span class="COMM">//window.status=m;</span><span class="WHIT">
<span class='line'>3870</span>
<span class='line'>3871</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">t.interval</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3872</span> </span><span class="WHIT"> </span><span class="NAME">t.do_log</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3873</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="PUNC">!</span><span class="NAME">_p.th</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3874</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">setTimeout</span><span class="PUNC">===</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3875</span> </span><span class="WHIT"> </span><span class="NAME">t.interval</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">t.do_log</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3876</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>3877</span> </span><span class="WHIT"> </span><span class="COMM">//_p.th=setTimeout(cn+'.do_log('+t.id+');',t.interval);</span><span class="WHIT">
<span class='line'>3878</span> </span><span class="WHIT"> </span><span class="NAME">_p.th</span><span class="PUNC">=</span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">_.do_log</span><span class="PUNC">(</span><span class="NAME">t.id</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">t.interval</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3879</span>
<span class='line'>3880</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">t.do_event</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3881</span> </span><span class="WHIT"> </span><span class="NAME">t.do_event</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3882</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3883</span>
<span class='line'>3884</span> </span><span class="COMM">/*
<span class='line'>3885</span> TODO:
<span class='line'>3886</span> other methods: INFO,DEBUG,WARNING,ERROR,FATAL,UNKNOWN
<span class='line'>3887</span> */</span><span class="WHIT">
<span class='line'>3888</span>
<span class='line'>3889</span> </span><span class="COMM">/**
<span class='line'>3890</span> * save message
<span class='line'>3891</span> * @name CeL.code.log.prototype.save
<span class='line'>3892</span> */</span><span class="WHIT">
<span class='line'>3893</span> </span><span class="NAME">save</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3894</span> </span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">,</span><span class="NAME">this.id</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="COMM">/*force*/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3895</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3896</span>
<span class='line'>3897</span> </span><span class="COMM">// ** important ** 這邊不能作 object 之 initialization否則因為 object 只會 copy reference因此 new 時東西會一樣。initialization 得在 _() 中作!</span><span class="WHIT">
<span class='line'>3898</span> </span><span class="COMM">//className_set:{},</span><span class="WHIT">
<span class='line'>3899</span>
<span class='line'>3900</span> </span><span class="COMM">/**
<span class='line'>3901</span> * log a warning
<span class='line'>3902</span> * @name CeL.code.log.prototype.warn
<span class='line'>3903</span> */</span><span class="WHIT">
<span class='line'>3904</span> </span><span class="NAME">warn</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="NAME">clean</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3905</span> </span><span class="WHIT"> </span><span class="NAME">this.log</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="NAME">clean</span><span class="PUNC">,</span><span class="STRN">'warn'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3906</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3907</span>
<span class='line'>3908</span> </span><span class="COMM">/**
<span class='line'>3909</span> * 表示是錯誤 error message
<span class='line'>3910</span> * @name CeL.code.log.prototype.error_prefix
<span class='line'>3911</span> */</span><span class="WHIT">
<span class='line'>3912</span> </span><span class="NAME">error_prefix</span><span class="PUNC">:</span><span class="STRN">'&lt;em>!! Error !!&lt;/em> '</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3913</span> </span><span class="COMM">/**
<span class='line'>3914</span> * deal with error object
<span class='line'>3915</span> * @name CeL.code.log.prototype.err
<span class='line'>3916</span> */</span><span class="WHIT">
<span class='line'>3917</span> </span><span class="NAME">err</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="NAME">clean</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3918</span> </span><span class="WHIT"> </span><span class="COMM">// from popErr()</span><span class="WHIT">
<span class='line'>3919</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">NL</span><span class="PUNC">=</span><span class="NAME">this.save_new_line</span><span class="PUNC">,</span><span class="NAME">T</span><span class="PUNC">=</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">,</span><span class="NAME">m</span><span class="PUNC">=</span><span class="NAME">e</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">?</span><span class="STRN">'Error '</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="PUNC">&</span><span class="NUMB">0xFFFF</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">e.name</span><span class="PUNC">?</span><span class="STRN">' ['</span><span class="PUNC">+</span><span class="NAME">e.name</span><span class="PUNC">+</span><span class="STRN">']'</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3920</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">' (facility code '</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">e.number</span><span class="PUNC">>></span><span class="NUMB">16</span><span class="PUNC">&</span><span class="NUMB">0x1FFF</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">'):'</span><span class="PUNC">+</span><span class="NAME">NL</span><span class="PUNC">+</span><span class="NAME">e.description.replace</span><span class="PUNC">(</span><span class="REGX">/\r?\n/g</span><span class="PUNC">,</span><span class="STRN">'&lt;br/>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3921</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">e.message</span><span class="PUNC">||</span><span class="NAME">e.message</span><span class="PUNC">==</span><span class="NAME">e.description</span><span class="PUNC">?</span><span class="STRN">''</span><span class="PUNC">:</span><span class="NAME">NL</span><span class="PUNC">+</span><span class="NAME">NL</span><span class="PUNC">+</span><span class="NAME">e.message.replace</span><span class="PUNC">(</span><span class="REGX">/\r?\n/g</span><span class="PUNC">,</span><span class="STRN">'&lt;br/>'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="PUNC">!</span><span class="NAME">e</span><span class="PUNC">||</span><span class="NAME">T</span><span class="PUNC">==</span><span class="STRN">'string'</span><span class="PUNC">?</span><span class="NAME">e</span><span class="PUNC">:</span><span class="STRN">'('</span><span class="PUNC">+</span><span class="NAME">T</span><span class="PUNC">+</span><span class="STRN">')'</span><span class="PUNC">+</span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3922</span>
<span class='line'>3923</span> </span><span class="WHIT"> </span><span class="NAME">this.log</span><span class="PUNC">(</span><span class="NAME">this.error_prefix</span><span class="PUNC">+</span><span class="NAME">m</span><span class="PUNC">,</span><span class="NAME">clean</span><span class="PUNC">,</span><span class="STRN">'err'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3924</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3925</span>
<span class='line'>3926</span>
<span class='line'>3927</span> </span><span class="COMM">/**
<span class='line'>3928</span> * 設定寫入到哪&lt;br/>set log board for each instance (document object)
<span class='line'>3929</span> * @name CeL.code.log.prototype.set_board
<span class='line'>3930</span> */</span><span class="WHIT">
<span class='line'>3931</span> </span><span class="NAME">set_board</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3932</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">this.id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3933</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3934</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">o</span><span class="PUNC">===</span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3935</span> </span><span class="WHIT"> </span><span class="NAME">_p.do_function</span><span class="PUNC">=</span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3936</span>
<span class='line'>3937</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="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">!==</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3938</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">=</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">===</span><span class="STRN">'object'</span><span class="PUNC">?</span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3939</span> </span><span class="WHIT"> </span><span class="NAME">_p.board</span><span class="PUNC">=</span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3940</span>
<span class='line'>3941</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_p.board</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3942</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3943</span>
<span class='line'>3944</span> </span><span class="COMM">/**
<span class='line'>3945</span> * 獲取當前 buffer 中的 log
<span class='line'>3946</span> * @name CeL.code.log.prototype.get_log
<span class='line'>3947</span> */</span><span class="WHIT">
<span class='line'>3948</span> </span><span class="NAME">get_log</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3949</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">this.id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">lbuf</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3950</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3951</span>
<span class='line'>3952</span> </span><span class="COMM">/**
<span class='line'>3953</span> * show/hide log board
<span class='line'>3954</span> * @name CeL.code.log.prototype.trigger
<span class='line'>3955</span> */</span><span class="WHIT">
<span class='line'>3956</span> </span><span class="NAME">trigger</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3957</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_s</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">this.id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">board.style</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3958</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">s</span><span class="PUNC">===</span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>3959</span> </span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">=</span><span class="NAME">_s.display</span><span class="PUNC">==</span><span class="STRN">'none'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3960</span> </span><span class="WHIT"> </span><span class="NAME">_s.display</span><span class="PUNC">=</span><span class="NAME">s</span><span class="PUNC">?</span><span class="STRN">'block'</span><span class="PUNC">:</span><span class="STRN">'none'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3961</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3962</span>
<span class='line'>3963</span> </span><span class="COMM">/**
<span class='line'>3964</span> * clear log board
<span class='line'>3965</span> * @name CeL.code.log.prototype.clear_board
<span class='line'>3966</span> */</span><span class="WHIT">
<span class='line'>3967</span> </span><span class="NAME">clear_board</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3968</span> </span><span class="WHIT"> </span><span class="NAME">b.innerHTML</span><span class="PUNC">=</span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3969</span> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3970</span>
<span class='line'>3971</span> </span><span class="COMM">/**
<span class='line'>3972</span> * 清除全部訊息 clear message
<span class='line'>3973</span> * @name CeL.code.log.prototype.clear
<span class='line'>3974</span> */</span><span class="WHIT">
<span class='line'>3975</span> </span><span class="NAME">clear</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3976</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_p</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">this.id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3977</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">_p.board</span><span class="PUNC">)</span><span class="NAME">this.clear_board</span><span class="PUNC">(</span><span class="NAME">_p.board</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3978</span> </span><span class="WHIT"> </span><span class="NAME">_p.lbuf</span><span class="PUNC">=</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3979</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3980</span>
<span class='line'>3981</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3982</span>
<span class='line'>3983</span>
<span class='line'>3984</span> </span><span class="COMM">/**
<span class='line'>3985</span> * 不 extend 的 member
<span class='line'>3986</span> * @ignore
<span class='line'>3987</span> */</span><span class="WHIT">
<span class='line'>3988</span> </span><span class="NAME">CeL.code.log</span><span class="WHIT">
<span class='line'>3989</span> </span><span class="PUNC">.</span><span class="NAME">no_extend</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 class='line'>3990</span>
<span class='line'>3991</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>3992</span> </span><span class="WHIT"> </span><span class="NAME">CeL.code.log</span><span class="WHIT">
<span class='line'>3993</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3994</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3995</span>
<span class='line'>3996</span> </span><span class="COMM">// ===================================================</span><span class="WHIT">
<span class='line'>3997</span>
<span class='line'>3998</span> </span><span class="COMM">/**
<span class='line'>3999</span> * modele namespace
<span class='line'>4000</span> * @type CeL.code.log
<span class='line'>4001</span> * @inner
<span class='line'>4002</span> * @ignore
<span class='line'>4003</span> */</span><span class="WHIT">
<span class='line'>4004</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CeL.setup_module</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>4005</span>
<span class='line'>4006</span> </span><span class="COMM">//WScript.Echo(n.extend);</span><span class="WHIT">
<span class='line'>4007</span>
<span class='line'>4008</span> </span><span class="COMM">//code_for_including[generateCode.dLK]='*var Debug={log:code_for_including()};';</span><span class="WHIT">
<span class='line'>4009</span>
<span class='line'>4010</span>
<span class='line'>4011</span> </span><span class="COMM">// 為本 library 用</span><span class="WHIT">
<span class='line'>4012</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">CeL.Log</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>4013</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ns.extend</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>4014</span>
<span class='line'>4015</span> </span><span class="WHIT"> </span><span class="COMM">// override CeL.log</span><span class="WHIT">
<span class='line'>4016</span> </span><span class="WHIT"> </span><span class="NAME">CeL.Log</span><span class="PUNC">=</span><span class="NAME">o</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>4017</span>
<span class='line'>4018</span> </span><span class="WHIT"> </span><span class="NAME">CeL.log</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>4019</span> </span><span class="WHIT"> </span><span class="NAME">CeL.warn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>4020</span> </span><span class="WHIT"> </span><span class="NAME">CeL.err</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>4021</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>4022</span>
<span class='line'>4023</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>4024</span>
<span class='line'>4025</span> </span></pre></body></html>