Get onload working somewhat for create screen

This commit is contained in:
Eric Fredricksen
2010-06-24 12:44:55 -07:00
parent 77b61b114f
commit 2bede6d1bf
2 changed files with 38 additions and 33 deletions
+12 -9
View File
@@ -4,6 +4,7 @@
<title>Progress Quest - Roll One Up</title> <title>Progress Quest - Roll One Up</title>
<script src="jquery.js"></script> <script src="jquery.js"></script>
<script src="config.js"></script> <script src="config.js"></script>
<script src="newguy.js"></script>
<style> <style>
input, button { display: inline; } input, button { display: inline; }
@@ -38,14 +39,14 @@ input, button { display: inline; }
<legend>Stats</legend> <legend>Stats</legend>
<table> <table>
<tr> <th> STR <td> 13 </tr> <tr> <th> STR <td id="STR">13</tr>
<tr> <th> DEX <td> 34 </tr> <tr> <th> CON <td id="CON">23</tr>
<tr> <th> CON <td> 23 </tr> <tr> <th> DEX <td id="DEX">34</tr>
<tr> <th> INT <td> 12 </tr> <tr> <th> INT <td id="INT">12</tr>
<tr> <th> WIS <td> 4 </tr> <tr> <th> WIS <td id="WIS">4</tr>
<tr> <th> CHA <td> 12 </tr> <tr> <th> CHA <td id="CHA">12</tr>
<tr> <th colspan=2> &nbsp; </tr> <tr> <th colspan=2> &nbsp; </tr>
<tr> <th> Total <td> 48 </tr> <tr> <th> Total <td id="Total">48</tr>
</table> </table>
<br> <br>
@@ -69,10 +70,12 @@ input, button { display: inline; }
<script> <script>
function fill(e, a, n) { function fill(e, a, n) {
var def = Random(a.length);
for (var i = 0; i < a.length; ++i) { for (var i = 0; i < a.length; ++i) {
var v = a[i].split("|")[0]; var v = a[i].split("|")[0];
$("<div><input type=radio name=\"" + n + "\" value=" + v +">" + var check = def == i ? " checked " : " ";
v + "</div>").appendTo(e); $("<div><input type=radio name=\"" + n + "\" value=\"" + v + "\" " +
check +">" + v + "</div>").appendTo(e);
} }
} }
fill("#races", K.Races, "Race"); fill("#races", K.Races, "Race");
+25 -23
View File
@@ -1,13 +1,12 @@
/* copyright (c)2002-2010 Eric Fredricksen all rights reserved */ /* copyright (c)2002-2010 Eric Fredricksen all rights reserved */
function UrlEncode(s) { function Random(n) {
NewGuyForm.PoorCodeDesign.InputString = s; return Math.floor(Math.random() * n);
return NewGuyForm.PoorCodeDesign.Encode;
} }
function Roll(stat) { function Roll(stat) {
stat.Tag = 3 + Random(6) + Random(6) + Random(6); stat.Tag = 3 + Random(6) + Random(6) + Random(6);
stat.Caption = IntToStr(stat.Tag); stat.html(stat.Tag);
} }
function Choose(n, k) { function Choose(n, k) {
@@ -20,21 +19,31 @@ function Choose(n, k) {
return result / d; return result / d;
} }
function TNewGuyForm_RollEm() { function RollEm() {
ReRoll.Tag = RandSeed(); var STR = $("STR");
var CON = $("CON");
var DEX = $("DEX");
var INT = $("INT");
var WIS = $("WIS");
var CHA = $("CHA");
var Total = $("Total");
var ReRoll = $("ReRoll");
//ReRoll.Tag = RandSeed();
Roll(STR); Roll(STR);
Roll(CON); Roll(CON);
Roll(DEX); Roll(DEX);
Roll(INT); Roll(INT);
Roll(WIS); Roll(WIS);
Roll(CHA); Roll(CHA);
Total.tag = STR.Tag + Con.Tag + DEX.Tag + Int.Tag + Wis.Tag + CHA.Tag; Total.tag = STR.Tag + CON.Tag + DEX.Tag + INT.Tag + WIS.Tag + CHA.Tag;
Total.Caption = IntToStr(Total.Tag); Total.html(Total.Tag);
/*
if (Total.Tag >= (63+18)) Total.Color = clRed if (Total.Tag >= (63+18)) Total.Color = clRed
else if (Total.Tag > (4 * 18)) Total.Color = clYellow else if (Total.Tag > (4 * 18)) Total.Color = clYellow
else if (Total.Tag <= (63-18)) Total.Color = clGray else if (Total.Tag <= (63-18)) Total.Color = clGray
else if (Total.Tag < (3 * 18)) Total.Color = clSilver else if (Total.Tag < (3 * 18)) Total.Color = clSilver
else Total.Color = clWhite; else Total.Color = clWhite;
*/
} }
function TNewGuyForm_RerollClick() { function TNewGuyForm_RerollClick() {
@@ -48,20 +57,13 @@ function TNewGuyForm_Go() {
return mrOk == ShowModa(); return mrOk == ShowModa();
} }
function TNewGuyForm_FormShow() { $(document).ready(function () {
if (Tag > 0) { //var caption = 'Progress Quest - New Character';
Tag = 0; //if (MainForm.GetHostName != '')
Caption = 'Progress Quest - New Character'; // caption = caption + ' [' + MainForm.GetHostName + ']';
if (MainForm.GetHostName != '') //Randomize();
Caption = Caption + ' [' + MainForm.GetHostName + ']';
Randomize();
RollEm(); RollEm();
with (Race) });
ItemIndex = Random(Items.Count);
with (Klass)
ItemIndex = Random(Items.Count);
}
}
function TNewGuyForm_UnrollClick() { function TNewGuyForm_UnrollClick() {
RandSeed = StrToInt(OldRolls.Items[0]); RandSeed = StrToInt(OldRolls.Items[0]);
@@ -103,8 +105,8 @@ function TNewGuyForm_SoldClick() {
if ((GetAccount() != '') || (GetPassword != '')) if ((GetAccount() != '') || (GetPassword != ''))
url = StuffString(url, 8, 0, GetAccount() + ':' + GetPassword() + '@'); url = StuffString(url, 8, 0, GetAccount() + ':' + GetPassword() + '@');
args = 'cmd=create' + args = 'cmd=create' +
'&name=' + UrlEncode(Name.Text) + '&name=' + escape(Name.Text) +
'&realm=' + UrlEncode(MainForm.GetHostName) + '&realm=' + escape(MainForm.GetHostName) +
RevString; RevString;
ParseSoldResponse(DownloadString(url + args)); ParseSoldResponse(DownloadString(url + args));
} catch (EWebError) { } catch (EWebError) {