Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ MENU MOVE ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
  2. function op(obj) {
  3.   x=document.getElementById(obj);
  4.   if(x.style.display == "none"){
  5.     x.setAttribute("style", "display:flex; align-items:center; justify-content:center");
  6.  } else {
  7.   x.setAttribute("style", "display:none");
  8.  }
  9. }  
  10.  
  11. // ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ CLICK SOUND ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
  12. var html5_audiotypes={
  13.     "mp3": "audio/mpeg",
  14.     "mp4": "audio/mp4",
  15.     "ogg": "audio/ogg",
  16.     "wav": "audio/wav"
  17. }
  18.  
  19. function createsoundbite(sound){
  20.     var html5audio=document.createElement('audio')
  21.     if (html5audio.canPlayType){
  22.         for (var i=0; i<arguments.length; i++){
  23.             var sourceel=document.createElement('source')
  24.             sourceel.setAttribute('src', arguments[i])
  25.             if (arguments[i].match(/\.(\w+)$/i))
  26.                 sourceel.setAttribute('type', html5_audiotypes[RegExp.$1])
  27.             html5audio.appendChild(sourceel)
  28.         }
  29.         html5audio.load()
  30.         html5audio.playclip=function(){
  31.             html5audio.pause()
  32.             html5audio.currentTime=0
  33.             html5audio.play()
  34.         }
  35.         return html5audio
  36.     }
  37.     else{
  38.         return {playclip:function(){throw new Error("Your browser doesn't support HTML5 audio unfortunately")}}
  39.     }
  40. }
  41.  
  42. var clicksound=createsoundbite("mp3/click.ogg", "mp3/click.mp3")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement