Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by stahlmanDesign

I am thinking of using Impact to make a calendar for the next NHL season. It works out pretty well to lay it out in Weltmeister where team logos are entities containing game time & info.

There would just be one entity called team. What would make it unique is the date value (gameday).

There are about 12 games per month. Each month could be a new "level" with its own layout, or just have each month off the the right and have a button scroll left and right.

But this is still tedious to update in Weltmeister after each game, and then bake and upload.

So I wonder is it possible to load an XML file from some other site, updated by someone else, and then have that data modify the entities' variables?

I would have some code in the "game" to look through parsed XML data. When it detects the entity with a corresponding date value, the final score variables in the entity would be changed which would then display it with an Impact font.

This would allow me to build a calendar that updates itself based on an XML file that other people will be responsible for changing. Sort of like loading high scores, but having those scores affect the game.

For example, in Weltmeister I would have an entity, and based on a key value, it would use a Winnipeg logo:

key: date
value: 20111001 <--- i.e. Oct. 1, 2011

key: visitor
value: winnipeg <--use winnipeg logo (tile #30) for entity

key: visitorScore
value: 2 <-- use -1 if game not yet played

key: homeScore
value: 3

key: overtime
value: YES

key: shootout
value: NO

etc.

1 decade ago by dominic

Well, yes. That sounds reasonable. Where's your problem now? :)

Actually loading the XML? Try XMLHttpRequest. Loading files from a different domain can be a bit more complicated though. Does the site you want to get the data from have a public API?

1 decade ago by stahlmanDesign

The same origin policy is a huge problem. How do other sites load data from say, ESPN, and then present that data on their own website? Or a news site loading weather data from a government meteorological database?

I don't know about an API, I just know the sports site can host an xml file that I can link to and read with browser, so I figured I could also have javascript parse it and use the data in Impact.

However, if I did host the XML file on the same site as my Impact calendar, it would still be easier to have people change that than to do things manually in WM. If I were to use XMLHttpRequest, would I put that in main.js?

1 decade ago by fugufish

@stahlmanDesign - doesn't matter where you put it.

i learned abt XMLHttpRequest here http://code.google.com/edu/ajax/tutorials/ajax-tutorial.html

i think you can achieve the same with jQuery (ajax is built it), but i prefer to construct my own ajax file.

can't really answer the same origin policy question, am still researching it :(

1 decade ago by stahlmanDesign

Thanks, that helps out. I've got it to load, now i just need to learn to parse it and turn it into variables.

I found another helpful site that compares different methods for load XML using JavaScript : http://www.steveborn.com/codenotes/LoadingXML.htm

1 decade ago by xdissent

You can circumvent the cross-origin request limitation using JSONP, but only if you're luck enough to find a sports site that wraps its data in JSONP. Otherwise you can write a simple PHP proxy script that lives on the same server as your "game". The script would just request the XML from the remote server and spit it out unmodified, although it can now be consumed by your XMLHttpRequest. It could be as easy as:

<?php echo file_get_contents('http://sports.com/hockey.xml'); ?>

If your host doesn't allow file_get_contents() with URLs (a common restriction of shared hosts), you can still use CURL to do the same thing.
Page 1 of 1
« first « previous next › last »