diff --git a/[web]/ajax/json.js b/[web]/ajax/json.js index e91078b1d..c5f12750a 100644 --- a/[web]/ajax/json.js +++ b/[web]/ajax/json.js @@ -59,148 +59,154 @@ if (!Object.prototype.toJSONString) { - Array.prototype.toJSONString = function () { - var a = [], // The array holding the member texts. - i, // Loop counter. - l = this.length, - v; // The value to be stringified. + Object.defineProperty(Array.prototype, 'toJSONString', { + enumerable: false, + value: function () { + let a = [], // The array holding the member texts. + i, // Loop counter. + l = this.length, + v; // The value to be stringified. // For each value in this array... - for (i = 0; i < l; i += 1) { - v = this[i]; - switch (typeof v) { - case 'object': + for (i = 0; i < l; i += 1) { + v = this[i]; + switch (typeof v) { + case 'object': // Serialize a JavaScript object value. Ignore objects thats lack the // toJSONString method. Due to a specification error in ECMAScript, // typeof null is 'object', so watch out for that case. - if (v) { - if (typeof v.toJSONString === 'function') { - a.push(v.toJSONString()); + if (v) { + if (typeof v.toJSONString === 'function') { + a.push(v.toJSONString()); + } + } else { + a.push('null'); } - } else { - a.push('null'); - } - break; + break; - case 'string': - case 'number': - case 'boolean': - a.push(v.toJSONString()); + case 'string': + case 'number': + case 'boolean': + a.push(v.toJSONString()); // Values without a JSON representation are ignored. + } } - } // Join all of the member texts together and wrap them in brackets. - return '[' + a.join(',') + ']'; - }; - - - Boolean.prototype.toJSONString = function () { - return String(this); - }; + return '[' + a.join(',') + ']'; + }, + }); + Object.defineProperty(Boolean.prototype, 'toJSONString', { + enumerable: false, + value: function () { + return String(this); + }, + }); - Date.prototype.toJSONString = function () { + Object.defineProperty(Date.prototype, 'toJSONString', { + enumerable: false, + value: function () { // Ultimately, this method will be equivalent to the date.toISOString method. - function f(n) { + function f(n) { // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; - } - - return '"' + this.getFullYear() + '-' + - f(this.getMonth() + 1) + '-' + - f(this.getDate()) + 'T' + - f(this.getHours()) + ':' + - f(this.getMinutes()) + ':' + - f(this.getSeconds()) + '"'; - }; + return n < 10 ? '0' + n : n; + } + return '"' + this.getFullYear() + '-' + + f(this.getMonth() + 1) + '-' + + f(this.getDate()) + 'T' + + f(this.getHours()) + ':' + + f(this.getMinutes()) + ':' + + f(this.getSeconds()) + '"'; + }, + }); - Number.prototype.toJSONString = function () { + Object.defineProperty(Number.prototype, 'toJSONString', { + enumerable: false, + value: function () { // JSON numbers must be finite. Encode non-finite numbers as null. - return isFinite(this) ? String(this) : 'null'; - }; - + return isFinite(this) ? String(this) : 'null'; + }, + }); - Object.prototype.toJSONString = function () { - var a = [], // The array holding the member texts. - k, // The current key. - v; // The current value. + Object.defineProperty(Object.prototype, 'toJSONString', { + enumerable: false, + value: function () { + let a = [], // The array holding the member texts. + k, // The current key. + v; // The current value. // Iterate through all of the keys in the object, ignoring the proto chain. - for (k in this) { - if (this.hasOwnProperty(k)) { - v = this[k]; - switch (typeof v) { - case 'object': + for (k in this) { + if (this.hasOwnProperty(k)) { + v = this[k]; + switch (typeof v) { + case 'object': // Serialize a JavaScript object value. Ignore objects that lack the // toJSONString method. Due to a specification error in ECMAScript, // typeof null is 'object', so watch out for that case. - if (v) { - if (typeof v.toJSONString === 'function') { - a.push(k.toJSONString() + ':' + v.toJSONString()); + if (v) { + if (typeof v.toJSONString === 'function') { + a.push(k.toJSONString() + ':' + v.toJSONString()); + } + } else { + a.push(k.toJSONString() + ':null'); } - } else { - a.push(k.toJSONString() + ':null'); - } - break; + break; - case 'string': - case 'number': - case 'boolean': - a.push(k.toJSONString() + ':' + v.toJSONString()); + case 'string': + case 'number': + case 'boolean': + a.push(k.toJSONString() + ':' + v.toJSONString()); // Values without a JSON representation are ignored. + } } } - } // Join all of the member texts together and wrap them in braces. - return '{' + a.join(',') + '}'; - }; - - - (function (s) { - -// Augment String.prototype. We do this in an immediate anonymous function to -// avoid defining global variables. + return '{' + a.join(',') + '}'; + } + }); // m is a table of character substitutions. - var m = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }; - + const m = { + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '"' : '\\"', + '\\': '\\\\' + }; - s.parseJSON = function (filter) { - var j; + Object.defineProperty(String.prototype, 'parseJSON', { + enumerable: false, + value: function (filter) { + let j; function walk(k, v) { - var i; + let i; if (v && typeof v === 'object') { for (i in v) { if (v.hasOwnProperty(i)) { @@ -242,11 +248,12 @@ if (!Object.prototype.toJSONString) { j = walk('', j); } return j; - }; - - - s.toJSONString = function () { + }, + }); + Object.defineProperty(String.prototype, 'toJSONString', { + enumerable: false, + value: function () { // If the string contains no control characters, no quote characters, and no // backslash characters, then we can simply slap some quotes around it. // Otherwise we must also replace the offending characters with safe @@ -254,7 +261,7 @@ if (!Object.prototype.toJSONString) { if (/["\\\x00-\x1f]/.test(this)) { return '"' + this.replace(/([\x00-\x1f\\"])/g, function (a, b) { - var c = m[b]; + let c = m[b]; if (c) { return c; } @@ -265,6 +272,6 @@ if (!Object.prototype.toJSONString) { }) + '"'; } return '"' + this + '"'; - }; - })(String.prototype); + }, + }); } diff --git a/[web]/webmap/css.css b/[web]/webmap/css.css index bc6dfb823..9aa61dee4 100644 --- a/[web]/webmap/css.css +++ b/[web]/webmap/css.css @@ -1,207 +1,38 @@ -#topbar, #addrightstopbar, #addacltopbar { +#topbar { + background: #555; + color: #fff; + font-weight: bold; + height: 23px; + left: 0; + padding: 7px; position: absolute; - top:0px; - right:0px; - left:0px; - height:23px; - background:#555555; - color:#FFFFFF; - padding:7px; - font-weight:bold; + right: 0; + top: 0; } body { - padding: 0px; - background: #FFFFFF; - font: bold 1em "Trebuchet MS", Arial, sans-serif; } + background: #00789d; + font: bold 1em "Trebuchet MS", Arial, sans-serif; + padding: 0; +} #map { + height: 100%; width: 100%; - height: 99%; -} - -#mainarea { - position: absolute; - left: 0px; - top: 37px; - bottom: 5px; - right: 5px; } -#datasets { - position: absolute; - right: 0px; - top: 37px; - width: 20%; - bottom: 0px; - background:#555555; - overflow:auto; -} - -.acl { +#popup { + background: #555; + border: 3px solid #000; + color: #fff; padding: 5px; - padding-left: 10px; - font-weight:bold; - cursor:pointer; + position: relative; } -#acllist, #rightsarea { +#mainarea { + bottom: 0; + left: 0; position: absolute; - left:0px; + right: 5px; top: 37px; - bottom: 20px; - right: 0px; - overflow:auto; - border-top: none; -} - -#rightsarea { - overflow:hide; -} - -#rightslist , #acllistcontent{ - height: 50%; - overflow:auto; - padding-left:10px; -} - -#acllistcontent { - padding:8px; -} - -#addrightsarea, #addaclarea { - position: absolute; - left:0px; - right:0px; - height: 50%; - bottom: 0px; - overflow:hide; -} - -#addaclarea { - height:30%; -} - -.indent { - padding-left: 10px; -} - -#topbar { - position: absolute; - top:0px; - right:0px; - left:0px; - height:23px; - background:#555555; - color:#FFFFFF; - padding:7px;" -} - -#acltopbarname { - font-size: 1.2em; - font-weight: bold; - -} - -#acltopbarbackbutton { - padding-right: 10px; - float:left; -} - -.headercell_first, .headercell { - width: 50px; - font-size: 1.2em; - font-weight: bold; - vertical-align: top; - color: #888888; -} - -.headercell { - border-top: 2px solid #888888; -} - -.rightcell { - width: 33%; -} - -#rightstable { - width:100%; - font-size: 1.0em; -} - -#acltopbarsearchbox { - float: right; -} - -#addrightscontent, #addaclcontent { - position: absolute; - top: 47px; - bottom: 0px; - left:20px; - right:20px; -} - -#addrightstabs { - position: absolute; - left: 0px; - top: 0px; - width: 20%; - bottom: 0px; -} - -#addrightssettings { - position: absolute; - left: 20%; - top: 0px; - width: 80%; - bottom: 0px; - border: 3px solid #888888; - border-left: 5px solid #888888; -} - -#addrightsettingspadding { - padding:8px; -} - -.addrighttab, .addrighttab_active { - font-size: 1.2em; - font-weight: bold; - cursor:pointer; - padding: 3px; - padding-left: 8px; - background: #DDDDDD; - margin-bottom: 2px; -} - -.addrighttab_active { - background: #888888; -} - -.addrighttabpane label, #addaclcontent label { - display: block; - float: left; - width: 130px; - padding: 3px 5px; - margin: 0 0 5px 0; - text-align: left; -} - - -.formfield { - clear: both; -} - -.addrighttabpane { - position: absolute; - top: 30px; -} - -#addrightbottombar { - position: absolute; - background: #888888; - bottom: 0px; - left:0px; - right:0px; - height: 24px; - padding-top:4px; } diff --git a/[web]/webmap/geticon.htm b/[web]/webmap/geticon.htm index b6a5e5b2c..fbb0b3ab0 100644 --- a/[web]/webmap/geticon.htm +++ b/[web]/webmap/geticon.htm @@ -1,14 +1,14 @@ <* local id = form.id if id and tonumber(id) >= 1 and tonumber(id) <= 63 then - local file = fileOpen ( "icons/" .. id .. ".png" ) + local file = fileOpen("icons/" .. id .. ".png") if file then while not fileIsEOF(file) do buffer = fileRead(file, 500) httpWrite(buffer, buffer:len()) end fileClose(file) - httpSetResponseHeader ( "content-type", "image/png") + httpSetResponseHeader("content-type", "image/png") else *> Could not read file diff --git a/[web]/webmap/map.htm b/[web]/webmap/map.htm index 45399b5c6..4f864e67e 100644 --- a/[web]/webmap/map.htm +++ b/[web]/webmap/map.htm @@ -1,22 +1,31 @@ - - + + + + + + Web map - - <* = call(getResourceFromName("ajax"),"start", getResourceName(getThisResource()) ) *> - - - - + + <*= call(getResourceFromName("ajax"), "start", getResourceName(getThisResource())) *> + + + + + + + + +
Map
+
-
+
+
diff --git a/[web]/webmap/map.lua b/[web]/webmap/map.lua index 6973a6f93..1e141b8a3 100644 --- a/[web]/webmap/map.lua +++ b/[web]/webmap/map.lua @@ -1,30 +1,49 @@ -function players() - local players = getElementsByType("player") +function getAllPlayers() local tbl = {} - for k,v in ipairs(players) do - local x,y = getElementPosition(v) - local playerinfo = {name=getPlayerName(v), pos={x=x,y=y}, isdead=isPedDead(v)} - if ( isPedInVehicle(v) ) then - playerinfo.vehicle = getVehicleName(getPedOccupiedVehicle(v)) + for _, v in ipairs(getElementsByType("player")) do + local x, y, z = getElementPosition(v) + local _, _, rot = getElementRotation(v) + tbl[#tbl + 1] = { + name = getPlayerName(v), + pos = { + x = x, + y = y, + z = z, + }, + rot = rot, + isdead = isPedDead(v), + } + if (isPedInVehicle(v)) then + tbl[#tbl].vehicle = getVehicleName(getPedOccupiedVehicle(v)) end - table.insert(tbl, playerinfo) end return tbl end -function sendPlayerMessage(playername, message) - local player = getPlayerFromName(playername) - if ( player ) then - outputChatBox(" " .. message, player) - end -end - -function getAllBlips() +function getAllRadarBlips() local tbl = {} - local blips = getElementsByType("blip") - for k,v in ipairs(blips) do - local x,y = getElementPosition(v) - table.insert(tbl, {element=v, icon=getBlipIcon(v), pos={x=x,y=y}}) + for _, v in ipairs(getElementsByType("blip")) do + local x, y, z = getElementPosition(v) + tbl[#tbl + 1] = { + element = v, + icon = getBlipIcon(v), + size = getBlipSize(v), + color = { + getBlipColor(v), + }, + pos = { + x = x, + y = y, + z = z, + }, + } end return tbl end + +function sendPlayerMessage(playername, message) + local player = getPlayerFromName(playername) + if (not player) then return end + outputServerLog(" " .. message, player) + outputChatBox(" " .. message, player) +end diff --git a/[web]/webmap/meta.xml b/[web]/webmap/meta.xml index be942976e..f60731e84 100644 --- a/[web]/webmap/meta.xml +++ b/[web]/webmap/meta.xml @@ -1,14 +1,17 @@ - -