AllenYuan

index.js attempt to read db

May 1st, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.   let PIXELSIZE = 2;
  3.   let REPEATSX = 20;
  4.   let REPEATSY = 15;
  5.   let DIMENSION = 25;
  6.  
  7.   let canvas = id('mycanvas');
  8.   let ctx = canvas.getContext("2d");
  9.   let canvasWidth = DIMENSION * REPEATSX * PIXELSIZE;
  10.   let canvasHeight = DIMENSION * REPEATSY * PIXELSIZE;
  11.   let selectedBox = null;
  12.  
  13.   canvas.width = canvasWidth;
  14.   canvas.height = canvasHeight;
  15.  
  16.   // Your web app's Firebase configuration
  17.   var firebaseConfig = {
  18.     apiKey: "AIzaSyDjLFcsO92KpwLiFe7Hsp4gVd51w61WIsk",
  19.     authDomain: "canvasgamedemo.firebaseapp.com",
  20.     databaseURL: "https://canvasgamedemo.firebaseio.com",
  21.     projectId: "canvasgamedemo",
  22.     storageBucket: "canvasgamedemo.appspot.com",
  23.     messagingSenderId: "258751262925",
  24.     appId: "1:258751262925:web:50cdf23c2265aa7ae07984"
  25.   };
  26.   // Initialize Firebase
  27.   firebase.initializeApp(firebaseConfig);
  28.   let db = firebase.firestore();
  29.  
  30.   db.collection('app').onSnapshot(function (grid) {
  31.     console.log(grid);
  32.     for(let change of grid.docChanges()) {
  33.       console.log(change);
  34.       if (!change.doc) continue;
  35.       let key = change.doc.id;
  36.       let data = change.doc.data().data;
  37.       if (key == 'grid') continue;
  38.     }
  39.   });
  40. // ...
Add Comment
Please, Sign In to add comment