Hacks

A new text input method

bbchen  25 May 2003 3:34 PM 10263 Reads   23 Comment(s) 
1.###edit includes/xoopscodes.php
Find:
le="color: #000000"><?php <textarea id='".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows'

after it add:
le="color: #000000"><?php onSelect='xoopsSavePosition("$textarea_id");' onClick='xoopsSavePosition("$textarea_id");' onKeyUp='xoopsSavePosition("$textarea_id");'

the code will be like this:
le="color: #000000"><?php <textarea id='".$textarea_id."' name='".$textarea_id."' cols='$cols' rows='$rows' onSelect='xoopsSavePosition("$textarea_id");' onClick='xoopsSavePosition("$textarea_id");' onKeyUp='xoopsSavePosition("$textarea_id");' >


2.Edit includes/xoopsjs.php
Modify the function like this:
function xoopsCodeUrl(id){ if (document.getSelection) {var selection=document.getSelection();} else if (document.selection) {var selection=document.selection.createRange().text;} else return; if (selection){ var text = prompt("<?php echo _ENTERURL;?>", selection);} else { var text = prompt("<?php echo _ENTERURL;?>", "");} var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { if (selection !=null){ var text2 = prompt("<?php echo _ENTERWEBTITLE;?>", selection);var selection="";} else{ var text2 = prompt("<?php echo _ENTERWEBTITLE;?>", "");} if ( text2 != null ) { if ( text2 == "" ) { var result = "[url=" + text + "]" + text + "[/url]"; } else { var pos = text2.indexOf(unescape('%00')); if(0 < pos){ text2 = text2.substr(0,pos); } var result = "[url=" + text + "]" + text2 + "[/url]"; } xoopsInsertText(domobj, result); } } domobj.focus(); } function xoopsCodeImg(id){ if (document.getSelection) {var selection=document.getSelection();} else if (document.selection) {var selection=document.selection.createRange().text;} else return; if (selection !=null){ var text = prompt("<?php echo _ENTERIMGURL;?>", selection); var selection="";} else { var text = prompt("<?php echo _ENTERIMGURL;?>", "");} var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var text2 = prompt("<?php echo _ENTERIMGPOS;?>n<?php echo _IMGPOSRORL;?>", ""); while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) { text2 = prompt("<?php echo _ERRORIMGPOS;?>n<?php echo _IMGPOSRORL;?>",""); } if ( text2 == "l" || text2 == "L" ) { text2 = " align=left"; } else if ( text2 == "r" || text2 == "R" ) { text2 = " align=right"; } else { text2 = ""; } var result = "[img" + text2 + "]" + text + "[/img]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeEmail(id){ if (document.getSelection) {var selection=document.getSelection();} else if (document.selection) {var selection=document.selection.createRange().text;} else return; if (selection !=null){ var text = prompt("<?php echo _ENTEREMAIL;?>", selection); var selection="";} else{ var text = prompt("<?php echo _ENTEREMAIL;?>", "");} var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var result = "[email]" + text + "[/email]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeQuote(id){ if (document.getSelection) {var selection=document.getSelection();} else if (document.selection) {var selection=document.selection.createRange().text;} else return; //document.forms[0].selectedtext.value = selection.replace(new RegExp('([\f\n\r\t\v ])+', 'g')," "); if (selection !=null){ var text = prompt("<?php echo _ENTERQUOTE;?>", selection);var selection="";} else{ var text = prompt("<?php echo _ENTERQUOTE;?>", "");} var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var pos = text.indexOf(unescape('%00')); if(0 < pos){ text = text.substr(0,pos); } var result = "[quote]" + text + "[/quote]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeCode(id){ if (document.getSelection) {var selection=document.getSelection();} else if (document.selection) {var selection=document.selection.createRange().text;} else return; // document.forms[0].selectedtext.value = selection.replace(new RegExp('([\f\n\r\t\v ])+', 'g')," "); if (selection !=null){ var text = prompt("<?php echo _ENTERCODE;?>", selection);var selection="";} else{ var text = prompt("<?php echo _ENTERCODE;?>", "");} var domobj = xoopsGetElementById(id); if ( text != null && text != "" ) { var result = "[code]" + text + "[ /code]"; xoopsInsertText(domobj, result); } domobj.focus(); } function xoopsCodeText(id, hiddentext){ var textareaDom = xoopsGetElementById(id); var textDom = xoopsGetElementById(id + "Addtext"); var fontDom = xoopsGetElementById(id + "Font"); var colorDom = xoopsGetElementById(id + "Color"); var sizeDom = xoopsGetElementById(id + "Size"); var xoopsHiddenTextDomStyle = xoopsGetElementById(hiddentext).style; var fontDomValue = fontDom.options[fontDom.options.selectedIndex].value; var colorDomValue = colorDom.options[colorDom.options.selectedIndex].value; var sizeDomValue = sizeDom.options[sizeDom.options.selectedIndex].value; if (document.getSelection) {var selection=document.getSelection();} else if (document.selection) {var selection=document.selection.createRange().text;} else return; // document.forms[0].selectedtext.value = selection.replace(new RegExp('([\f\n\r\t\v ])+', 'g')," "); if (selection) { var textDomValue = selection; var selection=""; } else { var textDomValue = textDom.value; } if ( textDomValue == "" ) { alert("<?php echo _ENTERTEXTBOX;?>"); textDom.focus(); } else { if ( fontDomValue != "FONT") { textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]"; fontDom.options[0].selected = true; } if ( colorDomValue != "COLOR") { textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]"; colorDom.options[0].selected = true; } if ( sizeDomValue != "SIZE") { textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]"; sizeDom.options[0].selected = true; } if (xoopsHiddenTextDomStyle.fontWeight == "bold") { textDomValue = "[b]" + textDomValue + "[/b]"; xoopsHiddenTextDomStyle.fontWeight = "normal"; } if (xoopsHiddenTextDomStyle.fontStyle == "italic") { textDomValue = "[i]" + textDomValue + "[/i]"; xoopsHiddenTextDomStyle.fontStyle = "normal"; } if (xoopsHiddenTextDomStyle.textDecoration == "underline") { textDomValue = "[u]" + textDomValue + "[/u]"; xoopsHiddenTextDomStyle.textDecoration = "none"; } if (xoopsHiddenTextDomStyle.textDecoration == "line-through") { textDomValue = "[d]" + textDomValue + "[/d]"; xoopsHiddenTextDomStyle.textDecoration = "none"; } xoopsInsertText(textareaDom, textDomValue); textDom.value = ""; xoopsHiddenTextDomStyle.color = "#000000"; xoopsHiddenTextDomStyle.fontFamily = ""; xoopsHiddenTextDomStyle.fontSize = "12px"; xoopsHiddenTextDomStyle.visibility = "hidden"; textareaDom.focus(); } }

Rating 0/5
Rating: 0/5 (0 votes)
Voting is disabled!


Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Categories