<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>a programmer's best friend - Experiments</title>
    <link>http://blog.php-tools.net/</link>
    <description>the blog of pat, the dog</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.0 - http://www.s9y.org/</generator>
    <pubDate>Fri, 03 Sep 2004 08:18:12 GMT</pubDate>

    <image>
        <url>http://blog.php-tools.net/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: a programmer's best friend - Experiments - the blog of pat, the dog</title>
        <link>http://blog.php-tools.net/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Hunting for Galactic Civilization's perfect starting location</title>
    <link>http://blog.php-tools.net/archives/69-Hunting-for-Galactic-Civilizations-perfect-starting-location.html</link>
            <category>Experiments</category>
    
    <comments>http://blog.php-tools.net/archives/69-Hunting-for-Galactic-Civilizations-perfect-starting-location.html#comments</comments>
    <wfw:comment>http://blog.php-tools.net/wfwcomment.php?cid=69</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.php-tools.net/rss.php?version=2.0&amp;type=comments&amp;cid=69</wfw:commentRss>
    

    <author>nospam@example.com (argh)</author>
    <content:encoded>
    Talking about what can be done with javascript... for the &lt;a href=&quot;http://blog.php-tools.net/exit.php?url=aHR0cDovL2V0aGVycGxhbmVzLm5ldC9HYWxDaXYvU3RhcnRpbmdMb2NhdGlvbnM=&amp;amp;entry_id=69&quot; title=&quot;http://etherplanes.net/GalCiv/StartingLocations&quot;  onmouseover=&quot;window.status=&#039;http://etherplanes.net/GalCiv/StartingLocations&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;Game Manager&lt;/a&gt; I built to calculate the values of starting locations in the &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=385&amp;amp;entry_id=69&quot; title=&quot;http://www.galciv.com&quot;  onmouseover=&quot;window.status=&#039;http://www.galciv.com&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;Galactic Civilizations&lt;/a&gt; PC game, I implemented language switching and skin switching entirely in javascript.&lt;br /&gt;
&lt;br /&gt;
The whole tool is built on objects that tightly communicate amongst themselves - each star system, planet or game is an object and can render itself. The layout control is mostly implemented with stylesheets, the javascript only rendering a very simple html structure. The core is the gameManager class itself - it renders the main navigation elements, and provides a series of helper methods (like the button() method that is used to render a button).&lt;br /&gt;
&lt;br /&gt;
The language switching was not too difficult - I first &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=386&amp;amp;entry_id=69&quot; title=&quot;http://www.google.de/search?q=javascript+load+external+script&quot;  onmouseover=&quot;window.status=&#039;http://www.google.de/search?q=javascript+load+external+script&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;googled&lt;/a&gt; around but the generally used trick with document.write( &#039;[script tag]&#039; ); makes Mozilla reload the page. I found a nicer way to do this: create the script tag with the document.createElement() method, and append it to the document&#039;s head tag with document.getElementsByTagName(&#039;head&#039;)[0].appendChild( tag ); As my language files consist of one file with a list of variables, they simply get replaced when loading the new script. Updating the display is a breeze, I just have to tell the objects to redraw themselves &lt;img src=&quot;http://blog.php-tools.net/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
The skin (stylesheet) switching proved a little more annoying: it works the same way than the javascript include, by appending a link tag to the head - but the existing styles do not get replaced, they are overwritten and extended. Meaning that if in my standard stylesheet, the h1 tag has a padding but not in the second stylesheet, that padding will still be there... Solution: delete all styles before loading the new stylesheet. That&#039;s easy to do by accessing the document&#039;s styleSheets property, going through each stylesheet and deleting each style rule via document.styleSheets[x].deleteRule( x ); Peter-Paul Koch has an excellent &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=387&amp;amp;entry_id=69&quot; title=&quot;http://www.quirksmode.org/dom/w3c_css.html&quot;  onmouseover=&quot;window.status=&#039;http://www.quirksmode.org/dom/w3c_css.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;reference&lt;/a&gt; on this.&lt;br /&gt;
&lt;br /&gt;
Currently the Game Manager only works with gecko-based browsers like &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=389&amp;amp;entry_id=69&quot; title=&quot;http://www.mozilla.org&quot;  onmouseover=&quot;window.status=&#039;http://www.mozilla.org&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;Mozilla&lt;/a&gt; or &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=389&amp;amp;entry_id=69&quot; title=&quot;http://www.mozilla.org&quot;  onmouseover=&quot;window.status=&#039;http://www.mozilla.org&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;Firefox&lt;/a&gt;, as I use some specific methods like the &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=390&amp;amp;entry_id=69&quot; title=&quot;http://www.mozilla.org/docs/dom/domref/dom_el_ref31.html&quot;  onmouseover=&quot;window.status=&#039;http://www.mozilla.org/docs/dom/domref/dom_el_ref31.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;addEventListener()&lt;/a&gt; method (to check when the external file has been loaded), and also because I used only the gecko implementation of the styleSheet access methods.&lt;br /&gt;
&lt;br /&gt;
The result matches my expectations: a blazingly fast online tool, that would have taken a lot of time to build with a PHP/Javascript mixture and would not have been this fast. Now I only need to implement the save button and it&#039;s ready to really rock &lt;img src=&quot;http://blog.php-tools.net/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; Implementing this would take a little time, but basically all I need is already there: if you clicked on one of the View XML buttons in the interface, you have seen that each object can render itself to XML too, so I would just have to submit that to a PHP script for storage, and parse existing XML to rebuild the needed settings... but that&#039;s for another blog entry &lt;img src=&quot;http://blog.php-tools.net/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
You can view the whole &lt;a href=&quot;http://blog.php-tools.net/exit.php?url_id=391&amp;amp;entry_id=69&quot; title=&quot;http://cvs.php-tools.net/horde/chora/cvs.php/GalCiv/StartingLocations?rt=argh&quot;  onmouseover=&quot;window.status=&#039;http://cvs.php-tools.net/horde/chora/cvs.php/GalCiv/StartingLocations?rt=argh&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; target=&quot;_blank&quot;&gt;Game Manager package&lt;/a&gt; in my personal WebCVS. 
    </content:encoded>

    <pubDate>Fri, 03 Sep 2004 10:18:12 +0200</pubDate>
    <guid isPermaLink="false">http://blog.php-tools.net/archives/69-guid.html</guid>
    
</item>

</channel>
</rss>