helpers.js 581 B

1234567891011121314151617181920
  1. var app = app || {};
  2. (function () {
  3. app.htmlUtils = {
  4. htmlEncodeText: function (value) {
  5. return $("<div/>").text(value).html();
  6. },
  7. htmlDecodeText: function (value) {
  8. return $("<div/>").html(value).text();
  9. },
  10. htmlEncodeJson: function (jsonObject) {
  11. return JSON.parse(app.htmlUtils.htmlEncodeText(JSON.stringify(jsonObject)));
  12. },
  13. htmlDecodeJson: function (jsonObject) {
  14. return JSON.parse(app.htmlUtils.htmlDecodeText(JSON.stringify(jsonObject)));
  15. }
  16. };
  17. })();