Implemeting Jass Tags Into Vbulletin.

Reaction score
341
Ok i searched this site for how to implement jass tags into a vbulletin site and i found a parser?

PHP:
<?php
// Jass Highlighter
// Written by Asger Feldthaus (KaTTaNa)

if(!defined('JASS_HIGHLIGHTER_INCLUDED'))  // Make sure it is only included once.
{
define('JASS_HIGHLIGHTER_INCLUDED', true);

function FixWord($word) {
  $Blocks = 
   " constant native function takes returns endfunction if then else elseif endif loop endloop exitwhen ( ) [ ] ";
   
  $Keywords = 
   " call set local return not and or ";

  $Values = 
   " true false null ";

  $Types = 
   " nothing array string integer real code boolean handle event player widget unit destructable item ability buff ".
   "force group trigger triggercondition triggeraction timer location region rect boolexpr sound conditionfunc filterfunc ".
   "unitpool itempool race alliancetype racepreference gamestate igamestate fgamestate playerstate playergameresult ".
   "unitstate aidifficulty eventid gameevent playerevent playerunitevent unitevent limitop widgetevent dialogevent ".
   "unittype gamespeed gamedifficulty gametype mapflag mapvisibility mapsetting mapdensity mapcontrol playerslotstate ".
   "volumegroup camerafield camerasetup playercolor placement startlocprio raritycontrol blendmode texmapflags effect ".
   "effecttype weathereffect terraindeformation fogstate fogmodifier dialog button quest questitem defeatcondition timerdialog ".
   "leaderboard multiboard multiboarditem trackable gamecache version itemtype texttag playerscore lightning pathingtype image ubersplat ".
   "attacktype damagetype weapontype soundtype ";
   
  if (strpos($Blocks, " ".$word." ")!== false) {
    return "<b>".$word."</b>";
  } 
  elseif (strpos($Keywords, " ".$word." ")!== false) {
    return "<span style=\"color: Navy;\">".$word."</span>";
  }
  elseif (strpos($Values, " ".$word." ")!== false) {
    return "<span style=\"color: Maroon;\">".$word."</span>";
  }
  elseif (strpos($Types, " ".$word." ")!== false) {
    return "<span style=\"color: rgb(50, 100, 200);\">".$word."</span>";
  }
  return $word;
}

function HighlightJass($text, $bb=false) { 
  $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  $special = "[]()";
  $str = "\"'";
  $trans = Array(">" => "&gt;", "<" => "&lt;", "&" => "&amp;");
  if (!$bb)
  {
  	$text = strtr($text, $trans);
  }
  else
  {
  	// Do some backwards working
	$tr = array('(' => '(',
				')' => ')',
				'[' => '[',
				']' => ']',
				'&quot;' => '"');
	$text = strtr($text,$tr);
  }
  
  $result = "";
  $comment = 0;
  $Lines = explode("\n", $text);
  $anchors = array();
  $n = 0;
  // First, find all functions and place an anchor there
  foreach($Lines as $Line) 
  {
  	// Leave anchor here?
	$reg = array();
	$anchors[$n] = '';
  	if (ereg('^ *(constant )? *(function|native)  *([a-zA-Z_][a-zA-Z_0-9]*)  *takes', $Line, $reg))
	{
		$l = max(0, $n-12);
		$anchors[$l] .= '<a name="'.strtolower($reg[3]).'"></a>';
	}
	$n++;
  }
  $n = 0;
  foreach($Lines as $Line) 
  {
    $result .= $anchors[$n];
	$Line = rtrim($Line);
	if ($isString) {
	  $result = $result . "</span>";
	}
    $stop = strpos($Line, "//");
	if ($stop === false) {
	  $stop = strlen($Line);
	  $comment = 0;
	} else {
	  $comment = 1;
	}
    $i = 0;
	$word = "";
	$isString = 0;
	$stringStarter = "";	
	$slashed = 0;
	// Highlight
	while ($i < $stop) {
	  $c = substr($Line, $i, 1);
	  $i += 1;
	  
	  if ($isString) {
	    $result = $result . $c;
	    if ($c == "\\") {
		  $slashed = ($slashed)? 0:1;
		} elseif (($c == $stringStarter) && !($slashed)) {
		  $result = $result . "</span>";
		  $isString = 0;
		} else {
		  $slashed = 0;
		}
	  } else {
	    // If normal character
	    if (strpos($chars, $c) !== false) {
          $word = $word . $c;
		
	    // If bracket
	    } elseif (strpos($special, $c) !== false) {
	      $result = $result . FixWord($word) . FixWord($c);
	    	$word = "";
		
	    // If string
        } elseif (strpos($str, $c) !== false) { 
	      $result = $result . FixWord($word) . "<span style=\"color: blue\">" . $c;
		  $slashed = 0;
		  $word = "";
		  $isString = 1;
		  $stringStarter = $c;
		
	    // If other character
	    } else {
	      $result = $result . FixWord($word) . $c;
		  $word = "";
        }
		
	  } // if ($isString)
	}
	$result = $result . FixWord($word);
	
	// Add comment
	if ($comment) {
	  $result = $result . "<span style=\"color: green;\">".strstr($Line, "//")."</span>";
	}
	// Add linebreak
	$result = $result . '<br />';
	$n++;
  }
  $result = substr($result, 0, strlen($result)-1); // Remove last linebreak
  
  if ($bb)
  {
  	$tr = array('(' => '(',
				')' => ')',
				'[' => '[',
				']' => ']');
	$result = strtr($result, $tr);
  }
  
  return $result;
}

}
?>


how would i use this to implement the jass tags?
 

TFlan

I could change this in my User CP.
Reaction score
64
Exactly.

A simple find and replace will do the trick.

With a condition to only do the find and replace within certain tags.

IE: [ jass] code here [/jass ]

writing the code... gimme a sec

PHP:
$content = "code here";
$content = HighlightJass($content);
$search = array( "[jass]", "[/jass]" );
$replace = array( 
	"<div style='margin:20px; margin-top:5px'>
		<div style='margin-bottom:2px'>Jass:</div>
		<div dir='ltr' style='text-align:left;'>
			<pre style='margin:0px; padding:6px; border:1px inset; width:800px; height:34px; overflow:auto'>",
			"</pre>
		</div>
	</div>" );
str_replace($search, $replace, $content);

I think thats how the Jass Highlighting script works. Send the text to the script using HighlightJass().

Then it searches for [ jass] and [/jass ] in the content and replaces it with what u see on this site prior to the code and after.

PS: i had to put a space ( ' ' ) inside the tags so the site didnt make the <pre> tags around my post.
 
Reaction score
341
thanks ill try that and post back if it works :)


EDIT : Im really confused , what do i do with the code you gave me?
 

TFlan

I could change this in my User CP.
Reaction score
64
... it just repeats the php code

What do you mean?

----

If all else fails, edit the source code of the posts php file to run that script. Could get messy and require alot of trial and error, but this is your last resort option.
 
Reaction score
341
whenever i add the bbcode and u type the "["jass] code.. [/jass"]" it just shows


PHP:
".$word.""; } elseif (strpos($Keywords, " ".$word." ")!== false) { return "".$word.""; } elseif (strpos($Values, " ".$word." ")!== false) { return "".$word.""; } elseif (strpos($Types, " ".$word." ")!== false) { return "".$word.""; } return $word; } function HighlightJass($text, $bb=false) { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; $special = "[]()"; $str = "\"'"; $trans = Array(">" => ">", "<" => "<", "&" => "&"); if (!$bb) { $text = strtr($text, $trans); } else { // Do some backwards working $tr = array('(' => '(', ')' => ')', '[' => '[', ']' => ']', '"' => '"'); $text = strtr($text,$tr); } $result = ""; $comment = 0; $Lines = explode("\n", $text); $anchors = array(); $n = 0; // First, find all functions and place an anchor there foreach($Lines as $Line) { // Leave anchor here? $reg = array(); $anchors[$n] = ''; if (ereg('^ *(constant )? *(function|native) *([a-zA-Z_][a-zA-Z_0-9]*) *takes', $Line, $reg)) { $l = max(0, $n-12); $anchors[$l] .= ''; } $n++; } $n = 0; foreach($Lines as $Line) { $result .= $anchors[$n]; $Line = rtrim($Line); if ($isString) { $result = $result . ""; } $stop = strpos($Line, "//"); if ($stop === false) { $stop = strlen($Line); $comment = 0; } else { $comment = 1; } $i = 0; $word = ""; $isString = 0; $stringStarter = ""; $slashed = 0; // Highlight while ($i < $stop) { $c = substr($Line, $i, 1); $i += 1; if ($isString) { $result = $result . $c; if ($c == "\\") { $slashed = ($slashed)? 0:1; } elseif (($c == $stringStarter) && !($slashed)) { $result = $result . ""; $isString = 0; } else { $slashed = 0; } } else { // If normal character if (strpos($chars, $c) !== false) { $word = $word . $c; // If bracket } elseif (strpos($special, $c) !== false) { $result = $result . FixWord($word) . FixWord($c); $word = ""; // If string } elseif (strpos($str, $c) !== false) { $result = $result . FixWord($word) . "" . $c; $slashed = 0; $word = ""; $isString = 1; $stringStarter = $c; // If other character } else { $result = $result . FixWord($word) . $c; $word = ""; } } // if ($isString) } $result = $result . FixWord($word); // Add comment if ($comment) { $result = $result . "".strstr($Line, "//").""; } // Add linebreak $result = $result . '
'; $n++; } $result = substr($result, 0, strlen($result)-1); // Remove last linebreak if ($bb) { $tr = array('(' => '(', ')' => ')', '[' => '[', ']' => ']'); $result = strtr($result, $tr); } return $result; } } ?> $content = "code here"; $content = HighlightJass($content); $search = array( "[jass]", "[/jass]" ); $replace = array( "
Jass:
",
            "" ); str_replace($search, $replace, $content);
 

TFlan

I could change this in my User CP.
Reaction score
64
Because you set the replacement text to be the actual script. So you said: Where there is [jass ] asdfasdf [/jass ] replace all of it with <script above>.

Do this, in the replacement textbox have this: HighlightJass({param});

Then add the actual script (without my addition to it) to the BBCode source page.

Try that.

You may need to add the php tags:
<?php HighlightJass( ?>{param}<?php ); ?>
 
Reaction score
341
ill try rite now


EDIT : i did whatever u told me to do ( i think.. ) does the same thing.

PHP:
HighlightJass({param});
<?php 
// Jass Highlighter 
// Written by Asger Feldthaus (KaTTaNa) 

if(!defined('JASS_HIGHLIGHTER_INCLUDED'))  // Make sure it is only included once. 
{ 
define('JASS_HIGHLIGHTER_INCLUDED', true); 

function FixWord($word) { 
  $Blocks =  
   " constant native function takes returns endfunction if then else elseif endif loop endloop exitwhen ( ) [ ] "; 
    
  $Keywords =  
   " call set local return not and or "; 

  $Values =  
   " true false null "; 

  $Types =  
   " nothing array string integer real code boolean handle event player widget unit destructable item ability buff ". 
   "force group trigger triggercondition triggeraction timer location region rect boolexpr sound conditionfunc filterfunc ". 
   "unitpool itempool race alliancetype racepreference gamestate igamestate fgamestate playerstate playergameresult ". 
   "unitstate aidifficulty eventid gameevent playerevent playerunitevent unitevent limitop widgetevent dialogevent ". 
   "unittype gamespeed gamedifficulty gametype mapflag mapvisibility mapsetting mapdensity mapcontrol playerslotstate ". 
   "volumegroup camerafield camerasetup playercolor placement startlocprio raritycontrol blendmode texmapflags effect ". 
   "effecttype weathereffect terraindeformation fogstate fogmodifier dialog button quest questitem defeatcondition timerdialog ". 
   "leaderboard multiboard multiboarditem trackable gamecache version itemtype texttag playerscore lightning pathingtype image ubersplat ". 
   "attacktype damagetype weapontype soundtype "; 
    
  if (strpos($Blocks, " ".$word." ")!== false) { 
    return "<b>".$word."</b>"; 
  }  
  elseif (strpos($Keywords, " ".$word." ")!== false) { 
    return "<span style=\"color: Navy;\">".$word."</span>"; 
  } 
  elseif (strpos($Values, " ".$word." ")!== false) { 
    return "<span style=\"color: Maroon;\">".$word."</span>"; 
  } 
  elseif (strpos($Types, " ".$word." ")!== false) { 
    return "<span style=\"color: rgb(50, 100, 200);\">".$word."</span>"; 
  } 
  return $word; 
} 

function HighlightJass($text, $bb=false) {  
  $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; 
  $special = "[]()"; 
  $str = "\"'"; 
  $trans = Array(">" => "&gt;", "<" => "&lt;", "&" => "&amp;"); 
  if (!$bb) 
  { 
      $text = strtr($text, $trans); 
  } 
  else 
  { 
      // Do some backwards working 
    $tr = array('(' => '(', 
                ')' => ')', 
                '[' => '[', 
                ']' => ']', 
                '&quot;' => '"'); 
    $text = strtr($text,$tr); 
  } 
   
  $result = ""; 
  $comment = 0; 
  $Lines = explode("\n", $text); 
  $anchors = array(); 
  $n = 0; 
  // First, find all functions and place an anchor there 
  foreach($Lines as $Line)  
  { 
      // Leave anchor here? 
    $reg = array(); 
    $anchors[$n] = ''; 
      if (ereg('^ *(constant )? *(function|native)  *([a-zA-Z_][a-zA-Z_0-9]*)  *takes', $Line, $reg)) 
    { 
        $l = max(0, $n-12); 
        $anchors[$l] .= '<a name="'.strtolower($reg[3]).'"></a>'; 
    } 
    $n++; 
  } 
  $n = 0; 
  foreach($Lines as $Line)  
  { 
    $result .= $anchors[$n]; 
    $Line = rtrim($Line); 
    if ($isString) { 
      $result = $result . "</span>"; 
    } 
    $stop = strpos($Line, "//"); 
    if ($stop === false) { 
      $stop = strlen($Line); 
      $comment = 0; 
    } else { 
      $comment = 1; 
    } 
    $i = 0; 
    $word = ""; 
    $isString = 0; 
    $stringStarter = "";     
    $slashed = 0; 
    // Highlight 
    while ($i < $stop) { 
      $c = substr($Line, $i, 1); 
      $i += 1; 
       
      if ($isString) { 
        $result = $result . $c; 
        if ($c == "\\") { 
          $slashed = ($slashed)? 0:1; 
        } elseif (($c == $stringStarter) && !($slashed)) { 
          $result = $result . "</span>"; 
          $isString = 0; 
        } else { 
          $slashed = 0; 
        } 
      } else { 
        // If normal character 
        if (strpos($chars, $c) !== false) { 
          $word = $word . $c; 
         
        // If bracket 
        } elseif (strpos($special, $c) !== false) { 
          $result = $result . FixWord($word) . FixWord($c); 
            $word = ""; 
         
        // If string 
        } elseif (strpos($str, $c) !== false) {  
          $result = $result . FixWord($word) . "<span style=\"color: blue\">" . $c; 
          $slashed = 0; 
          $word = ""; 
          $isString = 1; 
          $stringStarter = $c; 
         
        // If other character 
        } else { 
          $result = $result . FixWord($word) . $c; 
          $word = ""; 
        } 
         
      } // if ($isString) 
    } 
    $result = $result . FixWord($word); 
     
    // Add comment 
    if ($comment) { 
      $result = $result . "<span style=\"color: green;\">".strstr($Line, "//")."</span>"; 
    } 
    // Add linebreak 
    $result = $result . '<br />'; 
    $n++; 
  } 
  $result = substr($result, 0, strlen($result)-1); // Remove last linebreak 
   
  if ($bb) 
  { 
      $tr = array('(' => '(', 
                ')' => ')', 
                '[' => '[', 
                ']' => ']'); 
    $result = strtr($result, $tr); 
  } 
   
  return $result; 
} 

} 
HighlightJass({param});
?>

also i know vbulletin has highlighing because of the php tags and also thehelper.net is vbulletin.


EDIT : isnt the replacement box where u put the code..? if not where do i put it. ( wow i sound like a fucking retard )


Replacement:
This is the HTML code for the BB code replacement. Make sure that you include '{param}' (without the quotes) to insert the text between the opening and closing BB code tags, and '{option}' for the parameter within the BB code tag. You can only use {option} if 'Use Option' is set to yes.
e.g. you would use <b>{param}</b> for tags, <a href="{option}">{param}</a> for . You will always use '{param}', but you will only use '{option}' when "Use Option?" is "yes."
 

TFlan

I could change this in my User CP.
Reaction score
64
-.-'

Stupid pre-made forums... make your own, easier to work with...

---------

On topic:

When i said add the script. I meant go to the php page in your directory associated with BBcodes (idk if this is the path, but IE: /vbulletin/scripts/bbcode/script.php <-- for example, you will have to do some fishing to find the page), find the HTML one. and paste the Jass one under it. I'm assuming here that all the BBcodes are on the same page and loaded and run simultaneously.

For the replace textarea, what did you put in it? Did you add the PHP tags?
 

TFlan

I could change this in my User CP.
Reaction score
64
Instead, you need a vb "product" (a type of plugin).

Here's the one we had here, a long long time ago:

I love you for posting this.

Was about to download the forum and add the script in myself and send it to Trigger...
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> does that mean it's not as updated?

Well, I'm not sure all vJASS keywords are actually there...
Though, it's easy enough to add them.


But, yes...

The original KaTTana script was never used here.
I mean... look at that thing? What an insane coding.
Well, it probably works just fine, but I didn't like it just from the looks and style.

Instead, it has seen some replacements.
The limitation would be that it doesn't highlight strings.


However, since then, we moved on to "industrial strength" (famous last words).

Still, after all, this was in production here for at least a year or so.
It's tried and tested :p
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Mind posting the current version and a quick "how to implement", Ace?
Would help me a lot :)

(Currently, I have to post my JASS in simple code tags on another forum...)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top