From c270a09bffd0ca1af857eacfb67bb1f9083f9a46 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 19 Mar 2015 20:58:18 +0100 Subject: [PATCH] Fixed a shrimp-sandwich issue with encoding --- .../Json-FinancialAccountsTree.aspx.cs | 2 +- Site5/Controls/v5/Base/ComboGeographies.ascx | 60 ---------------- Site5/Controls/v5/Financial/ComboBudgets.ascx | 71 +++---------------- .../v5/Ledgers/Json-AccountPlanData.aspx.cs | 2 +- Site5/Swarmops-v5.js | 70 +++++++++++++++++- 5 files changed, 79 insertions(+), 126 deletions(-) diff --git a/Site5/Automation/Json-FinancialAccountsTree.aspx.cs b/Site5/Automation/Json-FinancialAccountsTree.aspx.cs index 1d75de38..952031f5 100644 --- a/Site5/Automation/Json-FinancialAccountsTree.aspx.cs +++ b/Site5/Automation/Json-FinancialAccountsTree.aspx.cs @@ -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 + '}'); } diff --git a/Site5/Controls/v5/Base/ComboGeographies.ascx b/Site5/Controls/v5/Base/ComboGeographies.ascx index a8f6fcf4..06158ad6 100644 --- a/Site5/Controls/v5/Base/ComboGeographies.ascx +++ b/Site5/Controls/v5/Base/ComboGeographies.ascx @@ -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); - \ No newline at end of file diff --git a/Site5/Controls/v5/Financial/ComboBudgets.ascx b/Site5/Controls/v5/Financial/ComboBudgets.ascx index c8d3b77b..0f7de2bf 100644 --- a/Site5/Controls/v5/Financial/ComboBudgets.ascx +++ b/Site5/Controls/v5/Financial/ComboBudgets.ascx @@ -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); - \ No newline at end of file diff --git a/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs b/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs index 8e655624..64663e68 100644 --- a/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs +++ b/Site5/Pages/v5/Ledgers/Json-AccountPlanData.aspx.cs @@ -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], diff --git a/Site5/Swarmops-v5.js b/Site5/Swarmops-v5.js index 23d1116a..79a77c3d 100644 --- a/Site5/Swarmops-v5.js +++ b/Site5/Swarmops-v5.js @@ -64,4 +64,72 @@ } return publicSymbols; -})(); \ No newline at end of file +})(); + + + +/* 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); + +