/* Code (C) Xanikseo 2008 Use but don't let loose. i.e. don't claim it. */ var xan_bb_tags = '',xan_bb_tags_after = ''; var regex_variable,regex_var_str,newline_button,x,i; undefined;null; // Speeds up all mentionings of these variables in some browsers function while_replace(text,replacetext,withtext) { while(text.split(replacetext).length>1) { text = text.replace(replacetext,withtext); } return text; } function no_bb_codes() { //Don't allow Xanik Tags to work in [code][/code] x = document.getElementsByTagName('code'); for(i=0;i["); } } function make_reg_ex(text) { //Turn string variables into string literals, (easiest way is to temporarily make it a regex) if(!text)return null; return '/' + text.replace(/\//g,'\\/') + '/'; } function stringise_reg(reg_exxx) { if(!reg_exxx)return null; return reg_exxx.toString().replace(/^\/(.*|\s*)\/$/,'$1').replace(/\\\//g, '/'); } function isPtype(ptype) { //Test if browsing a certain category of page switch(ptype) { case 'all': if(window.location.href.match(/\/topic\//) || window.location.href.match(/\/msg\//) || window.location.href.match(/\/post\//) || window.location.href.match(/\?c=32/) || window.location.href.match(/\/site\//) || window.location.href.match(/\/profile\//) || window.location.href.match(/\/single\//) || window.location.href.match(/\/search\//) && !window.location.href.match('&poll=') ) return true; break; case 'topic': if(window.location.href.match(/\/topic\//) || window.location.href.match(/\/msg\/\?c=1&folder=/) || window.location.href.match(/\/single\//) || window.location.href.match(/\/search\//) ) return true; break; case 'post': if(window.location.href.match(/\/post\//) || window.location.href.match(/\/msg\/\?c=2/) && !window.location.href.match('&poll=') ) return true; break; case 'sig': if(window.location.href.match(/\?c=32/) ) return true; break; case 'profile': if(window.location.href.match(/\profile\//) ) return true; break; case 'portal': if(window.location.href.match(/\/site\//) ) return true; break; } return false; } if(isPtype('all')) { no_bb_codes(); } function ubb_tag(name,beg,wrapHTML,variable,description,signature,button,button_val) { //Initiate all necessary functions if( isPtype('all') ) { if(signature == undefined){ signature = 3;}else if(!isFinite(signature)){button_val=signature;signature=3;} //Allow for button_val to be specified in signature variable ubb_tag2(name,beg,wrapHTML,variable,description,signature,'div'); ubb_tag2(name,beg,wrapHTML,variable,description,signature,'td'); //ubb_tag2(name,beg,wrapHTML,variable,description,signature,'span'); if(isPtype('post') || isPtype('sig') || window.location.href.match(/\/msg\/\?c=1&folder=/) ) { //Store functions to be executed when preview button is clicked xan_bb_tags += "ubb_tag2(stringise_reg("+make_reg_ex(name)+"),stringise_reg("+make_reg_ex(beg)+"),stringise_reg("+make_reg_ex(wrapHTML)+"),"+variable+",stringise_reg("+make_reg_ex(description)+"),"+signature+",'div');"; eval("if(typeof(xbb_"+beg+")=='function') xan_bb_tags_after += 'xbb_"+beg+"();'"); } if (isPtype('sig') && (signature == 0 || signature == 2) ) return; //Exit function if button is disabled (speeds up everything) if( (isPtype('sig') || isPtype('post')) && (button == undefined || button > 0 || !isFinite(button)) ) { x = document.getElementById('c_bbcode'); if(!(x.innerHTML.match('@@#@@'))) x.innerHTML += '
@@#@@

'; //First button is on a line of it's own if (button != undefined && !isFinite(button)) { button_val = button; } else if(button_val == undefined || button_val == '') { //These are for allowing certain variables to be new button values button_val = name; } if(signature == 4 || button == 2) { newline_button = '
'; } else { newline_button = ''; } x.innerHTML += " " + newline_button; } } } function ubb_tag2(name,beg,wrapHTML,variable,description,signature,tagtag) { x = document.getElementsByTagName(tagtag); i=x.length; while(i-->0) { //Faster way to loop in some browsers if(x[i].innerHTML.match(beg) && (x[i].className == 'c_post' || ( x[i].className == 'c_sig' && x[i].id != 'c_post' && (signature == 1 || signature > 2) ) || (tagtag == 'td' && signature >= 2 && (x[i].className == 'c_poll-choice' || x[i].className == 'c_poll-answer' || (isPtype('portal') && x[i].className == 'row1')) ) || x[i].className == 'portal_content' || x[i].parentNode.parentNode.parentNode.id == 'topic_review' || x[i].parentNode.parentNode.id == 'topic_review' || (x[i].id == 'c_post-preview' && !(isPtype('sig') && !(signature == 1 || signature > 2))) || x[i].parentNode.className == 'search_results' )) { //Test for right conditions in which to parse BB codes if(variable == 0) { regex_variable = new RegExp ("\\[" + beg + "\\](.*?|\\s*)\\[\\/" + beg + "\\]","g"); while(x[i].innerHTML.match(regex_variable)) { x[i].innerHTML = x[i].innerHTML.replace(regex_variable, wrapHTML = wrapHTML.replace(/<% INNER %>/g, '\$1')); } } else if(variable == 1) { regex_variable = new RegExp ("\\[" + beg + "=(.+?)\\](.*?|\\s*)\\[\\/" + beg + "\\]","g"); while(x[i].innerHTML.match(regex_variable)) { x[i].innerHTML = x[i].innerHTML.replace(regex_variable, wrapHTML = wrapHTML.replace(/<% INNER %>/g, '\$2').replace(/<% VAR(?:\[1\])? %>/g, '\$1')); } } else if(variable > 1) { regex_var_str = "(.+?),(.+?)"; for(a=2;a/g, '\$' + (variable+1)).replace(/<% VAR(?:\[1\])? %>/g, '\$1').replace(/<% VAR\[(\d+)\] %>/g, "$$$1") ); } } else if(variable == -1) { x[i].innerHTML = x[i].innerHTML.replace(new RegExp ("\\[" + beg + "\\]","g"),wrapHTML); } } } } // End of BB parsing function function hstat_xanik(text) { //Button of BB Code description put into little box document.posting.helpbox.value = text; } function add_ubb_tag_to_post(opentag,variable,description) { description = description.split('||'); var input_array = new Array(); if(variable == -1) { ZetaInsert("["+opentag+"]") return; } else if(variable == 0) { ZetaInsert("["+opentag+"]","[/"+opentag+"]") } else if(variable > 0) { for(ggjj=0;ggjj 0) { ZetaInsert('[' + opentag + '=' + input_array.join(",").replace(input_array[0] + ',','') + ']' + input_array[0] + '[/' + opentag + ']'); } } function Preview () { //Modified preview function, to be executed when preview button is pressed var b; if ($("#c_post-preview").length || $("#c_post textarea").val() || $("#txt_quote").val()) { if (!$("#c_post-preview").length) { $("#c_post").prepend("
"); } if ($("#txt_quote").length && $("#txt_quote").val()) { b = "[quote]" + $("#txt_quote").val() + "[/quote]"; } else { b = ""; } $.post(main_url + "tasks/", {task: 5, post: b + $("#c_post textarea").val()}, function (a) {$("#c_post-preview").html(a);no_bb_codes();eval(xan_bb_tags);eval(xan_bb_tags_after);$("#c_post-preview div.spoiler_toggle").click(function () {$(this).next().toggle();});}); } return false; }