Jump to content

Robert Moskowitz

Members
  • Posts

    39
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Robert Moskowitz's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Just an update that I have put this all 'into production'. The howtos can be accessed via: http://www.htt-consult.com/arm.html There were almost 100 boxes to modify, but I like to think it is worth it. Next I actually have to use these to build some new systems and see if I can get the mailserver working all the way through. THEN go back and learn some more CSS and further improve my page writing skills. thanks!
  2. The square brackets, fqdn does not work in the textarea. It would be nice, but I think the key here is that the is a textarea tag and all text is treated, well as text! Possibly some javascripting could stuff some replacement content into the textarea.
  3. My googling this has not only come up empty, but statements that it <b>Cannot</b> be done. I will work out an alternative approach, but any pointers on this is greatly appreciated!
  4. I want to italicize on word in a textarea. Something like: <style> .copy-area { margin-bottom: 2em; } .copy-area textarea { border:1px solid black; resize:none; font-size:inherit; padding-top:1em; margin-left:3em; width:20em; height:2em; overflow-y:hidden; overflow-x:auto; font-family: verdana,tahoma,'Bitstream Vera Sans','DejaVu Sans',arial,helvetica,sans-serif; } </style> <div class="copy-area"> <textarea id="box44" style="width:25em;height:2em;"> http://<i>fqdn</i>/roundcubemail/installer </textarea> </div> The italics tag worked fine in the old way I did things, but not surprisingly it does not work in my proper CSS style. So how do I change just a part of my text's font to italics? And, yes, this is the 44th textarea in this one howto and still more to convert.
  5. I am using Geany 1.35 on Fedora 28 (I really have to build my new Fedora 30 system). It does what I need (so far) both for html and xml (for IETF Internet Drafts). Add a Kensington Expert Optical Track ball with its scrolling wheel to move up and down in a doc easily, and I am set.
  6. I have always used overflow-y:auto with a fixed height for whatever textarea or other I wanted a scroll bar. But then my needs are rather simple.
  7. I came to the "don't bother about old browser support" late last night. Particularly when I stumbled across here that addEventListener is not supported prior to IE8. Anyway with all the help I have received here, below is what I have come up with and next to actually convert my howtos over to it. Thanks! I suspect I will be back with other calls for help! <head> <title>untitled</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Geany 1.34.1" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> .copy-area { margin-bottom: 2em; } .copy-area textarea { border:1px solid black; resize:none; font-size:inherit; padding-top:1em; margin-left:3em; width:20em; height:2em; overflow-y:hidden; overflow-x:auto; font-family: verdana,tahoma,'Bitstream Vera Sans','DejaVu Sans',arial,helvetica,sans-serif; } </style> </head> <body> <button style="margin-left:4em" onclick="clickselecttrue()"> Select text<br> (default) </button> <button style="margin-left:4em" onclick="clickselectfalse()">Copy text</button> <br><br> <div class="copy-area"> <textarea> sudo screen /dev/ttyUSB0 115200 </textarea> </div> <div class="copy-area"> <textarea style="height:7em;"> cat &lt;&lt;EOF&gt;&gt;/etc/aliases || exit 1 root: $admin_email EOF newaliases bind 'set disable-completion off' </textarea> </div> <script> var textareas = document.querySelectorAll(".copy-area textarea"); var clickselect = true; var i; for(i = 0; i < textareas.length; i++) { textareas[i].addEventListener("click", copyClipboard); textareas[i].readOnly = true; } function clickselecttrue() {clickselect = true} function clickselectfalse() {clickselect = false} function copyClipboard(e) { if (clickselect) { e.currentTarget.select(); } else { var elm = e.currentTarget; if(document.execCommand && document.queryCommandSupported && document.queryCommandSupported('copy')) { elm.select(); document.execCommand("copy"); } else { alert('Copy not supported'); } } } </script> </body>
  8. The following function works on the textarea and the button: function copyClipboard(e) { var elm = e.currentTarget; if(elm.nodeName.toLowerCase() == "button") { elm = elm.previousElementSibling; } if(document.execCommand && document.queryCommandSupported && document.queryCommandSupported('copy')) { elm.select(); document.execCommand("copy"); } else { alert('Copy not supported'); } } I suppose I can be pragmatic in that my howtos are about CentOS on ARMv7 SOC, so I would not expect a reader to be using an old IE browser... but it would be nice to have a copy that works for old IE for other use cases.
  9. In the following code, click on the button and the sudo command is copied into the clipboard. Click on the textarea and the clipboard is unchanged from whatever it previously had. So the question remains on how to get the event working on the textarea. <head> <title>untitled</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta name="generator" content="Geany 1.34.1" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> .copy-area { margin-bottom: 2em; } .copy-area textarea { border:1px solid black; resize:none; font-size:inherit; padding-top:1em; margin-left:3em; width:20em; height:2em; overflow-y:hidden; overflow-x:auto; font-family: verdana,tahoma,'Bitstream Vera Sans','DejaVu Sans',arial,helvetica,sans-serif; } .copy-area button { margin-left: 4em; } </style> </head> <body> <div class="copy-area"> <textarea readonly="readonly"> sudo screen /dev/ttyUSB0 115200 </textarea> <button>Copy text</button> </div> <div class="copy-area"> <textarea readonly="readonly" style="height:7em;"> cat &lt;&lt;EOF&gt;&gt;/etc/aliases || exit 1 root: $admin_email EOF newaliases bind 'set disable-completion off' </textarea> </div> <div class="copy-area"> <textarea readonly="readonly"> More code </textarea> </div> <br><br> <script> var textareas = document.querySelectorAll(".copy-area textarea"); var buttons = document.querySelectorAll(".copy-area button"); var i; for(i = 0; i < textareas.length; i++) { textareas[i].addEventListener("click", copyClipboard); } for(i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click", copyClipboard); } function copyClipboard(e) { var elm = e.currentTarget; if(elm.nodeName.toLowerCase() == "button") { elm = elm.previousElementSibling; } // for Internet Explorer if(document.body.createTextRange) { var range = document.body.createTextRange(); range.moveToElementText(elm); range.select(); document.execCommand("Copy"); alert("IE Copied content to clipboard"); } else if(window.getSelection) { // other browsers var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(elm); selection.removeAllRanges(); selection.addRange(range); document.execCommand("Copy"); alert("Copied content to clipboard"); } } </script> </body>
  10. ARGH. I just did something wrong in my browser and lost all I typed... Anyway to try again. I have learned the lesson from you to put all my style settings into the head instead of inline. My test coding is using inline to better see what I am doing and for posting here. My goal is for the event to trigger on clicking on the textarea, not a button. And to have a choice (set in the beginning of the howto) to by default just select the text, or if you are 'brave' to automate the copy to clipboard. I am a secure communications designer (think IPsec and HIP). It is my secure OS colleagues that cringed on just allowing the javascript to copy to the clipboard, so my goal is no button and choose what action. Now I see you put all the textareas into their own divisions, and put all these divisions into the same class. Is that for the style sheet control? I am looking at your javascript. Is what you are doing putting a listening event on both the textarea and the follow-on button? So to achieve my end goal I can drop all the button part. Looking at if condition in the beginning of the copyClipboard function, am I reading this right that if the button was the click event, then the elm is shifted to the prior (textarea) item? Perhaps I am learning something here. I will cobble trial code together.
  11. The saga is getting more twisted. Look at the code below that puts a onclick on both the textarea and a button. Same function, different results. The button onclick returns the content of the textarea to the clipboard. The textarea onclick does not. Further if I substitute elm = event.currentTarget and try the click on textarea, nothing to the clipboard... <textarea id="box22" readonly="readonly" onclick="copyClipboard('box22')" style="border:1px solid black;resize:none;font-size:inherit;padding-top:1em; margin-left:3em;width:20em;height:2em;overflow-y:hidden;overflow-x:auto; font-family: verdana,tahoma,'Bitstream Vera Sans','DejaVu Sans',arial,helvetica,sans-serif;"> sudo screen /dev/ttyUSB0 115200 </textarea> <button style="margin-left:4em" onclick="copyClipboard('box22')">Copy text</button> <br><br> <script> function copyClipboard(x) { //var elm = event.currentTarget; var elm = document.getElementById(x); alert(x); console.log(elm); // for Internet Explorer if(document.body.createTextRange) { var range = document.body.createTextRange(); range.moveToElementText(elm); range.select(); document.execCommand("Copy"); alert("IE Copied content to clipboard"); } else if(window.getSelection) { // other browsers var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(elm); selection.removeAllRanges(); selection.addRange(range); document.execCommand("Copy"); alert("Copied content to clipboard"); } } </script>
  12. Ah, so that is how log() works. I was realizing I was going to have to read up on it. Figured it could not have been to someplace in /var/log ! I will do some work on this, hopefully tomorrow. and get back here on what I find out.
  13. elm = event.currentTarget // onclick on a textarea and elm = document.getElementById(x) // where x is the id of a textarea do not produce the same results. I would like to replace the later some way with the former.
  14. Perhaps something like: e.currentTarget.element I am looking for a list elements under currentTarget. I have found that there is one: currentTarget.id
  15. My ongoing saga... One function uses e.currentTarget.select() and the other uses document.getElementById(x) Is there a object under currentTarget that would set a variable with the same content as document.getElementById(x)? function select(e) { e.currentTarget.select(); } function copyClipboard(x) { var elm = document.getElementById(x); // for Internet Explorer if(document.body.createTextRange) { var range = document.body.createTextRange(); range.moveToElementText(elm); range.select(); document.execCommand("Copy"); // alert("IE Copied content to clipboard"); } else if(window.getSelection) { // other browsers var selection = window.getSelection(); var range = document.createRange(); range.selectNodeContents(elm); selection.removeAllRanges(); selection.addRange(range); document.execCommand("Copy"); // alert("Copied content to clipboard"); } } thanks
×
×
  • Create New...