Merge pull request #5 from AysadKozanoglu/generate_textAreaConfigPhpini_copyButton
textarea with generated values with copy button
This commit is contained in:
commit
0621f37a76
3 changed files with 118 additions and 2 deletions
86
1
Normal file
86
1
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
|
||||||
|
//range slider
|
||||||
|
var $element = $('input[type="range"]');
|
||||||
|
|
||||||
|
$element
|
||||||
|
.rangeslider({
|
||||||
|
polyfill: false,
|
||||||
|
onInit: function() {
|
||||||
|
var $handle = $('.rangeslider__handle', this.$range);
|
||||||
|
updateHandle($handle[0], this.value);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('input', function(e) {
|
||||||
|
var $handle = $('.rangeslider__handle', e.target.nextSibling);
|
||||||
|
updateHandle($handle[0], this.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateHandle(el, val) {
|
||||||
|
el.textContent = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
//calculator
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
//calculate values automatically
|
||||||
|
sum();
|
||||||
|
$("#ram-total, #ram-reserved, #ram-buffer, #process-size").on("keydown keyup change", function() {
|
||||||
|
sum();
|
||||||
|
});
|
||||||
|
generateConfigCopy();
|
||||||
|
|
||||||
|
$("buttonCopy").click(function(){
|
||||||
|
copyClipboard
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function sum() {
|
||||||
|
//inputs
|
||||||
|
var ramtotal = document.getElementById('ram-total').value;
|
||||||
|
var ramreserved = document.getElementById('ram-reserved').value;
|
||||||
|
var rambuffer = document.getElementById('ram-buffer').value;
|
||||||
|
var processsize = document.getElementById('process-size').value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var buffer = 1 - (rambuffer / 100) ;
|
||||||
|
|
||||||
|
//[Total Available RAM] – [Reserved RAM] – [10% buffer] = [Available RAM for PHP]
|
||||||
|
var availableram = Math.round(((ramtotal - ramreserved) * buffer) * 10) / 10;
|
||||||
|
var availablerammb = Math.round(availableram * 1024);
|
||||||
|
|
||||||
|
// [Average Process Size] / [Available RAM for PHP]= [max_children]
|
||||||
|
var maxchildren = Math.floor(availablerammb / processsize);
|
||||||
|
var startservers = Math.floor(maxchildren * 0.25);
|
||||||
|
var minspare = Math.floor(maxchildren * 0.25);
|
||||||
|
var maxspare = Math.floor(maxchildren * 0.75);
|
||||||
|
|
||||||
|
|
||||||
|
if (!isNaN(availableram)) {
|
||||||
|
//Outputs
|
||||||
|
//document.getElementById('ram-buffer-percent').value = buffer;
|
||||||
|
document.getElementById('ram-available').value = availableram;
|
||||||
|
document.getElementById('ram-available-mb').value = Math.round(availableram * 1024);
|
||||||
|
document.getElementById('max-children').value = maxchildren;
|
||||||
|
document.getElementById('start-servers').value = startservers;
|
||||||
|
document.getElementById('min-spare').value = minspare;
|
||||||
|
document.getElementById('max-spare').value = maxspare;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateConfigCopy (){
|
||||||
|
document.getElementById('copyPasteArea').value = 'pm.max_children = ' + document.getElementById('max-children').value +'\n'
|
||||||
|
+ 'pm.start_servers = ' + document.getElementById('start-servers').value +'\n'
|
||||||
|
+ 'pm.min_spare_servers = ' + document.getElementById('min-spare').value +'\n'
|
||||||
|
+ 'pm.max_spare_servers = ' + document.getElementById('max-spare').value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyClipboard (){
|
||||||
|
var text = document.getElementById('copyPasteArea');
|
||||||
|
text.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
alert('copied to clipboard successfully.');
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<title>PHP-FPM Process Caluculator</title>
|
<title>PHP-FPM Process Caluculator</title>
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="Chris Moore">
|
<meta name="author" content="Chris Moore">
|
||||||
|
<meta name="author" content="Aysad Kozanoglu">
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rangeslider.js/2.3.0/rangeslider.min.css" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rangeslider.js/2.3.0/rangeslider.min.css" />
|
||||||
|
@ -85,6 +86,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
<form name="form1" method="post" name="coptypaste" id="copypaste">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="settingsPoolsPhp">php pool settings / tuning</label>
|
||||||
|
<textarea class="form-control" name="copyPasteArea" id="copyPasteArea" rows="4"></textarea>
|
||||||
|
<button name="buttonCopy" id="buttonCopy" onClick="copyClipboard()" type="button" class="btn btn-success">Copy to Clipboard</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
22
script.js
22
script.js
|
@ -27,6 +27,12 @@ $(document).ready(function() {
|
||||||
$("#ram-total, #ram-reserved, #ram-buffer, #process-size").on("keydown keyup change", function() {
|
$("#ram-total, #ram-reserved, #ram-buffer, #process-size").on("keydown keyup change", function() {
|
||||||
sum();
|
sum();
|
||||||
});
|
});
|
||||||
|
generateConfigCopy();
|
||||||
|
|
||||||
|
$("buttonCopy").click(function(){
|
||||||
|
copyClipboard
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function sum() {
|
function sum() {
|
||||||
|
@ -62,3 +68,19 @@ function sum() {
|
||||||
document.getElementById('max-spare').value = maxspare;
|
document.getElementById('max-spare').value = maxspare;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateConfigCopy (){
|
||||||
|
document.getElementById('copyPasteArea').value = 'pm.max_children = ' + document.getElementById('max-children').value +'\n'
|
||||||
|
+ 'pm.start_servers = ' + document.getElementById('start-servers').value +'\n'
|
||||||
|
+ 'pm.min_spare_servers = ' + document.getElementById('min-spare').value +'\n'
|
||||||
|
+ 'pm.max_spare_servers = ' + document.getElementById('max-spare').value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyClipboard (){
|
||||||
|
var text = document.getElementById('copyPasteArea');
|
||||||
|
text.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
alert('copied to clipboard successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue