Added alplora and datacenter beta program
This commit is contained in:
parent
8e5834b2dd
commit
ea2f6444db
152 changed files with 20967 additions and 160 deletions
2317
alplora/static/alplora/js/bootstrap.js
vendored
Executable file
2317
alplora/static/alplora/js/bootstrap.js
vendored
Executable file
File diff suppressed because it is too large
Load diff
7
alplora/static/alplora/js/bootstrap.min.js
vendored
Executable file
7
alplora/static/alplora/js/bootstrap.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
42
alplora/static/alplora/js/gen-ssh-key.js
Executable file
42
alplora/static/alplora/js/gen-ssh-key.js
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
$( document ).ready(function() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Create a file with ssh private key info
|
||||
function donwloadKeyFile(){
|
||||
|
||||
var key = $('#ssh_key').text();
|
||||
var a = window.document.createElement('a');
|
||||
|
||||
a.href = window.URL.createObjectURL(new Blob([key], {type: 'text'}));
|
||||
a.download = 'private_key.pem';
|
||||
|
||||
// Append anchor to body.
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
// Remove anchor from body
|
||||
document.body.removeChild(a);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Create a file with ssh private key info
|
||||
$('#download_ssh_key').on('click',donwloadKeyFile);
|
||||
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
var clipboard = new Clipboard('.to_copy');
|
||||
|
||||
clipboard.on('success', function(e) {
|
||||
var selector = "#";
|
||||
var copy_button_id = selector.concat(e.trigger.id);
|
||||
setTimeout(function(){
|
||||
$(copy_button_id).tooltip('hide');
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
});
|
||||
16
alplora/static/alplora/js/initial.js
Executable file
16
alplora/static/alplora/js/initial.js
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
$( document ).ready(function() {
|
||||
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
var clipboard = new Clipboard('.to_copy');
|
||||
|
||||
clipboard.on('success', function(e) {
|
||||
var selector = "#";
|
||||
var copy_button_id = selector.concat(e.trigger.id);
|
||||
setTimeout(function(){
|
||||
$(copy_button_id).tooltip('hide');
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
});
|
||||
4
alplora/static/alplora/js/jquery.js
vendored
Executable file
4
alplora/static/alplora/js/jquery.js
vendored
Executable file
File diff suppressed because one or more lines are too long
124
alplora/static/alplora/js/payment.js
Executable file
124
alplora/static/alplora/js/payment.js
Executable file
|
|
@ -0,0 +1,124 @@
|
|||
$( document ).ready(function() {
|
||||
|
||||
$.ajaxSetup({
|
||||
beforeSend: function(xhr, settings) {
|
||||
function getCookie(name) {
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie != '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
|
||||
// Only send the token to relative URLs i.e. locally.
|
||||
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var $form = $('#payment-form');
|
||||
$form.submit(payWithStripe);
|
||||
|
||||
/* If you're using Stripe for payments */
|
||||
function payWithStripe(e) {
|
||||
e.preventDefault();
|
||||
|
||||
/* Visual feedback */
|
||||
$form.find('[type=submit]').html('Validating <i class="fa fa-spinner fa-pulse"></i>');
|
||||
|
||||
var PublishableKey = window.stripeKey;
|
||||
Stripe.setPublishableKey(PublishableKey);
|
||||
Stripe.card.createToken($form, function stripeResponseHandler(status, response) {
|
||||
if (response.error) {
|
||||
/* Visual feedback */
|
||||
$form.find('[type=submit]').html('Try again');
|
||||
/* Show Stripe errors on the form */
|
||||
$form.find('.payment-errors').text(response.error.message);
|
||||
$form.find('.payment-errors').closest('.row').show();
|
||||
} else {
|
||||
/* Visual feedback */
|
||||
$form.find('[type=submit]').html('Processing <i class="fa fa-spinner fa-pulse"></i>');
|
||||
/* Hide Stripe errors on the form */
|
||||
$form.find('.payment-errors').closest('.row').hide();
|
||||
$form.find('.payment-errors').text("");
|
||||
// response contains id and card, which contains additional card details
|
||||
var token = response.id;
|
||||
// AJAX
|
||||
|
||||
//set token on a hidden input
|
||||
$('#id_token').val(token);
|
||||
$('#billing-form').submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Form validation */
|
||||
$.validator.addMethod("month", function(value, element) {
|
||||
return this.optional(element) || /^(01|02|03|04|05|06|07|08|09|10|11|12)$/.test(value);
|
||||
}, "Please specify a valid 2-digit month.");
|
||||
|
||||
$.validator.addMethod("year", function(value, element) {
|
||||
return this.optional(element) || /^[0-9]{2}$/.test(value);
|
||||
}, "Please specify a valid 2-digit year.");
|
||||
|
||||
validator = $form.validate({
|
||||
rules: {
|
||||
cardNumber: {
|
||||
required: true,
|
||||
creditcard: true,
|
||||
digits: true
|
||||
},
|
||||
expMonth: {
|
||||
required: true,
|
||||
month: true
|
||||
},
|
||||
expYear: {
|
||||
required: true,
|
||||
year: true
|
||||
},
|
||||
cvCode: {
|
||||
required: true,
|
||||
digits: true
|
||||
}
|
||||
},
|
||||
highlight: function(element) {
|
||||
$(element).closest('.form-control').removeClass('success').addClass('error');
|
||||
},
|
||||
unhighlight: function(element) {
|
||||
$(element).closest('.form-control').removeClass('error').addClass('success');
|
||||
},
|
||||
errorPlacement: function(error, element) {
|
||||
$(element).closest('.form-group').append(error);
|
||||
}
|
||||
});
|
||||
|
||||
paymentFormReady = function() {
|
||||
if ($form.find('[name=cardNumber]').hasClass("success") &&
|
||||
$form.find('[name=expMonth]').hasClass("success") &&
|
||||
$form.find('[name=expYear]').hasClass("success") &&
|
||||
$form.find('[name=cvCode]').val().length > 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$form.find('[type=submit]').prop('disabled', true);
|
||||
var readyInterval = setInterval(function() {
|
||||
if (paymentFormReady()) {
|
||||
$form.find('[type=submit]').prop('disabled', false);
|
||||
clearInterval(readyInterval);
|
||||
}
|
||||
}, 250);
|
||||
|
||||
});
|
||||
|
||||
57
alplora/static/alplora/js/pricing.js
Executable file
57
alplora/static/alplora/js/pricing.js
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
$( document ).ready(function() {
|
||||
|
||||
//we need to load first VMTypesData from base.html django template
|
||||
var pricingData = window.VMTypesData;
|
||||
|
||||
|
||||
// Function to calculate the price given a vm type
|
||||
function calculate_price(vm_type){
|
||||
|
||||
var ID_SELECTOR = "#";
|
||||
var CURRENCY = "CHF";
|
||||
var final_price_selector = ID_SELECTOR.concat(vm_type.concat('-final-price'));
|
||||
var final_price_input_selector = final_price_selector.concat('-input');
|
||||
var core_selector = ID_SELECTOR.concat(vm_type.concat('-cores'));
|
||||
var memory_selector = ID_SELECTOR.concat(vm_type.concat('-memory'));
|
||||
var disk_size_selector = ID_SELECTOR.concat(vm_type.concat('-disk_space'));
|
||||
|
||||
//Get vm type prices
|
||||
var cores = $(core_selector).val();
|
||||
var memory = $(memory_selector).val();
|
||||
var disk_size = $(disk_size_selector).val();
|
||||
var pricingData = eval(window.VMTypesData);
|
||||
var company_prices = _.head(_.filter(pricingData, {hosting_company: vm_type}));
|
||||
|
||||
//Calculate final price
|
||||
var price = company_prices.base_price;
|
||||
price += company_prices.core_price*cores;
|
||||
price += company_prices.memory_price*memory;
|
||||
price += company_prices.disk_size_price*disk_size;
|
||||
|
||||
console.log(final_price_input_selector);
|
||||
$(final_price_selector).text(price.toString().concat(CURRENCY));
|
||||
$(final_price_input_selector).attr('value', price);
|
||||
|
||||
}
|
||||
|
||||
//Listener function
|
||||
function change_attribute(e){
|
||||
|
||||
var vm_type = this.getAttribute('data-vm-type');
|
||||
calculate_price(vm_type);
|
||||
}
|
||||
|
||||
|
||||
//Listeners
|
||||
$('.cores-selector').on('change',change_attribute);
|
||||
|
||||
$('.memory-selector').on('change',change_attribute);
|
||||
|
||||
$('.disk-space-selector').on('change',change_attribute);
|
||||
|
||||
//Disable input
|
||||
$('.disk-space-selector').keypress(function(event){
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
});
|
||||
18
alplora/static/alplora/js/virtual_machine_detail.js
Executable file
18
alplora/static/alplora/js/virtual_machine_detail.js
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
$( document ).ready(function() {
|
||||
|
||||
$('#confirm-cancel').on('click', '.btn-ok', function(e) {
|
||||
$('#virtual_machine_cancel_form').trigger('submit');
|
||||
});
|
||||
|
||||
var hash = window.location.hash;
|
||||
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
|
||||
|
||||
$('.nav-tabs a').click(function (e) {
|
||||
$(this).tab('show');
|
||||
var scrollmem = $('body').scrollTop() || $('html').scrollTop();
|
||||
window.location.hash = this.hash;
|
||||
$('html,body').scrollTop(scrollmem);
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue