Jump to content
UBot Underground

Recommended Posts

Hi,

 

How would you go about creating this simple program:

 

1. User inputs several keywords to a text area.

 

2. Program removes all spaces and line breaks and replaces them with a comma.

 

3. Program displays the new list of comma separated keywords within  the same text area that the user used in 1.

 

4. User is able to copy the list of keywords to their clipboard.

 

Some ideas about how I could get started creating this would be appreciated.

 

John

 

 

 

Link to post
Share on other sites

If you are interested in a JavaScript only solution, give this a try:

ui html panel("<!DOCTYPE html>
<html>
    <head>
        <script type=\"text/javascript\" src=\"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.0.min.js\"></script>
        <script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js\"></script>    
    </head>
    <body>
        <textarea data-clipboard-text=\"\" id=\"txtWords\" cols=\'50\' rows=\'10\'></textarea>
        <button id=\"btnReplace\">Replace Words</button>
        <button id=\"btnCopyToClipboard\" style=\"display:none;\">Copy To Clipboard</button>        
        <script type=\"text/javascript\">
            $(document).ready(function()\{
                $(\"#btnReplace\").click(function()\{
                    $(\"#txtWords\").each(function()\{
                        this.value = this.value.replace(/(\\r\\n|\\n|\\r| )/gm,\",\");
                    \});
                    
                    $(\"#txtWords\").select();    
                    $(\"#btnCopyToClipboard\").click();    
                \});
                
                var clipboard = new Clipboard(\'#btnCopyToClipboard\', \{
                    text: function() \{
                        return $(\"#txtWords\").val();
                    \}
                \});
                clipboard.on(\'success\', function(e) \{
                    console.log(e);
                \});
                clipboard.on(\'error\', function(e) \{
                    console.log(e);
                \});
            \});
        </script>
    </body>
</html>",500)
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...