Added error callback parameter to ajax methods
This commit is contained in:
parent
3ed6b229f6
commit
1dad460368
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
@ -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>
|
33
kis-all.js
33
kis-all.js
@ -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
34
kis-lite-dom-min.js
vendored
@ -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}})})();
|
||||
|
@ -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
16
kis-lite-min.js
vendored
@ -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)})}})})();
|
||||
|
33
kis-lite.js
33
kis-lite.js
@ -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);
|
||||
});
|
||||
|
||||
/**
|
||||
|
42
kis-min.js
vendored
42
kis-min.js
vendored
@ -1,21 +1,21 @@
|
||||
(function(){if("undefined"!==typeof document.querySelector){var e,k,p,f;e=function(h){f="undefined"===typeof h?"undefined"!==typeof e.el?e.el:document.documentElement:"object"!==typeof h?k(h):h;e.prototype.el=f;var h=p(e),i;for(i in h)"object"===typeof h[i]&&(h[i].el=f);h.el=f;return h};k=function(h,e){var f;if("string"!=typeof h||"undefined"===typeof h)return h;f=null!=e&&1===e.nodeType?e:document;if(h.match(/^#([\w\-]+$)/))return document.getElementById(h.split("#")[1]);f=f.querySelectorAll(h);
|
||||
return 1===f.length?f[0]:f};p=function(e){var f;if("undefined"!==typeof e){if("undefined"!==typeof Object.create)return Object.create(e);f=typeof e;if(!("object"!==f&&"function"!==f))return f=function(){},f.prototype=e,new f}};e.ext=function(h,i){i.el=f;e[h]=i};e.ext("each",function(e){if("undefined"!==typeof f.length&&f!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(f,e);else{var i=f.length;if(0!==i)for(var l,j=0;j<i;j++)l=f.item(j)?f.item(j):f[j],e.call(l,l)}else e.call(f,
|
||||
f)});e.type=function(e){return function(){return e&&e!==this}.call(e)?(typeof e).toLowerCase():{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};e=window.$_=window.$_||e;e.$=k}})();"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(e){function k(a,b,c){var d,g;if(typeof a.hasAttribute!=="undefined"){a.hasAttribute(b)&&(d=a.getAttribute(b));g=true}else if(typeof a[b]!=="undefined"){d=a[b];g=false}else if(b==="class"&&typeof a.className!=="undefined"){b="className";d=a.className;g=false}if(typeof d==="undefined"&&(typeof c==="undefined"||c===null)){console.log(c);console.log(a);console.log("Element does not have the selected attribute");return null}if(typeof c==="undefined")return d;typeof c!=="undefined"&&c!==null?
|
||||
g===true?a.setAttribute(b,c):a[b]=c:c===null&&(g===true?a.removeAttribute(b):delete a[b]);return typeof c!=="undefined"?c:d}function p(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function f(a,b,c){var d,b=p(b);d={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof c==="undefined"&&a.style[b]!=="undefined")return a.style[b];if(typeof c==="undefined"&&a.style[d[b]]!=="undefined")return a.style[d[b]];if(typeof a.style[b]!=="undefined"){a.style[b]=
|
||||
c;return null}if(a.style[d[b]]){a.style[d[b]]=c;return null}console.log("Property "+b+" nor an equivalent seems to exist")}typeof document!=="undefined"&&!("classList"in document.createElement("a"))&&function(a){var a=(a.HTMLElement||a.Element).prototype,b=Object,c=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},d=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},g=function(a,b){this.name=a;this.code=DOMException[a];
|
||||
this.message=b},e=function(a,b){if(b==="")throw new g("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new g("INVALID_CHARACTER_ERR","String contains an invalid character");return d.call(a,b)},n=function(a){for(var b=c.call(a.className),b=b?b.split(/\s+/):[],d=0,g=b.length;d<g;d++)this.push(b[d]);this._updateClassName=function(){a.className=this.toString()}},f=n.prototype=[],h=function(){return new n(this)};g.prototype=Error.prototype;f.item=function(a){return this[a]||
|
||||
null};f.contains=function(a){return e(this,a+"")!==-1};f.add=function(a){a=a+"";if(e(this,a)===-1){this.push(a);this._updateClassName()}};f.remove=function(a){a=e(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};f.toggle=function(a){a=a+"";e(this,a)===-1?this.add(a):this.remove(a)};f.toString=function(){return this.join(" ")};if(b.defineProperty){f={get:h,enumerable:true,configurable:true};try{b.defineProperty(a,"classList",f)}catch(i){if(i.number===-2146823252){f.enumerable=false;
|
||||
b.defineProperty(a,"classList",f)}}}else b.prototype.__defineGetter__&&a.__defineGetter__("classList",h)}(self);e.ext("dom",{addClass:function(a){e.each(function(b){b.classList.add(a)})},removeClass:function(a){e.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 c=this.el;if(c.length>1&&typeof b==="undefined"){console.log(c);console.log("Must be a singular element")}else if(c.length>
|
||||
1&&typeof b!=="undefined")e.each(function(c){return k(c,a,b)});else return k(c,a,b)},text:function(a){var b,c,d;d=this.el;c=typeof d.textContent!=="undefined"?"textContent":typeof d.innerText!=="undefined"?"innerText":"innerHTML";b=d[c];if(typeof a!=="undefined")return d[c]=a;return b},css:function(a,b){if(typeof b==="undefined")return f(this.el,a);e.each(function(c){f(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}});if(typeof window.XMLHttpRequest!=="undefined"){var h={_do:function(a,b,c,d){var g=new XMLHttpRequest;typeof c==="undefined"&&(c=function(){});d=d?"POST":"GET";a=a+(d==="GET"?"?"+this._serialize(b):"");g.open(d,a);g.onreadystatechange=function(){g.readyState===
|
||||
4&&c(g.responseText)};if(d==="POST"){g.setRequestHeader("Content-Type","application/x-www-form-urlencoded");g.send(this._serialize(b))}else g.send(null)},_serialize:function(a){var b,c,d=[];for(b in a)if(a.hasOwnProperty(b)&&typeof a[b]!=="function"){c=a[b].toString();b=encodeURIComponent(b);c=encodeURIComponent(c);d.push(b+"="+c)}return d.join("&")}};e.ext("get",function(a,b,c){h._do(a,b,c,false)});e.ext("post",function(a,b,c){h._do(a,b,c,true)});e.ext("sse",function(a,b){var c;if(typeof EventSource!==
|
||||
"undefined"){c=new EventSource(a);c.onmessage=function(a){b.call(a.data,a.data)}}});var i,l,j,q;if(typeof document.addEventListener!=="undefined"){i=function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)};l=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}}else if(typeof document.attachEvent!=="undefined"){i=function(a,b,c){function d(a){c.apply(a)}if(typeof a.attachEvent!=="undefined"){l(b,c);a.attachEvent("on"+b,d);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:d})}else console.log("Failed to _attach event:"+b+" on "+a)};l=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[b])for(var g=d.listeners[b],e=g.length,f=0;f<e;f++)if(g[f].callback===c){a.detachEvent("on"+b,g[f]._listener);g.splice(f,1);g.length===0&&delete d.listeners[b];break}}}}j=function(a,b,c,d){var g,e;if(typeof a==="undefined"){console.log(arguments);
|
||||
console.log(b);return false}if(b.match(/^([\w\-]+)$/))d===true?i(a,b,c):l(a,b,c);else{b=b.split(" ");e=b.length;for(g=0;g<e;g++)j(a,b[g],c,d)}};q=function(a,b,c,d){j(a,c,function(c){var f,n,h,c=c||window.event;n=e.$(b,a);for(f in n){h=c.target||c.srcElement;if(h==n[f]){d.call(n[f],c);c.stopPropagation()}}},true)};e.ext("event",{add:function(a,b){e.each(function(c){j(c,a,b,true)})},remove:function(a,b){e.each(function(c){j(c,a,b,false)})},live:function(a,b,c){q(document.documentElement,a,b,c)},delegate:function(a,
|
||||
b,c){e.each(function(d){q(d,a,b,c)})}});if(typeof localStorage==="undefined"||typeof JSON==="undefined")return null;var m=localStorage,o=sessionStorage;e.ext("store",{get:function(a,b){var c=b?o.getItem(a):m.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?o.setItem(a,b):m.setItem(a,b)},remove:function(a,b){b?o.removeItem(a):m.removeItem(a)},getAll:function(a){var b,c={},d,g;g=a?m:o;b=g.length;for(a=0;a<b;a++){d=g.key(a);c[d]=g.getItem(d)}return c},clear:function(a){a?o.clear():
|
||||
m.clear()}});var s=function(a){var b=[],c=0,d={},g,b=r.object_keys(a);b.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),g=c+""===b,e=d+""===a;return g&&e?c>d?1:c<d?-1:0:g&&!e?1:!g&&e?-1:b>a?1:b<a?-1:0});c=b.length;for(g=0;g<c;g++)d[b[g]]=a[b[g]];return d},r={object_keys:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},object_values:function(a){var b=[],c;for(c in a)b.push(a[c]);return b},array_combine:function(a,b){var c={},d,g=0;e.type(a)!=="array"&&(a=this.object_values(a));
|
||||
e.type(b)!=="array"&&(b=this.object_values(b));d=a.length;if(d!==b.length){console.log("Object combine requires two arrays of the same size");return false}for(g=0;g<d;g++)c[a[g]]=b[g];return c},object_merge:function(){var a=Array.prototype.slice.call(arguments),b=a.length,c={},d,g=0,f,h,i;d=true;for(f=0;f<b;f++)if(e.type(a[f])!=="array"){d=false;break}if(d){c=[];for(f=0;f<b;f++)c=c.contact(a[f]);return c}for(i=f=0;f<b;f++){d=a[f];if(e.type(d)=="array"){h=0;for(g=d.length;h<g;h++)c[i++]=d[h]}else for(h in d)d.hasOwnProperty(h)&&
|
||||
(parseInt(h,10)+""===h?c[i++]=d[h]:c[h]=d[h])}return c},str_trans:function(a,b,c){var d=[],g=[],e=false,f=0,h=0,i="",j="",l="",k="",m;if(typeof b==="object"){b=s(b);for(m in b)if(b.hasOwnProperty(m)){d.push(m);g.push(b[m])}b=d;c=g}h=a.length;f=b.length;i=typeof c==="string";j=typeof b==="string";for(d=0;d<h;d++){e=false;if(j){a.charAt(d-1);l=a.charAt(d);a.charAt(d+1);for(g=0;g<f;g++)if(l==b.charAt(g)){e=true;break}}else for(g=0;g<f;g++)if(a.substr(d,b[g].length)==b[g]){e=true;d=d+b[g].length-1;break}k=
|
||||
e?k+(i?c.charAt(g):c[g]):k+a.charAt(d)}return k}};e.ext("util",r)}})($_);
|
||||
(function(){if("undefined"!==typeof document.querySelector){var d,o,p,e;d=function(g){e="undefined"===typeof g?"undefined"!==typeof d.el?d.el:document.documentElement:"object"!==typeof g?o(g):g;d.prototype.el=e;var g=p(d),i;for(i in g)"object"===typeof g[i]&&(g[i].el=e);g.el=e;return g};o=function(g,d){var e;if("string"!=typeof g||"undefined"===typeof g)return g;e=null!=d&&1===d.nodeType?d:document;if(g.match(/^#([\w\-]+$)/))return document.getElementById(g.split("#")[1]);e=e.querySelectorAll(g);
|
||||
return 1===e.length?e[0]:e};p=function(d){var e;if("undefined"!==typeof d){if("undefined"!==typeof Object.create)return Object.create(d);e=typeof d;if(!("object"!==e&&"function"!==e))return e=function(){},e.prototype=d,new e}};d.ext=function(g,i){i.el=e;d[g]=i};d.ext("each",function(d){if("undefined"!==typeof e.length&&e!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(e,d);else{var i=e.length;if(0!==i)for(var l,k=0;k<i;k++)l=e.item(k)?e.item(k):e[k],d.call(l,l)}else d.call(e,
|
||||
e)});d.type=function(d){return function(){return d&&d!==this}.call(d)?(typeof d).toLowerCase():{}.toString.call(d).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};d=window.$_=window.$_||d;d.$=o}})();"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(d){return Object.prototype.toString.apply(d)==="[object Array]"});
|
||||
(function(d){function o(a,b,c){var f,j;if(typeof a.hasAttribute!=="undefined"){a.hasAttribute(b)&&(f=a.getAttribute(b));j=true}else if(typeof a[b]!=="undefined"){f=a[b];j=false}else if(b==="class"&&typeof a.className!=="undefined"){b="className";f=a.className;j=false}if(typeof f==="undefined"&&(typeof c==="undefined"||c===null)){console.log(c);console.log(a);console.log("Element does not have the selected attribute");return null}if(typeof c==="undefined")return f;typeof c!=="undefined"&&c!==null?
|
||||
j===true?a.setAttribute(b,c):a[b]=c:c===null&&(j===true?a.removeAttribute(b):delete a[b]);return typeof c!=="undefined"?c:f}function p(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function e(a,b,c){var f,b=p(b);f={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if(typeof c==="undefined"&&a.style[b]!=="undefined")return a.style[b];if(typeof c==="undefined"&&a.style[f[b]]!=="undefined")return a.style[f[b]];if(typeof a.style[b]!=="undefined"){a.style[b]=
|
||||
c;return null}if(a.style[f[b]]){a.style[f[b]]=c;return null}console.log("Property "+b+" nor an equivalent seems to exist")}typeof document!=="undefined"&&!("classList"in document.createElement("a"))&&function(a){var a=(a.HTMLElement||a.Element).prototype,b=Object,c=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},f=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},j=function(a,b){this.name=a;this.code=DOMException[a];
|
||||
this.message=b},d=function(a,b){if(b==="")throw new j("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new j("INVALID_CHARACTER_ERR","String contains an invalid character");return f.call(a,b)},h=function(a){for(var b=c.call(a.className),b=b?b.split(/\s+/):[],f=0,j=b.length;f<j;f++)this.push(b[f]);this._updateClassName=function(){a.className=this.toString()}},e=h.prototype=[],g=function(){return new h(this)};j.prototype=Error.prototype;e.item=function(a){return this[a]||
|
||||
null};e.contains=function(a){return d(this,a+"")!==-1};e.add=function(a){a=a+"";if(d(this,a)===-1){this.push(a);this._updateClassName()}};e.remove=function(a){a=d(this,a+"");if(a!==-1){this.splice(a,1);this._updateClassName()}};e.toggle=function(a){a=a+"";d(this,a)===-1?this.add(a):this.remove(a)};e.toString=function(){return this.join(" ")};if(b.defineProperty){e={get:g,enumerable:true,configurable:true};try{b.defineProperty(a,"classList",e)}catch(i){if(i.number===-2146823252){e.enumerable=false;
|
||||
b.defineProperty(a,"classList",e)}}}else b.prototype.__defineGetter__&&a.__defineGetter__("classList",g)}(self);d.ext("dom",{addClass:function(a){d.each(function(b){b.classList.add(a)})},removeClass:function(a){d.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 c=this.el;if(c.length>1&&typeof b==="undefined"){console.log(c);console.log("Must be a singular element")}else if(c.length>
|
||||
1&&typeof b!=="undefined")d.each(function(c){return o(c,a,b)});else return o(c,a,b)},text:function(a){var b,c,f;f=this.el;c=typeof f.textContent!=="undefined"?"textContent":typeof f.innerText!=="undefined"?"innerText":"innerHTML";b=f[c];if(typeof a!=="undefined")return f[c]=a;return b},css:function(a,b){if(typeof b==="undefined")return e(this.el,a);d.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}});if(typeof window.XMLHttpRequest!=="undefined"){var g={_do:function(a,b,c,f,j){var d=new XMLHttpRequest;typeof c==="undefined"&&(c=function(){});j=j?"POST":"GET";a=a+(j==="GET"?"?"+this._serialize(b):"");d.open(j,a);d.onreadystatechange=function(){d.readyState===
|
||||
4&&(d.status===200?c.call(d.responseText,d.responseText):typeof f!=="undefined"&&f.call(d.status,d.status))};if(j==="POST"){d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.send(this._serialize(b))}else d.send(null)},_serialize:function(a){var b,c,f=[];for(b in a)if(a.hasOwnProperty(b)&&typeof a[b]!=="function"){c=a[b].toString();b=encodeURIComponent(b);c=encodeURIComponent(c);f.push(b+"="+c)}return f.join("&")}};d.ext("get",function(a,b,c,f){g._do(a,b,c,f,false)});d.ext("post",
|
||||
function(a,b,c,f){g._do(a,b,c,f,true)});d.ext("sse",function(a,b){var c;if(typeof EventSource!=="undefined"){c=new EventSource(a);c.onmessage=function(a){b.call(a.data,a.data)}}});var i,l,k,q;if(typeof document.addEventListener!=="undefined"){i=function(a,b,c){typeof a.addEventListener!=="undefined"&&a.addEventListener(b,c,false)};l=function(a,b,c){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(b,c,false)}}else if(typeof document.attachEvent!=="undefined"){i=function(a,b,c){function f(a){c.apply(a)}
|
||||
if(typeof a.attachEvent!=="undefined"){l(b,c);a.attachEvent("on"+b,f);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:f})}else console.log("Failed to _attach event:"+b+" on "+a)};l=function(a,b,c){if(typeof a.detachEvent!=="undefined"){var f=a.KIS_0_6_0;if(f&&f.listeners&&f.listeners[b])for(var d=f.listeners[b],e=d.length,h=0;h<e;h++)if(d[h].callback===c){a.detachEvent("on"+b,d[h]._listener);d.splice(h,1);d.length===
|
||||
0&&delete f.listeners[b];break}}}}k=function(a,b,c,f){var d,e;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))f===true?i(a,b,c):l(a,b,c);else{b=b.split(" ");e=b.length;for(d=0;d<e;d++)k(a,b[d],c,f)}};q=function(a,b,c,f){k(a,c,function(c){var e,h,g,c=c||window.event;h=d.$(b,a);for(e in h){g=c.target||c.srcElement;if(g==h[e]){f.call(h[e],c);c.stopPropagation()}}},true)};d.ext("event",{add:function(a,b){d.each(function(c){k(c,a,b,true)})},remove:function(a,
|
||||
b){d.each(function(c){k(c,a,b,false)})},live:function(a,b,c){q(document.documentElement,a,b,c)},delegate:function(a,b,c){d.each(function(f){q(f,a,b,c)})}});if(typeof localStorage==="undefined"||typeof JSON==="undefined")return null;var m=localStorage,n=sessionStorage;d.ext("store",{get:function(a,b){var c=b?n.getItem(a):m.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?n.setItem(a,b):m.setItem(a,b)},remove:function(a,b){b?n.removeItem(a):m.removeItem(a)},getAll:function(a){var b,
|
||||
c={},f,d;d=a?m:n;b=d.length;for(a=0;a<b;a++){f=d.key(a);c[f]=d.getItem(f)}return c},clear:function(a){a?n.clear():m.clear()}});var s=function(a){var b=[],c=0,d={},e,b=r.object_keys(a);b.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),f=c+""===b,e=d+""===a;return f&&e?c>d?1:c<d?-1:0:f&&!e?1:!f&&e?-1:b>a?1:b<a?-1:0});c=b.length;for(e=0;e<c;e++)d[b[e]]=a[b[e]];return d},r={object_keys:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},object_values:function(a){var b=[],
|
||||
c;for(c in a)b.push(a[c]);return b},array_combine:function(a,b){var c={},f,e=0;d.type(a)!=="array"&&(a=this.object_values(a));d.type(b)!=="array"&&(b=this.object_values(b));f=a.length;if(f!==b.length){console.log("Object combine requires two arrays of the same size");return false}for(e=0;e<f;e++)c[a[e]]=b[e];return c},object_merge:function(){var a=Array.prototype.slice.call(arguments),b=a.length,c={},f,e=0,g,h,i;f=true;for(g=0;g<b;g++)if(d.type(a[g])!=="array"){f=false;break}if(f){c=[];for(g=0;g<
|
||||
b;g++)c=c.contact(a[g]);return c}for(i=g=0;g<b;g++){f=a[g];if(d.type(f)=="array"){h=0;for(e=f.length;h<e;h++)c[i++]=f[h]}else for(h in f)f.hasOwnProperty(h)&&(parseInt(h,10)+""===h?c[i++]=f[h]:c[h]=f[h])}return c},str_trans:function(a,b,c){var d=[],e=[],g=false,h=0,i=0,k="",l="",o="",m="",n;if(typeof b==="object"){b=s(b);for(n in b)if(b.hasOwnProperty(n)){d.push(n);e.push(b[n])}b=d;c=e}i=a.length;h=b.length;k=typeof c==="string";l=typeof b==="string";for(d=0;d<i;d++){g=false;if(l){a.charAt(d-1);o=
|
||||
a.charAt(d);a.charAt(d+1);for(e=0;e<h;e++)if(o==b.charAt(e)){g=true;break}}else for(e=0;e<h;e++)if(a.substr(d,b[e].length)==b[e]){g=true;d=d+b[e].length-1;break}m=g?m+(k?c.charAt(e):c[e]):m+a.charAt(d)}return m}};d.ext("util",r)}})($_);
|
||||
|
@ -14,17 +14,17 @@
|
||||
}
|
||||
|
||||
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";
|
||||
@ -37,7 +37,18 @@
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -88,10 +99,11 @@
|
||||
* @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);
|
||||
});
|
||||
|
||||
/**
|
||||
@ -102,10 +114,11 @@
|
||||
* @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);
|
||||
});
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user