Loading src/windows/LocalNotificationUtil.js +46 −28 Changes for src/windows/LocalNotificationUtil.js: 46 added lines, 28 removed lines. Original line number Diff line number Diff line Loading @@ -93,38 +93,14 @@ exports.parseSound = function (path) { * @param {Object} options * Local notification properties * * @return {String} * Windows.Data.Xml.Dom.XmlDocument * @return Windows.Data.Xml.Dom.XmlDocument */ exports.build = function (options) { var title = options.title, message = options.text || '', sound = ''; if (!title || title === '') { title = 'Notification'; } if (options.sound) { sound = this.parseSound(options.sound); } var payload = "<toast> " + "<visual version='2'>" + "<binding template='ToastText02'>" + "<text id='2'>" + message + "</text>" + "<text id='1'>" + title + "</text>" + "</binding>" + "</visual>" + sound + "<json>" + JSON.stringify(options) + "</json>" + "</toast>"; var notification = new Windows.Data.Xml.Dom.XmlDocument(); var template = this.buildToastTemplate(options), notification = new Windows.Data.Xml.Dom.XmlDocument(); try { notification.loadXml(payload); notification.loadXml(template); } catch (e) { console.error( 'LocalNotification#schedule', Loading @@ -141,6 +117,48 @@ exports.build = function (options) { return notification; }; /** * Builds the toast template with the right style depend on the options. * * @param {Object} options * Local notification properties * * @return String */ exports.buildToastTemplate = function (options) { var title = options.title, message = options.text || '', json = JSON.stringify(options), sound = ''; if (options.sound && options.sound !== '') { sound = this.parseSound(options.sound); } if (title && title !== '') { return "<toast>" + "<visual>" + "<binding template='ToastText02'>" + "<text id='1'>" + title + "</text>" + "<text id='2'>" + message + "</text>" + "</binding>" + "</visual>" + sound + "<json>" + json + "</json>" + "</toast>"; } else { return "<toast>" + "<visual>" + "<binding template='ToastText01'>" + "<text id='1'>" + message + "</text>" + "</binding>" + "</visual>" + sound + "<json>" + json + "</json>" + "</toast>"; } }; /** * Short-hand method for the toast notification history. */ Loading Loading
src/windows/LocalNotificationUtil.js +46 −28 Changes for src/windows/LocalNotificationUtil.js: 46 added lines, 28 removed lines. Original line number Diff line number Diff line Loading @@ -93,38 +93,14 @@ exports.parseSound = function (path) { * @param {Object} options * Local notification properties * * @return {String} * Windows.Data.Xml.Dom.XmlDocument * @return Windows.Data.Xml.Dom.XmlDocument */ exports.build = function (options) { var title = options.title, message = options.text || '', sound = ''; if (!title || title === '') { title = 'Notification'; } if (options.sound) { sound = this.parseSound(options.sound); } var payload = "<toast> " + "<visual version='2'>" + "<binding template='ToastText02'>" + "<text id='2'>" + message + "</text>" + "<text id='1'>" + title + "</text>" + "</binding>" + "</visual>" + sound + "<json>" + JSON.stringify(options) + "</json>" + "</toast>"; var notification = new Windows.Data.Xml.Dom.XmlDocument(); var template = this.buildToastTemplate(options), notification = new Windows.Data.Xml.Dom.XmlDocument(); try { notification.loadXml(payload); notification.loadXml(template); } catch (e) { console.error( 'LocalNotification#schedule', Loading @@ -141,6 +117,48 @@ exports.build = function (options) { return notification; }; /** * Builds the toast template with the right style depend on the options. * * @param {Object} options * Local notification properties * * @return String */ exports.buildToastTemplate = function (options) { var title = options.title, message = options.text || '', json = JSON.stringify(options), sound = ''; if (options.sound && options.sound !== '') { sound = this.parseSound(options.sound); } if (title && title !== '') { return "<toast>" + "<visual>" + "<binding template='ToastText02'>" + "<text id='1'>" + title + "</text>" + "<text id='2'>" + message + "</text>" + "</binding>" + "</visual>" + sound + "<json>" + json + "</json>" + "</toast>"; } else { return "<toast>" + "<visual>" + "<binding template='ToastText01'>" + "<text id='1'>" + message + "</text>" + "</binding>" + "</visual>" + sound + "<json>" + json + "</json>" + "</toast>"; } }; /** * Short-hand method for the toast notification history. */ Loading