home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / discus / fpanel.js next >
Text File  |  2009-11-06  |  5KB  |  189 lines

  1. //
  2. // FORMATTING PANEL FOR DISCUS 'ADD A MESSAGE' box
  3. // Copyright (c) 2001, DiscusWare, LLC, all rights reserved
  4. // This code is distributed under the same terms as Discus itself
  5. //
  6.  
  7. function panelclose () {
  8.     if (document.userpass) {
  9.         if (document.userpass.format_b.value == 1) {    
  10.             insertText(document.userpass.message, '}');
  11.         }
  12.         if (document.userpass.format_i.value == 1) {    
  13.             insertText(document.userpass.message, '}');
  14.         }
  15.         if (document.userpass.format_u.value == 1) {    
  16.             insertText(document.userpass.message, '}');
  17.         }
  18. //        if (document.userpass.format_link.value == 1) {    
  19. //            insertText(document.userpass.message, '}');
  20. //        }
  21.         if (document.userpass.format_clr.value == 1) {    
  22.             insertText(document.userpass.message, '}');
  23.         }
  24.         if (document.userpass.format_font.value == 1) {    
  25.             insertText(document.userpass.message, '}');
  26.         }
  27.         if (document.userpass.format_size.value == 1) {    
  28.             insertText(document.userpass.message, '}');
  29.         }
  30.     }
  31.     return true;    
  32. }
  33.  
  34. function storeCursorPosition (elem) {
  35.     if (elem.createTextRange) {
  36.         elem.caretPos = document.selection.createRange().duplicate();
  37.     }
  38. }
  39.  
  40. function insertText (elem, text) {
  41.     elem.focus();
  42.     if (elem.createTextRange && elem.caretPos) {
  43.         var caretPos = elem.caretPos;
  44.         caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  45.     } else {
  46.         elem.value = elem.value + text;
  47.     }
  48. }
  49.  
  50. function bolder () {
  51.     if (document.userpass) {
  52.         if (document.userpass.format_b.value == 1) {
  53.             document.button_b.src = img_bold_up.src;
  54.             insertText(document.userpass.message, '}');
  55.             document.userpass.format_b.value = "0";
  56.         } else {
  57.             document.button_b.src = img_bold_dn.src;
  58.             insertText(document.userpass.message, '\\b{');
  59.             document.userpass.format_b.value = "1";
  60.         }
  61.         document.userpass.message.focus();
  62.     }
  63.     return false;
  64. }
  65.  
  66.  
  67. function linky_click (text) {
  68.     if (document.userpass) {
  69. //        if (document.userpass.format_link.value == 1) {
  70. //            document.button_link.src = img_link_up.src;
  71. //            insertText(document.userpass.message, '}');
  72. //            document.userpass.format_link.value = "";
  73. //        } else {
  74.             var l = prompt(text, "http://");
  75.             if (l != null) {
  76. //                document.button_link.src = img_link_dn.src;
  77.                 insertText(document.userpass.message, '\\newurl{' + l + ',' + l + '}');
  78. //                document.userpass.format_link.value = "1";
  79. //            }
  80.         }
  81.         document.userpass.message.focus();
  82.     }
  83.     return false;
  84. }
  85.  
  86. function italic () {
  87.     if (document.userpass) {
  88.         if (document.userpass.format_i.value == 1) {
  89.             document.button_i.src = img_ital_up.src;
  90.             insertText(document.userpass.message, '}');
  91.             document.userpass.format_i.value = "0";
  92.         } else {
  93.             document.button_i.src = img_ital_dn.src;
  94.             insertText(document.userpass.message, '\\i{');
  95.             document.userpass.format_i.value = "1";
  96.         }
  97.         document.userpass.message.focus();
  98.     }
  99.     return false;
  100. }
  101.  
  102. function underl () {
  103.     if (document.userpass) {
  104.         if (document.userpass.format_u.value == 1) {
  105.             document.button_u.src = img_undl_up.src;
  106.             insertText(document.userpass.message, '}');
  107.             document.userpass.format_u.value = "0";
  108.         } else {
  109.             document.button_u.src = img_undl_dn.src;
  110.             insertText(document.userpass.message, '\\u{');
  111.             document.userpass.format_u.value = "1";
  112.         }
  113.         document.userpass.message.focus();
  114.     }
  115.     return false;
  116. }
  117.  
  118. function smiley () {
  119.     if (document.userpass.inserter.value != "") {
  120.         if (typeof document.userpass.tagname != 'undefined') {
  121.             insertText(document.userpass.message, "\\" + document.userpass.tagname.value + "{" + document.userpass.inserter.value + "}");
  122.         } else {
  123.             insertText(document.userpass.message, "\\clipart{" + document.userpass.inserter.value + "}");
  124.         }
  125.         document.userpass.inserter.value = "";
  126.     }
  127.     document.userpass.message.focus();
  128. }
  129.  
  130. function colorsel () {
  131.     if (document.userpass) {
  132.         if (document.userpass.color) {
  133.             var z = document.userpass.color[document.userpass.color.selectedIndex].value;
  134.             if (z == "") {
  135.                 insertText(document.userpass.message, '}');
  136.                 document.userpass.format_clr.value = 0;
  137.             } else {
  138.                 if (document.userpass.format_clr.value == 1) {
  139.                     insertText(document.userpass.message, "}\\" + z + "{");
  140.                 } else {
  141.                     document.userpass.format_clr.value = 1;
  142.                     insertText(document.userpass.message, "\\" + z + "{");
  143.                 }
  144.             }    
  145.         }
  146.         document.userpass.message.focus();
  147.     }
  148. }
  149.  
  150. function fontsel () {
  151.     if (document.userpass) {
  152.         if (document.userpass.font) {
  153.             var z = document.userpass.font[document.userpass.font.selectedIndex].value;
  154.             if (z == "") {
  155.                 insertText(document.userpass.message, '}');
  156.                 document.userpass.format_font.value = 0;
  157.             } else {
  158.                 if (document.userpass.format_font.value == 1) {
  159.                     insertText(document.userpass.message, "}\\font{" + z + ",");
  160.                 } else {
  161.                     insertText(document.userpass.message, "\\font{" + z + ",");
  162.                     document.userpass.format_font.value = 1;
  163.                 }
  164.             }    
  165.         }
  166.         document.userpass.message.focus();
  167.     }
  168. }
  169.  
  170. function sizesel () {
  171.     if (document.userpass) {
  172.         if (document.userpass.size) {
  173.             var z = document.userpass.size[document.userpass.size.selectedIndex].value;
  174.             if (z == "") {
  175.                 insertText(document.userpass.message, '}');
  176.                 document.userpass.format_size.value = "0";
  177.             } else {
  178.                 if (document.userpass.format_size.value == 1) {
  179.                     insertText(document.userpass.message, "}\\" + z + "{");
  180.                 } else {
  181.                     insertText(document.userpass.message, "\\" + z + "{");
  182.                     document.userpass.format_size.value = 1;
  183.                 }
  184.             }    
  185.         }
  186.         document.userpass.message.focus();
  187.     }
  188. }
  189.