Skip to content

Commit

Permalink
Firefix release
Browse files Browse the repository at this point in the history
  • Loading branch information
vthorsteinsson committed Oct 16, 2017
1 parent c152564 commit 2b54fac
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 102 deletions.
6 changes: 3 additions & 3 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# App.yaml for the Netskrafl application on Google App Engine
#
application: netskrafl
version: firebase2
version: firefix
runtime: python27
api_version: 1
threadsafe: true
Expand Down Expand Up @@ -84,14 +84,14 @@ handlers:
static_files: static/\1
upload: static/.*\.css$
mime_type: text/css
expiration: "1d 0h"
expiration: "0d 1h" # Was "1d 0h"

# Catchall for JavaScript
- url: /static/(.*\.min\.js)(\?.*)?$
static_files: static/\1
upload: static/.*\.min\.js$
mime_type: application/javascript
expiration: "1d 0h"
expiration: "0d 1h" # Was "1d 0h"

# Font files that can be cached
- url: /static/glyphicons-regular.ttf
Expand Down
8 changes: 6 additions & 2 deletions skraflgame.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# -*- coding: utf-8 -*-

""" Game and User classes for Netskrafl
""" Game and User classes for netskrafl.is
Author: Vilhjalmur Thorsteinsson, 2014
Copyright (C) 2015-2017 Miðeind ehf.
Author: Vilhjalmur Thorsteinsson
The GNU General Public License, version 3, applies to this software.
For further information, see https://github.com/vthorsteinsson/Netskrafl
This module implements the User and Game classes for the
Netskrafl application. These classes form an intermediary
Expand Down
62 changes: 37 additions & 25 deletions static/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,35 +350,47 @@ function closePromoDialog() {

var maybePreventPullToRefresh = false;
var lastTouchY = 0;
var pullToRefreshDisabled = false;

function preventPullToRefresh()
function _touchstartHandler(e) {
if (e.touches.length != 1)
return;
lastTouchY = e.touches[0].clientY;
// Pull-to-refresh will only trigger if the scroll begins when the
// document's Y offset is zero.
maybePreventPullToRefresh = (window.pageYOffset === 0);
}

function _touchmoveHandler(e) {
var touchY = e.touches[0].clientY;
var touchYDelta = touchY - lastTouchY;
/* lastTouchY = touchY; */
if (maybePreventPullToRefresh) {
// To suppress pull-to-refresh it is sufficient to preventDefault the
// first overscrolling touchmove.
maybePreventPullToRefresh = false;
if (touchYDelta > 0)
e.preventDefault();
}
}

function preventPullToRefresh(enable)
{
/* Prevent the mobile (touch) behavior where pulling/scrolling the
page down, if already at the top, causes a refresh of the web page */
var touchstartHandler = function(e) {
if (e.touches.length != 1)
return;
lastTouchY = e.touches[0].clientY;
// Pull-to-refresh will only trigger if the scroll begins when the
// document's Y offset is zero.
maybePreventPullToRefresh = (window.pageYOffset === 0);
};

var touchmoveHandler = function(e) {
var touchY = e.touches[0].clientY;
var touchYDelta = touchY - lastTouchY;
/* lastTouchY = touchY; */
if (maybePreventPullToRefresh) {
// To suppress pull-to-refresh it is sufficient to preventDefault the
// first overscrolling touchmove.
maybePreventPullToRefresh = false;
if (touchYDelta > 0) {
e.preventDefault();
return;
}
if (enable) {
if (!pullToRefreshDisabled) {
document.addEventListener('touchstart', _touchstartHandler, false);
document.addEventListener('touchmove', _touchmoveHandler, { passive: false });
pullToRefreshDisabled = true;
}
}
else {
if (pullToRefreshDisabled) {
document.removeEventListener('touchstart', _touchstartHandler, false);
document.removeEventListener('touchmove', _touchmoveHandler, { passive: false });
pullToRefreshDisabled = false;
}
};
document.addEventListener('touchstart', touchstartHandler, false);
document.addEventListener('touchmove', touchmoveHandler, { passive: false });
}
}

6 changes: 3 additions & 3 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,12 @@ function mediaMinWidth768(mql) {
if (mql.matches) {
// Take action when min-width exceeds 768
uiFullscreen = true;
preventPullToRefresh(false);
}
else {
uiFullscreen = false;
/* Prevent mobile behavior where pull down (scroll) causes a page refresh */
preventPullToRefresh(true);
}
}

Expand Down Expand Up @@ -1008,9 +1011,6 @@ function initMain() {
/* Listen to media events, such as orientation changes */
initMediaListener();

/* Prevent mobile behavior where pull down (scroll) causes a page refresh */
preventPullToRefresh();

/* Call initialization that requires variables coming from the server */
lateInit();

Expand Down
26 changes: 15 additions & 11 deletions static/js/netskrafl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ function updateButtonState() {
}
showRecall = true;
}
if (showChallengeInfo)
showScramble = false;
$("div.submitmove").toggleClass("hidden", !showMove);
$("div.submitexchange").css("display", showExchange ? "block" : "none");
$("div.submitpass").css("display", showPass ? "block" : "none");
Expand Down Expand Up @@ -1639,20 +1641,20 @@ function rescrambleRack(ev) {

function updateBag(bag) {
/* Update the bag display in the lower right corner */
$("#bag").html("");
var bagC = $(".bag-content");
bagC.html("");
var lenbag = bag.length;
var ix = 0;
// If 7 or fewer unseen tiles, the bag is empty and they're all in the opponent's
// rack; display the tiles in the opponent's color
if (lenbag <= RACK_SIZE) {
$("#bag").toggleClass("new", false);
$("#bag").toggleClass("empty", true);
}
if (lenbag <= RACK_SIZE)
bagC
.toggleClass("new", false)
.toggleClass("empty", true);
else
if (gameUsesNewBag()) {
if (gameUsesNewBag())
// Indicate visually that we're using the new bag
$("#bag").toggleClass("new", true);
}
bagC.toggleClass("new", true);
while (lenbag > 0) {
/* Rows */
var str = "<tr>";
Expand All @@ -1666,7 +1668,7 @@ function updateBag(bag) {
lenbag--;
}
str += "</tr>";
$("#bag").append(str);
bagC.append(str);
}
}

Expand Down Expand Up @@ -2503,13 +2505,17 @@ function mediaMinWidth768(mql) {
$("div.heading").off("click");
// Enable clicking on player identifier buttons
$("div.player-btn").click(lookAtPlayer);
// Remove pull-to-refresh disabling hack, if present
preventPullToRefresh(false);
}
else {
uiFullscreen = false;
// Make header a click target
$("div.heading").click(function(e) { window.location.href = "/"; });
// Disable clicking on player identifier buttons
$("div.player-btn").off("click");
// Disable pull-to-refresh on mobile
preventPullToRefresh(true);
}
}

Expand Down Expand Up @@ -2623,8 +2629,6 @@ function initSkrafl(jQuery) {

initMediaListener(); // Initiate listening to media change events

preventPullToRefresh(); // Disable mobile behavior

lateInit();

if (igt.duration > 0)
Expand Down
Loading

0 comments on commit 2b54fac

Please sign in to comment.