Added error callback parameter to ajax methods

This commit is contained in:
Timothy Warren 2012-04-19 08:16:04 -04:00
parent 3ed6b229f6
commit 1dad460368
16 changed files with 256 additions and 191 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -21,17 +21,17 @@
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 15</span>
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ajax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">_do</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</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">isPost</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="NAME">_do</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="NAME">request</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'> 21</span>
<span class='line'> 22</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">"undefined"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 22</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">success_callback</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'> 23</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 25</span> * @private
<span class='line'> 26</span> */</span><span class="WHIT">
<span class='line'> 27</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="KEYW">function</span><span class="WHIT"> </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'> 27</span> </span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </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'> 28</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 29</span>
<span class='line'> 30</span> </span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isPost</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"GET"</span><span class="PUNC">;</span><span class="WHIT">
@ -44,100 +44,113 @@
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.readyState</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'> 39</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">request.responseText</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span>
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="NAME">request.setRequestHeader</span><span class="PUNC">(</span><span class="STRN">"Content-Type"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"application/x-www-form-urlencoded"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="NAME">request.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'> 52</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="NAME">_serialize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="NAME">pairs</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'> 59</span>
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">200</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="NAME">success_callback.call</span><span class="PUNC">(</span><span class="NAME">request.responseText</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.responseText</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 46</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">error_callback</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'> 47</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT"> </span><span class="NAME">error_callback.call</span><span class="PUNC">(</span><span class="NAME">request.status</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">request.status</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">
<span class='line'> 52</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span>
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"POST"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="NAME">request.setRequestHeader</span><span class="PUNC">(</span><span class="STRN">"Content-Type"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"application/x-www-form-urlencoded"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="NAME">request.send</span><span class="PUNC">(</span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</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">data.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </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="NAME">name</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'> 67</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="NAME">request.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'> 63</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">_serialize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="NAME">pairs</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'> 70</span>
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span>
<span class='line'> 73</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">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span>
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="NAME">pairs.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 78</span>
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pairs.join</span><span class="PUNC">(</span><span class="STRN">"&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span>
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 84</span> * Sends a GET type ajax request
<span class='line'> 85</span> *
<span class='line'> 86</span> * @name get
<span class='line'> 87</span> * @function
<span class='line'> 88</span> * @memberOf $_
<span class='line'> 89</span> * @param string url
<span class='line'> 90</span> * @param object data
<span class='line'> 91</span> * @param function callback
<span class='line'> 92</span> */</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'get'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</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'> 95</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span>
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 98</span> * Sends a POST type ajax request
<span class='line'> 99</span> *
<span class='line'>100</span> * @name post
<span class='line'>101</span> * @function
<span class='line'>102</span> * @memberOf $_
<span class='line'>103</span> * @param string url
<span class='line'>104</span> * @param object data
<span class='line'>105</span> * @param function callback
<span class='line'>106</span> */</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'post'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</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'>109</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">
<span class='line'>111</span> </span><span class="COMM">/**
<span class='line'>112</span> * Watches for server-sent events and applies a callback on message
<span class='line'>113</span> *
<span class='line'>114</span> * @name sse
<span class='line'>115</span> * @function
<span class='line'>116</span> * @memberOf $_
<span class='line'>117</span> * @param string url
<span class='line'>118</span> * @param function callback
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 77</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">data</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="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 81</span>
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span>
<span class='line'> 84</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">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span>
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="NAME">pairs.push</span><span class="PUNC">(</span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 89</span>
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pairs.join</span><span class="PUNC">(</span><span class="STRN">"&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span>
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'> 95</span> * Sends a GET type ajax request
<span class='line'> 96</span> *
<span class='line'> 97</span> * @name get
<span class='line'> 98</span> * @function
<span class='line'> 99</span> * @memberOf $_
<span class='line'>100</span> * @param string url
<span class='line'>101</span> * @param object data
<span class='line'>102</span> * @param function success_callback
<span class='line'>103</span> * @param function error_callback
<span class='line'>104</span> */</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'get'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</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'>107</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span>
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>110</span> * Sends a POST type ajax request
<span class='line'>111</span> *
<span class='line'>112</span> * @name post
<span class='line'>113</span> * @function
<span class='line'>114</span> * @memberOf $_
<span class='line'>115</span> * @param string url
<span class='line'>116</span> * @param object data
<span class='line'>117</span> * @param function success_callback
<span class='line'>118</span> * @param function error_callback
<span class='line'>119</span> */</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'sse'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">url</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">poll_rate</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">
<span class='line'>122</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">
<span class='line'>124</span> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>125</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">EventSource</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'>126</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT"> </span><span class="NAME">source</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">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">
<span class='line'>129</span> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="NAME">source.onmessage</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">event</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">event.data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event.data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">
<span class='line'>136</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'post'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="NAME">ajax._do</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">success_callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error_callback</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'>122</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">
<span class='line'>124</span> </span><span class="COMM">/**
<span class='line'>125</span> * Watches for server-sent events and applies a callback on message
<span class='line'>126</span> *
<span class='line'>127</span> * @name sse
<span class='line'>128</span> * @function
<span class='line'>129</span> * @memberOf $_
<span class='line'>130</span> * @param string url
<span class='line'>131</span> * @param function callback
<span class='line'>132</span> */</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="NAME">$_.ext</span><span class="PUNC">(</span><span class="STRN">'sse'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">url</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">poll_rate</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">
<span class='line'>135</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">source</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">
<span class='line'>137</span> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>138</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">EventSource</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'>139</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="NAME">source</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">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">
<span class='line'>142</span> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="NAME">source.onmessage</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">event</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">event.data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event.data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">
<span class='line'>149</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>

View File

@ -844,17 +844,17 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
}
var ajax = {
_do: function (url, data, callback, isPost)
_do: function (url, data, success_callback, error_callback, isPost)
{
var type,
request = new XMLHttpRequest();
if (typeof callback === "undefined")
if (typeof success_callback === "undefined")
{
/**
* @private
*/
callback = function (){};
success_callback = function (){};
}
type = (isPost) ? "POST" : "GET";
@ -867,7 +867,18 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
{
if (request.readyState === 4)
{
callback(request.responseText);
if (request.status === 200)
{
success_callback.call(request.responseText, request.responseText);
}
else
{
if (typeof error_callback !== 'undefined')
{
error_callback.call(request.status, request.status);
}
}
}
};
@ -918,10 +929,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
* @memberOf $_
* @param string url
* @param object data
* @param function callback
* @param function success_callback
* @param function error_callback
*/
$_.ext('get', function (url, data, callback){
ajax._do(url, data, callback, false);
$_.ext('get', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, false);
});
/**
@ -932,10 +944,11 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
* @memberOf $_
* @param string url
* @param object data
* @param function callback
* @param function success_callback
* @param function error_callback
*/
$_.ext('post', function (url, data, callback){
ajax._do(url, data, callback, true);
$_.ext('post', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, true);
});
/**

34
kis-lite-dom-min.js vendored
View File

@ -1,17 +1,17 @@
(function(){if("undefined"!==typeof document.querySelector){var c,f,e,a;c=function(b){a="undefined"===typeof b?"undefined"!==typeof c.el?c.el:document.documentElement:"object"!==typeof b?f(b):b;c.prototype.el=a;var b=e(c),d;for(d in b)"object"===typeof b[d]&&(b[d].el=a);b.el=a;return b};f=function(b,d){var a;if("string"!=typeof b||"undefined"===typeof b)return b;a=null!=d&&1===d.nodeType?d:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);a=a.querySelectorAll(b);
return 1===a.length?a[0]:a};e=function(b){var d;if("undefined"!==typeof b){if("undefined"!==typeof Object.create)return Object.create(b);d=typeof b;if(!("object"!==d&&"function"!==d))return d=function(){},d.prototype=b,new d}};c.ext=function(b,d){d.el=a;c[b]=d};c.ext("each",function(b){if("undefined"!==typeof a.length&&a!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(a,b);else{var d=a.length;if(0!==d)for(var h,g=0;g<d;g++)h=a.item(g)?a.item(g):a[g],b.call(h,h)}else b.call(a,
a)});c.type=function(b){return function(){return b&&b!==this}.call(b)?(typeof b).toLowerCase():{}.toString.call(b).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};c=window.$_=window.$_||c;c.$=f}})();"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true});"undefined"===typeof Array.isArray&&(Array.isArray=function(c){return Object.prototype.toString.apply(c)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var c={_do:function(c,e,a,b){var d=new XMLHttpRequest;typeof a==="undefined"&&(a=function(){});b=b?"POST":"GET";c=c+(b==="GET"?"?"+this._serialize(e):"");d.open(b,c);d.onreadystatechange=function(){d.readyState===4&&a(d.responseText)};if(b==="POST"){d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.send(this._serialize(e))}else d.send(null)},_serialize:function(c){var e,a,b=[];for(e in c)if(c.hasOwnProperty(e)&&typeof c[e]!==
"function"){a=c[e].toString();e=encodeURIComponent(e);a=encodeURIComponent(a);b.push(e+"="+a)}return b.join("&")}};$_.ext("get",function(f,e,a){c._do(f,e,a,false)});$_.ext("post",function(f,e,a){c._do(f,e,a,true)});$_.ext("sse",function(c,e){var a;if(typeof EventSource!=="undefined"){a=new EventSource(c);a.onmessage=function(b){e.call(b.data,b.data)}}})}})();
(function(){var c,f,e,a;if(typeof document.addEventListener!=="undefined"){c=function(b,d,a){typeof b.addEventListener!=="undefined"&&b.addEventListener(d,a,false)};f=function(b,d,a){typeof b.removeEventListener!=="undefined"&&b.removeEventListener(d,a,false)}}else if(typeof document.attachEvent!=="undefined"){c=function(b,a,h){function c(b){h.apply(b)}if(typeof b.attachEvent!=="undefined"){f(a,h);b.attachEvent("on"+a,c);b=b.KIS_0_6_0=b.KIS_0_6_0||{};b.listeners=b.listeners||{};b.listeners[a]=b.listeners[a]||
[];b.listeners[a].push({callback:h,_listener:c})}else console.log("Failed to _attach event:"+a+" on "+b)};f=function(b,a,h){if(typeof b.detachEvent!=="undefined"){var c=b.KIS_0_6_0;if(c&&c.listeners&&c.listeners[a])for(var e=c.listeners[a],f=e.length,i=0;i<f;i++)if(e[i].callback===h){b.detachEvent("on"+a,e[i]._listener);e.splice(i,1);e.length===0&&delete c.listeners[a];break}}}}e=function(b,a,h,g){var j,k;if(typeof b==="undefined"){console.log(arguments);console.log(a);return false}if(a.match(/^([\w\-]+)$/))g===
true?c(b,a,h):f(b,a,h);else{a=a.split(" ");k=a.length;for(j=0;j<k;j++)e(b,a[j],h,g)}};a=function(b,a,c,g){e(b,c,function(c){var h,i,e,c=c||window.event;i=$_.$(a,b);for(h in i){e=c.target||c.srcElement;if(e==i[h]){g.call(i[h],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(b,a){$_.each(function(c){e(c,b,a,true)})},remove:function(b,a){$_.each(function(c){e(c,b,a,false)})},live:function(b,d,c){a(document.documentElement,b,d,c)},delegate:function(b,d,c){$_.each(function(e){a(e,b,d,c)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(c){var c=(c.HTMLElement||c.Element).prototype,f=Object,e=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array.prototype.indexOf||function(b){for(var a=0,d=this.length;a<d;a++)if(a in this&&this[a]===b)return a;return-1},b=function(b,a){this.name=b;this.code=DOMException[b];this.message=a},d=function(d,c){if(c==="")throw new b("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(c))throw new b("INVALID_CHARACTER_ERR",
"String contains an invalid character");return a.call(d,c)},h=function(b){for(var a=e.call(b.className),a=a?a.split(/\s+/):[],d=0,c=a.length;d<c;d++)this.push(a[d]);this._updateClassName=function(){b.className=this.toString()}},g=h.prototype=[],j=function(){return new h(this)};b.prototype=Error.prototype;g.item=function(a){return this[a]||null};g.contains=function(a){return d(this,a+"")!==-1};g.add=function(a){a=a+"";if(d(this,a)===-1){this.push(a);this._updateClassName()}};g.remove=function(a){a=
d(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};g.toggle=function(a){a=a+"";d(this,a)===-1?this.add(a):this.remove(a)};g.toString=function(){return this.join(" ")};if(f.defineProperty){g={get:j,enumerable:true,configurable:true};try{f.defineProperty(c,"classList",g)}catch(k){if(k.number===-2146823252){g.enumerable=false;f.defineProperty(c,"classList",g)}}}else f.prototype.__defineGetter__&&c.__defineGetter__("classList",j)}(self);
(function(){function c(a,b,d){var c,e;if(typeof a.hasAttribute!=="undefined"){a.hasAttribute(b)&&(c=a.getAttribute(b));e=true}else if(typeof a[b]!=="undefined"){c=a[b];e=false}else if(b==="class"&&typeof a.className!=="undefined"){b="className";c=a.className;e=false}if(typeof c==="undefined"&&(typeof d==="undefined"||d===null)){console.log(d);console.log(a);console.log("Element does not have the selected attribute");return null}if(typeof d==="undefined")return c;typeof d!=="undefined"&&d!==null?e===
true?a.setAttribute(b,d):a[b]=d:d===null&&(e===true?a.removeAttribute(b):delete a[b]);return typeof d!=="undefined"?d:c}function f(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function e(a,b,c){var e,b=f(b);e={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof c==="undefined"&&a.style[b]!=="undefined")return a.style[b];if(typeof c==="undefined"&&a.style[e[b]]!=="undefined")return a.style[e[b]];if(typeof a.style[b]!=="undefined"){a.style[b]=
c;return null}if(a.style[e[b]]){a.style[e[b]]=c;return null}console.log("Property "+b+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(a){$_.each(function(b){b.classList.add(a)})},removeClass:function(a){$_.each(function(b){b.classList.remove(a)})},hide:function(){this.css("display","none")},show:function(a){typeof a==="undefined"&&(a="block");this.css("display",a)},attr:function(a,b){var d=this.el;if(d.length>1&&typeof b==="undefined"){console.log(d);console.log("Must be a singular element")}else if(d.length>
1&&typeof b!=="undefined")$_.each(function(d){return c(d,a,b)});else return c(d,a,b)},text:function(a){var b,c,e;e=this.el;c=typeof e.textContent!=="undefined"?"textContent":typeof e.innerText!=="undefined"?"innerText":"innerHTML";b=e[c];if(typeof a!=="undefined")return e[c]=a;return b},css:function(a,b){if(typeof b==="undefined")return e(this.el,a);$_.each(function(c){e(c,a,b)})},append:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML=
this.el.innerHTML+a},prepend:function(a){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){if(typeof a!=="undefined")this.el.innerHTML=a;return this.el.innerHTML}})})();
(function(){if("undefined"!==typeof document.querySelector){var e,g,f,b;e=function(a){b="undefined"===typeof a?"undefined"!==typeof e.el?e.el:document.documentElement:"object"!==typeof a?g(a):a;e.prototype.el=b;var a=f(e),d;for(d in a)"object"===typeof a[d]&&(a[d].el=b);a.el=b;return a};g=function(a,d){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=d&&1===d.nodeType?d:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
return 1===b.length?b[0]:b};f=function(a){var d;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);d=typeof a;if(!("object"!==d&&"function"!==d))return d=function(){},d.prototype=a,new d}};e.ext=function(a,d){d.el=b;e[a]=d};e.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{var d=b.length;if(0!==d)for(var c,h=0;h<d;h++)c=b.item(h)?b.item(h):b[h],a.call(c,c)}else a.call(b,
b)});e.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};e=window.$_=window.$_||e;e.$=g}})();"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true});"undefined"===typeof Array.isArray&&(Array.isArray=function(e){return Object.prototype.toString.apply(e)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var e={_do:function(e,f,b,a,d){var c=new XMLHttpRequest;typeof b==="undefined"&&(b=function(){});d=d?"POST":"GET";e=e+(d==="GET"?"?"+this._serialize(f):"");c.open(d,e);c.onreadystatechange=function(){c.readyState===4&&(c.status===200?b.call(c.responseText,c.responseText):typeof a!=="undefined"&&a.call(c.status,c.status))};if(d==="POST"){c.setRequestHeader("Content-Type","application/x-www-form-urlencoded");c.send(this._serialize(f))}else c.send(null)},
_serialize:function(e){var f,b,a=[];for(f in e)if(e.hasOwnProperty(f)&&typeof e[f]!=="function"){b=e[f].toString();f=encodeURIComponent(f);b=encodeURIComponent(b);a.push(f+"="+b)}return a.join("&")}};$_.ext("get",function(g,f,b,a){e._do(g,f,b,a,false)});$_.ext("post",function(g,f,b,a){e._do(g,f,b,a,true)});$_.ext("sse",function(e,f){var b;if(typeof EventSource!=="undefined"){b=new EventSource(e);b.onmessage=function(a){f.call(a.data,a.data)}}})}})();
(function(){var e,g,f,b;if(typeof document.addEventListener!=="undefined"){e=function(a,d,b){typeof a.addEventListener!=="undefined"&&a.addEventListener(d,b,false)};g=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}}else if(typeof document.attachEvent!=="undefined"){e=function(a,b,c){function e(a){c.apply(a)}if(typeof a.attachEvent!=="undefined"){g(b,c);a.attachEvent("on"+b,e);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[b]=a.listeners[b]||
[];a.listeners[b].push({callback:c,_listener:e})}else console.log("Failed to _attach event:"+b+" on "+a)};g=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var e=a.KIS_0_6_0;if(e&&e.listeners&&e.listeners[b])for(var f=e.listeners[b],g=f.length,i=0;i<g;i++)if(f[i].callback===c){a.detachEvent("on"+b,f[i]._listener);f.splice(i,1);f.length===0&&delete e.listeners[b];break}}}}f=function(a,b,c,h){var j,k;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))h===
true?e(a,b,c):g(a,b,c);else{b=b.split(" ");k=b.length;for(j=0;j<k;j++)f(a,b[j],c,h)}};b=function(a,b,c,e){f(a,c,function(c){var f,i,g,c=c||window.event;i=$_.$(b,a);for(f in i){g=c.target||c.srcElement;if(g==i[f]){e.call(i[f],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(c){f(c,a,b,true)})},remove:function(a,b){$_.each(function(c){f(c,a,b,false)})},live:function(a,d,c){b(document.documentElement,a,d,c)},delegate:function(a,d,c){$_.each(function(e){b(e,a,d,c)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(e){var e=(e.HTMLElement||e.Element).prototype,g=Object,f=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},a=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},d=function(c,d){if(d==="")throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new a("INVALID_CHARACTER_ERR",
"String contains an invalid character");return b.call(c,d)},c=function(a){for(var b=f.call(a.className),b=b?b.split(/\s+/):[],c=0,d=b.length;c<d;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},h=c.prototype=[],j=function(){return new c(this)};a.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){return d(this,a+"")!==-1};h.add=function(a){a=a+"";if(d(this,a)===-1){this.push(a);this._updateClassName()}};h.remove=function(a){a=
d(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};h.toggle=function(a){a=a+"";d(this,a)===-1?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(g.defineProperty){h={get:j,enumerable:true,configurable:true};try{g.defineProperty(e,"classList",h)}catch(k){if(k.number===-2146823252){h.enumerable=false;g.defineProperty(e,"classList",h)}}}else g.prototype.__defineGetter__&&e.__defineGetter__("classList",j)}(self);
(function(){function e(b,a,d){var c,e;if(typeof b.hasAttribute!=="undefined"){b.hasAttribute(a)&&(c=b.getAttribute(a));e=true}else if(typeof b[a]!=="undefined"){c=b[a];e=false}else if(a==="class"&&typeof b.className!=="undefined"){a="className";c=b.className;e=false}if(typeof c==="undefined"&&(typeof d==="undefined"||d===null)){console.log(d);console.log(b);console.log("Element does not have the selected attribute");return null}if(typeof d==="undefined")return c;typeof d!=="undefined"&&d!==null?e===
true?b.setAttribute(a,d):b[a]=d:d===null&&(e===true?b.removeAttribute(a):delete b[a]);return typeof d!=="undefined"?d:c}function g(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function f(b,a,d){var c,a=g(a);c={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof d==="undefined"&&b.style[a]!=="undefined")return b.style[a];if(typeof d==="undefined"&&b.style[c[a]]!=="undefined")return b.style[c[a]];if(typeof b.style[a]!=="undefined"){b.style[a]=
d;return null}if(b.style[c[a]]){b.style[c[a]]=d;return null}console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(b){$_.each(function(a){a.classList.add(b)})},removeClass:function(b){$_.each(function(a){a.classList.remove(b)})},hide:function(){this.css("display","none")},show:function(b){typeof b==="undefined"&&(b="block");this.css("display",b)},attr:function(b,a){var d=this.el;if(d.length>1&&typeof a==="undefined"){console.log(d);console.log("Must be a singular element")}else if(d.length>
1&&typeof a!=="undefined")$_.each(function(c){return e(c,b,a)});else return e(d,b,a)},text:function(b){var a,d,c;c=this.el;d=typeof c.textContent!=="undefined"?"textContent":typeof c.innerText!=="undefined"?"innerText":"innerHTML";a=c[d];if(typeof b!=="undefined")return c[d]=b;return a},css:function(b,a){if(typeof a==="undefined")return f(this.el,b);$_.each(function(d){f(d,b,a)})},append:function(b){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",b):this.el.innerHTML=
this.el.innerHTML+b},prepend:function(b){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){if(typeof b!=="undefined")this.el.innerHTML=b;return this.el.innerHTML}})})();

View File

@ -297,17 +297,17 @@ if (typeof Array.isArray === "undefined")
}
var ajax = {
_do: function (url, data, callback, isPost)
_do: function (url, data, success_callback, error_callback, isPost)
{
var type,
request = new XMLHttpRequest();
if (typeof callback === "undefined")
if (typeof success_callback === "undefined")
{
/**
* @private
*/
callback = function (){};
success_callback = function (){};
}
type = (isPost) ? "POST" : "GET";
@ -320,7 +320,18 @@ if (typeof Array.isArray === "undefined")
{
if (request.readyState === 4)
{
callback(request.responseText);
if (request.status === 200)
{
success_callback.call(request.responseText, request.responseText);
}
else
{
if (typeof error_callback !== 'undefined')
{
error_callback.call(request.status, request.status);
}
}
}
};
@ -371,10 +382,11 @@ if (typeof Array.isArray === "undefined")
* @memberOf $_
* @param string url
* @param object data
* @param function callback
* @param function success_callback
* @param function error_callback
*/
$_.ext('get', function (url, data, callback){
ajax._do(url, data, callback, false);
$_.ext('get', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, false);
});
/**
@ -385,10 +397,11 @@ if (typeof Array.isArray === "undefined")
* @memberOf $_
* @param string url
* @param object data
* @param function callback
* @param function success_callback
* @param function error_callback
*/
$_.ext('post', function (url, data, callback){
ajax._do(url, data, callback, true);
$_.ext('post', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, true);
});
/**

16
kis-lite-min.js vendored
View File

@ -1,9 +1,9 @@
(function(){if("undefined"!==typeof document.querySelector){var f,e,d,b;f=function(a){b="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?e(a):a;f.prototype.el=b;var a=d(f),c;for(c in a)"object"===typeof a[c]&&(a[c].el=b);a.el=b;return a};e=function(a,c){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
return 1===b.length?b[0]:b};d=function(a){var c;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);c=typeof a;if(!("object"!==c&&"function"!==c))return c=function(){},c.prototype=a,new c}};f.ext=function(a,c){c.el=b;f[a]=c};f.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{var c=b.length;if(0!==c)for(var g,d=0;d<c;d++)g=b.item(d)?b.item(d):b[d],a.call(g,g)}else a.call(b,
b)});f.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=e}})();"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
(function(){if("undefined"!==typeof document.querySelector){var f,g,d,c;f=function(a){c="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?g(a):a;f.prototype.el=c;var a=d(f),b;for(b in a)"object"===typeof a[b]&&(a[b].el=c);a.el=c;return a};g=function(a,b){var e;if("string"!=typeof a||"undefined"===typeof a)return a;e=null!=b&&1===b.nodeType?b:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);e=e.querySelectorAll(a);
return 1===e.length?e[0]:e};d=function(a){var b;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);b=typeof a;if(!("object"!==b&&"function"!==b))return b=function(){},b.prototype=a,new b}};f.ext=function(a,b){b.el=c;f[a]=b};f.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(c,a);else{var b=c.length;if(0!==b)for(var e,d=0;d<b;d++)e=c.item(d)?c.item(d):c[d],a.call(e,e)}else a.call(c,
c)});f.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=g}})();"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true});"undefined"===typeof Array.isArray&&(Array.isArray=function(f){return Object.prototype.toString.apply(f)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var f={_do:function(e,d,b,a){var c=new XMLHttpRequest;typeof b==="undefined"&&(b=function(){});a=a?"POST":"GET";e=e+(a==="GET"?"?"+this._serialize(d):"");c.open(a,e);c.onreadystatechange=function(){c.readyState===4&&b(c.responseText)};if(a==="POST"){c.setRequestHeader("Content-Type","application/x-www-form-urlencoded");c.send(this._serialize(d))}else c.send(null)},_serialize:function(e){var d,b,a=[];for(d in e)if(e.hasOwnProperty(d)&&typeof e[d]!==
"function"){b=e[d].toString();d=encodeURIComponent(d);b=encodeURIComponent(b);a.push(d+"="+b)}return a.join("&")}};$_.ext("get",function(e,d,b){f._do(e,d,b,false)});$_.ext("post",function(e,d,b){f._do(e,d,b,true)});$_.ext("sse",function(e,d){var b;if(typeof EventSource!=="undefined"){b=new EventSource(e);b.onmessage=function(a){d.call(a.data,a.data)}}})}})();
(function(){var f,e,d,b;if(typeof document.addEventListener!=="undefined"){f=function(a,c,b){typeof a.addEventListener!=="undefined"&&a.addEventListener(c,b,false)};e=function(a,c,b){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(c,b,false)}}else if(typeof document.attachEvent!=="undefined"){f=function(a,c,b){function d(a){b.apply(a)}if(typeof a.attachEvent!=="undefined"){e(c,b);a.attachEvent("on"+c,d);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[c]=a.listeners[c]||
[];a.listeners[c].push({callback:b,_listener:d})}else console.log("Failed to _attach event:"+c+" on "+a)};e=function(a,c,b){if(typeof a.detachEvent!=="undefined"){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[c])for(var e=d.listeners[c],f=e.length,h=0;h<f;h++)if(e[h].callback===b){a.detachEvent("on"+c,e[h]._listener);e.splice(h,1);e.length===0&&delete d.listeners[c];break}}}}d=function(a,c,b,j){var i,k;if(typeof a==="undefined"){console.log(arguments);console.log(c);return false}if(c.match(/^([\w\-]+)$/))j===
true?f(a,c,b):e(a,c,b);else{c=c.split(" ");k=c.length;for(i=0;i<k;i++)d(a,c[i],b,j)}};b=function(a,c,b,e){d(a,b,function(b){var d,f,g,b=b||window.event;f=$_.$(c,a);for(d in f){g=b.target||b.srcElement;if(g==f[d]){e.call(f[d],b);b.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(e){d(e,a,b,true)})},remove:function(a,b){$_.each(function(e){d(e,a,b,false)})},live:function(a,c,d){b(document.documentElement,a,c,d)},delegate:function(a,c,d){$_.each(function(e){b(e,a,c,d)})}})})();
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var f={_do:function(g,d,c,a,b){var e=new XMLHttpRequest;typeof c==="undefined"&&(c=function(){});b=b?"POST":"GET";g=g+(b==="GET"?"?"+this._serialize(d):"");e.open(b,g);e.onreadystatechange=function(){e.readyState===4&&(e.status===200?c.call(e.responseText,e.responseText):typeof a!=="undefined"&&a.call(e.status,e.status))};if(b==="POST"){e.setRequestHeader("Content-Type","application/x-www-form-urlencoded");e.send(this._serialize(d))}else e.send(null)},
_serialize:function(g){var d,c,a=[];for(d in g)if(g.hasOwnProperty(d)&&typeof g[d]!=="function"){c=g[d].toString();d=encodeURIComponent(d);c=encodeURIComponent(c);a.push(d+"="+c)}return a.join("&")}};$_.ext("get",function(g,d,c,a){f._do(g,d,c,a,false)});$_.ext("post",function(g,d,c,a){f._do(g,d,c,a,true)});$_.ext("sse",function(g,d){var c;if(typeof EventSource!=="undefined"){c=new EventSource(g);c.onmessage=function(a){d.call(a.data,a.data)}}})}})();
(function(){var f,g,d,c;if(typeof document.addEventListener!=="undefined"){f=function(a,b,e){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,e,false)};g=function(a,b,e){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,e,false)}}else if(typeof document.attachEvent!=="undefined"){f=function(a,b,e){function c(a){e.apply(a)}if(typeof a.attachEvent!=="undefined"){g(b,e);a.attachEvent("on"+b,c);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[b]=a.listeners[b]||
[];a.listeners[b].push({callback:e,_listener:c})}else console.log("Failed to _attach event:"+b+" on "+a)};g=function(a,b,e){if(typeof a.detachEvent!=="undefined"){var c=a.KIS_0_6_0;if(c&&c.listeners&&c.listeners[b])for(var d=c.listeners[b],g=d.length,f=0;f<g;f++)if(d[f].callback===e){a.detachEvent("on"+b,d[f]._listener);d.splice(f,1);d.length===0&&delete c.listeners[b];break}}}}d=function(a,b,e,c){var h,i;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))c===
true?f(a,b,e):g(a,b,e);else{b=b.split(" ");i=b.length;for(h=0;h<i;h++)d(a,b[h],e,c)}};c=function(a,b,c,f){d(a,c,function(c){var e,d,g,c=c||window.event;d=$_.$(b,a);for(e in d){g=c.target||c.srcElement;if(g==d[e]){f.call(d[e],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(c){d(c,a,b,true)})},remove:function(a,b){$_.each(function(c){d(c,a,b,false)})},live:function(a,b,e){c(document.documentElement,a,b,e)},delegate:function(a,b,e){$_.each(function(d){c(d,a,b,e)})}})})();

View File

@ -297,17 +297,17 @@ if (typeof Array.isArray === "undefined")
}
var ajax = {
_do: function (url, data, callback, isPost)
_do: function (url, data, success_callback, error_callback, isPost)
{
var type,
request = new XMLHttpRequest();
if (typeof callback === "undefined")
if (typeof success_callback === "undefined")
{
/**
* @private
*/
callback = function (){};
success_callback = function (){};
}
type = (isPost) ? "POST" : "GET";
@ -320,7 +320,18 @@ if (typeof Array.isArray === "undefined")
{
if (request.readyState === 4)
{
callback(request.responseText);
if (request.status === 200)
{
success_callback.call(request.responseText, request.responseText);
}
else
{
if (typeof error_callback !== 'undefined')
{
error_callback.call(request.status, request.status);
}
}
}
};
@ -371,10 +382,11 @@ if (typeof Array.isArray === "undefined")
* @memberOf $_
* @param string url
* @param object data
* @param function callback
* @param function success_callback
* @param function error_callback
*/
$_.ext('get', function (url, data, callback){
ajax._do(url, data, callback, false);
$_.ext('get', function (url, data, success_callback, error_callback){
ajax._do(url, data, success_callback, error_callback, false);
});
/**
@ -385,10 +397,11 @@ if (typeof Array.isArray === "undefined")
* @memberOf $_
* @param string url
* @param object data
* @param function callback
* @param function success_callback
* @param function error_callback