Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

Need help with stardate code

Aloittaja Burke ♞ Knight, elokuu 06, 2013, 08:21:11 IP

« edellinen - seuraava »

Burke ♞ Knight

I'm trying to add the Star Trek Stardate to new dev site. This will also become a mod.
I had thought I had it working, but the code caused the site to keep refreshing, only showing the stardate, and no site.

It would work fine the way it is coded now, yet I cannot seem to make it into a mod, as it messes up somehow.
It will show the text string I made, then instead of showing the stardate, it shows //>

Here is the section from the mod for the index.template.php change:
    <file name="$themedir/index.template.php">
        <operation>
            <search position="replace"><![CDATA[<li>', $context['current_time'], '</li>]]></search>
            <add><![CDATA[<li>', $context['current_time'], '</li>
            <li>', $txt['stardate'], ':
<script type="text/javascript"><!-- // --><![CDATA[
// -- made by Heath Coop of TrekConnection.com, please keep these credits when using this script
var Now = new Date();
var NowTime = Now.getTime()/1000;
var Day = Now.getDate();
var Month = Now.getMonth()+1;
var Year = Now.getYear();
if (Year < 2000) {
Year = Year + 1900;
}
if (Year<1000) {
YearDif = Math.abs(Year-87);
}
if (Year>1000) {
YearDif = Math.abs(Year-1987);
}
SDYear = 40000+(YearDif*1000);
YearStart = new Date(Year,0,1,0,0,0);
var YearStartTime = YearStart.getTime()/1000;
Days=(NowTime-YearStartTime)/86400;
if (Days>=183) {
SDYear = SDYear+1000;
SDDays = (Days*(1000/365))-500;
}
if (Days<183) {
SDDays = 500+(Days*(1000/365));
}
StarDate = Math.floor((SDYear+SDDays) * 10 + .5) / 10;
document.getElementById("myStardate").innerHTML = StarDate;
// ]]></script>
</li>]]></add>
        </operation>
    </file>


Needless to say, the original author of the code is not available. :(

Any help would be most appreciated.

Advertisement: