Fix ajax bug

This commit is contained in:
Timothy Warren 2012-11-15 13:42:14 -05:00
parent 8193bbab38
commit c861483d75
13 changed files with 1525 additions and 1038 deletions

File diff suppressed because one or more lines are too long

View File

@ -35,122 +35,127 @@
<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">
<span class='line'> 31</span>
<span class='line'> 32</span> </span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</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">"GET"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"?"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span>
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="NAME">request.open</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span>
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="NAME">request.onreadystatechange</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="WHIT">
<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="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 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 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'> 31</span> </span><span class="WHIT">
<span class='line'> 32</span> </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">"GET"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">url.match</span><span class="PUNC">(</span><span class="STRN">'?'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"?"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this._serialize</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="PUNC">:</span><span class="WHIT"> </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="WHIT">
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 38</span>
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="NAME">request.open</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span>
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">request.onreadystatechange</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="WHIT">
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</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'> 44</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 45</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'> 46</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 47</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'> 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="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'> 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="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'> 54</span> </span><span class="WHIT"> </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 class='line'> 57</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </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">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'> 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="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'> 62</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'> 63</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'> 64</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="KEYW">else</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="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'> 67</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'> 68</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 70</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'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 72</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'> 73</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 74</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'> 75</span>
<span class='line'> 76</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'> 77</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 78</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'> 79</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 82</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'> 83</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="KEYW">continue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </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">'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 class='line'>124</span> </span><span class="WHIT"> </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="PUNC">{</span><span class="WHIT">
<span class='line'>134</span>
<span class='line'>135</span> </span><span class="WHIT"> </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 class='line'>137</span> </span><span class="WHIT"> </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'> 87</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'> 88</span>
<span class='line'> 89</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'> 90</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'> 91</span>
<span class='line'> 92</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'> 93</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 94</span>
<span class='line'> 95</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'> 96</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span>
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>100</span> * Sends a GET type ajax request
<span class='line'>101</span> *
<span class='line'>102</span> * @name get
<span class='line'>103</span> * @function
<span class='line'>104</span> * @memberOf $_
<span class='line'>105</span> * @param string url
<span class='line'>106</span> * @param object data
<span class='line'>107</span> * @param function success_callback
<span class='line'>108</span> * @param function error_callback
<span class='line'>109</span> */</span><span class="WHIT">
<span class='line'>110</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'>111</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'>112</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span>
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>115</span> * Sends a POST type ajax request
<span class='line'>116</span> *
<span class='line'>117</span> * @name post
<span class='line'>118</span> * @function
<span class='line'>119</span> * @memberOf $_
<span class='line'>120</span> * @param string url
<span class='line'>121</span> * @param object data
<span class='line'>122</span> * @param function success_callback
<span class='line'>123</span> * @param function error_callback
<span class='line'>124</span> */</span><span class="WHIT">
<span class='line'>125</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'>126</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'>127</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span>
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="COMM">/**
<span class='line'>130</span> * Watches for server-sent events and applies a callback on message
<span class='line'>131</span> *
<span class='line'>132</span> * @name sse
<span class='line'>133</span> * @function
<span class='line'>134</span> * @memberOf $_
<span class='line'>135</span> * @param string url
<span class='line'>136</span> * @param function callback
<span class='line'>137</span> */</span><span class="WHIT">
<span class='line'>138</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="PUNC">{</span><span class="WHIT">
<span class='line'>139</span>
<span class='line'>140</span> </span><span class="WHIT"> </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'>141</span>
<span class='line'>142</span> </span><span class="WHIT"> </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="WHIT"> </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 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>
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="COMM">// Check for server-sent event support</span><span class="WHIT">
<span class='line'>143</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'>144</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</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'>146</span>
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
<span class='line'>148</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'>149</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'>150</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span>
<span class='line'>154</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>

View File

@ -819,7 +819,12 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
type = (isPost) ? "POST" : "GET";
url += (type === "GET") ? "?" + this._serialize(data) : '';
if (type === "GET")
{
url += ( ! url.match('?'))
? "?" + this._serialize(data)
: this._serialize(data);
}
request.open(type, url);

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

@ -1,8 +1,8 @@
(function(){if("undefined"!==typeof document.querySelector){var d,f,a,b;d=function(c){b="undefined"===typeof c?"undefined"!==typeof d.el?d.el:document.documentElement:f(c);d.prototype.el=b;var c=a(d),g;for(g in c)"object"===typeof c[g]&&(c[g].el=b);c.el=b;return c};f=function(c,b){var a;if("string"!=typeof c||"undefined"===typeof c)return c;a=null!=b&&1===b.nodeType?b:document;if(c.match(/^#([\w\-]+$)/))return document.getElementById(c.split("#")[1]);a=a.querySelectorAll(c);return 1===a.length?a[0]:
a};a=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}};d.ext=function(a,g){g.el=b;d[a]=g};d.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{var g=b.length;if(0!==g)for(var e,d=0;d<g;d++)e=b.item(d)?b.item(d):b[d],a.call(e,e)}else a.call(b,b)});d.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()};d=window.$_=window.$_||d;d.$=f}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)});
(function(){if("undefined"!==typeof window.XMLHttpRequest){var d={_do:function(d,a,b,c,g){var e=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});g=g?"POST":"GET";d+="GET"===g?"?"+this._serialize(a):"";e.open(g,d);e.onreadystatechange=function(){4===e.readyState&&(200===e.status?b.call(e.responseText,e.responseText):"undefined"!==typeof c&&c.call(e.status,e.status))};"POST"===g?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(a))):e.send(null)},
_serialize:function(d){var a,b,c=[];for(a in d)d.hasOwnProperty(a)&&"function"!==typeof d[a]&&(b=d[a].toString(),a=encodeURIComponent(a),b=encodeURIComponent(b),c.push(a+"="+b));return c.join("&")}};$_.ext("get",function(f,a,b,c){d._do(f,a,b,c,!1)});$_.ext("post",function(f,a,b,c){d._do(f,a,b,c,!0)});$_.ext("sse",function(d,a){var b;"undefined"!==typeof EventSource&&(b=new EventSource(d),b.onmessage=function(b){a.call(b.data,b.data)})})}})();
(function(){if("undefined"!==typeof window.XMLHttpRequest){var d={_do:function(d,a,b,c,g){var e=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});g=g?"POST":"GET";"GET"===g&&(d+=!d.match("?")?"?"+this._serialize(a):this._serialize(a));e.open(g,d);e.onreadystatechange=function(){4===e.readyState&&(200===e.status?b.call(e.responseText,e.responseText):"undefined"!==typeof c&&c.call(e.status,e.status))};"POST"===g?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(a))):
e.send(null)},_serialize:function(d){var a,b,c=[];for(a in d)d.hasOwnProperty(a)&&"function"!==typeof d[a]&&(b=d[a].toString(),a=encodeURIComponent(a),b=encodeURIComponent(b),c.push(a+"="+b));return c.join("&")}};$_.ext("get",function(f,a,b,c){d._do(f,a,b,c,!1)});$_.ext("post",function(f,a,b,c){d._do(f,a,b,c,!0)});$_.ext("sse",function(d,a){var b;"undefined"!==typeof EventSource&&(b=new EventSource(d),b.onmessage=function(b){a.call(b.data,b.data)})})}})();
(function(){var d,f;if("undefined"===typeof document.addEventListener)return!1;d=function(a,b,c,g){var e,f;if("undefined"===typeof a)return null;if(b.match(/^([\w\-]+)$/))!0===g?a.addEventListener(b,c,!1):a.removeEventListener(b,c,!1);else{b=b.split(" ");f=b.length;for(e=0;e<f;e++)d(a,b[e],c,g)}};f=function(a,b,c,g){d(a,c,function(c){var d,f;f=$_.$(b,a);for(d in f)c.target==f[d]&&(g.call(f[d],c),c.stopPropagation())},!0)};$_.ext("event",{add:function(a,b){$_.each(function(c){d(c,a,b,!0)})},remove:function(a,
b){$_.each(function(c){d(c,a,b,!1)})},live:function(a,b,c){f(document.documentElement,a,b,c)},delegate:function(a,b,c){$_.each(function(d){f(d,a,b,c)})}})})();
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(d){var d=(d.HTMLElement||d.Element).prototype,f=Object,a=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},c=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},g=function(a,d){if(""===d)throw new c("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new c("INVALID_CHARACTER_ERR",

View File

@ -284,7 +284,12 @@ if (typeof Array.isArray === "undefined")
type = (isPost) ? "POST" : "GET";
url += (type === "GET") ? "?" + this._serialize(data) : '';
if (type === "GET")
{
url += ( ! url.match('?'))
? "?" + this._serialize(data)
: this._serialize(data);
}
request.open(type, url);

4
kis-lite-min.js vendored
View File

@ -1,7 +1,7 @@
(function(){if("undefined"!==typeof document.querySelector){var d,f,c,a;d=function(b){a="undefined"===typeof b?"undefined"!==typeof d.el?d.el:document.documentElement:f(b);d.prototype.el=a;var b=c(d),g;for(g in b)"object"===typeof b[g]&&(b[g].el=a);b.el=a;return b};f=function(b,a){var c;if("string"!=typeof b||"undefined"===typeof b)return b;c=null!=a&&1===a.nodeType?a:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);c=c.querySelectorAll(b);return 1===c.length?c[0]:
c};c=function(b){var a;if("undefined"!==typeof b){if("undefined"!==typeof Object.create)return Object.create(b);a=typeof b;if(!("object"!==a&&"function"!==a))return a=function(){},a.prototype=b,new a}};d.ext=function(b,c){c.el=a;d[b]=c};d.ext("each",function(b){if("undefined"!==typeof a.length&&a!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(a,b);else{var c=a.length;if(0!==c)for(var e,d=0;d<c;d++)e=a.item(d)?a.item(d):a[d],b.call(e,e)}else b.call(a,a)});d.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()};d=window.$_=window.$_||d;d.$=f}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)});
(function(){if("undefined"!==typeof window.XMLHttpRequest){var d={_do:function(d,c,a,b,g){var e=new XMLHttpRequest;"undefined"===typeof a&&(a=function(){});g=g?"POST":"GET";d+="GET"===g?"?"+this._serialize(c):"";e.open(g,d);e.onreadystatechange=function(){4===e.readyState&&(200===e.status?a.call(e.responseText,e.responseText):"undefined"!==typeof b&&b.call(e.status,e.status))};"POST"===g?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(c))):e.send(null)},
_serialize:function(d){var c,a,b=[];for(c in d)d.hasOwnProperty(c)&&"function"!==typeof d[c]&&(a=d[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),b.push(c+"="+a));return b.join("&")}};$_.ext("get",function(f,c,a,b){d._do(f,c,a,b,!1)});$_.ext("post",function(f,c,a,b){d._do(f,c,a,b,!0)});$_.ext("sse",function(d,c){var a;"undefined"!==typeof EventSource&&(a=new EventSource(d),a.onmessage=function(a){c.call(a.data,a.data)})})}})();
(function(){if("undefined"!==typeof window.XMLHttpRequest){var d={_do:function(d,c,a,b,g){var e=new XMLHttpRequest;"undefined"===typeof a&&(a=function(){});g=g?"POST":"GET";"GET"===g&&(d+=!d.match("?")?"?"+this._serialize(c):this._serialize(c));e.open(g,d);e.onreadystatechange=function(){4===e.readyState&&(200===e.status?a.call(e.responseText,e.responseText):"undefined"!==typeof b&&b.call(e.status,e.status))};"POST"===g?(e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.send(this._serialize(c))):
e.send(null)},_serialize:function(d){var c,a,b=[];for(c in d)d.hasOwnProperty(c)&&"function"!==typeof d[c]&&(a=d[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),b.push(c+"="+a));return b.join("&")}};$_.ext("get",function(f,c,a,b){d._do(f,c,a,b,!1)});$_.ext("post",function(f,c,a,b){d._do(f,c,a,b,!0)});$_.ext("sse",function(d,c){var a;"undefined"!==typeof EventSource&&(a=new EventSource(d),a.onmessage=function(a){c.call(a.data,a.data)})})}})();
(function(){var d,f;if("undefined"===typeof document.addEventListener)return!1;d=function(c,a,b,g){var e,f;if("undefined"===typeof c)return null;if(a.match(/^([\w\-]+)$/))!0===g?c.addEventListener(a,b,!1):c.removeEventListener(a,b,!1);else{a=a.split(" ");f=a.length;for(e=0;e<f;e++)d(c,a[e],b,g)}};f=function(c,a,b,g){d(c,b,function(b){var d,f;f=$_.$(a,c);for(d in f)b.target==f[d]&&(g.call(f[d],b),b.stopPropagation())},!0)};$_.ext("event",{add:function(c,a){$_.each(function(b){d(b,c,a,!0)})},remove:function(c,
a){$_.each(function(b){d(b,c,a,!1)})},live:function(c,a,b){f(document.documentElement,c,a,b)},delegate:function(c,a,b){$_.each(function(d){f(d,c,a,b)})}})})();

View File

@ -284,7 +284,12 @@ if (typeof Array.isArray === "undefined")
type = (isPost) ? "POST" : "GET";
url += (type === "GET") ? "?" + this._serialize(data) : '';
if (type === "GET")
{
url += ( ! url.match('?'))
? "?" + this._serialize(data)
: this._serialize(data);
}
request.open(type, url);

8
kis-min.js vendored
View File

@ -8,10 +8,10 @@ return y.call(a,b)},u=function(a){for(var b=i.call(a.className),b=b?b.split(/\s+
k.toggle=function(a){a+="";-1===s(this,a)?this.add(a):this.remove(a)};k.toString=function(){return this.join(" ")};if(g.defineProperty){k={get:v,enumerable:!0,configurable:!0};try{g.defineProperty(e,"classList",k)}catch(z){-2146823252===z.number&&(k.enumerable=!1,g.defineProperty(e,"classList",k))}}else g.prototype.__defineGetter__&&e.__defineGetter__("classList",v)}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){"undefined"===typeof a&&(a="block");this.css("display",a)},attr:function(a,b){var c=this.el;if(1<c.length&&"undefined"===typeof b)return null;if(1<c.length&&"undefined"!==typeof b)d.each(function(c){return j(c,a,b)});else return j(c,a,b)},text:function(a){var b,c;c=this.el;b=c.textContent;return"undefined"!==typeof a?c.textContent=a:b},css:function(a,b){if("undefined"===typeof b)return m(this.el,a);d.each(function(c){m(c,a,b)})},append:function(a){"undefined"!==
typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML+=a},prepend:function(a){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){"undefined"!==typeof a&&(this.el.innerHTML=a);return this.el.innerHTML}});if("undefined"!==typeof window.XMLHttpRequest){var w={_do:function(a,b,c,f,d){var h=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});d=d?"POST":"GET";
a+="GET"===d?"?"+this._serialize(b):"";h.open(d,a);h.onreadystatechange=function(){4===h.readyState&&(200===h.status?c.call(h.responseText,h.responseText):"undefined"!==typeof f&&f.call(h.status,h.status))};"POST"===d?(h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(this._serialize(b))):h.send(null)},_serialize:function(a){var b,c,f=[];for(b in a)a.hasOwnProperty(b)&&"function"!==typeof a[b]&&(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){w._do(a,b,c,f,!1)});d.ext("post",function(a,b,c,f){w._do(a,b,c,f,!0)});d.ext("sse",function(a,b){var c;"undefined"!==typeof EventSource&&(c=new EventSource(a),c.onmessage=function(a){b.call(a.data,a.data)})});var n,t;if("undefined"===typeof document.addEventListener)return!1;n=function(a,b,c,d){var r,h;if("undefined"===typeof a)return null;if(b.match(/^([\w\-]+)$/))!0===d?a.addEventListener(b,c,!1):a.removeEventListener(b,c,!1);else{b=b.split(" ");
h=b.length;for(r=0;r<h;r++)n(a,b[r],c,d)}};t=function(a,b,c,f){n(a,c,function(c){var h,e;e=d.$(b,a);for(h in e)c.target==e[h]&&(f.call(e[h],c),c.stopPropagation())},!0)};d.ext("event",{add:function(a,b){d.each(function(c){n(c,a,b,!0)})},remove:function(a,b){d.each(function(c){n(c,a,b,!1)})},live:function(a,b,c){t(document.documentElement,a,b,c)},delegate:function(a,b,c){d.each(function(d){t(d,a,b,c)})}});if("undefined"===typeof localStorage||"undefined"===typeof JSON)return null;var p=localStorage,
q=sessionStorage;d.ext("store",{get:function(a,b){var c=b?q.getItem(a):p.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?q.setItem(a,b):p.setItem(a,b)},remove:function(a,b){b?q.removeItem(a):p.removeItem(a)},getAll:function(a){var b,c={},d,e;e=a?p:q;b=e.length;for(a=0;a<b;a++)d=e.key(a),c[d]=e.getItem(d);return c},clear:function(a){a?q.clear():p.clear()}});var x={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=
"GET"===d&&(a+=!a.match("?")?"?"+this._serialize(b):this._serialize(b));h.open(d,a);h.onreadystatechange=function(){4===h.readyState&&(200===h.status?c.call(h.responseText,h.responseText):"undefined"!==typeof f&&f.call(h.status,h.status))};"POST"===d?(h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(this._serialize(b))):h.send(null)},_serialize:function(a){var b,c,f=[];for(b in a)a.hasOwnProperty(b)&&"function"!==typeof a[b]&&(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){w._do(a,b,c,f,!1)});d.ext("post",function(a,b,c,f){w._do(a,b,c,f,!0)});d.ext("sse",function(a,b){var c;"undefined"!==typeof EventSource&&(c=new EventSource(a),c.onmessage=function(a){b.call(a.data,a.data)})});var n,t;if("undefined"===typeof document.addEventListener)return!1;n=function(a,b,c,d){var r,h;if("undefined"===typeof a)return null;if(b.match(/^([\w\-]+)$/))!0===d?a.addEventListener(b,c,!1):a.removeEventListener(b,
c,!1);else{b=b.split(" ");h=b.length;for(r=0;r<h;r++)n(a,b[r],c,d)}};t=function(a,b,c,f){n(a,c,function(c){var h,e;e=d.$(b,a);for(h in e)c.target==e[h]&&(f.call(e[h],c),c.stopPropagation())},!0)};d.ext("event",{add:function(a,b){d.each(function(c){n(c,a,b,!0)})},remove:function(a,b){d.each(function(c){n(c,a,b,!1)})},live:function(a,b,c){t(document.documentElement,a,b,c)},delegate:function(a,b,c){d.each(function(d){t(d,a,b,c)})}});if("undefined"===typeof localStorage||"undefined"===typeof JSON)return null;
var p=localStorage,q=sessionStorage;d.ext("store",{get:function(a,b){var c=b?q.getItem(a):p.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?q.setItem(a,b):p.setItem(a,b)},remove:function(a,b){b?q.removeItem(a):p.removeItem(a)},getAll:function(a){var b,c={},d,e;e=a?p:q;b=e.length;for(a=0;a<b;a++)d=e.key(a),c[d]=e.getItem(d);return c},clear:function(a){a?q.clear():p.clear()}});var x={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;"array"!==d.type(a)&&(a=this.object_values(a));"array"!==d.type(b)&&(b=this.object_values(b));f=a.length;if(f!==b.length)return!1;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,h,g,i;f=!0;for(h=0;h<b;h++)if("array"!==d.type(a[h])){f=!1;break}if(f){c=[];for(h=0;h<b;h++)c=c.contact(a[h]);return c}for(i=h=0;h<b;h++)if(f=a[h],"array"==d.type(f)){g=
0;for(e=f.length;g<e;g++)c[i++]=f[g]}else for(g in f)f.hasOwnProperty(g)&&(parseInt(g,10)+""===g?c[i++]=f[g]:c[g]=f[g]);return c},str_trans:function(a,b,c){var d=[],e=[],h=!1,g=0,i=0,j="",k="",l="",m="",n;if("object"===typeof b){c=[];h=0;g={};c=x.object_keys(b);c.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});h=c.length;for(i=0;i<h;i++)g[c[i]]=b[c[i]];b=g;for(n in b)b.hasOwnProperty(n)&&(d.push(n),e.push(b[n]));
b=d;c=e}i=a.length;g=b.length;j="string"===typeof c;k="string"===typeof b;for(d=0;d<i;d++){h=!1;if(k){a.charAt(d-1);l=a.charAt(d);a.charAt(d+1);for(e=0;e<g;e++)if(l==b.charAt(e)){h=!0;break}}else for(e=0;e<g;e++)if(a.substr(d,b[e].length)==b[e]){h=!0;d=d+b[e].length-1;break}m=h?m+(j?c.charAt(e):c[e]):m+a.charAt(d)}return m}};d.ext("util",x)}})($_);

View File

@ -29,7 +29,12 @@
type = (isPost) ? "POST" : "GET";
url += (type === "GET") ? "?" + this._serialize(data) : '';
if (type === "GET")
{
url += ( ! url.match('?'))
? "?" + this._serialize(data)
: this._serialize(data);
}
request.open(type, url);

View File

@ -34,67 +34,7 @@ for (var i = 0, tagName; tagName = HTML5[i]; i++) document.createElement(tagName
</section>
<script src="../kis-min.js"></script>
<script src="qunit/qunit.js"></script>
<script type="text/javascript">
//Selector test function
function $(a)
{
var x = document.querySelectorAll(a);
//Return the single object if applicable
return (x.length === 1) ? x[0] : x;
}
//Object equivalence function
function is_clone(o1, o2)
{
var n,
flag=true;
for(n in o1)
{
//Do a shallow compare -- first level only
if($_.type(o1[n]) === "object")
{
if($_.type(o2[n]) !== "object")
{
flag = false;
break;
}
}
else
{
if(o1[n] !== o2[n])
{
flag = false;
break;
}
}
}
for(n in o2)
{
//Do a shallow compare -- first level only
if($_.type(o1[n]) === "object")
{
if($_.type(o2[n]) !== "object")
{
flag = false;
break;
}
}
else
{
if(o2[n] !== o1[n])
{
flag = false;
break;
}
}
}
return flag;
}
</script>
<script src="qunit/test_funcs.js"></script>
<script src="tests/core.js"></script>
<script src="tests/ajax.js"></script>
<script src="tests/event.js"></script>

View File

@ -1,11 +1,11 @@
/**
* QUnit v1.3.0pre - A JavaScript Unit Testing Framework
* QUnit v1.11.0pre - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
* http://qunitjs.com
*
* Copyright (c) 2011 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
/** Font Family and Sizes */
@ -20,7 +20,7 @@
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
@ -38,10 +38,10 @@
line-height: 1em;
font-weight: normal;
border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
-webkit-border-top-right-radius: 15px;
-webkit-border-top-left-radius: 15px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
}
#qunit-header a {
@ -54,6 +54,11 @@
color: #fff;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 .5em 0 .1em;
}
#qunit-banner {
height: 5px;
}
@ -62,6 +67,7 @@
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
overflow: hidden;
}
#qunit-userAgent {
@ -71,6 +77,9 @@
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
}
/** Tests: Pass/Fail */
@ -102,19 +111,19 @@
color: #000;
}
#qunit-tests ol {
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
.qunit-collapsed {
display: none;
}
#qunit-tests table {
@ -157,8 +166,7 @@
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
margin: 0.5em;
padding: 0.4em 0.5em 0.4em 0.5em;
padding: 5px;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
@ -167,9 +175,9 @@
/*** Passing Styles */
#qunit-tests li li.pass {
color: #5E740B;
color: #3c510c;
background-color: #fff;
border-left: 26px solid #C6E746;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
@ -185,15 +193,15 @@
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 15px 15px;
-moz-border-radius: 0 0 15px 15px;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
@ -216,6 +224,9 @@
border-bottom: 1px solid white;
}
#qunit-testresult .module-name {
font-weight: bold;
}
/** Fixture */
@ -223,4 +234,6 @@
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

File diff suppressed because it is too large Load Diff

60
tests/qunit/test_funcs.js Normal file
View File

@ -0,0 +1,60 @@
// Query selector function
var $ = function(a)
{
var x = document.querySelectorAll(a);
//Return the single object if applicable
return (x.length === 1) ? x[0] : x;
}
//Object equivalence function
var is_clone = function(o1, o2)
{
var n,
flag=true;
for(n in o1)
{
//Do a shallow compare -- first level only
if($_.type(o1[n]) === "object")
{
if($_.type(o2[n]) !== "object")
{
flag = false;
break;
}
}
else
{
if(o1[n] !== o2[n])
{
flag = false;
break;
}
}
}
for(n in o2)
{
//Do a shallow compare -- first level only
if($_.type(o1[n]) === "object")
{
if($_.type(o2[n]) !== "object")
{
flag = false;
break;
}
}
else
{
if(o2[n] !== o1[n])
{
flag = false;
break;
}
}
}
return flag;
}