| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 |
<title>timeago.js: testcases.</title> |
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 7 |
<meta name="keywords" content="timeago, timeago.js, datetime,*** time ago, javascript timeago, react-timeago, jquery-timeago, timeago.org" /> |
| 8 |
<meta name="description" content="timeago.js is a tiny(2kb) library used to format date with `*** time ago`. eg: '3 hours ago'. No dependence. and support automatically updating fuzzy timestamps." /> |
| 9 |
<link rel="shortcut icon" href="clock.png" /> |
| 10 |
<link rel="bookmark" href="clock.png" /> |
| 11 |
<link rel="stylesheet" type="text/css" href="css.css" /> |
| 12 |
</head> |
| 13 |
<body> |
| 14 |
<div id="content"> |
| 15 |
<h1><img src="clock.png" /> timeago.js</h1> |
| 16 |
<h2> a tiny / simple library</h2> |
| 17 |
|
| 18 |
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> |
| 19 |
|
| 20 |
<ins class="adsbygoogle" |
| 21 |
style="display:block" |
| 22 |
data-ad-client="ca-pub-7292810486004926" |
| 23 |
data-ad-slot="7806394673" |
| 24 |
data-ad-format="auto"></ins> |
| 25 |
<script> |
| 26 |
(adsbygoogle = window.adsbygoogle || []).push({}); |
| 27 |
</script> |
| 28 |
|
| 29 |
<h3>What ?</h3> |
| 30 |
<p> |
| 31 |
<strong>timeago.js</strong> is a tiny(2kb) library used to format date with `*** time ago`. eg: '3 hours ago'. No dependency. and support automatically updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). <a href="https://github.com/hustcc/timeago.js">Download</a>, view the examples, and enjoy. |
| 32 |
</p> |
| 33 |
<div> |
| 34 |
<input type="button" onclick="javascript:start_render_all();" value="Auto-render all by native." /> |
| 35 |
<input type="button" onclick="javascript:stop_render_all();" value="Stop all Auto-render." /> |
| 36 |
</div> |
| 37 |
|
| 38 |
<h3>Test for native DOM</h3> |
| 39 |
<p class="native example"> |
| 40 |
You opened this page <time class="strong single">when you opened the page</time> |
| 41 |
<input type="button" onclick="javascript:start_single_native();" value="Start." /> |
| 42 |
<input type="button" onclick="javascript:stop_single_native();" value="Stop." /> |
| 43 |
</p> |
| 44 |
<p class="native example"> |
| 45 |
You opened this page <time class="strong">when you opened the page</time>. |
| 46 |
</p> |
| 47 |
|
| 48 |
<h3>Test for Locales ?</h3> |
| 49 |
<p class="locales example"> |
| 50 |
You opened this page <time class="strong single vi">when you opened the page</time>. |
| 51 |
<input type="button" onclick="javascript:start_vi();" value="Start." /> |
| 52 |
<input type="button" onclick="javascript:stop_vi();" value="Stop." /> |
| 53 |
</p> |
| 54 |
|
| 55 |
<h3>Test refreshing with minimal interval (every 3 second update) ?</h3> |
| 56 |
<p class="min-interval example"> |
| 57 |
You opened this page <time class="strong single minint">when you opened the page</time>. |
| 58 |
<input type="button" onclick="javascript:start_minint();" value="Start." /> |
| 59 |
<input type="button" onclick="javascript:stop_minint();" value="Stop." /> |
| 60 |
</p> |
| 61 |
</div> |
| 62 |
<div id="footer"> |
| 63 |
Copyright © 2016 How to user it, see <a href="https://timeago.org/" target="_blank" rel="nofollow">timeago.js</a>. |
| 64 |
Updated by <a href="http://Github.com/hustcc">Hustcc</a> |
| 65 |
</div> |
| 66 |
<script src="./timeago.full.min.js"></script> |
| 67 |
<script src="./index.js" type="text/javascript"></script> |
| 68 |
<script type="text/javascript"> |
| 69 |
init_test_page(); // 初始化标签上的时间 |
| 70 |
|
| 71 |
function start_render_all() { |
| 72 |
timeago.render(document.querySelectorAll('.example time')); |
| 73 |
} |
| 74 |
function stop_render_all() { |
| 75 |
timeago.cancel(); // cancel all. |
| 76 |
} |
| 77 |
|
| 78 |
function start_single_native() { |
| 79 |
timeago.render(document.querySelector('.native .single', 'zh_CN')); |
| 80 |
} |
| 81 |
|
| 82 |
function stop_single_native() { |
| 83 |
timeago.cancel(document.querySelector('.native .single')); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
function start_vi() { |
| 88 |
timeago.render(document.querySelector('.vi.single'), 'vi'); |
| 89 |
} |
| 90 |
|
| 91 |
function stop_vi() { |
| 92 |
timeago.cancel(document.querySelector('.vi.single')); |
| 93 |
} |
| 94 |
|
| 95 |
function start_minint() { |
| 96 |
timeago.render(document.querySelector('.minint.single'), 'en_US', { minInterval: 3 }); |
| 97 |
} |
| 98 |
function stop_minint() { |
| 99 |
timeago.cancel(document.querySelector('.minint.single')); |
| 100 |
} |
| 101 |
</script> |
| 102 |
</body> |
| 103 |
</html> |