Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" href="css/stylesheet_scoreboard_default.css" type="text/css" charset="utf-8">
- <script src="js/jquery-2.0.2.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/jstween-1.1.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/countries.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/javascript">
- var timestampOld;
- var timestamp;
- var pName1;
- var pScore1;
- var pName2;
- var pScore2;
- var pName3;
- var pScore3;
- var pName4;
- var pScore4;
- var pCountry1;
- var pCountry2;
- var pCountry3;
- var pCountry4;
- var oldCountry1 = "";
- var oldCountry2 = "";
- var oldCountry3 = "";
- var oldCountry4= "";
- var mText3;
- var mText4;
- var xmlDoc;
- var xhr = new XMLHttpRequest();
- var animating = false;
- var doUpdate = false;
- function init() {
- xhr.overrideMimeType('text/xml');
- var timeout = this.window.setInterval(function() {
- pollHandler();
- }, 250);
- $('#pFlag1').opacity(0);
- $('#pName1').html('');
- $('#pScore1').html('');
- $('#pFlag2').opacity(0);
- $('#pName2').html('');
- $('#pScore2').html('');
- $('#pFlag3').opacity(0);
- $('#pName3').html('');
- $('#pScore3').html('');
- $('#pFlag4').opacity(0);
- $('#pName4').html('');
- $('#pScore4').html('');
- $('#mText3').html('');
- $('#mText4').html('');
- $('#board').tween({
- top:{
- start: '-100',
- stop: '0',
- units: 'px',
- time: 0,
- duration: 0.8,
- effect:'easeOut'
- }
- });
- $('#board2').tween({
- top:{
- start: '-100',
- stop: '33',
- units: 'px',
- time: 0,
- duration: 0.8,
- effect:'easeOut'
- }
- });
- $.play();
- }
- function pollHandler()
- {
- loadData();
- if (timestamp != timestampOld) {
- doUpdate = true;
- }
- if (!animating && doUpdate) {
- updateBoard();
- }
- }
- function loadData() {
- xhr.open('GET', 'streamcontrol.xml');
- xhr.send();
- xhr.onreadystatechange = function(){
- xmlDoc = xhr.responseXML;
- pName1 = getValueFromTag(xmlDoc,'pName1');
- pName2 = getValueFromTag(xmlDoc,'pName2');
- pName3 = getValueFromTag(xmlDoc,'pName3');
- pName4 = getValueFromTag(xmlDoc,'pName4');
- pScore1 = getValueFromTag(xmlDoc,'pScore1');
- pScore2 = getValueFromTag(xmlDoc,'pScore2');
- pScore3 = getValueFromTag(xmlDoc,'pScore3');
- pScore4 = getValueFromTag(xmlDoc,'pScore4');
- pCountry1 = getCountry(getValueFromTag(xmlDoc,'pCountry1'));
- pCountry2 = getCountry(getValueFromTag(xmlDoc,'pCountry2'));
- pCountry3 = getCountry(getValueFromTag(xmlDoc,'pCountry3'));
- pCountry4 = getCountry(getValueFromTag(xmlDoc,'pCountry4'));
- mText3 = getValueFromTag(xmlDoc,'mText3');
- mText4 = getValueFromTag(xmlDoc,'mText4');
- timestampOld = timestamp;
- timestamp = getValueFromTag(xmlDoc,'timestamp');
- }
- }
- function updateBoard() {
- if ($('#pName1').html() != pName1) {
- animating = true;
- $('#pName1').tween({
- left:{
- start: 175,
- stop: 275,
- units: 'px',
- time: 0,
- duration: 0.5,
- effect:'easeIn'
- },
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pName1').html(pName1);
- }
- });
- $('#pName1').tween({
- left:{
- start: 275,
- stop: 175,
- units: 'px',
- time: 0.5,
- duration: 0.5,
- effect:'easeOut'
- },
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pName2').html() != pName2) {
- animating = true;
- $('#pName2').tween({
- left:{
- start: 775,
- stop: 675,
- units: 'px',
- time: 0,
- duration: 0.5,
- effect:'easeIn'
- },
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pName2').html(pName2);
- }
- });
- $('#pName2').tween({
- left:{
- start: 675,
- stop: 775,
- units: 'px',
- time: 0.5,
- duration: 0.5,
- effect:'easeOut'
- },
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pName3').html() != pName3) {
- animating = true;
- $('#pName3').tween({
- left:{
- start: 175,
- stop: 275,
- units: 'px',
- time: 0,
- duration: 0.5,
- effect:'easeIn'
- },
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pName3').html(pName3);
- }
- });
- $('#pName3').tween({
- left:{
- start: 275,
- stop: 175,
- units: 'px',
- time: 0.5,
- duration: 0.5,
- effect:'easeOut'
- },
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pName4').html() != pName4) {
- animating = true;
- $('#pName4').tween({
- left:{
- start: 775,
- stop: 675,
- units: 'px',
- time: 0,
- duration: 0.5,
- effect:'easeIn'
- },
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pName4').html(pName2);
- }
- });
- $('#pName4').tween({
- left:{
- start: 675,
- stop: 775,
- units: 'px',
- time: 0.5,
- duration: 0.5,
- effect:'easeOut'
- },
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pScore1').html() != pScore1) {
- animating = true;
- $('#pScore1').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pScore1').html(pScore1);
- }
- });
- $('#pScore1').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pScore2').html() != pScore2) {
- animating = true;
- $('#pScore2').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pScore2').html(pScore2);
- }
- });
- $('#pScore2').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pScore3').html() != pScore3) {
- animating = true;
- $('#pScore3').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pScore3').html(pScore1);
- }
- });
- $('#pScore3').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#pScore4').html() != pScore4) {
- animating = true;
- $('#pScore4').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pScore4').html(pScore2);
- }
- });
- $('#pScore4').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#mText3').html() != mText3) {
- animating = true;
- $('#mText3').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#mText3').html(mText3);
- }
- });
- $('#mText3').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if ($('#mText4').html() != mText4) {
- animating = true;
- $('#mText4').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#mText4').html(mText4);
- }
- });
- $('#mText4').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if (oldCountry1 != pCountry1 || $('#pFlag1').opacity() == 0) {
- animating = true;
- $('#pFlag1').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pFlag1').html('<img src="GoSquared/cropped/iso/64shiny/'+ pCountry1 +'.png" width="43" height="28">');
- oldCountry1 = pCountry1;
- }
- });
- $('#pFlag1').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if (oldCountry2 != pCountry2 || $('#pFlag2').opacity() == 0) {
- animating = true;
- $('#pFlag2').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pFlag2').html('<img src="GoSquared/cropped/iso/64shiny/'+ pCountry2 +'.png" width="43" height="28">');
- oldCountry2 = pCountry2;
- }
- });
- $('#pFlag2').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if (oldCountry3 != pCountry3 || $('#pFlag3').opacity() == 0) {
- animating = true;
- $('#pFlag3').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pFlag3').html('<img src="GoSquared/cropped/iso/64shiny/'+ pCountry3 +'.png" width="43" height="28">');
- oldCountry3 = pCountry3;
- }
- });
- $('#pFlag3').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- if (oldCountry4 != pCountry4 || $('#pFlag4').opacity() == 0) {
- animating = true;
- $('#pFlag4').tween({
- opacity: {
- start: 100,
- stop: 0,
- time: 0,
- duration: 0.5,
- effect: 'easeIn'
- },
- onStop: function(){
- $('#pFlag4').html('<img src="GoSquared/cropped/iso/64shiny/'+ pCountry4 +'.png" width="43" height="28">');
- oldCountry4 = pCountry4;
- }
- });
- $('#pFlag4').tween({
- opacity: {
- start: 0,
- stop: 100,
- time: 0.5,
- duration: 0.5,
- effect: 'easeOut'
- },
- onStop: function(){
- animating = false;
- }
- });
- }
- $.play();
- doUpdate = false;
- }
- function getValueFromTag (xmlDoc,tag) {
- if (xmlDoc.getElementsByTagName(tag).length != 0 ) {
- if (xmlDoc.getElementsByTagName(tag)[0].childNodes.length == 0) {
- return '';
- } else {
- return xmlDoc.getElementsByTagName(tag)[0].childNodes[0].nodeValue;
- }
- } else {
- return '';
- }
- }
- function getCountry (country) {
- var count = iso.findCountryByName(country);
- if (!count)
- count = iso.findCountryByCode(country);
- if (!count) {
- var count = new Array();
- count['value'] = "unknown";
- }
- return count['value'];
- }
- </script>
- </head>
- <body onLoad="init()">
- <div id="board">
- <div id="pFlag1"></div>
- <div id="pName1">Player 1</div>
- <div id="pScore1">99</div>
- <div id="pFlag2"></div>
- <div id="pName2">Player 2</div>
- <div id="pScore2">99</div>
- <div id="mText3">Test</div>
- <div id="mText4">Test2</div>
- </div>
- <div id="board2">
- <div id="pFlag3"></div>
- <div id="pName3">Player 3</div>
- <div id="pScore3">99</div>
- <div id="pFlag4"></div>
- <div id="pName4">Player 4</div>
- <div id="pScore4">99</div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement