2014-12-02 17:26:55 +01:00
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
var PHPCensor = {
|
2014-12-02 17:26:55 +01:00
|
|
|
|
intervals: {},
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
// Update latest builds every 5 seconds:
|
2016-07-19 20:28:11 +02:00
|
|
|
|
PHPCensor.getBuilds();
|
|
|
|
|
PHPCensor.intervals.getBuilds = setInterval(PHPCensor.getBuilds, 5000);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
|
|
|
|
// Update latest project builds every 10 seconds:
|
2016-07-21 17:20:34 +02:00
|
|
|
|
if (typeof PROJECT_ID != 'undefined') {
|
2016-07-19 20:28:11 +02:00
|
|
|
|
PHPCensor.intervals.getProjectBuilds = setInterval(PHPCensor.getProjectBuilds, 10000);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
}
|
2017-01-15 04:39:48 +01:00
|
|
|
|
|
|
|
|
|
if (typeof DASHBOARD != 'undefined') {
|
|
|
|
|
PHPCensor.intervals.getDashboard = setInterval(PHPCensor.getDashboard, 10000);
|
|
|
|
|
PHPCensor.intervals.getTimeline = setInterval(PHPCensor.getTimeline, 10000);
|
|
|
|
|
}
|
2014-12-02 17:26:55 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(window).on('builds-updated', function (e, data) {
|
2016-07-19 20:28:11 +02:00
|
|
|
|
PHPCensor.updateHeaderBuilds(data);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getBuilds: function () {
|
|
|
|
|
$.ajax({
|
2017-01-14 19:11:32 +01:00
|
|
|
|
url: APP_URL + 'build/ajax-queue',
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
|
|
|
|
success: function (data) {
|
2015-02-12 13:38:22 +01:00
|
|
|
|
$(window).trigger('builds-updated', [data]);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
},
|
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
error: PHPCensor.handleFailedAjax
|
2014-12-02 17:26:55 +01:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getProjectBuilds: function () {
|
|
|
|
|
$.ajax({
|
2017-03-23 13:53:24 +01:00
|
|
|
|
url: APP_URL + 'project/ajax-builds/' + PROJECT_ID + '?branch=' + PROJECT_BRANCH + '&environment=' + PROJECT_ENVIRONMENT + '&per_page=' + PER_PAGE,
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#latest-builds').html(data);
|
|
|
|
|
},
|
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
error: PHPCensor.handleFailedAjax
|
2014-12-02 17:26:55 +01:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2017-01-14 19:11:32 +01:00
|
|
|
|
getDashboard: function () {
|
|
|
|
|
$('.project-box').each(function(index) {
|
|
|
|
|
var projectId = this.id.substring(12);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: APP_URL + 'project/ajax-dashboard-project/' + projectId,
|
|
|
|
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$(('#project-box-' + projectId)).html(data);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
error: PHPCensor.handleFailedAjax
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getTimeline: function () {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: APP_URL + 'build/ajax-timeline',
|
|
|
|
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#timeline-box').html(data);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
error: PHPCensor.handleFailedAjax
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2014-12-02 17:26:55 +01:00
|
|
|
|
updateHeaderBuilds: function (data) {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-pending-list').empty();
|
|
|
|
|
$('.app-running-list').empty();
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
|
|
|
|
if (!data.pending.count) {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-pending').hide();
|
2014-12-02 17:26:55 +01:00
|
|
|
|
} else {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-pending').show();
|
|
|
|
|
$('.app-pending .header').text(Lang.get('n_builds_pending', data.pending.count));
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
|
|
|
|
$.each(data.pending.items, function (idx, build) {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-pending-list').append(build.header_row);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data.running.count) {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-running').hide();
|
2014-12-02 17:26:55 +01:00
|
|
|
|
} else {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-running').show();
|
|
|
|
|
$('.app-running .header').text(Lang.get('n_builds_running', data.running.count));
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
|
|
|
|
$.each(data.running.items, function (idx, build) {
|
2016-07-21 19:02:11 +02:00
|
|
|
|
$('.app-running-list').append(build.header_row);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-15 11:07:54 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get: function (uri, success) {
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
2016-07-21 17:20:34 +02:00
|
|
|
|
url: window.APP_URL + uri,
|
2015-10-15 11:07:54 +02:00
|
|
|
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
success();
|
|
|
|
|
},
|
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
error: PHPCensor.handleFailedAjax
|
2015-10-15 11:07:54 +02:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleFailedAjax: function (xhr) {
|
|
|
|
|
if (xhr.status == 401) {
|
2016-07-21 17:20:34 +02:00
|
|
|
|
window.location.href = window.APP_URL + 'session/login';
|
2015-10-15 11:07:54 +02:00
|
|
|
|
}
|
2014-12-02 17:26:55 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
PHPCensor.init();
|
2014-12-02 17:26:55 +01:00
|
|
|
|
|
2015-10-15 11:07:54 +02:00
|
|
|
|
function handleFailedAjax(xhr) {
|
2016-07-19 20:28:11 +02:00
|
|
|
|
PHPCensor.handleFailedAjax(xhr);
|
2014-12-02 17:26:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-27 15:09:14 +01:00
|
|
|
|
/**
|
|
|
|
|
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
|
|
|
|
|
* for the details of code below
|
|
|
|
|
*/
|
|
|
|
|
if (!Function.prototype.bind) {
|
|
|
|
|
Function.prototype.bind = function (oThis) {
|
|
|
|
|
if (typeof this !== "function") {
|
|
|
|
|
// closest thing possible to the ECMAScript 5 internal IsCallable function
|
|
|
|
|
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var aArgs = Array.prototype.slice.call(arguments, 1),
|
|
|
|
|
fToBind = this,
|
|
|
|
|
fNOP = function () {
|
|
|
|
|
},
|
|
|
|
|
fBound = function () {
|
|
|
|
|
return fToBind.apply(this instanceof fNOP && oThis
|
|
|
|
|
? this
|
|
|
|
|
: oThis,
|
|
|
|
|
aArgs.concat(Array.prototype.slice.call(arguments)));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fNOP.prototype = this.prototype;
|
|
|
|
|
fBound.prototype = new fNOP();
|
|
|
|
|
|
|
|
|
|
return fBound;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-16 02:59:27 +02:00
|
|
|
|
/**
|
2014-12-02 17:26:55 +01:00
|
|
|
|
* Used for delete buttons in the system, just to prevent accidental clicks.
|
|
|
|
|
*/
|
2017-01-14 10:58:55 +01:00
|
|
|
|
function confirmDelete(url, reloadAfter) {
|
2013-11-27 15:09:14 +01:00
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
var dialog = new PHPCensorConfirmDialog({
|
2017-01-14 10:58:55 +01:00
|
|
|
|
title: Lang.get('confirm_title'),
|
|
|
|
|
message: Lang.get('confirm_message'),
|
|
|
|
|
confirmBtnCaption: Lang.get('confirm_ok'),
|
|
|
|
|
cancelBtnCaption: Lang.get('confirm_cancel'),
|
2013-11-27 15:09:14 +01:00
|
|
|
|
/*
|
|
|
|
|
confirm-btn click handler
|
|
|
|
|
*/
|
|
|
|
|
confirmed: function (e) {
|
|
|
|
|
var dialog = this;
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Call delete URL
|
|
|
|
|
*/
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
2014-07-30 15:32:38 +02:00
|
|
|
|
success: function (data) {
|
2013-11-27 18:04:24 +01:00
|
|
|
|
if (reloadAfter) {
|
|
|
|
|
dialog.onClose = function () {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
};
|
2013-11-27 15:09:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-14 10:58:55 +01:00
|
|
|
|
dialog.showStatusMessage(Lang.get('confirm_success'), 500);
|
2013-11-27 15:09:14 +01:00
|
|
|
|
},
|
2014-07-30 15:32:38 +02:00
|
|
|
|
error: function (data) {
|
2017-01-14 10:58:55 +01:00
|
|
|
|
dialog.showStatusMessage(Lang.get('confirm_failed') + data.statusText);
|
2014-07-30 15:32:38 +02:00
|
|
|
|
|
|
|
|
|
if (data.status == 401) {
|
|
|
|
|
handleFailedAjax(data);
|
|
|
|
|
}
|
2013-11-27 15:09:14 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dialog.show();
|
2013-11-27 18:04:24 +01:00
|
|
|
|
return dialog;
|
2013-11-27 15:09:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-07-19 20:28:11 +02:00
|
|
|
|
* PHPCensorConfirmDialog constructor options object
|
2013-11-27 15:09:14 +01:00
|
|
|
|
* @type {{message: string, title: string, confirmBtnCaption: string, cancelBtnCaption: string, confirmed: Function}}
|
|
|
|
|
*/
|
2016-07-19 20:28:11 +02:00
|
|
|
|
var PHPCensorConfirmDialogOptions = {
|
2017-01-14 10:58:55 +01:00
|
|
|
|
message: 'Are you sure?',
|
|
|
|
|
title: 'Confirmation',
|
2013-11-27 15:09:14 +01:00
|
|
|
|
confirmBtnCaption: 'Ok',
|
|
|
|
|
cancelBtnCaption: 'Cancel',
|
|
|
|
|
confirmed: function (e) {
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
var PHPCensorConfirmDialog = Class.extend({
|
2013-12-07 16:35:44 +01:00
|
|
|
|
/**
|
|
|
|
|
* @private
|
|
|
|
|
* @var {bool} Determines whether the dialog has been confirmed
|
|
|
|
|
*/
|
|
|
|
|
confirmed: false,
|
2014-08-01 11:09:04 +02:00
|
|
|
|
|
2013-11-27 15:09:14 +01:00
|
|
|
|
/**
|
2016-07-19 20:28:11 +02:00
|
|
|
|
* @param {PHPCensorConfirmDialogOptions} options
|
2013-11-27 15:09:14 +01:00
|
|
|
|
*/
|
|
|
|
|
init: function (options) {
|
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
|
options = options ? $.extend(PHPCensorConfirmDialogOptions, options) : PHPCensorConfirmDialogOptions;
|
2013-11-27 15:09:14 +01:00
|
|
|
|
|
|
|
|
|
if (!$('#confirm-dialog').length) {
|
|
|
|
|
/*
|
|
|
|
|
Add the dialog html to a page on first use. No need to have it there before first use.
|
|
|
|
|
*/
|
|
|
|
|
$('body').append(
|
|
|
|
|
'<div class="modal fade" id="confirm-dialog">'
|
2017-01-13 19:01:41 +01:00
|
|
|
|
+ '<div class="modal-dialog">'
|
|
|
|
|
+ '<div class="modal-content">'
|
|
|
|
|
+ '<div class="modal-header">'
|
|
|
|
|
+ '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'
|
|
|
|
|
+ '<h4 class="modal-title"></h4>'
|
|
|
|
|
+ '</div>'
|
|
|
|
|
+ '<div class="modal-body">'
|
|
|
|
|
+ '<p></p>'
|
|
|
|
|
+ '</div>'
|
|
|
|
|
+ '<div class="modal-footer">'
|
|
|
|
|
+ '<button id="confirm-cancel" type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>'
|
|
|
|
|
+ '<button id="confirm-ok" type="button" class="btn btn-danger"></button>'
|
|
|
|
|
+ '</div>'
|
|
|
|
|
+ '</div>'
|
|
|
|
|
+ '</div>'
|
|
|
|
|
+ '</div>'
|
2013-11-27 15:09:14 +01:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Define dialog controls
|
|
|
|
|
*/
|
|
|
|
|
this.$dialog = $('#confirm-dialog');
|
2017-01-13 19:01:41 +01:00
|
|
|
|
this.$cancelBtn = this.$dialog.find('#confirm-cancel');
|
|
|
|
|
this.$confirmBtn = this.$dialog.find('#confirm-ok');
|
2013-11-27 15:09:14 +01:00
|
|
|
|
this.$title = this.$dialog.find('h4.modal-title');
|
|
|
|
|
this.$body = this.$dialog.find('div.modal-body');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Initialize its values
|
|
|
|
|
*/
|
2016-07-19 20:28:11 +02:00
|
|
|
|
this.$title.html(options.title ? options.title : PHPCensorConfirmDialogOptions.title);
|
|
|
|
|
this.$body.html(options.message ? options.message : PHPCensorConfirmDialogOptions.message);
|
2013-11-27 15:09:14 +01:00
|
|
|
|
this.$confirmBtn.html(
|
2016-07-19 20:28:11 +02:00
|
|
|
|
options.confirmBtnCaption ? options.confirmBtnCaption : PHPCensorConfirmDialogOptions.confirmBtnCaption
|
2013-11-27 15:09:14 +01:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.$cancelBtn.html(
|
2016-07-19 20:28:11 +02:00
|
|
|
|
options.cancelBtnCaption ? options.cancelBtnCaption : PHPCensorConfirmDialogOptions.cancelBtnCaption
|
2013-11-27 15:09:14 +01:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Events
|
|
|
|
|
*/
|
|
|
|
|
this.confirmBtnClick = options.confirmed;
|
|
|
|
|
|
|
|
|
|
/*
|
2013-11-27 18:04:24 +01:00
|
|
|
|
Re-bind handlers
|
2013-11-27 15:09:14 +01:00
|
|
|
|
*/
|
|
|
|
|
this.$confirmBtn.unbind('click');
|
|
|
|
|
this.$confirmBtn.click(this.onConfirm.bind(this));
|
|
|
|
|
|
2013-11-27 18:04:24 +01:00
|
|
|
|
this.$confirmBtn.unbind('hidden.bs.modal');
|
2013-12-07 16:35:44 +01:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Bind the close event of the dialog to the set of onClose* methods
|
|
|
|
|
*/
|
2013-11-27 18:04:24 +01:00
|
|
|
|
this.$dialog.on('hidden.bs.modal', function () {this.onClose()}.bind(this));
|
2013-12-07 16:35:44 +01:00
|
|
|
|
this.$dialog.on('hidden.bs.modal', function () {
|
|
|
|
|
if (this.confirmed) {
|
|
|
|
|
this.onCloseConfirmed();
|
|
|
|
|
} else {
|
|
|
|
|
this.onCloseCanceled();
|
|
|
|
|
}
|
|
|
|
|
}.bind(this));
|
2013-11-27 18:04:24 +01:00
|
|
|
|
|
2013-11-27 15:09:14 +01:00
|
|
|
|
/*
|
2014-12-02 17:26:55 +01:00
|
|
|
|
Restore state if was changed previously
|
2013-11-27 15:09:14 +01:00
|
|
|
|
*/
|
|
|
|
|
this.$cancelBtn.show();
|
|
|
|
|
this.$confirmBtn.show();
|
2013-12-07 16:35:44 +01:00
|
|
|
|
this.confirmed = false;
|
2013-11-27 15:09:14 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show dialog
|
|
|
|
|
*/
|
|
|
|
|
show: function () {
|
|
|
|
|
this.$dialog.modal('show');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hide dialog
|
|
|
|
|
*/
|
|
|
|
|
close: function () {
|
|
|
|
|
this.$dialog.modal('hide');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onConfirm: function (e) {
|
2013-12-07 16:35:44 +01:00
|
|
|
|
this.confirmed = true;
|
2013-11-27 15:09:14 +01:00
|
|
|
|
$(this).attr('disabled', 'disabled');
|
|
|
|
|
this.confirmBtnClick(e);
|
|
|
|
|
},
|
|
|
|
|
|
2013-12-07 16:35:44 +01:00
|
|
|
|
/**
|
|
|
|
|
* Called only when confirmed dialog was closed
|
|
|
|
|
*/
|
|
|
|
|
onCloseConfirmed: function () {},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called only when canceled dialog was closed
|
|
|
|
|
*/
|
|
|
|
|
onCloseCanceled: function () {},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called always when the dialog was closed
|
|
|
|
|
*/
|
2013-11-27 18:04:24 +01:00
|
|
|
|
onClose: function () {},
|
|
|
|
|
|
2013-11-27 15:09:14 +01:00
|
|
|
|
showStatusMessage: function (message, closeTimeout) {
|
|
|
|
|
this.$confirmBtn.hide();
|
2017-01-14 10:58:55 +01:00
|
|
|
|
this.$cancelBtn.hide();
|
2013-11-27 15:09:14 +01:00
|
|
|
|
|
|
|
|
|
/*
|
2014-12-02 17:26:55 +01:00
|
|
|
|
Status message
|
2013-11-27 15:09:14 +01:00
|
|
|
|
*/
|
|
|
|
|
this.$body.html(message);
|
|
|
|
|
|
|
|
|
|
if (closeTimeout) {
|
|
|
|
|
window.setTimeout(function () {
|
|
|
|
|
/*
|
|
|
|
|
Hide the dialog
|
|
|
|
|
*/
|
|
|
|
|
this.close();
|
|
|
|
|
}.bind(this), closeTimeout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-16 02:59:27 +02:00
|
|
|
|
/**
|
2014-12-02 17:26:55 +01:00
|
|
|
|
* Used to initialise the project form:
|
|
|
|
|
*/
|
2013-05-16 02:59:27 +02:00
|
|
|
|
function setupProjectForm()
|
|
|
|
|
{
|
2013-10-11 22:51:23 +02:00
|
|
|
|
$('.github-container').hide();
|
|
|
|
|
|
2014-08-01 11:09:04 +02:00
|
|
|
|
$('#element-reference').change(function()
|
|
|
|
|
{
|
|
|
|
|
var el = $(this);
|
|
|
|
|
var val = el.val();
|
|
|
|
|
var type = $('#element-type').val();
|
|
|
|
|
var acceptable = {
|
|
|
|
|
'github': {
|
|
|
|
|
'ssh': /git\@github\.com\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
|
|
|
|
'git': /git\:\/\/github.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
|
|
|
|
'http': /https\:\/\/github\.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
|
|
|
|
|
},
|
|
|
|
|
'bitbucket': {
|
|
|
|
|
'ssh': /git\@bitbucket\.org\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
|
|
|
|
'http': /https\:\/\/[a-zA-Z0-9_\-]+\@bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
|
|
|
|
|
'anon': /https\:\/\/bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if( acceptable[type] !== undefined ) {
|
|
|
|
|
for(var i in acceptable[type]) {
|
|
|
|
|
if(val.match(acceptable[type][i])) {
|
|
|
|
|
el.val(val.replace(acceptable[type][i], '$1'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#element-type').change(function() {
|
2013-10-11 22:51:23 +02:00
|
|
|
|
if ($(this).val() == 'github') {
|
|
|
|
|
$('#loading').show();
|
|
|
|
|
|
2014-07-30 15:32:38 +02:00
|
|
|
|
$.ajax({
|
|
|
|
|
dataType: "json",
|
2017-01-14 19:11:32 +01:00
|
|
|
|
url: window.APP_URL + 'project/ajax-github-repositories',
|
2014-07-30 15:32:38 +02:00
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#loading').hide();
|
2013-10-11 22:51:23 +02:00
|
|
|
|
|
2014-08-01 11:09:04 +02:00
|
|
|
|
if (data && data.repos) {
|
2014-07-30 15:32:38 +02:00
|
|
|
|
$('#element-github').empty();
|
2013-10-11 22:51:23 +02:00
|
|
|
|
|
2014-07-30 15:32:38 +02:00
|
|
|
|
for (var i in data.repos) {
|
|
|
|
|
var name = data.repos[i];
|
|
|
|
|
$('#element-github').append($('<option></option>').text(name).val(name));
|
|
|
|
|
}
|
2013-05-16 02:59:27 +02:00
|
|
|
|
|
2014-07-30 15:32:38 +02:00
|
|
|
|
$('.github-container').slideDown();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: handleFailedAjax
|
2013-10-11 22:51:23 +02:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$('.github-container').slideUp();
|
|
|
|
|
}
|
2014-08-01 11:09:04 +02:00
|
|
|
|
$('#element-reference').trigger('change');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#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('');
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-08-01 12:55:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-04 12:14:04 +01:00
|
|
|
|
var Lang = {
|
|
|
|
|
get: function () {
|
|
|
|
|
var args = Array.prototype.slice.call(arguments);;
|
|
|
|
|
var string = args.shift();
|
|
|
|
|
|
2016-07-21 17:20:34 +02:00
|
|
|
|
if (STRINGS[string]) {
|
|
|
|
|
args.unshift(STRINGS[string]);
|
2014-12-04 12:14:04 +01:00
|
|
|
|
return sprintf.apply(sprintf[0], args);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-14 10:58:55 +01:00
|
|
|
|
return string;
|
2014-12-04 12:14:04 +01:00
|
|
|
|
}
|
2014-12-07 12:51:41 +01:00
|
|
|
|
};
|