Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
I have tried and failed so many times at making an Info Center. Iv done the HTML, im just struggling to do the Javascript? Could someone help me please?

Eric

Eric Avatar



1,442


November 2005
If you have interest in coding, I'd recommend using this as a chance to grow and learn. This is how I started off (literally, making codes for proboards that I had no idea how to make).

What in specific are you having trouble with?

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
If you want to just work with the HTML and let a code handle the rest, try MYO info center.

ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
Chris: Iv used it before but the MYO Ionfe Center doesnt have certain functions that id like.

Eric: Well i was hoping to.
Im just having trouble making the code it self. Iv looked at loads of Info Center codes but i still dont get how it works and how to make it. How to clollect the data from the old info center and using it on the new one :'(

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Alright. Just an idea.

Anyways, most IC codes tend to be large, so most programmers compact them... a lot. It would help to look at simpler codes and learn how they fetch data. It's really a similar process. The key difference is that you aren't repeating the same step multiple times, but are instead doing 5 steps. (One for each IC section)

ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
But how would you collect the info for each section?


Last Edit: Oct 12, 2009 18:31:55 GMT by ǻñî§ђ™

Eric

Eric Avatar



1,442


November 2005
What you have to do is loop through all elements that could possibly contain the data that you need (in this case TDs, or table cells). Then you have to set up an if statement that targets the one particular element that you are trying to get at. You can do this by examining unique or rare attribute values combined with unique items contained within the innerHTML.

Once you have it limited down you can use splits, regular expressions or substrings to pull the data out.

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Sorry, I was assuming you knew enough coding already to be able to do that. If Eric's post isn't enough help and you want to try to make it yourself, try looking at the basic tutorials for PB coding we have here.

ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
Sorry it took so long to reply :P
Would that be the same if you were putting span tags in the html and then having the javascript below it? Like Calis MYO Info Center

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
ǻñî§ђ™ Avatar
Sorry it took so long to reply :P
Would that be the same if you were putting span tags in the html and then having the javascript below it? Like Calis MYO Info Center


You could do it either way. If you put the spans in, then you just do a line like this:

document.getElementById("ID_OF_THE_SPAN_HERE").innerHTML = VARIABLE_NAME;

ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
Chris Avatar
ǻñî§ђ™ Avatar
Sorry it took so long to reply :P
Would that be the same if you were putting span tags in the html and then having the javascript below it? Like Calis MYO Info Center


You could do it either way. If you put the spans in, then you just do a line like this:

document.getElementById("ID_OF_THE_SPAN_HERE").innerHTML = VARIABLE_NAME;


Thanks Chris, but im stuck now :( Ive made the code but its not working :( I dont get whats stopping it working. Heres the code:

<script type="text/javascript">
<!--
var fTitle = "Forum Title"; // Forum Title
var group = [];
group[0] = ["Administrators","700000"];
group[1] = ["Global Moderators","000070"];
group[2] = ["Moderators","007000"];

if(!location.href.match(/action/) || location.href.match(/action=home/)){
var td = document.getElementsByTagName("td");
var table = document.getElementsByTagName('table');
for(a=0;a<td.length;a++){
if(td.className == "catbg" && td.innerHTML.match(/Forum Statistics/)) {
var totalposts = (td[a+2].innerHTML.match(/Total Posts: (\d+)(,\d+)?<br/i)) ? RegExp.$1+RegExp.$2: '';
var totaltopics = (td[a+2].innerHTML.match(/Total Topics: (\d+)(,\d+)? &/i)) ? RegExp.$1+RegExp.$2: '';
var totalmembs = (td[a+2].innerHTML.match(/Total Members: (.+?)<br/i)) ? RegExp.$1: '';
var newmemb = (td[a+2].innerHTML.match(/Newest Member: (.+?)<\/a>/i)) ? RegExp.$1+'</a>': '';
var lastpost = (td[a+2].innerHTML.match(/Last Updated Topic: (.+?) by/i)) ? RegExp.$1: 'n/a';
var lastuser = (td[a+2].innerHTML.match(/by (.+?) \(/i)) ? RegExp.$1: 'n/a';
}
if(td
.className == "catbg" && td.innerHTML.match(/Users Online/)) {
var mostonline = (td[a+4].innerHTML.split(/Most\susers\s/)[1].split(/, /i)[0].split(/<br/i)[0]);
var nowonline = (td[a+4].innerHTML.split(/<br>/i)[1]);
var staffonline = (td[a+4].innerHTML.match(/(\d+) Staff/i)) ? RegExp.$1: '0';
var usersonline = (td[a+4].innerHTML.match(/(\d+) Member/i)) ? RegExp.$1: '0';
var guestsonline = (td[a+4].innerHTML.match(/(\d+) Guest/i)) ? RegExp.$1: '0';
}
if(td
.className == "catbg" && td.innerHTML.match(/Today's Birthdays/)) {
var bdaylist = td[a+2].innerHTML.split(/today.<br/i)[1];
}
var legend = new String();
for(var b=0;b<group.length;b++){
legend += '<font color='+group[1]+'>'+group[0]+'</font><br/>';
}
if(staffonline=="0" && usersonline=="0"){
var nowonline = "<i>No members online!</i>";
}
if(bdaylist=="0"){
var bdaylist = "<i>No birthdays today!</i>";
}
for(a=0;a<table.length;a++){
if(table
.width == "100%" && table.cellPadding == "4" && table.innerHTML.match(/Info Center/i)) {
table
.parentNode.innerHTML = '<table cellspacing="1" cellpadding="4" class="bordercolor" width="92%" align="center" vAlighn="top"><tr><td class="titlebg" align="center" width="100%" colspan="3"><b>Info Center</b></td></tr><tr><td class="windowbg" align="center" colspan="1" width="33%">'+fTitle+' would like to welcome '+newmemb+'' to the forum. We now have a grand total of '+totalmembs+'!<br/></td><td class="windowbg" align="left" colspan="1" width="33%"><b>Last Topic:</b> '+lastpost+'<br/><b>Updated By:</b> '+lastuser+'</td><td class="windowbg" align="center" colspan="1" width="33%"> We have a grand total of <b>'+totalposts+'</b> posts in <b>'+totaltopics+'</b> topics!</td></tr><tr><td class="windowbg" align="left" colspan="1" width="33%" rowspan="2">'+legend+'</td><td class="catbg" align="left" colspan="2" width="67%"><div style="float:left;">'+staffonline+' Staff, '+usersonline+' Members, and '+guestsonline+' Guests></div><div style="float:right">Most users ever '+mostonline+'</div></td></tr><tr><td class="windowbg" align="left" colspan="2" width="67%">'+nowonline+'</td></tr><tr><td class="windowbg" align="left" colspan="3" width="100%">'+bdaylist+'<br/>'+fTitle+' would like to wish these people a very Happy Birthday!</td></tr></table>';
}
}
}
//-->
</script>


ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
Can anyone help please? :)

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
:P Two days for a bump? I hadn't even seen this thread yet. Please try to be patient.

Anyways, you have a syntax error...

Error: missing ; before statement
Source file: cdmod.proboards.com/index.cgi
Line: 268, Column: 77
Source code:
="center" colspan="1" width="33%">'+fTitle+' would like to welcome '+newmemb+'' to the forum. We now have a grand total of '+totalmembs+'!<br/></td><td class="windowbg" align="left" colspan="1" width="33%"><b>Last Topic:</b> '+lastpost+'<br/><b>Updated By



That's what Firefox says. If you look, you'll notice you have two single quotes right next to each other. That's your error. :)

JD

JD Avatar



1,032


June 2008
Also, you have vAlighn instead of vAlign :D

ǻñî§ђ™

ǻñî§ђ™ Avatar
Always in disguise!

*
Banned

64


March 2009
Sorry Chris :(
Thanks Chris and James, but it still isnt working :( I removed thequote that was supposed to be cauing the trouble but it still isnt working :(

<script type="text/javascript">
<!--
var fTitle = "Forum Title"; // Forum Title
var group = [];
group[0] = ["Administrators","700000"];
group[1] = ["Global Moderators","000070"];
group[2] = ["Moderators","007000"];

if(!location.href.match(/action/) || location.href.match(/action=home/)){
var td = document.getElementsByTagName("td");
var table = document.getElementsByTagName('table');
for(a=0;a<td.length;a++){
if(td.className == "catbg" && td.innerHTML.match(/Forum Statistics/)) {
var totalposts = (td[a+2].innerHTML.match(/Total Posts: (\d+)(,\d+)?<br/i)) ? RegExp.$1+RegExp.$2: '';
var totaltopics = (td[a+2].innerHTML.match(/Total Topics: (\d+)(,\d+)? &/i)) ? RegExp.$1+RegExp.$2: '';
var totalmembs = (td[a+2].innerHTML.match(/Total Members: (.+?)<br/i)) ? RegExp.$1: '';
var newmemb = (td[a+2].innerHTML.match(/Newest Member: (.+?)<\/a>/i)) ? RegExp.$1+'</a>': '';
var lastpost = (td[a+2].innerHTML.match(/Last Updated Topic: (.+?) by/i)) ? RegExp.$1: 'n/a';
var lastuser = (td[a+2].innerHTML.match(/by (.+?) \(/i)) ? RegExp.$1: 'n/a';
}
if(td
.className == "catbg" && td.innerHTML.match(/Users Online/)) {
var mostonline = (td[a+4].innerHTML.split(/Most\susers\s/)[1].split(/, /i)[0].split(/<br/i)[0]);
var nowonline = (td[a+4].innerHTML.split(/<br>/i)[1]);
var staffonline = (td[a+4].innerHTML.match(/(\d+) Staff/i)) ? RegExp.$1: '0';
var usersonline = (td[a+4].innerHTML.match(/(\d+) Member/i)) ? RegExp.$1: '0';
var guestsonline = (td[a+4].innerHTML.match(/(\d+) Guest/i)) ? RegExp.$1: '0';
}
if(td
.className == "catbg" && td.innerHTML.match(/Today's Birthdays/)) {
var bdaylist = td[a+2].innerHTML.split(/today.<br/i)[1];
}
var legend = new String();
for(var b=0;b<group.length;b++){
legend += '<font color='+group[1]+'>'+group[0]+'</font><br/>';
}
if(staffonline=="0" && usersonline=="0"){
var nowonline = "<i>No members online!</i>";
}
if(bdaylist=="0"){
var bdaylist = "<i>No birthdays today!</i>";
}
for(a=0;a<table.length;a++){
if(table
.width == "100%" && table.cellPadding == "4" && table.innerHTML.match(/Info Center/i)) {
table
.parentNode.innerHTML = '<table cellspacing="1" cellpadding="4" class="bordercolor" width="92%" align="center" vAlign="top"><tr><td class="titlebg" align="center" width="100%" colspan="3"><b>Info Center</b></td></tr><tr><td class="windowbg" align="center" colspan="1" width="33%">'+fTitle+' would like to welcome '+newmemb+' to the forum. We now have a grand total of '+totalmembs+'!<br/></td><td class="windowbg" align="left" colspan="1" width="33%"><b>Last Topic:</b> '+lastpost+'<br/><b>Updated By:</b> '+lastuser+'</td><td class="windowbg" align="center" colspan="1" width="33%"> We have a grand total of <b>'+totalposts+'</b> posts in <b>'+totaltopics+'</b> topics!</td></tr><tr><td class="windowbg" align="left" colspan="1" width="33%" rowspan="2">'+legend+'</td><td class="catbg" align="left" colspan="2" width="67%"><div style="float:left;">'+staffonline+' Staff, '+usersonline+' Members, and '+guestsonline+' Guests></div><div style="float:right">Most users ever '+mostonline+'</div></td></tr><tr><td class="windowbg" align="left" colspan="2" width="67%">'+nowonline+'</td></tr><tr><td class="windowbg" align="left" colspan="3" width="100%">'+bdaylist+'<br/>'+fTitle+' would like to wish these people a very Happy Birthday!</td></tr></table>';
}
}
}
//-->
</script>


newBookmarkLockedFalling