Easier copying of terminal contents

This commit is contained in:
Gina Häußge 2017-11-13 14:10:54 +01:00
parent f9c738541f
commit 0b1db60d8b
3 changed files with 16 additions and 4 deletions

View file

@ -1154,7 +1154,7 @@ var escapeUnprintableCharacters = function(str) {
};
var copyToClipboard = function(text) {
var temp = $("<input>");
var temp = $("<textarea>");
$("body").append(temp);
temp.val(text).select();
document.execCommand("copy");

View file

@ -305,6 +305,10 @@ $(function() {
}
};
self.copyAll = function() {
copyToClipboard(self.plainLogLines().join("\n"));
};
// command matching regex
// (Example output for inputs G0, G1, G28.1, M117 test)
// - 1: code including optional subcode. Example: G0, G1, G28.1, M117

View file

@ -7,9 +7,17 @@
<a class="btn add-on" id="terminal-send" data-bind="click: sendCommand, enable: isOperational() && loginState.isUser()">{{ _('Send') }}</a>
</div>
</div>
<small class="pull-left" data-bind="visible: fancyFunctionality()"><button class="btn btn-mini" data-bind="click: toggleAutoscroll, css: {active: autoscrollEnabled}">{{ _('Autoscroll') }}</button> <span data-bind="text: lineCount, visible: enableFancyFunctionality"></span></small>
<small class="pull-right" data-bind="visible: fancyFunctionality()"><a href="#" data-bind="click: scrollToEnd">{{ _("Scroll to end") }}</a>&nbsp;|&nbsp;<a href="#" data-bind="click: selectAll">{{ _("Select all") }}</a></small>
<small class="pull-left text-warning" data-bind="visible: !fancyFunctionality()" style="display: none">{{ _('For performance reasons only a limited amount of terminal functionality is enabled right now.') }}</small>
<small class="pull-left" data-bind="visible: fancyFunctionality()">
<button class="btn btn-mini" data-bind="click: toggleAutoscroll, css: {active: autoscrollEnabled}">{{ _('Autoscroll') }}</button>
<span data-bind="text: lineCount, visible: enableFancyFunctionality"></span>
<span data-bind="visible: !autoscrollEnabled() && enableFancyFunctionality()" style="display: none">(<a href="javascript:void(0)" data-bind="click: scrollToEnd">{{ _("Scroll to end") }}</a>)</span>
</small>
<small class="pull-right">
<a href="javascript:void(0)" data-bind="click: copyAll"><i class="fa fa-copy" title="{{ _('Copy all') }}"></i> {{ _('Copy all') }}</a>
</small>
<small class="pull-left text-warning" data-bind="visible: !fancyFunctionality()" style="display: none">
{{ _('For performance reasons only a limited amount of terminal functionality is enabled right now.') }}
</small>
</div>
<div class="row-fluid">