Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #54 from jeffposnick/no-more-third-party-directory
Browse files Browse the repository at this point in the history
No more third party directory
  • Loading branch information
jeffposnick committed Dec 23, 2014
2 parents c315ac6 + 19548ab commit 17008e4
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 731 deletions.
16 changes: 9 additions & 7 deletions app/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@
"tests"
],
"dependencies": {
"polymer": "Polymer/polymer#^0.5.2",
"paper-tabs": "Polymer/paper-tabs#^0.5.2",
"paper-fab": "Polymer/paper-fab#^0.5.2",
"paper-item": "Polymer/paper-item#^0.5.2",
"paper-button": "Polymer/paper-button#552f5bbc1796207ebff82171316d639c0d5b7afd",
"paper-toast": "Polymer/paper-toast#^0.5.2",
"closure-compiler": "https://dl.google.com/closure-compiler/compiler-latest.zip",
"core-a11y-keys": "Polymer/core-a11y-keys#^0.5.2",
"core-drawer-panel": "Polymer/core-drawer-panel#^0.5.2",
"core-menu": "Polymer/core-menu#^0.5.2",
"google-apis": "GoogleWebComponents/google-apis#^0.4.3",
"google-youtube": "GoogleWebComponents/google-youtube#^1.0.1",
"i18n-msg": "ebidel/i18n-msg#^0.0.1",
"closure-compiler": "https://dl.google.com/closure-compiler/compiler-latest.zip"
"js-signals": "millermedeiros/js-signals#^1.0.0",
"paper-button": "Polymer/paper-button#552f5bbc1796207ebff82171316d639c0d5b7afd",
"paper-fab": "Polymer/paper-fab#^0.5.2",
"paper-item": "Polymer/paper-item#^0.5.2",
"paper-tabs": "Polymer/paper-tabs#^0.5.2",
"paper-toast": "Polymer/paper-toast#^0.5.2",
"polymer": "Polymer/polymer#^0.5.2",
"shed": "wibblymat/shed"
},
"resolutions": {
"polymer": "^0.5.2",
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/components/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ CDS.Button = (function() {
ripple.style.opacity = '0.4';
ripple.classList.remove('button__ripple--animate');

requestAnimFrame(reset);
window.requestAnimationFrame(reset);

}

function reset() {

if (frameCount-- > 0) {
requestAnimFrame(reset);
window.requestAnimationFrame(reset);
} else {

transformString = 'translate(-50%, -50%) ' +
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CDS.Toast = function(message) {
this.element_.appendChild(this.elementInner_);
document.body.appendChild(this.element_);

requestAnimFrame(this.hide);
window.requestAnimationFrame(this.hide);

return this;
};
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/helper/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ CDS.History = (function() {

function onPopState(evt) {
evt.preventDefault();
requestAnimFrame(manageCards);
window.requestAnimationFrame(manageCards);
}

function onTransitionEnd() {
transitioningCard = null;
requestAnimFrame(manageCards);
window.requestAnimationFrame(manageCards);
}

function forth(path) {
window.history.pushState(null, "", path);
requestAnimFrame(manageCards);
window.requestAnimationFrame(manageCards);
}

function back() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@
var tx = that._db.transaction(STORE, 'readwrite');
var store = tx.objectStore(STORE);
var results = [];
for (var key of keys) {
keys.forEach(function(key) {
store.get(key).onsuccess(function(result) {
results.push(result);
});
}
});
tx.oncomplete = function() { resolve(results); };
tx.onabort = function() { reject(tx.error); };
});
Expand All @@ -132,9 +132,9 @@
return new Promise(function(resolve, reject) {
var tx = that._db.transaction(STORE, 'readwrite');
var store = tx.objectStore(STORE);
for (var entry of entries) {
entries.forEach(function(entry) {
store.put(entry.value, entry.key);
}
});
tx.oncomplete = function() { resolve(undefined); };
tx.onabort = function() { reject(tx.error); };
});
Expand All @@ -144,8 +144,9 @@
return new Promise(function(resolve, reject) {
var tx = that._db.transaction(STORE, 'readwrite');
var store = tx.objectStore(STORE);
for (var key of keys)
store.delete(key);
keys.forEach(function(key) {
store.delete(key);
});
tx.oncomplete = function() { resolve(undefined); };
tx.onabort = function() { reject(tx.error); };
});
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

'use strict';

// @codekit-prepend 'third_party/signals.min.js'
// @codekit-prepend 'third_party/requestAnimationFrame.js'
// @codekit-prepend '../bower_components/js-signals/dist/signals.min.js'

exports.IOWA = {};

Expand Down
48 changes: 22 additions & 26 deletions app/scripts/shed-offline-analytics.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
// TODO (jeffposnick): Reach out to inexorabletash (Joshua Bell) about making this into a package
// that we can install in a standard location and add to the dependencies.
importScripts('scripts/third_party/simpledb_polyfill.js');
importScripts('scripts/helper/simpledb.js');

var DB_NAME = 'shed-offline-analytics';
var EXPIRATION_TIME_DELTA = 86400000; // One day, in milliseconds.

function replayQueuedRequests() {
simpleDB.open(DB_NAME).then(function(db) {
db.forEach(function(url) {
db.get(url).then(function(originalTimestamp) {
var timeDelta = Date.now() - originalTimestamp;
// See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt
var replayUrl = url + '&qt=' + timeDelta;
db.forEach(function(url, originalTimestamp) {
var timeDelta = Date.now() - originalTimestamp;
// See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#qt
var replayUrl = url + '&qt=' + timeDelta;

console.log('About to replay:', replayUrl);
fetch(replayUrl).then(function(response) {
if (response.status >= 500) {
// This will cause the promise to reject, triggering the .catch() function.
return Response.error();
}
console.log('About to replay:', replayUrl);
fetch(replayUrl).then(function(response) {
if (response.status >= 500) {
// This will cause the promise to reject, triggering the .catch() function.
return Response.error();
}

console.log('Replay succeeded:', replayUrl);
console.log('Replay succeeded:', replayUrl);
db.delete(url);
}).catch(function(error) {
if (timeDelta > EXPIRATION_TIME_DELTA) {
// After a while, Google Analytics will no longer accept an old ping with a qt=
// parameter. The advertised time is ~4 hours, but we'll attempt to resend up to 24
// hours. This logic also prevents the requests from being queued indefinitely.
console.error('Replay failed, but the original request is too old to retry any further. Error:', error);
db.delete(url);
}).catch(function(error) {
if (timeDelta > EXPIRATION_TIME_DELTA) {
// After a while, Google Analytics will no longer accept an old ping with a qt=
// parameter. The advertised time is ~4 hours, but we'll attempt to resend up to 24
// hours. This logic also prevents the requests from being queued indefinitely.
console.error('Replay failed, but the original request is too old to retry any further. Error:', error);
db.delete(url);
} else {
console.error('Replay failed, and will be retried the next time the service worker starts. Error:', error);
}
});
} else {
console.error('Replay failed, and will be retried the next time the service worker starts. Error:', error);
}
});
});
});
Expand Down
8 changes: 0 additions & 8 deletions app/scripts/third_party/requestAnimationFrame.js

This file was deleted.

83 changes: 0 additions & 83 deletions app/scripts/third_party/serviceworker-cache-polyfill.js

This file was deleted.

Loading

0 comments on commit 17008e4

Please sign in to comment.