Fixed a shrimp-sandwich issue with encoding

This commit is contained in:
Rick Falkvinge
2015-03-19 20:58:18 +01:00
parent 6f275f5de6
commit c270a09bff
5 changed files with 79 additions and 126 deletions
@@ -129,7 +129,7 @@ namespace Swarmops.Frontend.Automation
childStrings.Add ('{' + String.Format (
"\"id\":\"{0}\",\"text\":\"{1}\"",
account.Identity,
Server.HtmlEncode (JsonSanitize (account.Name))
JsonSanitize (account.Name)
) + grandChildren + '}');
}
@@ -58,66 +58,6 @@
});
});
// below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain: enables keyboard navigation
(function () {
$.extend($.fn.combotree.methods, {
nav: function (jq, dir) {
return jq.each(function () {
var opts = $(this).combotree('options');
var t = $(this).combotree('tree');
var nodes = t.tree('getChildren');
if (!nodes.length) { return }
var node = t.tree('getSelected');
if (!node) {
t.tree('select', dir > 0 ? nodes[0].target : nodes[nodes.length - 1].target);
} else {
var index = 0;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].target == node.target) {
index = i;
break;
}
}
if (dir > 0) {
while (index < nodes.length - 1) {
index++;
if ($(nodes[index].target).is(':visible')) { break }
}
} else {
while (index > 0) {
index--;
if ($(nodes[index].target).is(':visible')) { break }
}
}
t.tree('select', nodes[index].target);
}
if (opts.selectOnNavigation) {
var node = t.tree('getSelected');
$(node.target).trigger('click');
$(this).combotree('showPanel');
}
});
}
});
$.extend($.fn.combotree.defaults.keyHandler, {
up: function () {
$(this).combotree('nav', -1);
},
down: function () {
$(this).combotree('nav', 1);
},
enter: function () {
var t = $(this).combotree('tree');
var node = t.tree('getSelected');
if (node) {
$(node.target).trigger('click');
}
$(this).combotree('hidePanel');
}
});
})(jQuery);
</script>
<span id="<%=this.ClientID %>_SpanGeographies"><select class="easyui-combotree" name="DropGeographies" id="<%=this.ClientID %>_DropGeographies" animate="true" style="width:324px"></select></span>
+8 -63
View File
@@ -19,15 +19,20 @@
{
Response.Write(this.OnClientLoaded + "();");
}%>
}
},
onSelect: function(account) {
console.log(account);
<%
if (!String.IsNullOrEmpty(this.OnClientSelect))
{
Response.Write(", onSelect: function(account) { " + this.OnClientSelect + "(account.id); }");
Response.Write(this.OnClientSelect + "(account.id);");
}
%>
});
}
});
$('#<%=this.ClientID %>_SpanBudgets span.combo input.textbox-text').click(function () {
$('#<%=this.ClientID %>_SpanBudgets span.combo span span.combo-arrow').click();
@@ -49,66 +54,6 @@
});
});
// below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain: enables keyboard navigation
(function () {
$.extend($.fn.combotree.methods, {
nav: function (jq, dir) {
return jq.each(function () {
var opts = $(this).combotree('options');
var t = $(this).combotree('tree');
var nodes = t.tree('getChildren');
if (!nodes.length) { return }
var node = t.tree('getSelected');
if (!node) {
t.tree('select', dir > 0 ? nodes[0].target : nodes[nodes.length - 1].target);
} else {
var index = 0;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].target == node.target) {
index = i;
break;
}
}
if (dir > 0) {
while (index < nodes.length - 1) {
index++;
if ($(nodes[index].target).is(':visible')) { break }
}
} else {
while (index > 0) {
index--;
if ($(nodes[index].target).is(':visible')) { break }
}
}
t.tree('select', nodes[index].target);
}
if (opts.selectOnNavigation) {
var node = t.tree('getSelected');
$(node.target).trigger('click');
$(this).combotree('showPanel');
}
});
}
});
$.extend($.fn.combotree.defaults.keyHandler, {
up: function () {
$(this).combotree('nav', -1);
},
down: function () {
$(this).combotree('nav', 1);
},
enter: function () {
var t = $(this).combotree('tree');
var node = t.tree('getSelected');
if (node) {
$(node.target).trigger('click');
}
$(this).combotree('hidePanel');
}
});
})(jQuery);
</script>
<span id="<%=this.ClientID %>_SpanBudgets"><select class="easyui-combotree" url="<%=this.DataUrl %>" name="DropBudgets" id="<%=this.ClientID %>_DropBudgets" animate="true" style="width:324px"></select></span>
@@ -160,7 +160,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
String.Format (
"\"id\":\"{0}\",\"accountName\":\"{1}\",\"owner\":\"{2}\",\"balance\":\"{3}\",\"budget\":\"{4}\",\"action\":\"{5}\",\"inactive\":\"{6}\"",
account.Identity,
Server.HtmlEncode (JsonSanitize (account.Name)),
JsonSanitize (account.Name),
ownerString,
this._hashedAccounts[account.Identity].Count > 1
? JsonDualString (account.Identity, this._treeBalanceLookup[account.Identity],
+69 -1
View File
@@ -64,4 +64,72 @@
}
return publicSymbols;
})();
})();
/* Overrides for EasyUI */
/* Nav in ComboTree */
// below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain: enables keyboard navigation
(function () {
$.extend($.fn.combotree.methods, {
nav: function (jq, dir) {
return jq.each(function () {
var opts = $(this).combotree('options');
var t = $(this).combotree('tree');
var nodes = t.tree('getChildren');
if (!nodes.length) { return }
var node = t.tree('getSelected');
if (!node) {
t.tree('select', dir > 0 ? nodes[0].target : nodes[nodes.length - 1].target);
} else {
var index = 0;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].target == node.target) {
index = i;
break;
}
}
if (dir > 0) {
while (index < nodes.length - 1) {
index++;
if ($(nodes[index].target).is(':visible')) { break }
}
} else {
while (index > 0) {
index--;
if ($(nodes[index].target).is(':visible')) { break }
}
}
t.tree('select', nodes[index].target);
}
if (opts.selectOnNavigation) {
var node = t.tree('getSelected');
$(node.target).trigger('click');
$(this).combotree('showPanel');
}
});
}
});
$.extend($.fn.combotree.defaults.keyHandler, {
up: function () {
$(this).combotree('nav', -1);
},
down: function () {
$(this).combotree('nav', 1);
},
enter: function () {
var t = $(this).combotree('tree');
var node = t.tree('getSelected');
if (node) {
$(node.target).trigger('click');
}
$(this).combotree('hidePanel');
}
});
})(jQuery);