Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"env": {
"browser": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"curly": [
"error",
"all"
],
"consistent-this": [
"error",
"that"
],
"no-console": 0,
"no-unused-vars": 0
},
"globals": {
"Navigo": true,
"mdc": true,
"importScripts": true,
"FriendlyEats": true,
"firebase": true,
"Promise": true
}
}
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- "7"
install:
- npm install -g eslint
- npm install
script:
- ./test.sh
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ Please follow the [Cloud Firestore Web Codelab](https://codelabs.developers.goog
## License

© Google, 2017. Licensed under an [Apache-2](../LICENSE) license.

## Build Status

[![Build Status](https://travis-ci.org/firebase/friendlyeats-web.svg?branch=master)](https://travis-ci.org/firebase/friendlyeats-web)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"author": "",
"devDependencies": {
"eslint": "^4.17.0",
"prettier": "^1.5.3"
}
}
48 changes: 25 additions & 23 deletions scripts/FriendlyEats.Mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
* Adds a set of mock Restaurants to the Cloud Firestore.
*/
FriendlyEats.prototype.addMockRestaurants = function() {
const promises = [];
var promises = [];

for (let i = 0; i < 20; i++) {
let name =
for (var i = 0; i < 20; i++) {
var name =
this.getRandomItem(this.data.words) +
' ' +
this.getRandomItem(this.data.words);
let category = this.getRandomItem(this.data.categories);
let city = this.getRandomItem(this.data.cities);
let price = Math.floor(Math.random() * 4) + 1;
let photoID = Math.floor(Math.random() * 22) + 1;
let photo = `https://storage.googleapis.com/firestorequickstarts.appspot.com/food_${photoID}.png`;
let numRatings = 0;
let avgRating = 0;
var category = this.getRandomItem(this.data.categories);
var city = this.getRandomItem(this.data.cities);
var price = Math.floor(Math.random() * 4) + 1;
var photoID = Math.floor(Math.random() * 22) + 1;
var photo = 'https://storage.googleapis.com/firestorequickstarts.appspot.com/food_' + photoID + '.png';
var numRatings = 0;
var avgRating = 0;

const promise = this.addRestaurant({
name,
category,
price,
city,
numRatings,
avgRating,
photo
var promise = this.addRestaurant({
name: name,
category: category,
price: price,
city: city,
numRatings: numRatings,
avgRating: avgRating,
photo: photo
});

if (!promise) {
Expand All @@ -58,14 +58,16 @@ FriendlyEats.prototype.addMockRestaurants = function() {
/**
* Adds a set of mock Ratings to the given Restaurant.
*/
FriendlyEats.prototype.addMockRatings = async function(restaurantID) {
for (let r = 0; r < 5*Math.random(); r++) {
const rating = this.data.ratings[
FriendlyEats.prototype.addMockRatings = function(restaurantID) {
var ratingPromises = [];
for (var r = 0; r < 5*Math.random(); r++) {
var rating = this.data.ratings[
parseInt(this.data.ratings.length*Math.random())
];
rating.userName = 'Bot (Web)';
rating.timestamp = new Date();
rating.userId = firebase.auth().currentUser.uid;
await this.addRating(restaurantID, rating);
ratingPromises.push(this.addRating(restaurantID, rating));
}
};
return Promise.all(ratingPromises);
};
Loading