Version: 1.1, by oasi
Developer Last Online: Dec 2008
Category: BB Code Enhancements -
Version: 3.7.x
Rating:
Released: 10-15-2008
Last Update: Never
Installs: 86
Re-useable Code Translations Is in Beta Stage
No support by the author.
Hi all
I've made a Custom BBcode to be able to insert any kind of google map into the forum posts, so the Plugins I tried were'nt working as we expected.
I post the code, I hope it can be useful for anyone.
Security problems, improvements and tunning will be apreciated...
I used the tag [gmap], and inside you have to copy the code for the HTML inclusion you can copy when you click the link icon in the map:
Code:
<script type="text/javascript">
function ckURL()
{ if ((u.indexOf("http://")!=u.lastIndexOf("http://"))||u.lastIndexOf("http://")!=0){return false;}
if (u.indexOf('"')>=0) {return false;}
if (u.indexOf("http://maps.google")!=0){return false;}
return true;
}
t='';incr=0;t_i="{param}";
t_n_q=t_i.replace(/"/g,'"');
if(t_n_q.indexOf("91;url")>0)
{ if(t_n_q.indexOf('91;url="')>0){t=t_n_q.substr(t_n_q.indexOf('91;url="')+8,t_n_q.length);t_n_q='';}
if(t_n_q.indexOf('91;url=')>0) {t=t_n_q.substr(t_n_q.indexOf('91;url=')+7,t_n_q.length);t_n_q='';a=t.replace(/93;/g,'"');t=a;incr=2;}
if(t_n_q.indexOf('91;url')>0) {if (t_n_q.indexOf('93;')==(t_n_q.indexOf('91;url')+8)){t=t_n_q.substr(t_n_q.indexOf('91;url')+11,t_n_q.length);a=t.replace(/91;/g,'"');t=a;}}
}
else
{ t=t_n_q.substr(t_n_q.indexOf('src="')+5,t_n_q.length);}
u=t.substr(0,t.indexOf('"')-incr);
up=u.replace(/amp;/g,'');u=up;
if (ckURL())
{ document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+u+'"></iframe>');}
else
{document.write("<p><b>Wrong map URL, edit the post to change it.</b></p>Reload the page when finished to check if correct.");}
</script>
The others settings for the BBCode are:
Use {option}: -> No Remove Tag If Empty -> Yes Disable BB Code Within This BB Code -> Yes Disable Smilies Within This BB Code -> Yes Disable Word Wrapping Within This BB Code ->Yes
Please, mark as installed if it worked and you are using it.
Hope it helps!
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I have been running this mod for a few days and not found any of the issues that other people are describing. So here is some information that may or may not help other mod users:
1) The Google Maps API key is irrelevant to this mod and is a red herring
2) You have to get the code to embed from:
<script type="text/javascript">
function checkURL()
{
if ((url.indexOf("http://")!=url.lastIndexOf("http://"))||url.lastIndexOf("http://")!=0){return false;}
if (url.indexOf('"')>=0) {return false;}
if (url.indexOf("http://maps.google")!=0){return false;}
return true
}
tot='{param}';
tot=tot.substr(tot.indexOf("src="")+10,tot.length);
url=tot.substr(0,tot.indexOf("""));
urlp=url.replace(/;amp;/g,';');
url=urlp;
if (checkURL())
{
document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+url+'"></iframe>');
}
else
{
document.write("<p><b>Wrong map URL, edit the post to change it.</b></p>Reload the page when finished to check if correct.");
}
</script>
Example
[gmap]iframe code[/gmap]
Description:
Embeds Google maps into posts. To use this find the map you want on Google Maps, click the link icon and select all text that is in the "Paste HTML to embed in website" section. Then paste into the post surround by [gmap][/gmap]
Use {option}:
No
Button Image (Optional)
I didn't define one, you can if you want
Remove Tag If Empty
Disable BB Code Within This BB Code
Disable Smilies Within This BB Code
Disable Word Wrapping Within This BB Code
All yes
itried the above mentioned and i got the following error!
Quote:
Wrong map URL, edit the post to change it.
Reload the page when finished to check if correct.
Finally I've been able to reproduce this!!
I'm using the advanced Browser Firefox, so despite of using the WYSIWYG editor I wasn't having this problem...
Now I've been testing and I'm have a solution, I have to do some more testing, but tomorrow I'll post the new version.
<script type="text/javascript"> function ckURL() { if ((u.indexOf("http://")!=u.lastIndexOf("http://"))||u.lastIndexOf("http://")!=0){return false;} if (u.indexOf('"')>=0) {return false;} if (u.indexOf("http://maps.google")!=0){return false;} return true; }
if (ckURL()) { document.write('<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+u+'"></iframe>');} else {document.write("<p><b>Wrong map URL, edit the post to change it.</b></p>Reload the page when finished to check if correct.");} </script>
Please help us look into it to see what's possibly wrong.
I don't know why your gmap pasted code isn't chaged to html chars...
" should be "
< should ve <
An easy "fix" would be to change this line in the code:
t_i="{param}";
to
t_i='{param}';
But if could fail if there is some ' char into the code of the map...
Try it...
Oh, I tried with what you suggested and it works now.
So at least it works for my system. But as your concern, it might not be stable. Please help me to find what could be the reason that let my system not identical with yours.