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.
Internet Explored adds [URL] tags to the Google code and this causes the map not to
show. You see
"Wrong map URL, edit the post to change it. Reload the page when finished to check if correct."
You need to edit the [URL] tags out. Firefox and Chrome do not add these tags when
posting the Google code.
If you can see WHITE where the map should be in IE, then Refreshing the page with the <REFRESH>
button will not cause the map to show. HOWEVER right clicking on where the map should be and selecting
REFRESH will cause the map to show.
I noticed that IE will show the map only the first time the page with the map is accessed. After that it will
not load the map the next time the page is loaded ( unless you use the above mentioned refresh ).
I wonder is someone with code experience could modify the script to detect if IE is the
browser and if so detected, refresh the frame twice and also remove any URL /URL
tags from betten the GAMP /GMAP tags.
<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>
This worked for me when I used Firefox to do add the BBcode. But strangely, when I used
IE it did not work.
It been working fine for a few weeks and today we have hit a glitch, I think its always been there but only showed up today
until now all [gmap] code has been in threads started by one of 2 Admins, members have replied with maps and they have showed up with no problems. Today a supermod posted a map in his own thread and it errored and didnt show up, Even if an Admin post a [gmap] in that thread it wouldnt show up. Cut and paste the same code into a Admin started thread, it works fine
doing the research on my forum, Admins have HTML turned on, no one else does, I dont want to turn it on if I can help it.
will turning HTML on for everyone but turn HTML code of be safe?
I will do some more testing, but I wont be near a puter for the next 24hr
until now all [gmap] code has been in threads started by one of 2 Admins, members have replied with maps and they have showed up with no problems. Today a supermod posted a map in his own thread and it errored and didnt show up, Even if an Admin post a [gmap] in that thread it wouldnt show up. Cut and paste the same code into a Admin started thread, it works fine
doing the research on my forum, Admins have HTML turned on, no one else does, I dont want to turn it on if I can help it.
will turning HTML on for everyone but turn HTML code of be safe?
I will do some more testing, but I wont be near a puter for the next 24hr
any thoughts or ideas?
ta
Marty
Every thing I have read suggests keep HTML turned off for the forums. I am admin on
my forum and I do not have HTML turned on and my users can post maps.