|  |  |  | 
|---|
|  |  |  | <meta charset="UTF-8"> | 
|---|
|  |  |  | <title>NEWS</title> | 
|---|
|  |  |  | <style> | 
|---|
|  |  |  | /** {*/ | 
|---|
|  |  |  | /*    padding: 0;*/ | 
|---|
|  |  |  | /*    margin: 0;*/ | 
|---|
|  |  |  | /*}*/ | 
|---|
|  |  |  | .container { | 
|---|
|  |  |  | height: 100%; | 
|---|
|  |  |  | width: 100%; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /*=============== SCROLL UP ===============*/ | 
|---|
|  |  |  | .scrollup { | 
|---|
|  |  |  | text-decoration: none; | 
|---|
|  |  |  | 
|---|
|  |  |  | bottom: 5%; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .news-desc { | 
|---|
|  |  |  | font-size: 14px; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .level-1 { | 
|---|
|  |  |  | color: #333333; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .level-2 { | 
|---|
|  |  |  | color: #1E9FFF; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .level-3 { | 
|---|
|  |  |  | color: red; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </style> | 
|---|
|  |  |  | </head> | 
|---|
|  |  |  | <body> | 
|---|
|  |  |  | <div class="container"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <a class="scrollup" id="scroll-up"> | 
|---|
|  |  |  | <span>顶部</span> | 
|---|
|  |  |  | </a> | 
|---|
|  |  |  | </body> | 
|---|
|  |  |  | <script src="../static/js/jquery/jquery-3.3.1.min.js"></script> | 
|---|
|  |  |  | <script src="../static/js/handlebars/handlebars-v4.5.3.js"></script> | 
|---|
|  |  |  | <script src="../static/js/common.js"></script> | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | var autoScroll = true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | setInterval(()=>{ | 
|---|
|  |  |  | $("body").append(new Date() + "<h4>Hello World</h4>"); | 
|---|
|  |  |  | if (autoScroll) { | 
|---|
|  |  |  | window.scrollTo(0, document.body.scrollHeight) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, 500) | 
|---|
|  |  |  | $.ajax({ | 
|---|
|  |  |  | url: baseUrl + "/news/print", | 
|---|
|  |  |  | // headers: {'token': localStorage.getItem('token')}, | 
|---|
|  |  |  | method: 'GET', | 
|---|
|  |  |  | success: function (res) { | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | let template = Handlebars.compile($('#newsTpl').html()); | 
|---|
|  |  |  | $('.container').html(template({list: eval(res.data)})); | 
|---|
|  |  |  | if (autoScroll) { | 
|---|
|  |  |  | window.scrollTo(0, document.body.scrollHeight) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (res.code === 403) { | 
|---|
|  |  |  | window.location.href = baseUrl + "/login"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | console.error(res.msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, 1000) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  | <script type="text/template" id="newsTpl"> | 
|---|
|  |  |  | {{#each list}} | 
|---|
|  |  |  | <div class="news-desc level-{{l}}"> | 
|---|
|  |  |  | <span>{{t}}</span> - <span>{{v}}</span> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | {{/each}} | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  | </html> | 
|---|