function ffpad(n) { return n < 10 ? '0' + n : n } var ff_newstemplate_success = '\
\
\ \ \ \ \
\
\
\
\
News
\
\
    \ <% json.news.forEach(function(item, i) { %>\ <% var date = new Date(item.timestamp) %>\
  • \
    <%= ffpad(date.getDate()) %>.<%= ffpad(date.getMonth() + 1) %>.<%= date.getFullYear() %>
    \
    <%= item.title %>
    \
    <%= item.text %>
    \ <% if(item.link) { %>\ \ <% } %>\
  • \ <% }) %> \
\
\
\
\
\
\
System Requirements
\
\
    \
  • \
    WordPress
    \ <% if (requirements.wp_status) { %>\
    ✔︎\ <% } else { %>\
    ✘\ <% } %>\ Version <%= requirements.wp %>\
    \
  • \
  • \
    PHP
    \ <% if (requirements.php_status) { %>\
    ✔︎\ <% } else { %>\
    ✘\ <% } %>\ Version <%= requirements.php %>\
    \
  • \
  • \
    Memory Limit
    \ <% if (requirements.memory_status) { %>\
    ✔︎\ <% } else { %>\
    ✘\ <% } %>\ <%= requirements.memory %>\
    \
  • \
  • \
    Upload Max. Filesize
    \ <% if (requirements.upload_status) { %>\
    ✔︎\ <% } else { %>\
    ✘\ <% } %>\ <%= requirements.upload %>\ <% if (!requirements.upload_status) { %>\ (Recommended 64M)\ <% } %>\ \
    \
  • \
\
\
\
\
\
\
Need Help?
\
\ \ <% json.buttons.forEach(function(item, i){ %>\ \ <% }) %>\
\
\
\
\
\
\
\
Social Stream Applications
\
\
<%= json.apps.title %>
\

<%= json.apps.description %>

\
    \ <% for(var key in json.apps.items){ %>\
  • \
    \ \
    \
    \
    <%= json.apps.items[key].name %>
    \
    <%= json.apps.items[key].description %>
    \ \
    \
  • \ <% } %>\
\
\
\
\
\
'; var ff_newstemplate_error = '\
Something went wrong, please try to reload.
'; (function ($) { $(document).ready(function () { function fetchJSON() { return $.ajax({ type: 'GET', timeout: 10000, url: location.protocol + '//flow.looks-awesome.com/service/news/news-1.1.json', data: { field: 'test' }, dataType: 'jsonp', jsonpCallback: 'grace', crossDomain: true }) } function renderPage(json) { var $el = $('#news_page') var tpl = _.template(ff_newstemplate_success) var html = tpl({ assets_url: FFIADMIN.assets_url, requirements: FFIADMIN.requirements, json: json, plugins: FFIADMIN.plugins }) $el.html(html) } function renderError() { var $el = $('#news_page') var tpl = _.template(ff_newstemplate_error) var html = tpl({}) $el.html(html) } var request = fetchJSON() request.done(function (data) { renderPage(data); }).fail(function (err) { renderError() }) }) })(jQuery)