diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d27fd8f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2016 Mahdi Al-Farra. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 1dbe3cf..8781af5 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,41 @@ # Loud Links The library creates HTML5 audio element and uses it to play mp3/ogg audio files which is currently [supported](http://caniuse.com/#feat=audio) in all browsers. -# [Demo](http://loudlinks.rocks) -# [Download](https://loudlinks.rocks/js/loudlinks-1.0.min.js) +## [Demo](http://loudlinks.rocks) +## [Download](https://loudlinks.rocks/js/loudlinks-1.0.min.js) +------------------------ ## Usage -It’s super simple, attach the library to your project and follow these 3 steps: - ### Step 1 -At the root of your website directory create a folder named **“sounds”** with 2 more folders inside it with the names **“mp3”** & **“ogg”**. - -![sound folders](http://loudlinks.rocks/images/sound-folders.png) - ------------------------- - -### Step 2 - -Add the class **“loud-link-hover”** to any link/element that you want to give a sound on hover. +Include the minified Javascript right before the `` tag of your page. ```html - +... + + + ``` -Or add the class **“loud-link-click”** to any link/element that you want to give a sound on click. +### Step 2 + +Add the class **“loud-link-hover”** to any link/element that you want to give a sound on hover, or add the class **“loud-link-click”** to any link/element that you want to give a sound on click. ```html - + + ``` -* * * ### Step 3 -Add the attribute **data-src”** to the element & write in it the name of your sound without the extension. +Add the attribute **data-sound”** to the element with absolute URL of your sound file, substituting `{{type}}` for where `mp3` or `ogg` would be (e.g. `http://example.com/audio/noise.{{type}}` ), or just the name of your sound file without the extension if your files are located at the root of your website under `sounds/` folder with `mp3/` and `ogg/` subdirectories. ```html - + + ``` ------------------------- - - -## Done & Done -# [Demo](http://loudlinks.rocks) -# [Download](https://loudlinks.rocks/js/loudlinks-1.0.min.js) +## License +See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT). diff --git a/loudlinks-1.0.js b/loudlinks-1.0.js deleted file mode 100644 index 55c5e79..0000000 --- a/loudlinks-1.0.js +++ /dev/null @@ -1,125 +0,0 @@ -var loudlinks = (function(){ - - // Create audio element and make it awesome - var generateAudioElement = (function() { - var audioPlayer = document.createElement('audio'); // create the audio element - audioPlayer.id = 'loudLinksAudioPlayer'; // give the audio element the proper id - audioPlayer.preload = true; // audio element preload attribute - - var source1 = document.createElement('source'); // creating a source element - var source2 = document.createElement('source'); - source1.id = 'mp3Source'; - source2.id = 'oggSource'; - - audioPlayer.appendChild(source1); // appending the sources to the player element - audioPlayer.appendChild(source2); - - document.body.appendChild(audioPlayer); // appending the player to the body - })(); - - // declaring stuff --------------------------------------------- - var audioSrc; - var soundMp3Link; - var soundOggLink; - var element; - - var LoudLinksHover = document.getElementsByClassName('loud-link-hover'); - var LoudLinksClick = document.getElementsByClassName('loud-link-click'); - var audioPlayer = document.getElementById('loudLinksAudioPlayer'); - var mp3Location = 'sounds/mp3/'; // mp3 sounds location - var oggLocation = 'sounds/ogg/'; // ogg sounds location - var mp3Source = document.getElementById('mp3Source'); - var oggSource = document.getElementById('oggSource'); - // ------------------------------------------------------------ - - // check if the browser supports Audio ¯\_(ツ)_/¯ - checkAudioSupport = function() { - return !!document.createElement('audio').canPlayType; - } - - // get the audio source and appending it to