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.

Create New BBCodes - to Javascript Experts

View previous topic View next topic Go down

Solved Create New BBCodes - to Javascript Experts

Post by Ahmed.K on October 17th 2012, 8:33 pm

I found a good topic to create new BBCodes on the forumotion boards
Here: http://www.avacweb.com/t428-28-create-new-bbcodes-with-new-lgbb (I advise to take a look on it. It's nice topic)


Now, Is it possible to use the same idea to use the BBCode here:

Code:
<script type="text/javascript">var pgn4webURL = "http://pgn4web.casaschi.net";
if (!document.getElementById("pgn4webEncoderScript")) { document.write('<script id="pgn4webEncoderScript" type="text/javascript" src="' + pgn4webURL + '/pgn-encoder.js"></' + 'script>'); }</script>
<script type='text/javascript'>var pgn4webTextareaIdNum;
if (pgn4webTextareaIdNum === undefined) { pgn4webTextareaIdNum = 1; }
pgn4webTextareaId = "pgn4web_" + pgn4webTextareaIdNum++;
document.write("<textarea id='" + pgn4webTextareaId +"' style='display: none;'>");</script>

{param} // it works when i add data here, I tested it in widget.

</textarea>
<script type='text/javascript'>
pgnText = document.getElementById(pgn4webTextareaId).value;
pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' ');
pgnText = pgnText.replace(/\[(FONT[^\]]*|[^\]]*FONT)\]/gi, ' ');
height = 268;
multiGamesRegexp = /\s*\[\s*\w+\s*"[^"]*"\s*\]\s*[^\s\[\]]+[\s\S]*\[\s*\w+\s*"[^"]*"\s*\]\s*/m;
if (multiGamesRegexp.test(pgnText)) { height += 34; }
pgnEncoded = EncodePGN(pgnText);
document.write("<iframe src='" + pgn4webURL + "/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=____&dcs=RsCo&bbcs=RsCo&hm=b&hcs=FpBE&bd=c&cbcs=YKqR&ctcs=BoBo&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=VtCE&fms=14&fcs=m&cd=i&bcs=____&fp=13&hl=t&fh=b&fw=p&pe=" + pgnEncoded + "' frameborder=0 width=100% height=" + height + " scrolling='no' marginheight='0' marginwidth='0'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>");
</script>
and this is the BBcode tag name: [pgn] [/pgn]


Is it possible? for example,

Code:
LGBB.add('pgn', {
  close: true,
  replacement: '<div (the code here)>{CONTENT}</div>'
});


Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on October 17th 2012, 9:48 pm

helping about this new BBCode? I don't think so.

This BBCode will change chess games from text (1. e4 e5 2. .......) to real board
Demo: http://pgn4web-test.casaschi.net/phpbb/viewtopic.php?f=2&t=2

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by LGforum on October 19th 2012, 3:01 pm

Yes it can surely, if I fully understand the BBcode workings then something like this should work:
Code:
LGBB.add('pgn', {
    close : true,
    replacement: '<iframe src="http://pgn4web.casaschi.net/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=____&dcs=RsCo&bbcs=RsCo&hm=b&hcs=FpBE&bd=c&cbcs=YKqR&ctcs=BoBo&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=VtCE&fms=14&fcs=m&cd=i&bcs=____&fp=13&hl=t&fh=b&fw=p&pe={CONTENT}" frameborder="0" width="100%" height="268" scrolling="no" marginheight="0" marginwidth="0">your web browser and/or your host do not support iframes as required to display the chessboard</iframe>',
    replace: function(content) {
        return encodePGN(content);
    }
});

But for it to work, you'll need to put this inside a widget or an announcement:
Code:
<script id="pgn4webEncoderScript" type="text/javascript" src="http://pgn4web.casaschi.net/pgn-encoder.js"></script>

If it doesn't work, then leave it like that and I'll come and take a look.

LGforum
Hyperactive

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

http://www.avacweb.com/

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on October 19th 2012, 9:55 pm

Doesn't work.
You have a private message with an admin account on the test forum if you want it.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on October 22nd 2012, 3:18 am

Still doesn't work.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by LGforum on October 22nd 2012, 4:03 am

Sorry, I had forgotten, I'll try and take a look sometime tomorrow for you.

LGforum
Hyperactive

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

http://www.avacweb.com/

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on October 28th 2012, 9:04 pm

Ah, but it's still doesn't work.
Anyway, I think that the LGBB code is not fully compatible with forumotion boards. but it works fine when using simple codes like bspoiler, noguest,....etc.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 3rd 2012, 11:58 am

If anyone (but just Javascript experts this time please) has a solution for this BBCode, contact me.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by LGforum on November 4th 2012, 1:32 am

What I posted should work. Did you put the script tag in an announcement or site description? It's important to do so.

Secondly, did you get any error in the browsers error console?

LGforum
Hyperactive

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

http://www.avacweb.com/

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 4th 2012, 5:46 am

I did exactly what you said, and it still doesn't work.

And yes, i get error in the browsers error console:

Code:
Error: ReferenceError: encodePGN is not defined
Source File: http://tester.forumotion.com/99600.js
Line: 1

By the way, you already received a private message with an admin account to see that.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by LGforum on November 4th 2012, 1:16 pm

Thank you that has helped.

Change this line: return encodePGN(content);
to this: return EncodePGN(content);

LGforum
Hyperactive

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

http://www.avacweb.com/

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 4th 2012, 2:17 pm

Doesn't work correctly.

To see how it looks when it work correctly, I used the original code in widget and it works correctly (just i replaced this - {param} - in the original code with the game)
Here

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 5th 2012, 10:41 am

It doesn't work because you did not use the full code.

You did not use this part:
Code:
pgnText = document.getElementById(pgn4webTextareaId).value;
pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' ');
pgnText = pgnText.replace(/\[(FONT[^\]]*|[^\]]*FONT)\]/gi, ' ');
height = 268;
multiGamesRegexp = /\s*\[\s*\w+\s*"[^"]*"\s*\]\s*[^\s\[\]]+[\s\S]*\[\s*\w+\s*"[^"]*"\s*\]\s*/m;
if (multiGamesRegexp.test(pgnText)) { height += 34; }
pgnEncoded = EncodePGN(pgnText);
I received a private message from the author:
It looks the PunBB code adds some spurious html tags to the PGN content.

The javascript code already tries to get rid of those but this line might have to be tweaked:

pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' ');

Try something slightly different in the replace action until the PGN is passed clean (you can check it clicking square D8), such as

pgnText = pgnText.replace(/\s*<\s*br\s*>\s*/gi, ' ');

This might work better...
I think you should use this part?

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by JavaMan on November 5th 2012, 2:51 pm

Hi Ahmed,

Dion is a very good programmer. I'm absolutely sure that he (the only person) can solve this problem easily. Please check your mailbox.

JavaMan
New Member

Posts : 1
Reputation : 1
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 5th 2012, 8:09 pm

No, thanks. I will continue with LGforum here.

Now, this one doesn't work too?!

Code:
LGBB.add('pgn', {
    close : true,
    replacement: 'pgnText = document.getElementById(pgn4webTextareaId).value;
pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' ');
pgnText = pgnText.replace(/\[(FONT[^\]]*|[^\]]*FONT)\]/gi, ' ');
height = 268;
multiGamesRegexp = /\s*\[\s*\w+\s*"[^"]*"\s*\]\s*[^\s\[\]]+[\s\S]*\[\s*\w+\s*"[^"]*"\s*\]\s*/m;
if (multiGamesRegexp.test(pgnText)) { height += 34; }
pgnEncoded = EncodePGN(pgnText);

<iframe src="http://pgn4web.casaschi.net/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=____&dcs=RsCo&bbcs=RsCo&hm=b&hcs=FpBE&bd=c&cbcs=YKqR&ctcs=BoBo&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=VtCE&fms=14&fcs=m&cd=i&bcs=____&fp=13&hl=t&fh=b&fw=p&pe={CONTENT}" frameborder="0" width="100%" height="268" scrolling="no" marginheight="0" marginwidth="0">your web browser and/or your host do not support iframes as required to display the chessboard</iframe>',
    replace: function(content) {
        return encodePGN(content);
    }
});

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by LGforum on November 5th 2012, 9:20 pm

No that won't work. And those bits I missed out aren't needed, other than for removing unneeded bits which will not exist in what we are doing.

Try this:
Code:
LGBB.add('pgn', {
    close : true,
    replacement: '<iframe src="http://pgn4web.casaschi.net/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=____&dcs=RsCo&bbcs=RsCo&hm=b&hcs=FpBE&bd=c&cbcs=YKqR&ctcs=BoBo&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=VtCE&fms=14&fcs=m&cd=i&bcs=____&fp=13&hl=t&fh=b&fw=p&pe={CONTENT}" frameborder="0" width="100%" height="268" scrolling="no" marginheight="0" marginwidth="0">your web browser and/or your host do not support iframes as required to display the chessboard</iframe>',
    replace: function(content) {
        return EncodePGN(content.replace(/\s*<\s*br\s*>\s*/gi, ' '));
    }
});
I've added the replacement suggested by the author. You'll have to forgive me if this takes a while; I know nothing about chess. Razz

@JavaMan wrote: I'm absolutely sure that he (the only person) can solve this problem easily.
Seeing as I'm the creator of the LGBB API & parser - I'm pretty positive I understand it more than most.

LGforum
Hyperactive

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

http://www.avacweb.com/

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 6th 2012, 6:23 pm

Thanks it works fine now.

But there are some important options not working, this one is important... FEN string (fenString), here

I received a private message from the author about this issue:
I have no idea how you came up with the code below.

I only know that everything you can do with board.html is documented
here, including loading a FEN string:
https://code.google.com/p/pgn4web/wiki/BoardWidget_instructions

How to apply those instructions to your code, that you need to ask to
whoever supplied that code.

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by kirk on November 7th 2012, 1:48 am

@JavaMan wrote:Hi Ahmed,

Dion is a very good programmer. I'm absolutely sure that he (the only person) can solve this problem easily. Please check your mailbox.


Dion left and deleted his account like a year ago.. So not sure what this statement is all about? I am sure there are other staff and members that can help just as well Smile

I feel there is no need to even mention/post replies such as this here, it is not helping others for someone to have to check their mailbox. If you have something that is going to help someone and would like to share with all them please do state it here, If not, then that just send off the message and keep it to yourself.

I understand you are new here, but this will only cause other members to to want to know how to do it and is no good if the information and or tutorials is something you sent in a pm to someone.
We do not to support like that here, this is a public support forum open to all. So in the future if you would like to only share something through pm, please be sure to only do that and keep it between you and the member you are sharing with.

Thank you Smile


kirk
Forumaster

Male Posts : 11037
Reputation : 651
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 10th 2012, 7:03 pm

Doesn't work correctly because we should use the same thing here

Code:
<script type="text/javascript">
var pgn4webURL = "http://pgn4web.casaschi.net";
if (!document.getElementById("pgn4webEncoderScript")) { document.write('<script id="pgn4webEncoderScript" type="text/javascript" src="' + pgn4webURL + '/pgn-encoder.js"></' + 'script>'); }
</script>
<script type='text/javascript'>
var pgn4webTextareaIdNum;
if (pgn4webTextareaIdNum === undefined) { pgn4webTextareaIdNum = 1; }
pgn4webTextareaId = "pgn4web_" + pgn4webTextareaIdNum++;
document.write("<textarea id='" + pgn4webTextareaId +"' style='display: none;'>");
</script>
[FEN "{TEXT}"]
[SetUp "1"]
*
</textarea>
<script type='text/javascript'>
pgnText = document.getElementById(pgn4webTextareaId).value;
pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' ');
height = 240;
pgnEncoded = EncodePGN(pgnText);
document.write("<iframe src='" + pgn4webURL + "/board.html?am=n&d=3000&ss=26&ps=d&pf=d&lcs=TtKN&dcs=LHCg&bbcs=LHCg&hm=b&hcs=mF9_&bd=h&cbcs=RZmI&ctcs=zEtr&hd=j&md=f&tm=13&fhcs=$$$$&fhs=80p&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=80p&fcs=m&cd=i&bcs=TtKN&fp=13&hl=t&fh=b&fw=p&pe=" + pgnEncoded + "' frameborder=0 width=100% height=" + height + " scrolling='no' marginheight='0' marginwidth='0'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>");
</script>
but with tag name: [fen] [/fen]
I tested it in widget, and working fine, when i add the fen position here {TEXT}


Now, what about this one, will work?

Code:
LGBB.add('fen', {
    close : true,
    replacement: '<iframe src="http://pgn4web.casaschi.net/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=____&dcs=RsCo&bbcs=RsCo&hm=b&hcs=FpBE&bd=c&cbcs=YKqR&ctcs=BoBo&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=VtCE&fms=14&fcs=m&cd=i&bcs=____&fp=13&hl=t&fh=b&fw=p&pe=[FEN "{TEXT}"][SetUp "1"]" frameborder="0" width="100%" height="268" scrolling="no" marginheight="0" marginwidth="0">your web browser and/or your host do not support iframes as required to display the chessboard</iframe>',
    replace: function(content) {
        return EncodePGN(content.replace(/\s*<\s*br\s*>\s*/gi, ' '));
    }
});

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 11th 2012, 6:34 pm

I tested it, but does not work properly, any ideas?

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by LGforum on November 13th 2012, 12:36 am

Try this:
Code:
LGBB.add('fen', {
    close : true,
    replacement: '<iframe src="http://pgn4web.casaschi.net/board.html?am=n&d=3000&ss=26&ps=d&pf=d&lcs=TtKN&dcs=LHCg&bbcs=LHCg&hm=b&hcs=mF9_&bd=h&cbcs=RZmI&ctcs=zEtr&hd=j&md=f&tm=13&fhcs=$$$$&fhs=80p&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=80p&fcs=m&cd=i&bcs=TtKN&fp=13&hl=t&fh=b&fw=p&pe={CONTENT}" frameborder="0" width="100%" height="240" scrolling="no" marginheight="0" marginwidth="0">your web browser and/or your host do not support iframes as required to display the chessboard</iframe>',
    replace: function(content) {
        content = '[FEN "' + content + '"]\n[SetUp "1"]\n*';
        return EncodePGN(content.replace(/\s*<\s*br\s*>\s*/gi, ' '));
    }
});

I'm getting confused now though with all the chess stuff... Razz

LGforum
Hyperactive

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

http://www.avacweb.com/

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by Ahmed.K on November 13th 2012, 3:48 am

Thanks. It works great.


To Forumotion team,
I have a very active site and it works great for me.
So, I advise to take a look at this topic (LGBB). and post it in (Updates and new features)
It works perfectly with Forumotion boards.
This will be useful for all Forumotion members!

Ahmed.K
Forumember

Posts : 349
Reputation : 4
Language : English

Back to top Go down

Solved Re: Create New BBCodes - to Javascript Experts

Post by SLGray on November 13th 2012, 3:55 am

Topic Solved & Locked


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35629
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.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