Browse Source

Added ability to add multiple public keys.

pull/24/head
Teknikode 8 years ago
parent
commit
6cfa5c315f
  1. 24
      home/profile.php
  2. 59
      templates/default/js/profile.js

24
home/profile.php

@ -181,9 +181,27 @@ if (isset($_GET['id'])) @@ -181,9 +181,27 @@ if (isset($_GET['id']))
</div>
<hr>
<div class="row">
<div class="form-group col-sm-12">
<label for="update_public_key"><h4>Public Key</h4></label>
<input class="form-control" id="update_public_key" name="update_public_key" placeholder="ssh-rsa mypublickeytothegreatestgitintheworld" title="enter your public key" type="text" value="<?php echo $Profile_User->public_key; ?>" />
<div class="col-sm-12">
<h4>Public Key(s)</h4>
<input id="update_public_key" name="update_public_key" type="hidden" value="<?php echo $Profile_User->public_key; ?>" />
</div>
</div>
<div class="row">
<div class="col-sm-12" id="public_key_list">
<?php
$keyList = explode(",", $Profile_User->public_key);
foreach ($keyList as $key)
{
?>
<div class="alert alert-success public_key_<?php echo $key; ?>"><button type="button" class="close public_key_delete" id="<?php echo $key; ?>">&times;</button><?php echo $key; ?></div>
<?php
}
?>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<button class="btn btn-md btn-primary" id="add_public_key"><i class="glyphicon glyphicon-plus"></i> Add Key</button>
</div>
</div>
<!-- Blog Settings -->

59
templates/default/js/profile.js

@ -1,4 +1,7 @@ @@ -1,4 +1,7 @@
$(document).ready(function() {
linkKeyDelete('.public_key_delete');
$('#delete_account').click(function() {
bootbox.confirm("Are you sure you want to delete your account?", function(result)
{
@ -12,8 +15,6 @@ $(document).ready(function() { @@ -12,8 +15,6 @@ $(document).ready(function() {
if(html=='true')
{
window.location.href = "../../../";
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Your account has been successfully deleted.</div>');
}
else
{
@ -26,6 +27,40 @@ $(document).ready(function() { @@ -26,6 +27,40 @@ $(document).ready(function() {
});
});
$("#add_public_key").click(function() {
bootbox.prompt("Enter your Public Key (including ssh-rsa)", function(result) {
if (result)
{
prev_keys = $("#update_public_key").val();
var prev_split = prev_keys.split(",");
var key_used = false;
var index = fileList.indexOf(podFile);
if (index != -1)
{
key_used = true;
}
if (!key_used)
{
if (prev_split)
{
$("#update_public_key").val(prev_keys + ',' + result);
}
else
{
$("#update_public_key").val(result);
}
$("#public_key_list").append('<div class="alert alert-success public_key_'+result+'"><button type="button" class="close public_key_delete" id="'+result+'">&times;</button>'+result+'</div>');
linkKeyDelete('.public_key_delete');
}
else
{
bootbox.alert("The key '"+result+"' is already added.", function() { });
}
}
});
return false;
});
$("#update_submit").click(function(){
current_password=encodeURIComponent($("#update_password_current").val());
password=encodeURIComponent($("#update_password").val());
@ -57,4 +92,22 @@ $(document).ready(function() { @@ -57,4 +92,22 @@ $(document).ready(function() {
});
return false;
});
});
});
function linkKeyDelete(selector)
{
$(selector).click(function(){
var object = $(this);
key=encodeURIComponent(object.attr('id'));
prev_keys = $("#update_public_key").val();
var prev_split = prev_keys.split(",");
var index = prev_split.indexOf(key);
if (index != -1)
{
prev_split.splice(index, 1);
$("#update_public_key").val(prev_split.toString());
}
$(".public_key_"+key).remove();
return false;
});
}
Loading…
Cancel
Save