Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 177 lines (157 sloc) 7.42 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Command Line Generator</title>
<meta name="description" content="command line generator">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<style>
.mgn {
margin: 1rem;
}
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<form>
<div class="input-group mb-3 mgn">
<div class="input-group-prepend">
<button id="btn_copy" class="btn btn-success" onclick="javascript:return false;">Copy</button>
</div>
<textarea type="text" class="form-control" rows="3" placeholder="Result will shown here" id='result'> </textarea>
</div>
</form>
</div>
<div class="container">
<form>
<h3>
<a href="https://docs.docker.com/engine/reference/run/">docker run</a>
</h3>
<div class="form-check form-check-inline">
<input class="form-check-input checkbox-group-1" type="checkbox" checked value="-d --restart unless-stopped">
</div>
<div class="form-check form-check-inline">
<input class="form-check-input checkbox-group-1" type="checkbox" value="--rm -it">
</div>
<div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" checked value="--net host">
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" value="--privileged">
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" value="-v /:/host">
</div>
</div>
<div class="form-inline">
<input class="form-check-input" type="checkbox" value="-v /dev:/dev -v /lib/modules:/lib/modules">
</div>
<div class="form-inline">
<input class="form-check-input" type="checkbox" value="--user=root --cap-add=ALL --pid=host --ipc=host">
</div>
<div class="form-inline">
<input class="form-check-input" type="checkbox" value='--env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw"'>
</div>
<div class="form-inline">
<input class="form-control mgn txt" placeholder="IMAGE">
<input class="form-check-input checkbox-group-2" type="checkbox" checked value="">
<input class="form-check-input checkbox-group-2" type="checkbox" value="/bin/bash">
<input class="form-check-input checkbox-group-2" type="checkbox" value="/bin/sh" style="margin-left:0.5rem;">
</div>
</form>
<form>
<h3>
<a href="https://docs.docker.com/engine/reference/commandline/exec/">docker exec</a>
</h3>
<div class="form-inline">
<input class="form-check-input" type="checkbox" checked value="-it">
<input class="form-control mgn txt" placeholder="CONTAINER">
<input class="form-check-input checkbox-group-3" type="checkbox" checked value="">
<input class="form-check-input checkbox-group-3" type="checkbox" value="/bin/bash">
<input class="form-check-input checkbox-group-3" type="checkbox" value="/bin/sh" style="margin-left:0.5rem;">
</div>
</form>
</div>
<div>
<hr />
<div class="container d-flex justify-content-center">
<p>
<a href="https://github.com/fzinfz/scripts/blob/master/docs/cmd.html">Source Code</a>
</p>
</div>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script>
$('a').attr('target', '_blank');
$('.form-check-input').each(function (index) {
$(this).attr('id', 'checkbox_' + index);
var e = '<label class="form-check-label" for="checkbox_' + index + '">' + $(this).val() + '</label>';
$(this).after(e);
})
function cmd_generate() {
setTimeout(() => {
var result = $(this).closest('form').find('a').text() + ' '; //prefix
var txt = $(this).closest('form').find('.txt').val() + ' '; //input text
if (result.includes('docker run'))
result += '--name ' + txt.replace(/.*\//, "").replace(/:/, "-") + ' '; // --name
$(this).closest('form').find('input').each(function (index, item) {
if ($(item).prop('checked') || (!$(item).is(':checkbox'))) {
result += $(item).val() + ' ';
}
});
$('#result').val(result);
}, 100);
}
$('input').not('.checkbox-group-1').on('click input focus', cmd_generate)
$('.txt').first().focus();
function handle_checkbox(event) {
var v = $(this).val();
var checked = $(this).prop('checked');
$(event.data.class).each(function (index, item) {
if ($(item).val() == v) return true;
$(item).prop('checked', !checked)
});
$(this).closest('form').find('.txt').focus();
}
for (var i = 1; i <= 3; i++) {
var s = '.checkbox-group-' + i;
$(s).on('click', { class: s }, handle_checkbox);
}
$('#btn_copy').on("click", function () {
$('#result').select();
document.execCommand("copy");
$('#btn_copy').text("Copied");
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-4845608-5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments) };
gtag('js', new Date());
gtag('config', 'UA-4845608-5');
</script>
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?2d7d9d6bb9fdf9d1d65d3d9c0624a6f9";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
You can’t perform that action at this time.