PageRenderTime 41ms CodeModel.GetById 38ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/war/src/main/webapp/plugins/symphony-news-getter/plugin.ftl

http://github.com/b3log/b3log-solo
Freemarker Template | 64 lines | 57 code | 7 blank | 0 comment | 0 complexity | d62499413dc9392eebf32abc1cdf31db MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
 1<link type="text/css" rel="stylesheet" href="${staticServePath}/plugins/symphony-news-getter/style.css"/>
 2<div id="symphonyNewsGetterPanel">
 3    <div class="module-panel">
 4        <div class="module-header">
 5            <h2>${b3logAnnounceLabel}</h2>
 6        </div>
 7        <div class="module-body padding12">
 8            <div id="symphonyNewsGetter">
 9            </div>
10        </div>
11    </div>
12</div>
13<script type="text/javascript">
14    plugins.symphonyNewsGetter = {
15        init: function () {
16            $("#loadMsg").text("${loadingLabel}");
17            
18            $("#symphonyNewsGetter").css("background",
19            "url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent");
20            
21            $.ajax({
22                url: "http://symphony.b3log.org:80/get-news",
23                type: "GET",
24                dataType:"jsonp",
25                jsonp: "callback",
26                error: function(){
27                    $("#symphonyNewsGetter").html("Loading B3log Announcement failed :-(").css("background", "none");
28                },
29                success: function(data, textStatus){
30                    var articles = data.articles;
31                    if (0 === articles.length) {
32                        return;
33                    }
34            
35                    var listHTML = "<ul>";
36                    for (var i = 0; i < articles.length; i++) {
37                        var article = articles[i];
38                        var articleLiHtml = "<li>"
39                            + "<a target='_blank' href='" + article.articlePermalink + "'>"
40                            +  article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateDate, 1); + "</span></li>"
41                        listHTML += articleLiHtml
42                    }
43                    listHTML += "</ul>";
44                    
45                    $("#symphonyNewsGetter").html(listHTML).css("background", "none");
46                }
47            });
48            
49            $("#loadMsg").text("");
50        }
51    };
52    
53    /*
54     * ????
55     */
56    admin.plugin.add({
57        "id": "symphonyNewsGetter",
58        "path": "/main/panel1",
59        "content": $("#symphonyNewsGetterPanel").html()
60    });
61    
62    // ??????
63    $("#symphonyNewsGetterPanel").remove();
64</script>