The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

LGs BBcode problems

View previous topic View next topic Go down

LGs BBcode problems

Post by nextlevelgaming on July 31st 2012, 1:55 am

I'm trying to create BBcodes for my website so that myself and Moderators can but information and such in a post. I tried following the code but i was lost once i put it into the javascript. Here is my code so far...

Code:
1.[codetitle=Javascript]var LGBB_copyright = "LGBB, a Javascript BB Code parser for Forumotion Boards. Copyright © by AvacWeb 2011-2012. All Rights Reserved. Use of this script is not allowed without this entire copyright notice in place. No Distribution without authors consent.";>var LGBB={bbcodes:{div:{tags:{open:/\[div(?:=['"]?(\w+)['"]?)?]/,close:/\[\/div]/},reps:{open:'<div class="$1">',close:"</div>"},test:!1},span:{tags:{open:/\[span(?:=['"]?(\w+)['"]?)?]/,close:/\[\/span]/},reps:{open:'<span class="$1">',close:"</span>"},test:!1},header:{tags:{open:/\[h([1-6])]/,close:/\[\/h([1-6])]/},reps:{open:"<h$1>",close:"</h$1>"},test:!1},codename:{tags:{open:/Code:([^\[]+)\<code\>(?:\<br\>)?\[codetitle=["']?(\w+)["']?]/},reps:{open:"$2:$1<code>"}}},add_bbcode:function(a){LGBB.bbcodes[a.tags.open]=a},finishers:[],afterposts:[],after_finished:function(a){LGBB.finishers.push(a)},after_post:function(a){LGBB.afterposts.push(a)},content_classnames:{phpbb3:"content",invision:"post-entry",punbb:"entry-content",phpbb2:"postbody"},version:"phpbb3",parse_posts:!0,parse:function(a,e){for(var g in LGBB.bbcodes){var b=LGBB.bbcodes[g];if(!b.test||b.test.test(a)){if(b.tags.close)for(var d=RegExp("string"==typeof b.tags.open?"\\["+b.tags.open+"]":b.tags.open.source,"g"),c=RegExp("string"==typeof b.tags.close?"\\[\\/"+b.tags.close+"]":b.tags.close.source,"g");d.test(a)&&c.test(a);){c.lastIndex<d.lastIndex&&(c.lastIndex=d.lastIndex);var f=a.substring(d.lastIndex,c.lastIndex),h=a.substring(0,d.lastIndex),i=a.substring(h.length+f.length);if(!b.before||b.before.call(e,f.replace(c,"")))h=h.replace(d,b.reps.open),f=f.replace(c,b.reps.close),a=h+f+i}else d=RegExp("string"==typeof b.tags.open?"\\["+b.tags.open+"]":b.tags.open.source,'g'),a=a.replace(d,b.reps.open);b.after&&b.after.call(e,e)}}return a}};$(function(){if(LGBB.parse_posts){for(var a=jQuery(".post"),e=a.length,g=0,b=LGBB.content_classnames[LGBB.version];g<e;g++){var d=a[g],c=jQuery("."+b,d);if(c.length&&(c=c[0],content=c.innerHTML,content=LGBB.parse(content,d),c.innerHTML=content,LGBB.afterposts.length))for(var c=0,f=LGBB.afterposts.length;c<f;c++)LGBB.afterposts[c].call(d,d)}if(LGBB.finishers.length){a=0;for(e=LGBB.finishers.length;a<e;a++)LGBB.finishers[a]()}}});>
LGBB.version = 'phpbb2';

[panda=js]>//call the LGBB.add_bbcode function any time after the script in a JS fileLGBB.add_bbcode({        //specify the opening and closing tags. Do not include [ or / symbols. 

tags: {     

open: 'info', //these can be a simple string or regExp if you know regex.     

close: 'info' //you can make codes without a close tag. Like the codetitle tag.  },   
 
reps: {     

open: '<div class="info">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis ante mauris, sagittis condimentum odio. Donec sodales magna', //the content that the open tag will be replaced with.     

close: '</div>'  //the content the close tag will be replaced with.  },       

after: function(post) {                //you can specify a function to execute after this tag has been parsed. This is optional      //it takes one parameter, the current post it is parsing.                jQuery(post).addClass('infoPost');  },       

before: function(content) {                //you can also specify a function to run before this certain tag is parsed.                //it takes one parameter the content in between the two tags.                //this acts a filter function. Return false if you do not want this tag to be parsed.      if(content == 'example please') alert('Info!');                return true;  }  });


any help would be great. thanks guys

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: LGs BBcode problems

Post by LGforum on July 31st 2012, 2:22 am

Well a lot of what you have there isn't code. Have you like quoted me on avacweb and then copied it? Just copy what the tutorial tells you too.

You need the first bulk, and the you can add new bbcodes by following the API. Refer to the Example for help.

For some reason you've included the example in your code? Lol

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: LGs BBcode problems

Post by nextlevelgaming on July 31st 2012, 6:24 pm

hmmm maybe i followed it wrong... I thought you said to put that first big piece which i believe is the API then add the version then add the BBCODES you want? if im wrong im wrong lmbo. but ill try again, i was up for 40 hours when i tried to do this

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: LGs BBcode problems

Post by LGforum on July 31st 2012, 10:50 pm

Yes that is correct. Add the API, then add BBcodes using the API. There are many additions provided in the topic.

But if you are using the code you have in the first post, then some of it is not even Javascript, such as this on the first line: 1.[codetitle=Javascript]


LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum