Code:
var m_bHelpOn = false;
var m_bHelpPrompt = false;
var m_bHelpOff = true;
var code = true;
var m_HelpStatus = 0
setHelpState(m_HelpStatus)
// -1 = help alerts on
// 0 = No help
// 1 = Prompt for properties
// browser sniffing to compensate for yes you guessed it!!
var m_bIsFF = false;
var m_bIsIE = false;
if (navigator.userAgent.toLowerCase().indexOf("microsoft") > 0) {
m_bIsIE = true;
}
if(navigator.userAgent.toLowerCase().indexOf("firefox") > 0){
m_bIsFF = true;
}
// prototype method to fix yet another IE shortcoming
// this time it's the lack of indexOf on arrays.
if(!Array.indexOf){
Array.prototype.indexOf = function(obj){
for(var i=0; i<this.length; i++){
if(this[i]==obj){
return i;
}
}
return -1;
}
}
var m_sSelText = "";
var m_oTextEditID = "details";
var m_asTagsFormat = new Array("b","i","u","s","strong","em","lcase","c","ucase","o","sup","sub");
var m_asTitleFormat = new Array("bold","italic","underline","strikethough","strong","emphasis","lowercase","capitalise","uppercase","overline","superscript","subscript");
var m_sHelpFormat = "The ~ tag displays the enclosed text as ~ ";
var m_sUseFormat = " \n\n USE: [#]This is some ~ text[/#]";
var m_sPromptFormat = "Text to be shown as ~.";
var m_asTagsAlign = new Array("left","center","right");
var m_asTitleAlign = new Array("left","centre","right");
var m_sHelpAlign = "The ~ tag aligns the enclosed text ~ ";
var m_sUseAlign = " \n\n USE: [#]This is some ~ aligned text[/#]";
var m_sPromptAlign = "Text to be aligned ~.";
var m_sHelpSize = " Sets the text size. Possible values are 1 to 8.";
var m_sUseSize = " \n\nUSE: [size=#]This is size # text[/size]"
var m_sPromptSize = "Text to be size #";
var m_sHelpHeading = " Sets the heading size. Possible values are 1 to 6.";
var m_sUseHeading = " \n\nUSE: [h#]This is a size # heading[/h#]"
var m_sPromptHeading = "Text to be a heading size #";
var m_sHelpColour = " Sets the text colour.";
var m_sUseColour = " \n\nUSE: [#]This is # text[/#]"
var m_sPromptColour = "Text to be coloured #";
var m_asTagsLinks = new Array("url","ftp","mail","referal","img","aff","jump");
var m_asTitleLinks = new Array("link","FTP","email","referral","image","affiliate","jump");
var m_asProtocol = new Array("http://","ftp://","mailto:","","http://","","");
var m_asSample = new Array("www.example.com","example.com","name@example.com","www.example.com/?id=refcode","www.example.com","/jump.asp?site=www.example.com?refid=code","/jump.asp?site=www.example.com");
var m_sHelpLinks = "The # tag is used to create a ; hyperlink";
var m_sUseLinks = " \n\nUSE: [#=\";¬\"]Anchor Text[/#] ";
var m_sUseLinksExtra = " \n\n Leave off the ; to create a link to the local site ";
var m_sPromptLinks = " ; URL for the link";
var m_sHelpFont = " Sets the font face.";
var m_sUseFont = " \n\nUSE: This text in # font "
var m_sPromptFont = "Text to be # font";
var m_asTagsQuote = new Array("quote","rant");
var m_asTitleQuote = new Array(" a quote"," a rant");
var m_sHelpQuote = "The [#] tag displays the enclosed text as ~ ";
var m_sUseQuote = " \n\n USE: [#]This is ~ [/#]";
var m_sPromptQuote = "Text to be shown as a ~.";
var m_sQuoteTitle = "Enter a title for the # box";
var m_asTagsElement = new Array("both","left","right","p","div");
var m_abEmptyElement = new Array(true,true,true,false,false,false);
var m_asETags = new Array("clear","clear","clear","p","div");
var m_asTitleElement = new Array("clearing","clearing","clearing","paragraph","division");
var m_sHelpElement = "This [~] tag inserts a ~:# element ";
var m_sHelpEmptyElement = "The # tag inserts a ~ element ";
var m_sUseElement = " \n\n USE: [#]~[/#]";
var m_sUseEmptyElement = " \n\n USE: [~]#[/~]";
var m_sPromptElement = "Text to be inside a #.";
var m_asTagsSearch = new Array("google","yahoo","msn");
var m_asTitleSearch = new Array("Google","Yahoo!","msn");
var m_sHelpSearch = "The [search] tag creates a link to search ~ for the phrase";
var m_sUseSearch = " \n\n USE: [search=#]This is some text to search ~ for[/search]";
var m_sPromptSearch = "Text to search ~ for.";
function setURL(p_sTag) {
var l_sLinkText = "";
var l_sURI = null;
var l_sUseLinks = null;
if (p_sTag != "mail") {
l_sUseLinks = m_sUseLinks + m_sUseLinksExtra;
l_sPromptLinks = m_sPromptLinks + m_sUseLinksExtra;
} else {
l_sUseLinks = m_sUseLinks;
l_sPromptLinks = m_sPromptLinks
}
if (m_bHelpOn) {
alert(setDetails(m_sHelpLinks, m_asProtocol, m_asSample, m_asTitleLinks, m_asTagsLinks, p_sTag ) + setDetails(l_sUseLinks, m_asProtocol, m_asSample, m_asTitleLinks, m_asTagsLinks, p_sTag ) );
}
l_sURI = prompt(setDetails(l_sPromptLinks, m_asProtocol, m_asSample, m_asTitleLinks, m_asTagsLinks, p_sTag ),getProtocol(m_asProtocol, m_asTagsLinks ,p_sTag));
if (l_sURI != null) {
if (m_sSelText != "") {
l_sLinkText = getLinkText(p_sTag, l_sURI, m_sSelText);
} else {
l_sLinkText = getLinkText(p_sTag, l_sURI, "");
}
}
if (l_sLinkText != "") {
insertText(m_oTextEditID,l_sLinkText);
}
document.thisform.url.selectedIndex = 0;
}
function getLinkText(p_sTag, p_sURI, p_sAnchor) {
var l_sLinkText = "";
if (p_sAnchor == "") {
p_sAnchor = prompt("Anchor text for the link (leave blank to use URL)","");
}
if (p_sURI != "") {
l_sLinkText = "[" + p_sTag +"=\"" + p_sURI + "\"]" ;
if (p_sAnchor != "") {
l_sLinkText += p_sAnchor + "[/" + p_sTag +"]";
} else {
l_sLinkText += p_sURI + "[/" + p_sTag +"]";
}
}
//document.getElementById("msg").innerHTML = p_sURI + " Selected " + p_sAnchor;
return l_sLinkText;
}
function setDetails(p_sStr, p_PArray, p_SArray, p_TitleArray, p_TagArray, p_sTag ) {
if (p_PArray) {
p_sStr = p_sStr.replace( /;/g, p_PArray[p_TagArray.indexOf(p_sTag)]);
}
if (p_SArray) {
p_sStr = p_sStr.replace( /¬/g, p_SArray[p_TagArray.indexOf(p_sTag)]);
}
if (p_TitleArray) {
p_sStr = p_sStr.replace( /~/g, p_TitleArray[p_TagArray.indexOf(p_sTag)] )
}
return p_sStr.replace( /#/g, p_sTag );
}
function getProtocol(p_PArray, p_TagArray ,p_sTag) {
return p_PArray[p_TagArray.indexOf(p_sTag)];
}
function getIsEmpty(p_PArray, p_TagArray ,p_sTag) {
return p_PArray[p_TagArray.indexOf(p_sTag)];
}
function getTag(p_PArray, p_TagArray ,p_sTag) {
return p_PArray[p_TagArray.indexOf(p_sTag)];
}
function setLinkText(p_sTag,p_sURI) {
return "[" + p_sTag + "=\"" + p_sURI + "\"]" + m_sSelText + "[/" + p_sTag + "]";
}
function insertSymbol(p_sText) {
insertText(m_oTextEditID,"[" + p_sText + "]");
document.thisform.symbol.selectedIndex = 0;
}
function getSelText(p_sObjID) {
l_oObj = document.getElementById(p_sObjID);
if (m_bIsFF) {
m_sSelText = (l_oObj.value).substring(l_oObj.selectionStart, l_oObj.selectionEnd);
} else {
if (window.getSelection){
m_sSelText = window.getSelection();
}else if (document.getSelection){
m_sSelText = document.getSelection();
}else if (document.selection){
m_sSelText = document.selection.createRange().text;
}
}
}
function insertText(p_oObj, p_sText) {
l_oObj = document.getElementById(p_oObj);
if (document.selection) {
l_oObj.focus();
var l_sSel = document.selection.createRange();
l_sSel.text = p_sText;
} else if (l_oObj.selectionStart || l_oObj.selectionStart == '0') {
var l_iStartPos = l_oObj.selectionStart;
var l_iEndPos = l_oObj.selectionEnd;
l_oObj.value = l_oObj.value.substring(0, l_iStartPos)+ p_sText+ l_oObj.value.substring(l_iEndPos, l_oObj.value.length);
} else {
l_oObj.value += p_sText;
}
m_sSelText = "";
l_sSel = null;
}
function appendText(p_oObj, p_sText) {
p_oObj.value += p_sText;
}
function prependText(p_oObj, p_sText) {
p_oObj.value = p_sText + p_oObj.value;
}
function setSearch(p_sValue) {
if (m_bHelpOn) {
alert( setPrompt(m_sHelpSearch, m_asTitleSearch,m_asTagsSearch, p_sValue ) + setPrompt(m_sUseSearch, m_asTitleSearch,m_asTagsSearch, p_sValue ) );
}
if (m_sSelText == "") {
m_sSelText = prompt(setPrompt(m_sPromptSearch,m_asTitleSearch, m_asTagsSearch, p_sValue ),"Text");
}
if (m_sSelText!=null) {
l_sText="[search=\"" + p_sValue +"\"]" + m_sSelText + "[/search]";
insertText(m_oTextEditID,l_sText);
}
// document.thisform.se.selectedIndex = 0;
}
function setElement(p_sValue) {
var l_bIsEmpty = getIsEmpty(m_abEmptyElement,m_asTagsElement,p_sValue);
var l_sTag = "";
var l_sText = "";
if (l_bIsEmpty) {
l_sTag = getTag(m_asETags,m_asTagsElement,p_sValue);
} else {
l_sTag = p_sValue;
}
if (m_bHelpOn) {
if (l_bIsEmpty) {
alert( setPrompt(m_sHelpElement, m_asETags,m_asTagsElement, p_sValue ) + setPrompt(m_sUseEmptyElement, m_asETags,m_asTagsElement, p_sValue ) );
} else {
alert( setPrompt(m_sHelpEmptyElement, m_asTitleElement,m_asTagsElement, p_sValue ) + setPrompt(m_sUseElement, m_asTitleElement,m_asTagsElement, p_sValue ) );
}
}
if (!l_bIsEmpty) {
if (m_sSelText == "") {
m_sSelText = prompt(setQuest(m_sPromptElement,p_sValue ),"");
}
}
if (l_bIsEmpty) {
l_sText="[" + l_sTag +"]" + p_sValue + "[/" + l_sTag +"]";
} else {
if (m_sSelText!=null) {
l_sText="[" + l_sTag +"]" + m_sSelText + "[/" + l_sTag +"]";
}
}
if (l_sText != "") {
insertText(m_oTextEditID,l_sText);
}
document.thisform.element.selectedIndex = 0;
}
function setHeading(p_sValue) {
if (m_bHelpOn) {
alert( m_sHelpHeading + setQuest(m_sUseHeading,p_sValue ) );
}
if (m_sSelText == "") {
m_sSelText=prompt(setQuest(m_sPromptHeading, p_sValue ),"Text");
}
if (m_sSelText!=null) {
l_sText="[h" + p_sValue +"]" + m_sSelText + "[/h" + p_sValue +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.heading.selectedIndex = 0;
}
function setColour(p_sValue) {
if (m_bHelpOn) {
alert( m_sHelpColour + setQuest(m_sUseColour,p_sValue ) );
}
if (m_sSelText == "") {
m_sSelText=prompt(setQuest(m_sPromptColour, p_sValue ),"Text");
}
if (m_sSelText!=null) {
l_sText="[" + p_sValue +"]" + m_sSelText + "[/" + p_sValue +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.colour.selectedIndex = 0;
}
function setFont(p_sValue) {
if (m_bHelpOn) {
alert( m_sHelpFont + setQuest(m_sUseFont,p_sValue ) );
}
if (m_sSelText == "") {
m_sSelText=prompt(setQuest(m_sPromptFont, p_sValue ),"Text");
}
if (m_sSelText!=null) {
l_sText="" + m_sSelText + "";
insertText(m_oTextEditID,l_sText);
}
document.thisform.font.selectedIndex = 0;
}
function setSize(p_sValue) {
if (m_bHelpOn) {
alert( m_sHelpSize + setQuest(m_sUseSize,p_sValue ) );
}
if (m_sSelText == "") {
m_sSelText=prompt(setQuest(m_sPromptSize, p_sValue ),"Text");
}
if (m_sSelText!=null) {
l_sText="[size" + p_sValue +"]" + m_sSelText + "[/size]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.size.selectedIndex = 0;
}
function setAlign(p_sValue) {
if (m_bHelpOn) {
alert( setPrompt(m_sHelpAlign, m_asTitleAlign,m_asTagsAlign, p_sValue ) + setPrompt(m_sUseAlign, m_asTitleAlign,m_asTagsAlign, p_sValue ) );
}
if (m_sSelText == "") {
m_sSelText = prompt(setPrompt(m_sPromptAlign,p_sValue ),m_sSelText);
}
if (m_sSelText!=null) {
l_sText="[" + p_sValue +"]" + m_sSelText + "[/" + p_sValue +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.align.selectedIndex = 0;
}
function setQuote(p_sValue) {
if (m_bHelpOn) {
alert( setPrompt(m_sHelpQuote, m_asTitleQuote,m_asTagsQuote, p_sValue ) + setPrompt(m_sUseQuote, m_asTitleQuote,m_asTagsQuote, p_sValue ) );
}
if (m_sSelText == "") {
if (p_sValue != "rant") {
var l_sTitle = prompt(setQuest(m_sQuoteTitle, p_sValue));
}
m_sSelText=prompt(setQuest(m_sPromptQuote, p_sValue ),"Text");
} else {
if (p_sValue != "rant") {
var l_sTitle = prompt(setQuest(m_sQuoteTitle, p_sValue));
}
}
if (m_sSelText!=null) {
l_sText="[" + p_sValue;
if (l_sTitle) {
l_sText += "=\"" + l_sTitle + "\"";
}
l_sText += "]" + m_sSelText + "[/" + p_sValue +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.size.selectedIndex = 0;
}
function setAffProduct() {
var l_oSelected = document.getElementById("affref");
l_sSelText = l_oSelected.options[l_oSelected.selectedIndex].value;
l_sTag = "referal";
if (l_sSelText!=null) {
l_sText="[" + l_sTag + "=\"" + l_sSelText + "\"]" + l_sSelText + "[/" + l_sTag +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.affref.selectedIndex = 0;
}
function setQuickProduct() {
var l_oSelected = document.getElementById("quickref");
l_sSelText = l_oSelected.options[l_oSelected.selectedIndex].value;
l_sTag = "qprod";
if (l_sSelText!=null) {
l_sText="[" + l_sTag + "=\"" + l_sSelText + "\"]" + l_sSelText + "[/" + l_sTag +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.quickref.selectedIndex = 0;
}
function setFormat(p_sTag) {
if (m_bHelpOn) {
alert( setPrompt(m_sHelpFormat, m_asTitleFormat,m_asTagsFormat, p_sTag ) + setPrompt(m_sUseFormat, m_asTitleFormat,m_asTagsFormat, p_sTag ) );
}
if (m_sSelText == "") {
m_sSelText=prompt(setPrompt(m_sPromptFormat, m_asTitleFormat,m_asTagsFormat, p_sTag ),"Text");
}
if (m_sSelText!=null) {
l_sText="[" + p_sTag +"]" + m_sSelText + "[/" + p_sTag +"]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.format.selectedIndex = 0;
}
function setArticle(p_sText) {
if (p_sText!="") {
l_sText="[article]" + p_sText + "[/article]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.sel_article.selectedIndex = 0;
}
function setCore(p_sText) {
if (p_sText!="") {
l_sText="[local]" + p_sText + "[/local]";
insertText(m_oTextEditID,l_sText);
}
document.thisform.sel_core.selectedIndex = 0;
}
function setPrompt(p_sStr, p_TitleArray, p_TagArray, p_sTag ) {
if (p_TitleArray) {
p_sStr = p_sStr.replace( /~/g, p_TitleArray[p_TagArray.indexOf(p_sTag)] )
}
return p_sStr.replace( /#/g, p_sTag );
}
function setQuest(p_sStr, p_sTag ) {
return p_sStr.replace( /#/g, p_sTag );
}
function ltrim(s) {
return s.replace( /^\s*/, "" );
}
function rtrim(s) {
return s.replace( /\s*$/, "" );
}
function trim ( s ) {
return rtrim(ltrim(s));
}
function setHelpState(p_iSel){
m_HelpStatus = p_iSel;
if (m_HelpStatus == -1){
m_bHelpOff = false;
m_bHelpPrompt = false;
m_bHelpOn = true;
} else if (m_HelpStatus == 0) {
m_bHelpOn = false;
m_bHelpPrompt = false;
m_bHelpOff = true;
} else if (m_HelpStatus == 1) {
m_bHelpOn = false;
m_bHelpOff = false;
m_bHelpPrompt = true;
}
}
setUserText
function setUserText(p_sValue) {
l_sText = "[" + p_sValue +"]";
if (m_bHelpOn) {
alert("Special function to insert predefined text \n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
document.thisform.usertext.selectedIndex = 0;
}
function setUserSnippet(p_sValue, p_iUserId) {
l_sText = '[snippet=\"' + p_iUserId + '\"]' + p_sValue + '[/snippet]';
if (m_bHelpOn) {
alert("Special function to insert user defined text snippets \n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
document.thisform.usersnippet.selectedIndex = 0;
}
function co() {
l_sText = "[company]";
if (m_bHelpOn) {
alert("Special function to add company name to text \n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
}
function copy() {
l_sText = "[copy]";
if (m_bHelpOn) {
alert("Special function to add copyright symbol © to text \n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
}
function tm() {
l_sText = "[tm]";
if (m_bHelpOn) {
alert("Special function to add trademark symbol ™ to text \n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
}
function reg() {
l_sText = "[reg]";
if (m_bHelpOn) {
alert("Special function to add registrated mark ® to text \n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
}
function hr() {
l_sText = "[hr]";
if (m_bHelpOn) {
alert("Horizontal Rule creates a horizontal line across the page.\n\nUSE: " + l_sText);
} else {
insertText(m_oTextEditID,l_sText);
}
}
function CheckLen(p_sShowCount, p_sInput, p_iLimit) {
e = document.getElementById(p_sInput);
if (e.value.length > p_iLimit) {
// if too long...trim it!
e.value = e.value.substring(0, p_iLimit);
// otherwise, update 'characters left' counter
} else {
document.getElementById(p_sShowCount).innerHTML = p_iLimit - e.value.length;
}
}
// to be rewritten
function list() {
if (m_bHelpOn) {
alert("List Tag Builds a bulleted, numbered, or alphabetical list.\n\nUSE:- item1[/*]
- item2[/*]
- item3[/*]
");
} else if (m_bHelpOff) {
AddTxt="
- [li] [/li][li] [/li][li] [/li]
";
AddText(AddTxt);
} else {
type=prompt("Type of list Enter \'A\' for alphabetical, \'1\' for numbered, Leave blank for bulleted.","");
while ((type!="") && (type!="A") && (type!="a") && (type!="1") && (type!=null)) {
type=prompt("ERROR! The only possible values for type of list are blank 'A' and '1'.","");
}
if (type!=null) {
if (type=="") {
AddTxt="[list]";
} else {
AddTxt="
- ";
}
txt="1";
while ((txt!="") && (txt!=null)) {
txt=prompt("List item Leave blank to end list","");
if (txt!="") {
AddTxt+="[li]"+txt+"[/li]";
}
}
if (type=="") {
AddTxt+="
";
} else {
AddTxt+="[/list="+type+"]";
}
AddText(AddTxt);
}
}
}
function resizeTextarea()
{
if (document.thisform.SelectSize.value == 1)
{
document.thisform.details.cols = 45;
document.thisform.details.rows = 11;
}
if (document.thisform.SelectSize.value == 2)
{
document.thisform.details.cols = 70;
document.thisform.details.rows = 12;
}
if (document.thisform.SelectSize.value == 3)
{
document.thisform.details.cols = 90;
document.thisform.details.rows = 12;
}
if (document.thisform.SelectSize.value == 4)
{
document.thisform.details.cols = 130;
document.thisform.details.rows = 15;
}
}
function ResetForm(form) {
var where_to= confirm("Do you really want to Reset the Form Fields?");
if (where_to== true) {
form.reset();
}
}
function viewPost()
{
if (document.thisform.details)
{
if (trim(document.thisform.details.value)=="")
{
return false
} else {
popupWin = window.open('/preview.asp', 'preview_page', 'scrollbars=yes,width=900,height=600')
return true
}
}
}
function closePreview() {
popupWin.close;
}