Separate JS and CSS into external files. See #18
This commit is contained in:
parent
6ee0b57434
commit
7ad996ce7c
|
@ -64,104 +64,15 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($build->getStatus() == 0 || $build->getStatus() == 1 || true): ?>
|
||||
<script>
|
||||
setInterval(function()
|
||||
{
|
||||
$.getJSON('/build/data/<?php print $build->getId(); ?>', updateBuildView);
|
||||
}, 10000);
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<script>
|
||||
window.initial = <?php print $data; ?>;
|
||||
|
||||
function updateBuildView(data)
|
||||
<?php if($build->getStatus() == 0 || $build->getStatus() == 1 || true): ?>
|
||||
setInterval(function()
|
||||
{
|
||||
console.log(data);
|
||||
$('#status').attr('class', 'alert');
|
||||
|
||||
var cls;
|
||||
var msg;
|
||||
|
||||
switch(data.status)
|
||||
{
|
||||
case 0:
|
||||
cls = 'alert-info';
|
||||
msg = 'This build has not yet started.';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cls = 'alert-warning';
|
||||
msg = 'This build is in progress.';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cls = 'alert-success';
|
||||
msg = 'This build was successful!';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
cls = 'alert-error';
|
||||
msg = 'This build has failed.';
|
||||
break;
|
||||
}
|
||||
|
||||
$('#status').addClass(cls).text(msg);
|
||||
|
||||
if(data.created)
|
||||
{
|
||||
$('#created').text(data.created);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#created').text('Not created yet.');
|
||||
}
|
||||
|
||||
if(data.started)
|
||||
{
|
||||
$('#started').text(data.started);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#started').text('Not started yet.');
|
||||
}
|
||||
|
||||
if(data.finished)
|
||||
{
|
||||
$('#finished').text(data.finished);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#finished').text('Not finished yet.');
|
||||
}
|
||||
|
||||
if(data.plugins)
|
||||
{
|
||||
$('#plugins').empty();
|
||||
|
||||
for(var plugin in data.plugins)
|
||||
{
|
||||
var row = $('<tr>').addClass(data.plugins[plugin] ? 'success' : 'error');
|
||||
var name = $('<td>').html('<strong>' + plugin + '</strong>');
|
||||
var status = $('<td>').text(data.plugins[plugin] ? 'OK' : 'Failed');
|
||||
|
||||
row.append(name);
|
||||
row.append(status);
|
||||
$('#plugins').append(row);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var row = $('<tr>');
|
||||
var col = $('<td>').attr('colspan', 2).text('No plugins have run yet.');
|
||||
|
||||
row.append(col);
|
||||
$('#plugins').empty().append(row);
|
||||
}
|
||||
|
||||
$('#log').html(data.log);
|
||||
}
|
||||
$.getJSON('/build/data/<?php print $build->getId(); ?>', updateBuildView);
|
||||
}, 10000);
|
||||
<?php endif; ?>
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
|
|
|
@ -8,69 +8,10 @@
|
|||
|
||||
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900,300italic' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/phpci.css">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script src="/assets/js/bootstrap.min.js"></script>
|
||||
|
||||
<style>
|
||||
body
|
||||
{
|
||||
background: #246;
|
||||
font-family: Roboto, Arial, Sans-Serif;
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
padding-top: 70px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
background: #fff;
|
||||
border: 10px solid #369;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.widget-title, .modal-header, .table th, div.dataTables_wrapper .ui-widget-header, .ui-dialog .ui-dialog-titlebar {
|
||||
background-color: #efefef;
|
||||
background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea));
|
||||
background-image: -webkit-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -moz-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -ms-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -o-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#eaeaea',GradientType=0 ); /* IE6-9 */
|
||||
border-bottom: 1px solid #CDCDCD;
|
||||
}
|
||||
|
||||
#title
|
||||
{
|
||||
background: #f8f8f8;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin: -10px -10px 15px -10px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#title h1
|
||||
{
|
||||
font-size: 2em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
|
||||
function confirmDelete(url)
|
||||
{
|
||||
if(confirm('Are you sure you want to delete this?'))
|
||||
{
|
||||
window.location.href = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<script src="/assets/js/phpci.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
|
|
|
@ -22,84 +22,18 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
window.return_url = <?php print json_encode((empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); ?>
|
||||
<?php
|
||||
$gh = \b8\Registry::getInstance()->get('github_app', null);
|
||||
|
||||
if($gh)
|
||||
{
|
||||
if($gh) {
|
||||
print 'window.github_app_id = ' . json_encode($gh['id']) . ';' . PHP_EOL;
|
||||
}
|
||||
|
||||
if(!empty($token))
|
||||
{
|
||||
if(!empty($token)) {
|
||||
print 'window.github_token = ' . json_encode($token) . ';' . PHP_EOL;
|
||||
}
|
||||
?>
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#element-reference').change(function()
|
||||
{
|
||||
var el = $(this);
|
||||
var val = el.val();
|
||||
|
||||
var acceptable = {
|
||||
'github_ssh': /git\@github\.com\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'github_git': /git\:\/\/github.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'github_http': /https\:\/\/github\.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/,
|
||||
'bb_ssh': /git\@bitbucket\.org\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'bb_http': /https\:\/\/[a-zA-Z0-9_\-]+\@bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'bb_anon': /https\:\/\/bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
|
||||
};
|
||||
|
||||
for(var i in acceptable) {
|
||||
if(val.match(acceptable[i])) {
|
||||
el.val(val.replace(acceptable[i], '$1'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#element-type').change(function()
|
||||
{
|
||||
if(!window.github_app_id || $(this).val() != 'github' || window.github_token) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show sign in with Github button.
|
||||
var el = $('#element-reference');
|
||||
var rtn = <?php print json_encode((empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); ?>;
|
||||
var url = 'https://github.com/login/oauth/authorize?client_id=' + window.github_app_id + '&scope=repo&redirect_uri=' + rtn;
|
||||
var btn = $('<a>').addClass('btn btn-inverse').text('Sign in with Github').attr('href', url);
|
||||
|
||||
el.after(btn);
|
||||
el.remove();
|
||||
});
|
||||
|
||||
$('#element-github').change(function()
|
||||
{
|
||||
var val = $('#element-github').val();
|
||||
|
||||
if(val != 'choose') {
|
||||
$('#element-type').val('github');
|
||||
$('#element-reference').val(val);
|
||||
|
||||
$('label[for=element-reference]').hide();
|
||||
$('label[for=element-type]').hide();
|
||||
$('#element-reference').hide();
|
||||
$('#element-type').hide();
|
||||
$('#element-token').val(window.github_token);
|
||||
$('#element-title').val(val);
|
||||
}
|
||||
else {
|
||||
$('label[for=element-reference]').show();
|
||||
$('label[for=element-type]').show();
|
||||
$('#element-reference').show();
|
||||
$('#element-type').show();
|
||||
$('#element-reference').val('');
|
||||
$('#element-token').val('');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(setupProjectForm);
|
||||
</script>
|
42
assets/css/phpci.css
Normal file
42
assets/css/phpci.css
Normal file
|
@ -0,0 +1,42 @@
|
|||
body
|
||||
{
|
||||
background: #246;
|
||||
font-family: Roboto, Arial, Sans-Serif;
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
padding-top: 70px;
|
||||
}
|
||||
|
||||
#content
|
||||
{
|
||||
background: #fff;
|
||||
border: 10px solid #369;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.widget-title, .modal-header, .table th, div.dataTables_wrapper .ui-widget-header, .ui-dialog .ui-dialog-titlebar {
|
||||
background-color: #efefef;
|
||||
background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea));
|
||||
background-image: -webkit-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -moz-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -ms-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -o-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
background-image: -linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#eaeaea',GradientType=0 ); /* IE6-9 */
|
||||
border-bottom: 1px solid #CDCDCD;
|
||||
}
|
||||
|
||||
#title
|
||||
{
|
||||
background: #f8f8f8;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin: -10px -10px 15px -10px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#title h1
|
||||
{
|
||||
font-size: 2em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
BIN
assets/js/.DS_Store
vendored
BIN
assets/js/.DS_Store
vendored
Binary file not shown.
171
assets/js/phpci.js
Normal file
171
assets/js/phpci.js
Normal file
|
@ -0,0 +1,171 @@
|
|||
/**
|
||||
* Used for delete buttons in the system, just to prevent accidental clicks.
|
||||
*/
|
||||
function confirmDelete(url)
|
||||
{
|
||||
if(confirm('Are you sure you want to delete this?'))
|
||||
{
|
||||
window.location.href = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the build screen. Called at regular intervals on /build/view/X
|
||||
*/
|
||||
function updateBuildView(data)
|
||||
{
|
||||
$('#status').attr('class', 'alert');
|
||||
|
||||
var cls;
|
||||
var msg;
|
||||
|
||||
switch(data.status)
|
||||
{
|
||||
case 0:
|
||||
cls = 'alert-info';
|
||||
msg = 'This build has not yet started.';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cls = 'alert-warning';
|
||||
msg = 'This build is in progress.';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cls = 'alert-success';
|
||||
msg = 'This build was successful!';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
cls = 'alert-error';
|
||||
msg = 'This build has failed.';
|
||||
break;
|
||||
}
|
||||
|
||||
$('#status').addClass(cls).text(msg);
|
||||
|
||||
if(data.created)
|
||||
{
|
||||
$('#created').text(data.created);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#created').text('Not created yet.');
|
||||
}
|
||||
|
||||
if(data.started)
|
||||
{
|
||||
$('#started').text(data.started);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#started').text('Not started yet.');
|
||||
}
|
||||
|
||||
if(data.finished)
|
||||
{
|
||||
$('#finished').text(data.finished);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#finished').text('Not finished yet.');
|
||||
}
|
||||
|
||||
if(data.plugins)
|
||||
{
|
||||
$('#plugins').empty();
|
||||
|
||||
for(var plugin in data.plugins)
|
||||
{
|
||||
var row = $('<tr>').addClass(data.plugins[plugin] ? 'success' : 'error');
|
||||
var name = $('<td>').html('<strong>' + plugin + '</strong>');
|
||||
var status = $('<td>').text(data.plugins[plugin] ? 'OK' : 'Failed');
|
||||
|
||||
row.append(name);
|
||||
row.append(status);
|
||||
$('#plugins').append(row);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var row = $('<tr>');
|
||||
var col = $('<td>').attr('colspan', 2).text('No plugins have run yet.');
|
||||
|
||||
row.append(col);
|
||||
$('#plugins').empty().append(row);
|
||||
}
|
||||
|
||||
$('#log').html(data.log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to initialise the project form:
|
||||
*/
|
||||
function setupProjectForm()
|
||||
{
|
||||
$('#element-reference').change(function()
|
||||
{
|
||||
var el = $(this);
|
||||
var val = el.val();
|
||||
|
||||
var acceptable = {
|
||||
'github_ssh': /git\@github\.com\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'github_git': /git\:\/\/github.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'github_http': /https\:\/\/github\.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/,
|
||||
'bb_ssh': /git\@bitbucket\.org\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'bb_http': /https\:\/\/[a-zA-Z0-9_\-]+\@bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
||||
'bb_anon': /https\:\/\/bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
|
||||
};
|
||||
|
||||
for(var i in acceptable) {
|
||||
if(val.match(acceptable[i])) {
|
||||
el.val(val.replace(acceptable[i], '$1'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#element-type').change(function()
|
||||
{
|
||||
if(!window.github_app_id || $(this).val() != 'github' || window.github_token) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show sign in with Github button.
|
||||
var el = $('#element-reference');
|
||||
var rtn = window.return_url;
|
||||
var url = 'https://github.com/login/oauth/authorize?client_id=' + window.github_app_id + '&scope=repo&redirect_uri=' + rtn;
|
||||
var btn = $('<a>').addClass('btn btn-inverse').text('Sign in with Github').attr('href', url);
|
||||
|
||||
el.after(btn);
|
||||
el.remove();
|
||||
});
|
||||
|
||||
$('#element-github').change(function()
|
||||
{
|
||||
var val = $('#element-github').val();
|
||||
|
||||
if(val != 'choose') {
|
||||
$('#element-type').val('github');
|
||||
$('#element-reference').val(val);
|
||||
|
||||
$('label[for=element-reference]').hide();
|
||||
$('label[for=element-type]').hide();
|
||||
$('#element-reference').hide();
|
||||
$('#element-type').hide();
|
||||
$('#element-token').val(window.github_token);
|
||||
$('#element-title').val(val);
|
||||
}
|
||||
else {
|
||||
$('label[for=element-reference]').show();
|
||||
$('label[for=element-type]').show();
|
||||
$('#element-reference').show();
|
||||
$('#element-type').show();
|
||||
$('#element-reference').val('');
|
||||
$('#element-token').val('');
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue