Browse Source

Added html2text convert for desktop notifications.

Martin Edenhofer 9 years ago
parent
commit
84894944a7

+ 1 - 1
app/assets/javascripts/app/controllers/widget/online_notification.coffee

@@ -154,7 +154,7 @@ class App.OnlineNotificationWidget extends App.Controller
             title = item.objectNative.activityMessage(item)
           else
             title = "Need objectNative in item #{item.object}.find(#{item.o_id})"
-          title = title.replace(/<.+?>/g, '"')
+          title = App.Utils.html2text(title.replace(/<.+?>/g, '"'))
           @notifyDesktop(
             url: item.link
             title: title

+ 5 - 0
public/assets/tests/html_utils.js

@@ -84,6 +84,11 @@ test("html2text", function() {
   result = App.Utils.html2text(source)
   equal(result, should, source)
 
+  source = "<div>Some &amp; &lt;Value&gt;</div>"
+  should = "Some & <Value>"
+  result = App.Utils.html2text(source)
+  equal(result, should, source)
+
   source = "<div>Some</div><div>&lt;b&gt;Value&lt;/b&gt;</div>"
   should = "Some\n<b>Value</b>"
   result = App.Utils.html2text(source)