Refactor info page.

This commit is contained in:
Lars Jung 2015-05-14 14:22:40 +02:00
parent 9090c28f04
commit 95f087cfd6
3 changed files with 37 additions and 26 deletions

View file

@ -10,11 +10,3 @@ block body
div#content div#content
h1#header h1#header
a(href='#{pkg.homepage}') #{pkg.name} a(href='#{pkg.homepage}') #{pkg.name}
div#support
| Show your support with a donation!
div.paypal
form(action='https://www.paypal.com/cgi-bin/webscr', method='post', target='_blank')
input(type='hidden', name='cmd', value='_s-xclick')
input(type='hidden', name='hosted_button_id', value='8WSPKWT7YBTSQ')
input(type='image', src!='#{public_href}images/ui/paypal.svg', name='submit', alt='PayPal')

View file

@ -33,20 +33,17 @@
} }
#support { #support {
margin: 12px auto 24px auto; margin: 24px auto;
padding: 6px 18px; padding: 18px 0 6px 0;
width: 210px; width: 292px;
background: @col-back-panel; background: @col-back-panel;
border: 1px solid @col-border; border: 1px solid @col-border;
border-radius: 4px; border-radius: 4px;
.paypal {
margin: 12px 0 0 0;
}
input[type="image"] { input[type="image"] {
border: 0; border: 0;
width: 100px; width: 100px;
padding: 12px 48px;
} }
} }
@ -78,7 +75,7 @@
display: inline-block; display: inline-block;
text-align: left; text-align: left;
list-style-type: none; list-style-type: none;
margin: 96px 0; margin: 48px 0;
padding: 0; padding: 0;
.test { .test {

View file

@ -1,14 +1,14 @@
modulejs.define('main/info', ['$', 'config', 'core/server'], function ($, config, server) { modulejs.define('main/info', ['$', 'config', 'core/resource', 'core/server'], function ($, config, resource, server) {
var testsTemp = var tplTests =
'<ul id="tests">'; '<ul id="tests">';
var testTemp = var tplTest =
'<li class="test">' + '<li class="test">' +
'<span class="label"></span>' + '<span class="label"></span>' +
'<span class="result"></span>' + '<span class="result"></span>' +
'<div class="info"></div>' + '<div class="info"></div>' +
'</li>'; '</li>';
var loginTemp = var tplLogin =
'<div id="login-wrapper">' + '<div id="login-wrapper">' +
'<input id="pass" type="password" placeholder="password"/>' + '<input id="pass" type="password" placeholder="password"/>' +
'<span id="login">login</span>' + '<span id="login">login</span>' +
@ -18,12 +18,23 @@ modulejs.define('main/info', ['$', 'config', 'core/server'], function ($, config
'Change it in \'_h5ai/conf/options.json\'.' + 'Change it in \'_h5ai/conf/options.json\'.' +
'</div>' + '</div>' +
'</div>'; '</div>';
var tplSupport =
'<div id="support">' +
'Show your support with a donation!' +
'<div class="paypal">' +
'<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">' +
'<input type="hidden" name="cmd" value="_s-xclick" />' +
'<input type="hidden" name="hosted_button_id" value="8WSPKWT7YBTSQ" />' +
'<input type="image" src="' + resource.image('paypal') + '" name="submit" alt="PayPal" />' +
'</form>' +
'</div>' +
'</div>';
var setup = config.setup; var setup = config.setup;
function addTest(label, info, passed, result) { function addTest(label, info, passed, result) {
var $test = $(testTemp).appendTo('#tests'); var $test = $(tplTest).appendTo('#tests');
$test.find('.label').text(label); $test.find('.label').text(label);
$test.find('.result') $test.find('.result')
.addClass(passed ? 'passed' : 'failed') .addClass(passed ? 'passed' : 'failed')
@ -33,13 +44,20 @@ modulejs.define('main/info', ['$', 'config', 'core/server'], function ($, config
function addTests() { function addTests() {
$(testsTemp).appendTo('#content'); $(tplTests).appendTo('#content');
addTest( addTest(
'h5ai version', 'Only green if this is an official h5ai release', 'h5ai version', 'Only green if this is an official h5ai release',
/^\d+\.\d+\.\d+$/.test(setup.VERSION), setup.VERSION /^\d+\.\d+\.\d+$/.test(setup.VERSION), setup.VERSION
); );
if (setup.AS_ADMIN) {
addAdminTests();
}
}
function addAdminTests() {
addTest( addTest(
'Index file found', 'Add <code>' + setup.INDEX_HREF + '</code> to your index file list', 'Index file found', 'Add <code>' + setup.INDEX_HREF + '</code> to your index file list',
setup.INDEX_HREF setup.INDEX_HREF
@ -133,9 +151,14 @@ modulejs.define('main/info', ['$', 'config', 'core/server'], function ($, config
} }
} }
function addSupport() {
$(tplSupport).appendTo('#content');
}
function addLogin() { function addLogin() {
$(loginTemp).appendTo('#content'); $(tplLogin).appendTo('#content');
if (setup.AS_ADMIN) { if (setup.AS_ADMIN) {
$('#pass').remove(); $('#pass').remove();
@ -153,10 +176,9 @@ modulejs.define('main/info', ['$', 'config', 'core/server'], function ($, config
function init() { function init() {
addSupport();
addLogin(); addLogin();
if (setup.AS_ADMIN) { addTests();
addTests();
}
} }