Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts

    Cool Undo, Redo and save? + few small problems

    Hi i have finished a simple script which has a massive amount of buttons which insert different text into a box. I have tried adding these functions to my code but they seem to have no effect when used.
    function doUndo()
    {
    iView.document.execCommand('undo', false, null);
    }

    function doRedo()
    {
    iView.document.execCommand('redo', false, null);
    }

    I have searched coding forums and found an alternative but i have no idea how to implement it into my script. http://www.codingforums.com/showthre...highlight=undo

    Could someone show me how to get these buttons working, any way?

    I have also a save button next to redo and undo. Is it possible that when pressed it could bring up a save as.. dialog box and save the text in the main box as a .txt file?

    There are also a few minor problems i cant seem to get round such as the 2nd small text box having unwanted scrollbars and when you click on it to type the flashing bar does not go to the beggining like the main text box. Also, for some unknown reason the copy button is not lined up like the other buttons. It needs to be the last button.

    Here is the script... if you look at it and think what the hell is this lol then its a 'text advert creator' for a game league website which i am trying to make.

    Thanks in advance if anyone can help with any aspect of this.

    Edit: Oh crap i forgot to mention that the insert button works but it deletes everything else and only works once. It inserts the text in the small box into the main box. How can i prevent this? It needs to work similarly to the other buttons.

    Ps. Sorry about the stupid amount of functions, i know there must have been a simple way round this but i couldnt work it out lol. The window is meant to be lined up so the rows of buttons are as long as the main text box. (it will be a pop up window)

    Code:
    <script type="text/javascript">
        function clearDefault(el) {
    el.value = ""
    }
    
        function text1(el) {
    el.value += "!!!!"
    }
        function text2(el) {
    el.value += ".::"
    }
      function text3(el) {
    el.value += "::."
    }   
      function text4(el) {
    el.value += ">>>"
    }
      function text5(el) {
    el.value += "<<<"
    }
      function text6(el) {
    el.value += "Join@Jpool.co.uk"
    }
        function text7(el) {
    el.value += "€r"
    } 
       function text8(el) {
    el.value += "€b"
    }
       function text9(el) {
    el.value += "€g"
    }
       function text10(el) {
    el.value += "€y"
    }
       function text11(el) {
    el.value += "€m"
    }
       function text12(el) {
    el.value += "€c"
    }
      function text13(el) {
    el.value += "www.Jpool.co.uk"
    }
      function text14(el) {
    el.value += "[["
    }
      function text15(el) {
    el.value += "]]"
    }
      function text16(el) {
    el.value += "!!"
    }
      function text17(el) {
    el.value += "!!!"
    }
      function text18(el) {
    el.value += "(("
    }
      function text19(el) {
    el.value += "))"
    }
      function text20(el) {
    el.value += "//"
    }
      function text21(el) {
    el.value += "\\"
    }
      function text22(el) {
    el.value += "{"
    }
      function text23(el) {
    el.value += "}"
    }
      function text24(el) {
    el.value += "{{"
    }
      function text25(el) {
    el.value += "}}"
    }
      function text26(el) {
    el.value += "^^"
    }
      function text27(el) {
    el.value += "<<>>"
    }
      function text28(el) {
    el.value += "<>"
    }
      function text29(el) {
    el.value += "-::"
    }
      function text30(el) {
    el.value += "::-"
    }
      function text31(el) {
    el.value += "+//="
    }
      function text32(el) {
    el.value += "=\\+"
    }
      function text33(el) {
    el.value += "--==<<"
    }
      function text34(el) {
    el.value += ">>==--"
    }
      function text35(el) {
    el.value += "<--+-->"
    }
      function text36(el) {
    el.value += "{}"
    }
      function text37(el) {
    el.value += ".::."
    }
      function text38(el) {
    el.value += "4 man "
    }
      function text39(el) {
    el.value += "8 man "
    }
      function text40(el) {
    el.value += "16 man "
    }
      function text41(el) {
    el.value += "32 man "
    }
      function text42(el) {
    el.value += "64 man "
    }
      function text43(el) {
    el.value += "1 vs 1"
    }
      function text44(el) {
    el.value += "2 vs 2"
    }
      function text45(el) {
    el.value += "3 vs 3"
    }
      function text46(el) {
    el.value += "4 vs 4"
    }
      function text47(el) {
    el.value += "5 vs 5"
    }
      function text48(el) {
    el.value += "6 vs 6"
    }
      function text49(el) {
    el.value += "SE"
    }
      function text50(el) {
    el.value += "DE"
    }
      function text51(el) {
    el.value += "Swiss"
    }
      function text52(el) {
    el.value += "True Swiss"
    }
      function text53(el) {
    el.value += "--=--=--"
    }
      function text54(el) {
    el.value += "--=--"
    }
    function text55(el) {
    el.value += "<~~~>"
    }
    
    
    function countit(what){
    
    
    
    formcontent=what.form.TextareaName.value
    what.form.displaycount.value=formcontent.length
    }
    
    
          function storeCaret (textEl) {
           if (textEl.createTextRange) 
             textEl.caretPos = document.selection.createRange().duplicate();
         }
         function insertAtCaret (textEl, text) {
           if (textEl.createTextRange && textEl.caretPos) {
             var caretPos = textEl.caretPos;
             caretPos.text =
               caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
                 text + ' ' : text;
           }
           else
             textEl.value  = text;
         }
    function cmdA(el) {
    with(el){
    focus(); select(); 
    }
    if(document.all){
    frm = document.FormName;
    txt = el.createTextRange();
    txt.execCommand('Copy'); 
    window.status='Selected and Copied to Clipboard!';
    frm.copyButton.value='Copied!';
    setTimeout('frm.copyButton.value="Copy";window.status=""',6000);
    }
    else {
    window.status='Press Ctrl & C to Copy the Text to the Clipboard';
    setTimeout('window.status=""',6000);
    }
    } 
    </script>
    </HEAD>
    
    <BODY>
    <form action="" name="FormName" method="post">
    <TEXTAREA NAME="TextareaName" COLS="53" ROWS="5"></TEXTAREA><br>
    <TEXTAREA NAME="jumpnumber" ROWS="1" COLS="10" WRAP="soft" 
                   ONSELECT="storeCaret(this);"
                   ONCLICK="storeCaret(this);"
                   ONKEYUP="storeCaret(this);"
         >
         </TEXTAREA>
    <input type="button" width="120" NAME="copyButton" value=" Insert " onClick="insertAtCaret(this.form.TextareaName, 
         this.form.jumpnumber.value);">
    <input type="button" width="120" NAME="copyButton" value=" Blue " onClick="text8(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" Red " onClick="text7(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="Green" onClick="text9(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" Gold " onClick="text10(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="Purple" onClick="text11(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="Turquoise" onClick="text12(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="!!" onClick="text16(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="!!!" onClick="text17(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="!!!!" onClick="text1(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" .:: " onClick="text2(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" ::. " onClick="text3(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=">>> " onClick="text4(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" <<<" onClick="text5(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" [[ " onClick="text14(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" ]] " onClick="text15(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" (( " onClick="text18(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" )) " onClick="text19(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" // " onClick="text20(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" \\ " onClick="text21(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" { " onClick="text22(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" } " onClick="text23(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" {{ " onClick="text24(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" }} " onClick="text25(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="-::" onClick="text29(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="::-" onClick="text30(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="+//=" onClick="text31(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="=\\+" onClick="text32(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="--==<<" onClick="text33(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=">>==--" onClick="text34(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="<--+-->" onClick="text35(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="{}" onClick="text36(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" .::. " onClick="text37(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="  ^^ " onClick="text26(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="<<>>" onClick="text27(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" <> " onClick="text28(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="--=--=--" onClick="text53(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="--=--" onClick="text54(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="<~~~>" onClick="text55(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="Join@Jpool.co.uk" onClick="text6(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="www.Jpool.co.uk" onClick="text13(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="  4 man  " onClick="text38(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" 8 man " onClick="text39(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" 16 man " onClick="text40(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" 32 man " onClick="text41(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="64 man" onClick="text42(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="  1 vs 1  " onClick="text43(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="2 vs 2" onClick="text44(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="3 vs 3" onClick="text45(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="4 vs 4" onClick="text46(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="5 vs 5" onClick="text47(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="6 vs 6" onClick="text48(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="SE" onClick="text49(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" DE " onClick="text50(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="Swiss" onClick="text51(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="True Swiss" onClick="text52(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" Clear " onClick="clearDefault(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" Undo " onClick="clearDefault(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value=" Redo " onClick="clearDefault(TextareaName)">
    <input type="button" width="120" NAME="copyButton" value="Save.." onClick="clearDefault(TextareaName)">
    <input type="button" value="Calculate Characters"
          onClick="countit(this)"> <input type="text" VALUE="Max 200" name="displaycount" size="10"></p>
          <div align="center"><center><p><font face="arial" size="-2">
    <input type="button" width="120" NAME="copyButton" value="Copy" onClick="cmdA(TextareaName)">
    </form>
    Last edited by bunion; 01-10-2005 at 05:22 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •