[DEV] Syntax Highlighter 1.0.15

Moderator: Moderators

<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Sat Mar 26, 2011 10:51 pm

[DEV] Syntax Highlighter 1.0.15

Greetings,

Latest release of the Syntax Highlighter, having fixed (hopefully) the issue mentioned here and also updated GeSHi to version 1.0.8.10 so there are now 202 supported languages.

To update from version 1.0.14 simply upload the file: includes/hooks/hook_syntax_highlighter.php replacing the existing file and you're all done.

Note: If you've altered any of the optional flags in the file you may want to reset them before uploading the updated file, there is also a new flag that will enable GeSHi normal line numbers by default if set to 'true'.

Any problems, hopefully there won't be but if there are let me know :)
You do not have the required permissions to view the files attached to this post.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

Graham

Very New Member
Very New Member

Posts: 5

Joined: Wed Apr 27, 2011 1:12 pm

Post Wed Apr 27, 2011 1:25 pm

Re: [DEV] Syntax Highlighter 1.0.15

I can not install this using Automod - it returns the following error:

  Code:
The MOD is missing a find matching the action ‘<!-- ul end -->’
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Wed Apr 27, 2011 2:22 pm

Re: [DEV] Syntax Highlighter 1.0.15

Greetings,

Thought I'd incorporated the changes to make it work with the AutoMOD, obviously not, anyway if you want to do it yourself read this:

viewtopic.php?f=5&t=91&start=10

otherwise if I have time tonight when I get in from work I'll make the alterations and reupload the 'install.xml' file for people who use automod.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

Graham

Very New Member
Very New Member

Posts: 5

Joined: Wed Apr 27, 2011 1:12 pm

Post Wed Apr 27, 2011 2:48 pm

Re: [DEV] Syntax Highlighter 1.0.15

Thanks for the really fast reply! I'll look into it :)

After installing the mod I have the following javascript error (both FF and IE8 report the same error):

  Code:
Error: SXBB[id].resize is not a function
Source File: classes/scripts/select_expand_bbcodes.js
Line: 197


The file itself:
  Code:
/*************************************************************
 *   SXBB - Select Expand BBcodes MOD v1.0.2
 *
 *   Copyright (C) 2004, Markus (http://www.phpmix.com)
 *   This script is released under GPL License.
 *   Feel free to use this script (or part of it) wherever you need
 *   it ...but please, give credit to original author. Thank you. :-)
 *   We will also appreciate any links you could give us.
 *
 *   Enjoy! ;-)
 *
 *************************************************************/

//
// ADVICE: Editor Settings -> TabSize 4 ;-)
//

function SXBB_IsIEMac()
{
   // Any better way to detect IEMac?
   var ua = String(navigator.userAgent).toLowerCase();
   if( document.all && ua.indexOf("mac") >= 0 )
   {
      return true;
   }
   return false;
}
function SXBB_IsOverflowAble()
{
   // Reliable overflow usage seems to require correct DOM support with some exceptions:
   // - Opera5/6 renders 'auto' as if it was 'visible'. Bang!
   // - IEMac seems to be buggy in some circumstances:
   //   http://sonofhans.net/mac_ie5_bug/
   //
   if( document.getElementById && document.childNodes && !SXBB_IsIEMac() )
   {
      return true;
   }
   return false;
}

function _SXBB(id)
{
   this.id = id;
   this.size = this.min = 70;   // --- Adjust MINIMUM_BLOCK_HEIGHT here :-)
   this.extra = 5;         // --- This is added to height when expanded
   this.margin = 20;      // --- Hide [expand] command if just a few pixels height when expanded.
   this.T = [];
}

_SXBB.prototype.genCmd = function(cmd, txt)
{
   return '&nbsp;[&nbsp;<a href="javascript:void(0)" onclick="SXBB[\''+this.id+'\'].'+cmd+'(\''+txt+'\');" onfocus="this.blur();">'+txt+'</a>&nbsp;]';
}

_SXBB.prototype.writeCmd = function()
{
   var s='';
   if( (document.selection && !SXBB_IsIEMac()) || (document.createRange && (document.getSelection || window.getSelection)) )
   {
      s += this.genCmd('select', this.T['select']);
   }
   if( SXBB_IsOverflowAble() )
   {
      // Actually, the [expand] link will be placed by the onload event (if necessary) :-)
      s += '<span id="'+this.id+'x"></span>';
   }
   document.write(s);   // ‹Select› ‹Expand›
}

_SXBB.prototype.writeDiv = function()
{
   // Use 'overflow:auto;height:#px' only if 'overflow:auto' is supported...
   // Works on IE4+, Mozilla, Opera7, Safari
   // Fails on IEMac, NS4, Opera6-
   //
   var s = ( SXBB_IsOverflowAble() ? 'style="margin: 0px; padding: 0px; overflow: auto; height: '+this.min+'px;"' : 'style="padding: 0px; margin: 0px;"' );
   document.write('<div id="'+this.id+'" '+s+'>');
}

_SXBB.prototype.getObj = function(id)
{
   return ( document.getElementById ? document.getElementById(id) : null );
}

_SXBB.prototype.select = function()
{
   var o = this.getObj(this.id);
   if( !o ) return;
   var r, s;
   if( document.selection && !SXBB_IsIEMac() )
   {
      // Works on: IE5+
      // To be confirmed: IE4? / IEMac fails?
      r = document.body.createTextRange();
      r.moveToElementText(o);
      r.select();
   }
   else if( document.createRange && (document.getSelection || window.getSelection) )
   {
      // Works on: Netscape/Mozilla/Konqueror/Safari
      // To be confirmed: Konqueror/Safari use window.getSelection ?
      r = document.createRange();
      r.selectNodeContents(o);
      s = window.getSelection ? window.getSelection() : document.getSelection();
      s.removeAllRanges();
      s.addRange(r);
   }
}

_SXBB.prototype.resize = function(cmd)
{
   var o = this.getObj(this.id);
   if( !o )
   {
      return;
   }
   var x = this.getObj(this.id+'x');
   if( !x )
   {
      return;
   }

   // First, deal with requested command...
   if( cmd == 'onload' || cmd == 'onresize' )
   {
      if( o.scrollHeight <= this.min ) { x.innerHTML = ''; return; }
      if( x.innerHTML != '' ) { return; }
      if( cmd == 'onload' )
      {
         x.innerHTML = this.genCmd('resize', this.T['expand']);
         return;
      }
      cmd = this.T['contract'];
   }
   if( cmd == this.T['expand'] )
   {
      this.size = o.scrollHeight + this.extra;
      o.style.height = 'auto';
      o.style.overflow = 'visible';
      // Check to conditionally hide the [expand] link, if once expanded, adding [contract] is not really useful.
      x.innerHTML = ( (o.scrollHeight-this.margin) > this.min ? this.genCmd('resize', this.T['contract']) : '' );
   }
   else
   {
      this.size = this.min;
      o.style.height = this.size + 'px';
      o.style.overflow = 'auto';
      x.innerHTML = this.genCmd('resize', this.T['expand']);
   }
   if( cmd != 'onresize' )
   {
      // If necessary, adjust height of outer blocks...
      if( o.parentNode )
      {
         for( o = o.parentNode; o.parentNode; o = o.parentNode )
         {
            if( o.tagName && o.tagName == 'DIV' && o.id && o.id.indexOf('SXBB') == 0 )
            {
               if( !document.all ) SXBB[o.id].resize(this.T['contract']);
               SXBB[o.id].resize(this.T['expand']);
            }
         }
      }
   }
   return false;
}

// --------------------------------------------------------------------------------
// Actually, this script is being included for every instance of a boxed BBCode,
// so... we MUST do something to ensure we only do the job just once!
//
if( typeof(SXBB) == 'undefined' ) {
// --------------------------------------------------------------------------------

var SXBB = [];

// --------------------------------------------------------------------------------
if( SXBB_IsOverflowAble() ) {   // The following is Not necessary on some browsers!
// --------------------------------------------------------------------------------

var SXBB_oldOnLoad = null;
var SXBB_oldOnResize = null;

function SXBB_onLoad()
{
   if( SXBB_oldOnLoad ) { SXBB_oldOnLoad(); SXBB_oldOnLoad = null; }
   SXBB_evalSize('onload');
}
function SXBB_onResize()
{
   if( SXBB_oldOnResize ) { SXBB_oldOnResize(); SXBB_oldOnResize = null; }
   SXBB_evalSize('onresize');
}
function SXBB_evalSize(cmd)
{
   for( var id in SXBB ) SXBB[id].resize(cmd);
}

if( window.addEventListener )
{
   // The DOM method
   window.addEventListener('load', SXBB_onLoad, false);
   window.addEventListener('resize', SXBB_onResize, false);
}
else if( window.attachEvent )
{
   // The IE Method
   window.attachEvent('onload', SXBB_onLoad);
   window.attachEvent('onresize', SXBB_onResize);
}
else
{
   // The 'legacy' method
   SXBB_oldOnLoad = window.onload;
   SXBB_oldOnResize = window.onresize;
   window.onload = SXBB_onLoad;
   window.onresize = SXBB_onResize;
}

// --------------------------------------------------------------------------------
}   // if( SXBB_IsOverflowAble() )
// --------------------------------------------------------------------------------
}   // if( typeof(SXBB) == 'undefined' )
// --------------------------------------------------------------------------------
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Wed Apr 27, 2011 3:04 pm

Re: [DEV] Syntax Highlighter 1.0.15

Greetings,

Strange I use FF, currently using FF 4 and have not had that issue, have had it with IE and solved it by turning off the notification for scripting errors.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

Graham

Very New Member
Very New Member

Posts: 5

Joined: Wed Apr 27, 2011 1:12 pm

Post Wed Apr 27, 2011 3:17 pm

Re: [DEV] Syntax Highlighter 1.0.15

The conflict appears to be with some RocketTheme script, although it worked fine in 1.0.12 (which is strange as select_expand_bbcodes.js has remained the same version). The live site: http://digital-diy.com/forum/

Our little community has gotten quite familiar with your great mod. I'd rather not use 1.0.12 - any guidance from here would be appreciated
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Wed Apr 27, 2011 3:32 pm

Re: [DEV] Syntax Highlighter 1.0.15

Greetings,

I'll have a look when I get home, as I should really be working ;)

And if your into electronics and stuff have you seen: http://www.designspark.com/ it's actually very good software ... ;)
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Wed Apr 27, 2011 5:47 pm

Re: [DEV] Syntax Highlighter 1.0.15

Greetings,

Had a look at the js file and compared the 1.0.12 and 1.0.15 versions using Textpad and they are identical, so if the 1.0.12 supplied version works without errors then use that.

Also had a quick look around your site and the explanation of the 'lines' command was wrong. Using the lines command with either 'n or normal' or 'f or fancy' will result in normal lines numbers or fancy line numbers where every nth line will be highlighted.

Examples, normal first:
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. this is
  2. a normal
  3. list with
  4. normal
  5. lines
  6. as i like normal
  7. things more
  8. than fancy things
Parsed in 0.020 seconds, using GeSHi 1.0.8.11

and the fancy version, the fancy line is line 5, with lines 1 and 3 highlighted:
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. this is
  2. a normal
  3. list with
  4. normal
  5. lines
  6. as i like normal
  7. things more
  8. than fancy things
Parsed in 0.020 seconds, using GeSHi 1.0.8.11

and the option only works when a language is specified, or put another way when GeSHi is used as it's GeSHi that does the normal/fancy lines.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

Graham

Very New Member
Very New Member

Posts: 5

Joined: Wed Apr 27, 2011 1:12 pm

Post Sat Apr 30, 2011 3:54 am

Re: [DEV] Syntax Highlighter 1.0.15

Thank you for the heads up - I will update the guide :)

I thought I had this fixed at one stage, although revisiting the forum today I noticed the error was back. All other conflicts have been resolved except for "SXBB[id].resize is not a function"

I had a tip from someone that perhaps an element of SXBB was undefined. His suggestion was to wrap "SXBB[id].resize(cmd);" in a conditional if, from:
  Code:
function SXBB_evalSize(cmd) {
   for( var id in SXBB ) SXBB[id].resize(cmd);
}

to
  Code:
function SXBB_evalSize(cmd) {
   for( var id in SXBB ) {
      if (SXBB[id] !== undefined) {
         SXBB[id].resize(cmd);
      }
   }
}

Although the error still occurs. Here's a demo.
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Sat Apr 30, 2011 3:27 pm

Re: [DEV] Syntax Highlighter 1.0.15

Greetings,

Found another thing I missed, I removed the 'Select' option from the top line as it selected the line numbers as well and I find it easier to just download the file and open it in Textpad and from there I can copy paste it to where ever I want.

To make the change do this:
Syntax: [ Download ] [ Hide ]
Using phpBB MOD Template Syntax Highlighting
#
#-----[ OPEN ]-------------------------------------------------------
#

classes/scripts/select_expand_bbcode.js

#
#-----[ FIND ]-------------------------------------------------------
#

        if( (document.selection && !SXBB_IsIEMac()) || (document.createRange && (document.getSelection || window.getSelection)) )
        {
                s += this.genCmd('select', this.T['select']);
        }

#
#-----[ REPLACE WITH ]-----------------------------------------------
#

        if( (document.selection && !SXBB_IsIEMac()) || (document.createRange && (document.getSelection || window.getSelection)) )
        {
// Commented out due to select actually selecting the line numbers
// best thing to do is just download the file and open it in a text editor ...
//              s += this.genCmd('select', this.T['select']);
        }

#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------------
#
# EoM
Parsed in 0.026 seconds, using GeSHi 1.0.8.11


And looking into the javascript error now... tried it in IE 6 and no error, I don't get one in FF 3.6.16 or 4 which I use at work. Will try it it IE8, Chrome, Safari and Opera when I get to work on Tuesday ...
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
Next

Return to phpBB 3 MODs [Developement]

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for blacklist.org.