Using Javascript from SpiderBasic
falsam
 
Posts: 269
Joined: Mon May 05, 2014 9:49 pm
Location: France

notification.js

by falsam Sat Jan 07, 2017 11:57 pm

■ 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

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
poshu
 
Posts: 73
Joined: Mon Feb 24, 2014 11:46 pm

Re: notification.js

by poshu Wed Jan 11, 2017 1:02 am

Nice one, thanks!
kwandjeen
 
Posts: 6
Joined: Thu Oct 27, 2016 8:02 pm

Re: notification.js

by kwandjeen Wed Jan 11, 2017 9:40 am

Nice Falsam :)
Return to Javascript

Who is online

Users browsing this forum: No registered users and 1 guest