@@ -30,9 +30,7 @@ function showNotification(serviceId) {
3030 setTitle ( 'Notification Profile(Notify)' ) ;
3131
3232 let str = '' ;
33- str += '<form action="' + uri + '" method="POST" id="notificationForm"' +
34- ' name="notificationForm" enctype="multipart/form-data"' +
35- ' onsubmit="return false;">' ;
33+ str += '<form id="notificationForm" name="notificationForm">' ;
3634
3735 if ( myDeviceName . indexOf ( 'Pebble' ) == - 1 &&
3836 myDeviceName . indexOf ( 'SmartWatch' ) == - 1 &&
@@ -254,39 +252,32 @@ function doUnregisterNotificationError(serviceId) {
254252 */
255253function doNotificationNotify ( serviceId ) {
256254 let myForm = document . getElementById ( 'notificationForm' ) ;
257- let myFormData = new FormData ( myForm ) ;
258- let myXhr = new XMLHttpRequest ( ) ;
259- myXhr . open ( myForm . method , myForm . action , true ) ;
260- myXhr . onreadystatechange = function ( ) {
261- if ( myXhr . readyState === 4 ) {
262- if ( myXhr . status === 200 || myXhr . status == 0 ) {
263- if ( DEBUG ) {
264- console . log ( 'Response:' + myXhr . responseText )
265- }
266- let obj = JSON . parse ( myXhr . responseText ) ;
267- if ( obj . result == 0 ) {
268- let str = '' ;
269- if ( myDeviceName . indexOf ( 'Pebble' ) != - 1 ) {
270- } else if ( myDeviceName . indexOf ( 'SmartWatch' ) != - 1 ) {
271- } else {
272- str += '<center>' ;
273- str += '<input type="button" onclick="notificationDel(\'' +
274- serviceId + '\',\'' + obj . notificationId +
275- '\');" value="Delete" type="button" >' ;
276- str += '</center>' ;
277- reloadMenu ( str )
278- }
279- } else {
280- showError ( 'POST notification/notify' ,
281- obj . errorCode , obj . errorMessage ) ;
282- }
283- } else {
284- alert ( 'error:' + myXhr . status ) ;
285- }
286- closeLoading ( ) ;
255+ let inputs = myForm . elements ;
256+ let params = { serviceId } ;
257+ parseInputElements ( inputs , params ) ;
258+
259+ sdk . post ( {
260+ profile : 'notification' ,
261+ attribute : 'notify' ,
262+ params
263+ } ) . then ( json => {
264+ closeLoading ( ) ;
265+
266+ let str = '' ;
267+ if ( myDeviceName . indexOf ( 'Pebble' ) != - 1 ) {
268+ } else if ( myDeviceName . indexOf ( 'SmartWatch' ) != - 1 ) {
269+ } else {
270+ str += '<center>' ;
271+ str += '<input type="button" onclick="notificationDel(\'' +
272+ serviceId + '\',\'' + json . notificationId +
273+ '\');" value="Delete" type="button" >' ;
274+ str += '</center>' ;
275+ reloadMenu ( str )
287276 }
288- } ;
289- myXhr . send ( myFormData ) ;
277+ } ) . catch ( e => {
278+ closeLoading ( ) ;
279+ showError ( 'POST notification/notify' , e . errorCode , e . errorMessage ) ;
280+ } ) ;
290281}
291282
292283/**
0 commit comments