This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function go() { | |
| var userId = prompt('Username?', 'Guest'); | |
| var userData = { name: userId }; | |
| tryCreateUser(userId, userData); | |
| } | |
| var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users'; | |
| function userCreated(userId, success) { | |
| if (!success) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function go() { | |
| var userId = prompt('Username?', 'Guest'); | |
| // Consider adding '/<unique id>' if you have multiple games. | |
| var gameRef = new Firebase(GAME_LOCATION); | |
| assignPlayerNumberAndPlayGame(userId, gameRef); | |
| }; | |
| // The maximum number of players. If there are already | |
| // NUM_PLAYERS assigned, users won't be able to join the game. | |
| var NUM_PLAYERS = 4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function makeList(ref) { | |
| var fruits = ["banana", "apple", "grape", "orange"]; | |
| for (var i = 0; i < fruits.length; i++) { | |
| ref.push(fruits[i]); | |
| } | |
| } | |
| function getFirstFromList(ref, cb) { | |
| ref.startAt().limit(1).once("child_added", function(snapshot) { | |
| cb(snapshot.val()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function pushSomething(ref) { | |
| // Let's push something. push() returns a reference that you can hold onto! | |
| var justPushed = ref.push({test: "push"}); | |
| // We return a reference, but you can also return the name of the newly | |
| // created object with .name(). | |
| return justPushed; | |
| } | |
| function removeItem(ref) { | |
| // Now we can get back to that item we just pushed via .child(). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Firebase = require("./firebase-node.js"); | |
| function Queue(ref) { | |
| this._ref = ref; | |
| } | |
| Queue.prototype.pop = function(cb) { | |
| this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Firebase = require("./firebase-node.js"); | |
| function Queue(ref) { | |
| this._ref = ref; | |
| } | |
| Queue.prototype.pop = function(cb) { | |
| this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (Components && Components.classes) { | |
| // This means we are in a Firefox extension. | |
| var appShell = Components.classes["@mozilla.org/appshell/appShellService;1"] | |
| .getService(Components.interfaces.nsIAppShellService); | |
| // hiddenDoc will now point to a regular DOM document. | |
| var hiddenDoc = appShell.hiddenDOMWindow.document; | |
| // Create an iframe. | |
| let iframe = hiddenDoc.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- ../backbone/examples/todos/todos.js 2013-01-08 17:02:02.000000000 -0800 | |
| +++ todos.js 2013-01-10 17:33:56.000000000 -0800 | |
| @@ -1,7 +1,6 @@ | |
| // An example Backbone application contributed by | |
| // [Jérôme Gravel-Niquet](http://jgn.me/). This demo uses a simple | |
| -// [LocalStorage adapter](backbone-localstorage.html) | |
| -// to persist Backbone models within your browser. | |
| +// Firebase adapter to persist Backbone models. | |
| // Load the application once the DOM is ready, using `jQuery.ready`: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getParent(snapshot) { | |
| // You can get the reference (A Firebase object) from a snapshot | |
| // using .ref(). | |
| var ref = snapshot.ref(); | |
| // Now simply find the parent and return the name. | |
| return ref.parent().name(); | |
| } | |
| var testRef = new Firebase("https://example.firebaseIO-demo.com/foo/bar"); | |
| testRef.once("value", function(snapshot) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -ur ../todomvc/architecture-examples/angularjs/index.html examples/todomvc/index.html | |
| --- ../todomvc/architecture-examples/angularjs/index.html 2013-03-15 15:31:06.000000000 -0700 | |
| +++ examples/todomvc/index.html 2013-03-22 15:21:00.000000000 -0700 | |
| @@ -61,9 +61,10 @@ | |
| </footer> | |
| <script src="components/todomvc-common/base.js"></script> | |
| <script src="components/angular/angular.js"></script> | |
| + <script src="https://cdn.firebase.com/v0/firebase.js"></script> | |
| + <script src="../../angularFire.js"></script> | |
| <script src="js/app.js"></script> |