extracted urlParam jquery addon

This commit is contained in:
e7d 2017-05-14 10:51:19 +02:00
parent 76791333c7
commit d5297d4f89
3 changed files with 9 additions and 9 deletions

View File

@ -62,6 +62,7 @@
</div> </div>
<script src="https://static.e7d.io/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://static.e7d.io/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/urlParam.jquery.js"></script>
<script src="js/gamepad.js"></script> <script src="js/gamepad.js"></script>
<script src="js/app.js"></script> <script src="js/app.js"></script>
</body> </body>

View File

@ -1,12 +1,3 @@
$.urlParam = function(name) {
let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results === null) {
return null;
} else {
return decodeURIComponent(results[1]) || 0;
}
};
class Gamepad { class Gamepad {
constructor() { constructor() {
this.haveEvents = 'ongamepadconnected' in window; this.haveEvents = 'ongamepadconnected' in window;

8
js/urlParam.jquery.js Normal file
View File

@ -0,0 +1,8 @@
$.urlParam = function(name) {
let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results === null) {
return null;
} else {
return decodeURIComponent(results[1]) || 0;
}
};