/usr/share/qt5/doc/qtquick/qtquick-demos-tweetsearch-content-tweetsearch-js.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tweetsearch.js Example File | Qt Quick 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li><a href="qtquick-demos-tweetsearch-example.html">Qt Quick Demo - Tweet Search</a></li>
<li>tweetsearch.js Example File</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">tweetsearch.js Example File</h1>
<span class="subtitle">demos/tweetsearch/content/tweetsearch.js</span>
<!-- $$$demos/tweetsearch/content/tweetsearch.js-description -->
<div class="descr"> <a name="details"></a>
<pre class="js">.pragma library
<span class="keyword">function</span> <span class="name">formatDate</span>(<span class="name">date</span>)
{
var <span class="name">da</span> = new <span class="name">Date</span>(<span class="name">date</span>)
<span class="keyword">return</span> <span class="name">da</span>.<span class="name">toDateString</span>()
}
<span class="keyword">function</span> <span class="name">demoToken</span>()
{
var <span class="name">a</span> = new <span class="name">Array</span>(<span class="number">22</span>).<span class="name">join</span>(<span class="string">'A'</span>)
<span class="keyword">return</span> <span class="name">a</span> <span class="operator">+</span> <span class="name">String</span>.<span class="name">fromCharCode</span>(<span class="number">0x44</span>, <span class="number">0x69</span>, <span class="number">0x4a</span>, <span class="number">0x52</span>, <span class="number">0x51</span>, <span class="number">0x41</span>, <span class="number">0x41</span>, <span class="number">0x41</span>, <span class="number">0x41</span>,
<span class="number">0x41</span>, <span class="number">0x41</span>, <span class="number">0x74</span>, <span class="number">0x2b</span>, <span class="number">0x72</span>, <span class="number">0x6a</span>, <span class="number">0x6c</span>, <span class="number">0x2b</span>, <span class="number">0x71</span>,
<span class="number">0x6d</span>, <span class="number">0x7a</span>, <span class="number">0x30</span>, <span class="number">0x72</span>, <span class="number">0x63</span>, <span class="number">0x79</span>, <span class="number">0x2b</span>, <span class="number">0x42</span>, <span class="number">0x62</span>,
<span class="number">0x75</span>, <span class="number">0x58</span>, <span class="number">0x42</span>, <span class="number">0x42</span>, <span class="number">0x73</span>, <span class="number">0x72</span>, <span class="number">0x55</span>, <span class="number">0x48</span>, <span class="number">0x47</span>,
<span class="number">0x45</span>, <span class="number">0x67</span>, <span class="number">0x3d</span>, <span class="number">0x71</span>, <span class="number">0x30</span>, <span class="number">0x45</span>, <span class="number">0x4b</span>, <span class="number">0x32</span>, <span class="number">0x61</span>,
<span class="number">0x57</span>, <span class="number">0x71</span>, <span class="number">0x51</span>, <span class="number">0x4d</span>, <span class="number">0x62</span>, <span class="number">0x31</span>, <span class="number">0x35</span>, <span class="number">0x67</span>, <span class="number">0x43</span>,
<span class="number">0x5a</span>, <span class="number">0x4e</span>, <span class="number">0x77</span>, <span class="number">0x5a</span>, <span class="number">0x6f</span>, <span class="number">0x39</span>, <span class="number">0x79</span>, <span class="number">0x71</span>, <span class="number">0x61</span>,
<span class="number">0x65</span>, <span class="number">0x30</span>, <span class="number">0x68</span>, <span class="number">0x70</span>, <span class="number">0x65</span>, <span class="number">0x32</span>, <span class="number">0x46</span>, <span class="number">0x44</span>, <span class="number">0x73</span>,
<span class="number">0x53</span>, <span class="number">0x39</span>, <span class="number">0x32</span>, <span class="number">0x57</span>, <span class="number">0x41</span>, <span class="number">0x75</span>, <span class="number">0x30</span>, <span class="number">0x67</span>)
}
<span class="keyword">function</span> <span class="name">linkForEntity</span>(<span class="name">entity</span>)
{
<span class="keyword">return</span> (<span class="name">entity</span>.<span class="name">url</span> ? <span class="name">entity</span>.<span class="name">url</span> :
(<span class="name">entity</span>.<span class="name">screen_name</span> ? <span class="string">'https://twitter.com/'</span> <span class="operator">+</span> <span class="name">entity</span>.<span class="name">screen_name</span> :
<span class="string">'https://twitter.com/search?q=%23'</span> <span class="operator">+</span> <span class="name">entity</span>.<span class="name">text</span>))
}
<span class="keyword">function</span> <span class="name">textForEntity</span>(<span class="name">entity</span>)
{
<span class="keyword">return</span> (<span class="name">entity</span>.<span class="name">display_url</span> ? <span class="name">entity</span>.<span class="name">display_url</span> :
(<span class="name">entity</span>.<span class="name">screen_name</span> ? <span class="name">entity</span>.<span class="name">screen_name</span> : <span class="name">entity</span>.<span class="name">text</span>))
}
<span class="keyword">function</span> <span class="name">insertLinks</span>(<span class="name">text</span>, entities)
{
<span class="keyword">if</span> (typeof <span class="name">text</span> <span class="operator">!==</span> <span class="string">'string'</span>)
<span class="keyword">return</span> <span class="string">""</span>;
<span class="keyword">if</span> (!<span class="name">entities</span>)
<span class="keyword">return</span> <span class="name">text</span>;
// Add all links (urls, usernames and hashtags) to an array and sort them in
// descending order of appearance in text
var <span class="name">links</span> = []
<span class="keyword">if</span> (<span class="name">entities</span>.<span class="name">urls</span>)
<span class="name">links</span> <span class="operator">=</span> <span class="name">entities</span>.<span class="name">urls</span>.<span class="name">concat</span>(<span class="name">entities</span>.<span class="name">hashtags</span>, <span class="name">entities</span>.<span class="name">user_mentions</span>)
<span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">entities</span>.<span class="name">url</span>)
<span class="name">links</span> <span class="operator">=</span> <span class="name">entities</span>.<span class="name">url</span>.<span class="name">urls</span>
<span class="name">links</span>.<span class="name">sort</span>(<span class="keyword">function</span>(<span class="name">a</span>, b) { <span class="keyword">return</span> <span class="name">b</span>.<span class="name">indices</span>[<span class="number">0</span>] <span class="operator">-</span> <span class="name">a</span>.<span class="name">indices</span>[<span class="number">0</span>] })
<span class="keyword">for</span> (<span class="keyword">var</span> <span class="name">i</span> = <span class="number">0</span>; <span class="name">i</span> <span class="operator"><</span> <span class="name">links</span>.<span class="name">length</span>; i++) {
var <span class="name">offset</span> = <span class="name">links</span>[<span class="name">i</span>].<span class="name">url</span> ? <span class="number">0</span> : <span class="number">1</span>
<span class="name">text</span> <span class="operator">=</span> <span class="name">text</span>.<span class="name">substring</span>(<span class="number">0</span>, <span class="name">links</span>[<span class="name">i</span>].<span class="name">indices</span>[<span class="number">0</span>] <span class="operator">+</span> <span class="name">offset</span>) <span class="operator">+</span>
<span class="string">'<a href=\"'</span> <span class="operator">+</span> <span class="name">linkForEntity</span>(<span class="name">links</span>[<span class="name">i</span>]) <span class="operator">+</span> <span class="string">'\">'</span> <span class="operator">+</span>
<span class="name">textForEntity</span>(<span class="name">links</span>[<span class="name">i</span>]) <span class="operator">+</span> <span class="string">'</a>'</span> <span class="operator">+</span>
<span class="name">text</span>.<span class="name">substring</span>(<span class="name">links</span>[<span class="name">i</span>].<span class="name">indices</span>[<span class="number">1</span>])
}
<span class="keyword">return</span> <span class="name">text</span>.<span class="name">replace</span>(/\n/g, <span class="string">'<br>'</span>);
}</pre>
</div>
<!-- @@@demos/tweetsearch/content/tweetsearch.js -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|