Geolocation API


More information

Latitude:
Longitude:
Accuracy: m

Code for this:

            function success(position) {
                $("#lat").append(position.coords.latitude);
                $("#lon").append(position.coords.longitude);
                $("#acc").append(position.coords.accuracy);
            };

            function error(error) {
                alert("Sorry, there is an error :-/");
            };

            navigator.geolocation.getCurrentPosition(success, error);
          
          

getUserMedia API

Supported only from mobile - non standard API

More information


Code for this:

            if (navigator.getUserMedia) {
               navigator.getUserMedia({ audio: true, video: { width: 1280, height: 720 } },
                  function(stream) {
                     var video = document.querySelector('video');
                     video.src = window.URL.createObjectURL(stream);
                     video.onloadedmetadata = function(e) {
                       video.play();
                     };
                  },
                  function(err) {
                     alert("The following error occurred: " + err.name);
                  }
               );
            } else {
               alert("getUserMedia not supported");
            }
          
          

Fullscreen API


More information



Code for this:

            var pikachu = document.querySelector("#pikachu");
            
            if (pikachu.requestFullscreen) {
              pikachu.requestFullscreen();
            }

            
            

Notification API


Code for this:

              if (!("Notification" in window)) {
                alert("This browser does not support desktop notification");
              }

              else if (Notification.permission === "granted") {
                var notification = new Notification("Hi people!");
              }

              else if (Notification.permission !== 'denied') {
                Notification.requestPermission(function (permission) {
                  if (permission === "granted") {
                    var notification = new Notification("Hi people!");
                  }
                });
              }
          
          

Web Speech API

Text-to-speech

More information




Code for this:
              
                  var phrase = document.getElementById("phrase").value;
                  var speech = new SpeechSynthesisUtterance(phrase);
                  window.speechSynthesis.speak(speech);
              
            

Web Speech API

Speech-to-text

More information




Code for this:
              
                  var recognition = new SpeechRecognition();
                  recognition.lang = 'en-US';
                  recognition.interimResults = false;

                  recognition.start();
                  console.log('Ready to receive a color command.');

                  recognition.onresult = function (event) {
                      var text = event.results[0][0].transcript;
                      $("#speeched").append(text);
                  }
              
            

Workers

More information





Code for this:
              

                //main script
                    var myWorker = new Worker("worker.js");
                      console.log($("#dataForWorker").val());
                      myWorker.postMessage([$("#dataForWorker").val()]);
                      console.log('Message posted to worker');

                      myWorker.onmessage = function(result){
                          console.log(result);
                          $("#result").append(result.data)
                      };

                //worker.js
                  onmessage = function(e) {
                      console.log('Message received from main script');
                      var workerResult = "Hi, i am the worker, you have just sent me this data: "+e.data[0];
                      console.log('Posting message back to main script');
                      postMessage(workerResult);

                  };