mirror of
https://github.com/dmuth/diceware.git
synced 2024-11-21 08:26:29 -05:00
Added mobile detection and auto-scrolling when on mobile.
This commit is contained in:
parent
2b0e6b2c49
commit
88b36faca7
2 changed files with 24 additions and 0 deletions
|
@ -92,6 +92,8 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<a name="roll_dice_button" ></a>
|
||||
|
||||
<h2>
|
||||
Number of Dice to roll:
|
||||
</h2>
|
||||
|
|
22
main.js
22
main.js
|
@ -110,12 +110,34 @@ function display_results() {
|
|||
} // End of display_results()
|
||||
|
||||
|
||||
/**
|
||||
* Return true if we are running on a mobile screen.
|
||||
*/
|
||||
function is_mobile() {
|
||||
|
||||
if (jQuery(window).width() < 480) {
|
||||
return(true);
|
||||
}
|
||||
|
||||
return(false);
|
||||
|
||||
} // End of is_mobile()
|
||||
|
||||
|
||||
//
|
||||
// Handler when the "Roll Dice" button is clicked. It gets the
|
||||
// passphrase and updates the HTML with it.
|
||||
//
|
||||
jQuery("#roll_dice").on("click", function(e) {
|
||||
|
||||
//
|
||||
// If we're running on an iPhone or similar, scroll down so that we can
|
||||
// see the dice rolls and passphrase.
|
||||
//
|
||||
if (is_mobile()) {
|
||||
location.hash = "#roll_dice_button";
|
||||
}
|
||||
|
||||
//
|
||||
// Remove any old results
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue