diff options
author | mattab <matthieu.aubry@gmail.com> | 2016-10-04 00:57:00 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2016-10-04 00:57:00 +0300 |
commit | c8ec06e1989da61090af348ae33d12f7e290610e (patch) | |
tree | cb8b528f0f30e9ee550b9c463226dcf669c5d794 /plugins/SegmentEditor/javascripts | |
parent | 609457da84a3a0301159952d1e36a8865934ef34 (diff) |
Fix the JS error without breaking existing logic
Diffstat (limited to 'plugins/SegmentEditor/javascripts')
-rw-r--r-- | plugins/SegmentEditor/javascripts/Segmentation.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/plugins/SegmentEditor/javascripts/Segmentation.js b/plugins/SegmentEditor/javascripts/Segmentation.js index 12470675be..28280a1a5d 100644 --- a/plugins/SegmentEditor/javascripts/Segmentation.js +++ b/plugins/SegmentEditor/javascripts/Segmentation.js @@ -86,14 +86,24 @@ Segmentation = (function($) { var title; if( current != "") { - var currentDecoded = piwikHelper.htmlDecode(current); - var selector = 'div.segmentList ul li[data-definition="'+currentDecoded+'"]'; + // this code is mad, and may drive you mad. + // the whole segmentation editor needs to be rewritten in AngularJS with clean code + var selector = 'div.segmentList ul li[data-definition="'+current+'"]'; var foundItems = $(selector, this.target); if (foundItems.length === 0) { - currentDecoded = piwikHelper.htmlDecode(decodeURIComponent(current)); - selector = 'div.segmentList ul li[data-definition="'+currentDecoded+'"]'; - foundItems = $(selector, this.target); + try { + currentDecoded = piwikHelper.htmlDecode(current); + selector = 'div.segmentList ul li[data-definition="'+currentDecoded+'"]'; + foundItems = $(selector, this.target); + } catch(e) {} + } + if (foundItems.length === 0) { + try { + currentDecoded = piwikHelper.htmlDecode(decodeURIComponent(current)); + selector = 'div.segmentList ul li[data-definition="'+currentDecoded+'"]'; + foundItems = $(selector, this.target); + } catch(e) {} } if (foundItems.length > 0) { |