...

View Full Version : Posting info from Javascript API



Ninetail
03-15-2012, 06:39 PM
Hi everyone!

Firstly, im a beginner in Javascript, totally noobie. Much why this is posted! :rolleyes:

I have found this site:
http://www.forswor.com/index.php/data-apis/

And I want to use this to post the server status on my forum/website.

How exactly do I do that?
I know there are examples and such and I have read and read on that page but I cannot figure out how to do this.

I cant just paste:
<script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php"> </script>

How would I get this to show the information of say for example Bloodworthy server and in text?
I tried adding the line document.write(forswor_server_name);, but didnt show up anything - stupid as I am obviously I have no clue what im doing.
I can manage html\css and some php but this is new for me, hehe.

Thank you so much for reading an idiots post! :thumbsup:
Most regards, me.

DaveyErwin
03-15-2012, 06:52 PM
<html>
<head>
<title>Colour Changer</title>
<script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php">
</script>
<script>alert(forswor_server_state)</script>
</head>
<body>

</body>
</html>


<html>
<head>
<title>Colour Changer</title>
<script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php">
</script>

</head>
<body>
<script>
document.write("forswor_server_state = ");
document.write(forswor_server_state);
</script>
</body>
</html>

Ninetail
03-15-2012, 11:51 PM
Hey thanks alot! Really appreciate it!

<html>
<head>
<script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php?server=Bloodworthy">
</script>

</head>
<body>
<script>
document.write("Server: ");
document.write(forswor_server_name);
document.write("Server status: ");
document.write(forswor_server_state);
document.write("Server load: ");
document.write(forswor_server_load_txt);
</script>
</body>
</html>

I have two more questions.

1. How do I make a new line? like <br>
I couldnt make <br> <br \> or \n to work.

2. How do I make an image to appear if forswor_server_state turns out UP?
One image for UP and one for DOWN. I imagine if else to be involved.

Example images:
http://www.forswor.com/forswor_services/prod/serverwidget/images/up.png
http://www.forswor.com/forswor_services/prod/serverwidget/images/down.png

Thank you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum