Merge pull request #3627 from Faerdan/dev

Fixed client side UI failure caused by apostrophes in text.
This commit is contained in:
Zuhayr
2013-09-01 04:50:16 -07:00
7 changed files with 65 additions and 24 deletions
+7 -2
View File
@@ -41,10 +41,15 @@ json_writer
if(!i)
break
if(targ == "\n")
txt = copytext(txt, 1, i) + "\\n" + copytext(txt, i+1)
txt = copytext(txt, 1, i) + "\\n" + copytext(txt, i+2)
start = i + 1 // 1 character added
if(targ == "'")
txt = copytext(txt, 1, i) + "`" + copytext(txt, i+1) // apostrophies fuck shit up...
start = i + 1 // 1 character added
else
txt = copytext(txt, 1, i) + "\\" + copytext(txt, i)
start = i + 2
start = i + 2 // 2 characters added
return {""[txt]""}
is_associative(list/L)
+4 -2
View File
@@ -139,11 +139,13 @@
var/template_data_json = "{}" // An empty JSON object
if (templatel_data.len > 0)
template_data_json = list2json(templatel_data)
template_data_json = list2json(templatel_data)
var/initial_data_json = "{}" // An empty JSON object
if (initial_data.len > 0)
initial_data_json = list2json(initial_data)
//user << initial_data_json
var/url_parameters_json = list2json(list("src" = "\ref[src]"))
@@ -254,7 +256,7 @@
return // Cannot update UI, no visibility
data = modify_data(data)
//user << list2json(data)
user << output(list2params(list(list2json(data))),"[window_id].browser:receiveUpdateData")
on_close_winset()
+6 -3
View File
@@ -21,11 +21,12 @@
/obj/machinery/chem_dispenser/proc/recharge()
if(stat & (BROKEN|NOPOWER)) return
var/addenergy = 2
var/addenergy = 1
var/oldenergy = energy
energy = min(energy + addenergy, max_energy)
if(energy != oldenergy)
use_power(3000) // This thing uses up alot of power (this is still low as shit for creating reagents from thin air)
use_power(1500) // This thing uses up alot of power (this is still low as shit for creating reagents from thin air)
nanomanager.update_uis(src) // update all UIs attached to src
/obj/machinery/chem_dispenser/power_change()
if(powered())
@@ -33,6 +34,7 @@
else
spawn(rand(0, 15))
stat |= NOPOWER
nanomanager.update_uis(src) // update all UIs attached to src
/obj/machinery/chem_dispenser/process()
@@ -73,6 +75,7 @@
data["amount"] = amount
data["energy"] = energy
data["maxEnergy"] = max_energy
data["isBeakerLoaded"] = beaker ? 1 : 0
@@ -103,7 +106,7 @@
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
if (!ui)
ui = new(user, src, ui_key, "chem_dispenser.tmpl", "Chem Dispenser 5000", 370, 585)
ui = new(user, src, ui_key, "chem_dispenser.tmpl", "Chem Dispenser 5000", 370, 605)
// When the UI is first opened this is the data it will use
ui.set_initial_data(data)
ui.open()
+23 -12
View File
@@ -307,17 +307,30 @@ div.notice
padding: 0;
}
.progressBar
.displayBar
{
width: 240px;
height: 14px;
position: relative;
width: 236px;
height: 16px;
border: 1px solid #666666;
float: left;
margin: 0 5px;
margin: 0 5px 0 0;
overflow: hidden;
background: #000000;
}
.progressFill
.displayBarText
{
position: absolute;
top: -2px;
left: 5px;
width: 100%;
height: 100%;
color: #ffffff;
font-weight: normal;
}
.displayBarFill
{
width: 0%;
height: 100%;
@@ -326,32 +339,30 @@ div.notice
float: left;
}
.progressFill.alignRight
.displayBarFill.alignRight
{
float: right;
}
.progressFill.good
.displayBarFill.good
{
color: #ffffff;
background: #4f7529;
}
.progressFill.average
.displayBarFill.average
{
color: #ffffff;
background: #cd6500;
}
.progressFill.bad
.displayBarFill.bad
{
color: #ffffff;
background: #ee0000;
}
.progressFill.highlight
.displayBarFill.highlight
{
color: #ffffff;
background: #8BA5C4;
+8 -3
View File
@@ -75,7 +75,7 @@ NanoBaseHelpers = function ()
return '';
},
// Display a bar. Used to show health, capacity, etc.
displayBar: function(value, rangeMin, rangeMax, styleClass) {
displayBar: function(value, rangeMin, rangeMax, styleClass, showText) {
if (rangeMin < rangeMax)
{
@@ -100,14 +100,19 @@ NanoBaseHelpers = function ()
}
}
if (typeof styleClass == 'undefined')
if (typeof styleClass == 'undefined' || !styleClass)
{
styleClass = '';
}
if (typeof showText == 'undefined' || !showText)
{
showText = '';
}
var percentage = Math.round((value - rangeMin) / (rangeMax - rangeMin) * 100);
return '<div class="progressBar"><div class="progressFill ' + styleClass + '" style="width: ' + percentage + '%;"></div></div>';
return '<div class="displayBar ' + styleClass + '"><div class="displayBarFill ' + styleClass + '" style="width: ' + percentage + '%;"></div><div class="displayBarText ' + styleClass + '">' + showText + '</div></div>';
}
});
}
+16 -1
View File
@@ -59,6 +59,11 @@ NanoUpdate = function ()
var body = $('body'); // We store data in the body tag, it's as good a place as any
_data = body.data('initialData');
if (!_data)
{
alert('Error: Initial data did not load correctly.');
}
var templateData = body.data('templateData');
@@ -118,7 +123,17 @@ NanoUpdate = function ()
// Receive update data from the server
var receiveUpdateData = function (jsonString)
{
var updateData = jQuery.parseJSON(jsonString);
var updateData;
try
{
updateData = jQuery.parseJSON(jsonString);
}
catch (error)
{
alert(error.Message);
return;
}
if (_isInitialised) // templates have been loaded and are observing the data. We need to update it recursively
{
+1 -1
View File
@@ -3,7 +3,7 @@
Energy:
</div>
<div class="itemContent">
{^{:energy}}
{^{:~displayBar(energy, 0, maxEnergy, 'good', energy + ' Units')}}
</div>
</div>