Page 1 of 1

notification.js

Posted: Sat Jan 07, 2017 11:57 pm
by falsam
■ Author
http://adodson.com/notification.js/#notificationjs

■ Demo
http://falsam.com/sbtest/notification.html

■ Code

Code: Select all

;See : http://adodson.com/notification.js/#notificationjs

Procedure.i HeaderInclude(filename.s)
  Protected filetype.s = GetExtensionPart(filename) 
  
  Select LCase(filetype)
    Case "less"     
      !$('<link rel="stylesheet/less" type="text/css">').attr('href',v_filename).appendTo('head');
    Case "css"     
      !$('<link rel="stylesheet" type="text/css">').attr('href',v_filename).appendTo('head');
    Case "js"     
      !$('<script type="text/javascript"></script>').attr('src',v_filename).appendTo('head');      
  EndSelect   
EndProcedure

CompilerIf #PB_Compiler_IsMainFile  
  HeaderInclude("assets/js/notification.js")
CompilerEndIf

Procedure InitNotification()
  !if(Notification.permission !== 'granted'){
  !	Notification.requestPermission();
  !}
EndProcedure

Procedure SendNotification()
  Protected title.s = "Hello"
  Protected message.s = "This is your first notification"
  Protected icon.s = "assets/images/star.ico"
  
  !n = new Notification( v_title, {
  !	body: v_message, 
  !	icon : v_icon
  !});  
EndProcedure

Procedure Start()
  InitNotification()
    
  OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_Background) 
  ButtonGadget(0, 10, 20, 110, 24, "Test notification")
  
  BindGadgetEvent(0, @SendNotification())
EndProcedure

start()
■ Download Source
http://falsam.com/sbtest/data/notification.zip

Re: notification.js

Posted: Wed Jan 11, 2017 1:02 am
by poshu
Nice one, thanks!

Re: notification.js

Posted: Wed Jan 11, 2017 9:40 am
by kwandjeen
Nice Falsam :)