date.htm

<html>
<head>
    <title>Date</title>
<link rel="stylesheet" type="text/css" href="breaking.css" />
<script src="include.js" type="text/javascript"></script>
<script src="dateinc.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
   //These functions handle various user commands (button clicks and so on)
   function awardAttractionDice(e)
   {
       var elem = getClickedElement(e);

       var elemSiblings = elem.parentNode.getElementsByTagName("img");

       for (var i = 0; i < elemSiblings.length; i++)
       {
          elemSiblings[i].src = "images/BlueDieGiving.gif";
          elemSiblings[i].className = "BlueDieGiving";

          elemSiblings[i].onclick = null;
       }

        doHttpRequest(httpXMLUser, handleHttpUserResponse, "awardattractiondice.php", "POST");
   }

   function awardBonusDie(e)
   {
       var elem = getClickedElement(e);

       elem.src = "images/BlueDieGiving.gif";
    
       elem.onclick = null;

        doHttpRequest(httpXMLUser, handleHttpUserResponse, "awardbonusdie.php", "POST");
   }

   function rollDice(e)
   {

       var elem = getClickedElement(e);

       var elemSiblings = elem.parentNode.getElementsByTagName("img");

       for (var i = 0; i < elemSiblings.length; i++)
       {
          elemSiblings[i].src = "images/BlueDieRolling.gif";
          elemSiblings[i].className = "BlueDieRolling";

          elemSiblings[i].onclick = null;
       }

        doHttpRequest(httpXMLUser, handleHttpUserResponse, "rolldice.php", "POST");
   }

   function rollConflictDice(gameusermapid)
   {
        var urlPost = "rollconflictdice.php?gameusermapid=" + gameusermapid;
  
        doHttpRequest(httpXMLUser, handleHttpUserResponse, urlPost, "POST");
   }

   function rollCompatibilityDice(compatibilityid)
   {
        var urlPost = "rollcompatibilitydice.php?compatibilityid=" + compatibilityid;

        doHttpRequest(httpXMLUser, handleHttpUserResponse, urlPost, "POST");
   }

   function proposeConflict(gameusermapid)
   {
        var urlPost = "proposeconflict.php?gameusermapid=" + gameusermapid;
  
        doHttpRequest(httpXMLUser, handleHttpUserResponse, urlPost, "POST");
   }

   function proposeCompatibility(compatibilityid)
   {
        var urlPost = "proposecompatibility.php?compatibilityid=" + compatibilityid;

        doHttpRequest(httpXMLUser, handleHttpUserResponse, urlPost, "POST");
   }

   function getClickedElement(e)
   {
         if (!e)
         {
             e = window.event;
         }

         var elemClicked;

         if (e.target)
         {
             elemClicked = e.target;
         }
         else
         {
             elemClicked = e.srcElement;
         }
 
         return elemClicked;
   }

   function rerollDie(e)
   {
       var elem = getClickedElement(e);

       elem.src = "images/BlueDieRolling.gif";
    
       elem.onclick = null;

       doHttpRequest(httpXMLUser, handleHttpUserResponse, "rerolldie.php", "POST");
   }

   function increaseAttraction(e)
   {
        document.getElementById("buttonIncreaseAttraction").style.display = "none";
        document.getElementById("buttonAddCompatibility").style.display = "none";
        document.getElementById("textAddCompatibility").style.display = "none";

        document.getElementById("paraNextDate").style.display = "block";

        doHttpRequest(httpXMLUser, handleHttpUserResponse, "increaseattraction.php", "POST");
   }

   //This handles the return key being pressed in the Compatibility edit field
   function handleCompatibilityReturn()
   {
        addCompatibility();
   }

   function handleTraitReturn()
   {
        addTrait();
   }

   function addCompatibility()
   {
        var urlPost = "putcompatibility.php?description=" + document.getElementById("textAddCompatibility").value;
        
        doHttpRequest(httpXMLUser, handleHttpUserResponse, urlPost, "POST");
   }

  function addTrait()
   {
        var urlPost = "puttraits.php?trait0=" + document.getElementById("textAddTrait").value;
        
        doHttpRequest(httpXMLUser, handleHttpUserResponse, urlPost, "POST");
   }

   function endTurn()
   {
        doHttpRequest(httpXMLUser, handleHttpUserResponse, "nextturn.php", "POST");
   }

   function endDate()
   {
        doHttpRequest(httpXMLUser, handleHttpUserResponse, "enddate.php", "POST");
   }

//Note that this file and betweendates.php
//handle this function differently
function setBetweenDatesFromXML(node) 
{
     var fBetweenDates= getTextFromNode(node);

     if (fBetweenDates == 1)
     {
              top.location = "betweendates.htm";
     }
}

//Similarly, betweendates.php has a different version 
//of this function
function setDateNoFromXML(node) 
{
     iDateNo = getTextFromNode(node);

     var elemDate = document.getElementById("idDate");

     if (iDateNo == 0)
     {
         elemDate.innerHTML = "First date";
     }
     else if (iDateNo == 1)
     {
         elemDate.innerHTML = "Second date";
     }
     else if (iDateNo == 2)
     {
         elemDate.innerHTML = "Third date";
     }
}
   //An automatic function, called on a timer every n seconds 
   function getDateState() 
   {
        doHttpRequest(httpXMLTimer, handleHttpTimerResponse, "getdatestate.php", "GET");
   }

   function handleHttpTimerResponse() 
   {
       parseXMLWithCallback(httpXMLTimer.responseXML, displayNode);

       setTimeout("getDateState()",5000);
   }

   function handleHttpUserResponse() 
   {
       parseXMLWithCallback(httpXMLUser.responseXML, displayNode);
   }

   function setPermanenceDiceFromXML()
   {
   }

   function setPermanenceSuccessesFromXML()
   {
   }

   function setPermanenceFailuresFromXML()
   {
   }

   function setPermanenceRerollsFromXML()
   {
   }
</script>
</head>
<body onload="getDateState()">
<table>
<tr>
    <td width="50%">
       <h1><span id="idDate"></span><span id="idTurn"></span></h1>
    </td>    
    <td width="50%" class="right">
        <span id="idPermanentAttraction"></span><span id="idTemporaryAttraction"></span>
    </td>    
</tr>
</table>

<div class="intro" id="idStatus"></div>
<div id="idInstructions" class="intro"></div>
<table class="highlighted">
  <tr>
  <th width="33%">Your dice</th>
  <th width="33%">Rolled dice</th>
  <th width="33%">Your partner's dice</th>
  </tr>
  <tr id = "idRowDice">
    <td width="33%" id = "idCellActivePlayer">
      <p id="idParaRerollableDiceAwardedGuide" style='display:none'>You've awarded your partner these dice:</p>
      <p id="idParaRerollableDiceAwardedActivePlayer" style='display:none'>Your partner has awarded you these dice:</p>
       <span id="idRerollableDiceAwarded"></span>
       <span id="idRollDiceButton" style='display:none' ><input type="button" style='display:none' id="buttonRollDice" value="Roll dice" onclick="rollDice()"></span>
    </td>
    <td width="33%">
      <p id="idParaSuccesses" style='display:none'>These dice are <i>successes</i>.</p>
       <span id="idSingleRollSuccesses"></span><span id="idRerollableSuccesses"></span>
       <input type="text" style='display:none' id="textAddCompatibility" onKeyPress ="handleKeyPress(event, handleCompatibilityReturn)">
       <input type="button" style='display:none' id="buttonAddCompatibility" value="Add compatibility" onclick="addCompatibility()">
       <input type="button" style='display:none' id="buttonIncreaseAttraction" value="Increase attraction" onclick="increaseAttraction()">
       <p style='display:none' id="paraNextDate"><i>Starting next date...</i></p>
       <p id="idParaRerollsGuide" style='display:none'>Every time your parner narrates something that puts their character at a disadvantage, they may reroll one of these dice.</p>
       <p id="idParaRerollsActivePlayer" style='display:none'>Every time you narrate something that puts your character at a disadvantage, reroll one of these dice, by clicking on it.</p>
       <span id="idRerolls"></span>
       <span id="idRerollDieButton" style='display:none' ><input type="button" style='display:none' id="buttonRerollDie" value="Reroll die" onclick="rerollDie()"></span>
       <p id="idParaFailures" style='display:none'>These dice are <i>failures</i>.</p>
       <span id="idRerollFailures"></span>
       <span id="idSingleRollFailures"></span>
    </td>
    <td width="33%" id = "idCellGuide">
      <p id="idParaAttractionDiceGuide" style='display:none'>These are <i>Attraction Dice</i>. When your partner starts the date by doing something attractive, click on these dice to give them to your partner.</p>
      <p id="idParaAttractionDiceActivePlayer" style='display:none'>These are <i>Attraction Dice</i>. Your partner will give you these dice when you start the date by doing something attractive.</p>
      <span id="idAttractionDiceToAward"></span>
      <span id="idAwardAttractionDiceButton" style='display:none' ><input type="button" style='display:none' id="buttonAwardAttractionDice" value="Award Attraction Dice" onclick="awardAttractionDice()"></span>
      <p id="idParaBonusDiceGuide" style='display:none'>These are <i>Bonus Dice</i>. When your partner describes doing something that puts their character at an advantage, click on a die to give it to your partner.</p>
      <p id="idParaBonusDiceActivePlayer" style='display:none'>These are <i>Bonus Dice</i>. Your partner will give you these dice when you describe doing something that puts your character at an advantage.</p>
      <span id="idBonusDiceToAward"></span>
      <span id="idAwardBonusDieButton" style='display:none' ><input type="button" style='display:none' id="buttonAwardBonusDie" value="Award Bonus Die" onclick="awardBonusDie()"></span>
    </td>
  </tr>
</table>
<p>
<table class="highlighted">
<tr>
  <th width="33%"><span id="idMyName"></span></th>
  <th width="33%">Compatibilities</th>
  <th width="33%"><span id="idTheirName"></span></th>
</tr>
<tr>
  <td width="33%"><i>Conflict: <span id="idMyConflict"></span></i></td>
  <td width="33%"><i><span id="idCompatibilities"></span></i></td>
  <td width="33%"><i>Conflict: <span id="idTheirConflict"></span></i></td>
</tr>
<tr>
  <td width="33%" class="understated"><span id="idMyTraits"></span></td>
  <td width="33%" class="understated"></td>
  <td width="33%" class="understated"><span id="idTheirTraits"></span></td>
</tr>
<tr>
  <td width="33%"><div class="slightlyunderstated"><i>Add trait:</i>
     <input type="text" class="slightlyunderstated" id="textAddTrait" onKeyPress ="handleKeyPress(event, handleTraitReturn)">
     <input type="button" class="slightlyunderstated" id="buttonAddTrait" value="Add trait" onclick="addTrait()">
     </div>
  </td>
  <td width="33%" class="understated"></td>
  <td width="33%" class="understated"><span id="idTheirTraits"></span></td>
</tr>

</table>
<input type="button" style='display:none' id="buttonEndTurn" value="End Turn" onclick="endTurn()">
<input type="button" style='display:none' id="buttonEndDate" value="End Date" onclick="endDate()">
</body>
</html>