mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-29 00:34:00 -06:00
Lose code supporting loading jquery. Check for no browser with !document.
This commit is contained in:
@@ -496,14 +496,16 @@ function ListBox(id, columns, fixedkeys) {
|
|||||||
this.remove0 = function (n) {
|
this.remove0 = function (n) {
|
||||||
if (game[this.id])
|
if (game[this.id])
|
||||||
game[this.id].shift();
|
game[this.id].shift();
|
||||||
this.box.find("tr").first().remove();
|
if (this.box)
|
||||||
|
this.box.find("tr").first().remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.remove1 = function (n) {
|
this.remove1 = function (n) {
|
||||||
var t = game[this.id].shift();
|
var t = game[this.id].shift();
|
||||||
game[this.id].shift();
|
game[this.id].shift();
|
||||||
game[this.id].unshift(t);
|
game[this.id].unshift(t);
|
||||||
this.box.find("tr").eq(1).remove();
|
if (this.box)
|
||||||
|
this.box.find("tr").eq(1).remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -543,7 +545,7 @@ function StrToIntDef(s, def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!navigator.v8)
|
if (document)
|
||||||
$(document).ready(FormCreate);
|
$(document).ready(FormCreate);
|
||||||
|
|
||||||
|
|
||||||
@@ -940,7 +942,7 @@ function FormCreate() {
|
|||||||
|
|
||||||
AllLists = [Traits,Stats,Spells,Equips,Inventory,Plots,Quests];
|
AllLists = [Traits,Stats,Spells,Equips,Inventory,Plots,Quests];
|
||||||
|
|
||||||
if (!navigator.v8) {
|
if (document) {
|
||||||
Kill = $("#Kill");
|
Kill = $("#Kill");
|
||||||
|
|
||||||
$("#quit").click(quit);
|
$("#quit").click(quit);
|
||||||
@@ -986,7 +988,7 @@ function LoadCharacter() {
|
|||||||
|
|
||||||
LoadGame(sheet);
|
LoadGame(sheet);
|
||||||
|
|
||||||
if (!navigator.v8)
|
if (document)
|
||||||
$("#title").text("Progress Quest - " + GameSaveName());
|
$("#title").text("Progress Quest - " + GameSaveName());
|
||||||
|
|
||||||
if (window.location.href.indexOf("?quit#") > 0)
|
if (window.location.href.indexOf("?quit#") > 0)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
function Roll(stat) {
|
function Roll(stat) {
|
||||||
stats[stat] = 3 + Random(6) + Random(6) + Random(6);
|
stats[stat] = 3 + Random(6) + Random(6) + Random(6);
|
||||||
if (!navigator.v8)
|
if (document)
|
||||||
$("#"+stat).text(stats[stat]);
|
$("#"+stat).text(stats[stat]);
|
||||||
return stats[stat];
|
return stats[stat];
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ function RollEm() {
|
|||||||
(total < (3 * 18)) ? 'silver' :
|
(total < (3 * 18)) ? 'silver' :
|
||||||
'white';
|
'white';
|
||||||
|
|
||||||
if (!navigator.v8) {
|
if (document) {
|
||||||
var Total = $("#Total");
|
var Total = $("#Total");
|
||||||
Total.text(total);
|
Total.text(total);
|
||||||
Total.css("background-color", color);
|
Total.css("background-color", color);
|
||||||
@@ -70,7 +70,7 @@ function fill(e, a, n) {
|
|||||||
var v = a[i].split("|")[0];
|
var v = a[i].split("|")[0];
|
||||||
var check = (def == i) ? " checked " : " ";
|
var check = (def == i) ? " checked " : " ";
|
||||||
if (def == i) traits[n] = v;
|
if (def == i) traits[n] = v;
|
||||||
if (!navigator.v8) {
|
if (document) {
|
||||||
$("<div><input type=radio id='" + v + "' name=\"" + n + "\" value=\"" + v + "\" " +
|
$("<div><input type=radio id='" + v + "' name=\"" + n + "\" value=\"" + v + "\" " +
|
||||||
check +"><label for='" + v + "'>" + v + "</label></div>").appendTo(e);
|
check +"><label for='" + v + "'>" + v + "</label></div>").appendTo(e);
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ function NewGuyFormLoad() {
|
|||||||
fill("#races", K.Races, "Race");
|
fill("#races", K.Races, "Race");
|
||||||
fill("#classes", K.Klasses, "Class");
|
fill("#classes", K.Klasses, "Class");
|
||||||
|
|
||||||
if (!navigator.v8) {
|
if (document) {
|
||||||
$("#Reroll").click(RerollClick);
|
$("#Reroll").click(RerollClick);
|
||||||
$("#Unroll").click(UnrollClick);
|
$("#Unroll").click(UnrollClick);
|
||||||
$("#RandomName").click(GenClick);
|
$("#RandomName").click(GenClick);
|
||||||
@@ -105,7 +105,7 @@ function NewGuyFormLoad() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!navigator.v8)
|
if (document)
|
||||||
$(document).ready(NewGuyFormLoad);
|
$(document).ready(NewGuyFormLoad);
|
||||||
|
|
||||||
/* Multiplayer:
|
/* Multiplayer:
|
||||||
@@ -191,7 +191,7 @@ function sold() {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!navigator.v8) {
|
if (document) {
|
||||||
newguy.Traits.Name = $("#Name").val();
|
newguy.Traits.Name = $("#Name").val();
|
||||||
newguy.Traits.Race = $("input:radio[name=Race]:checked").val();
|
newguy.Traits.Race = $("input:radio[name=Race]:checked").val();
|
||||||
newguy.Traits.Class = $("input:radio[name=Class]:checked").val();
|
newguy.Traits.Class = $("input:radio[name=Class]:checked").val();
|
||||||
@@ -219,7 +219,7 @@ function cancel() {
|
|||||||
|
|
||||||
function GenClick() {
|
function GenClick() {
|
||||||
traits.Name = GenerateName();
|
traits.Name = GenerateName();
|
||||||
if (!navigator.v8)
|
if (document)
|
||||||
$("#Name").attr("value", traits.Name);
|
$("#Name").attr("value", traits.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,68 +1,39 @@
|
|||||||
//!/usr/bin/env v8
|
//!/usr/bin/env v8
|
||||||
|
|
||||||
function noop() {}
|
|
||||||
function nada() { return {}; }
|
|
||||||
|
|
||||||
var document = {
|
|
||||||
addEventListener: noop,
|
|
||||||
createElement: function () {
|
|
||||||
var result = {
|
|
||||||
style: {},
|
|
||||||
getElementsByTagName: nada,
|
|
||||||
appendChild: noop,
|
|
||||||
};
|
|
||||||
result.lastChild = result;
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
documentElement: {
|
|
||||||
insertBefore: noop,
|
|
||||||
removeChild: noop,
|
|
||||||
},
|
|
||||||
getElementById: nada,
|
|
||||||
createComment: noop,
|
|
||||||
createDocumentFragment: nada,
|
|
||||||
};
|
|
||||||
|
|
||||||
var window = {
|
var window = {
|
||||||
location: {href: "#Woogle"},
|
location: {href: "#Woogle"},
|
||||||
|
|
||||||
localStorage: {
|
localStorage: {
|
||||||
items: {},
|
items: null,
|
||||||
|
|
||||||
getItem: function(key) {
|
getItem: function(key) {
|
||||||
|
if (!this.items) {
|
||||||
|
try {
|
||||||
|
this.items = JSON.parse(read("local.storage"));
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
this.items = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.items[key];
|
return this.items[key];
|
||||||
},
|
},
|
||||||
|
|
||||||
setItem: function (key, value) {
|
setItem: function (key, value) {
|
||||||
this.items[key] = value;
|
this.items[key] = value;
|
||||||
|
write("local.storage", JSON.stringify(this.items));
|
||||||
},
|
},
|
||||||
|
|
||||||
removeItem: function (key) {
|
removeItem: function (key) {
|
||||||
delete this.items[key];
|
delete this.items[key];
|
||||||
|
write("local.storage", JSON.stringify(this.items));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
document: document,
|
|
||||||
addEventListener: noop,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var location = window.location;
|
var location = window.location;
|
||||||
|
|
||||||
var v8 = true;
|
var $ = function () { return null; };
|
||||||
|
|
||||||
var $ = function () {
|
|
||||||
return null;
|
|
||||||
return {
|
|
||||||
click: noop,
|
|
||||||
keypress: noop,
|
|
||||||
ready: noop,
|
|
||||||
unload: noop,
|
|
||||||
bind: noop,
|
|
||||||
text: noop,
|
|
||||||
appendTo: noop,
|
|
||||||
attr: noop,
|
|
||||||
focus: noop,
|
|
||||||
select: noop,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
$.isFunction = function (obj) {
|
$.isFunction = function (obj) {
|
||||||
return toString.call(obj) === "[object Function]";
|
return toString.call(obj) === "[object Function]";
|
||||||
},
|
},
|
||||||
@@ -87,21 +58,10 @@ $.each = function (object, callback) {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var document = null;
|
||||||
|
|
||||||
var navigator = {
|
|
||||||
v8: true,
|
|
||||||
userAgent: "V8 Shell"
|
|
||||||
};
|
|
||||||
var alert = function (m) { print("ALERT: " + m); };
|
var alert = function (m) { print("ALERT: " + m); };
|
||||||
|
|
||||||
var randseed = function () {};
|
|
||||||
try {
|
|
||||||
window.localStorage.items = JSON.parse(read("local.storage"));
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
window.localStorage.items = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
var now = 0;
|
var now = 0;
|
||||||
var timers = [{}];
|
var timers = [{}];
|
||||||
function setInterval(callback, interval) {
|
function setInterval(callback, interval) {
|
||||||
@@ -109,10 +69,13 @@ function setInterval(callback, interval) {
|
|||||||
return timers.length-1;
|
return timers.length-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load("jquery.js");
|
|
||||||
//var $ = window.$;
|
|
||||||
load("config.js");
|
load("config.js");
|
||||||
|
|
||||||
|
var cs = 0;
|
||||||
|
for (var c in loadRoster())
|
||||||
|
cs++;
|
||||||
|
print(cs, "characters");
|
||||||
|
|
||||||
load("newguy.js");
|
load("newguy.js");
|
||||||
NewGuyFormLoad();
|
NewGuyFormLoad();
|
||||||
sold();
|
sold();
|
||||||
@@ -129,11 +92,11 @@ timeGetTime = function () {
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < 1000; ++i) {
|
for (var i = 0; i < 100000; ++i) {
|
||||||
//assert(timers.id == 1);// TODO: this is for simplicity
|
//assert(timers.id == 1);// TODO: this is for simplicity
|
||||||
now += timers[1].interval;
|
now += timers[1].interval;
|
||||||
timers[1].callback();
|
timers[1].callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveGame();
|
SaveGame();
|
||||||
print(guy, game.elapsed, game.tasks, game.task);//JSON.stringify(loadSheet(guy)));
|
print(guy, game.elapsed, game.tasks, game.Traits.Level, game.task);//JSON.stringify(loadSheet(guy)));
|
||||||
|
|||||||
Reference in New Issue
Block a user