Rename app.p2p to app.conn

This commit is contained in:
Robin Linus 2015-12-31 02:23:39 +01:00
parent cb0eca4220
commit e384312e2c
4 changed files with 16 additions and 16 deletions

View file

@ -89,37 +89,37 @@
}, },
attached: function() { attached: function() {
this.async(function() { this.async(function() {
app.p2p.addEventListener('file-offered', function(e) { app.conn.addEventListener('file-offered', function(e) {
if (e.detail.to === this.contact.peerId) { if (e.detail.to === this.contact.peerId) {
this.status = 'Waiting to accept...'; this.status = 'Waiting to accept...';
} }
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('upload-started', function(e) { app.conn.addEventListener('upload-started', function(e) {
if (e.detail.to === this.contact.peerId) { if (e.detail.to === this.contact.peerId) {
this.status = 'Uploading...'; this.status = 'Uploading...';
} }
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('download-started', function(e) { app.conn.addEventListener('download-started', function(e) {
if (e.detail.from === this.contact.peerId) { if (e.detail.from === this.contact.peerId) {
this.status = 'Downloading...'; this.status = 'Downloading...';
} }
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('upload-complete', function(e) { app.conn.addEventListener('upload-complete', function(e) {
if (e.detail.from === this.contact.peerId) { if (e.detail.from === this.contact.peerId) {
this.status = ''; this.status = '';
} }
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('download-complete', function(e) { app.conn.addEventListener('download-complete', function(e) {
if (e.detail.from === this.contact.peerId) { if (e.detail.from === this.contact.peerId) {
this.status = ''; this.status = '';
} }
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('file-declined', function(e) { app.conn.addEventListener('file-declined', function(e) {
if (e.detail.from === this.contact.peerId) { if (e.detail.from === this.contact.peerId) {
this.status = ''; this.status = '';
} }
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('upload-error', function(e) { app.conn.addEventListener('upload-error', function(e) {
this.status = ''; this.status = '';
}.bind(this), false); }.bind(this), false);
}, 200); }, 200);

View file

@ -88,7 +88,7 @@
_fileSelected: function(e) { _fileSelected: function(e) {
var peerId = e.model.item.peerId; var peerId = e.model.item.peerId;
var file = e.detail; var file = e.detail;
app.p2p.sendFile(peerId, file); app.conn.sendFile(peerId, file);
} }
}); });
</script> </script>

View file

@ -48,20 +48,20 @@
is: 'file-receiver', is: 'file-receiver',
attached: function() { attached: function() {
this.async(function() { this.async(function() {
app.p2p.addEventListener('file-offer', function(e) { app.conn.addEventListener('file-offer', function(e) {
this.file = e.detail; this.file = e.detail;
this.$.dialog.open(); this.$.dialog.open();
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('file-received', function(e) { app.conn.addEventListener('file-received', function(e) {
this._fileReceived(e.detail); this._fileReceived(e.detail);
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('file-declined', function(e) { app.conn.addEventListener('file-declined', function(e) {
app.displayToast('User declined file ' + e.detail.name); app.displayToast('User declined file ' + e.detail.name);
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('upload-complete', function(e) { app.conn.addEventListener('upload-complete', function(e) {
app.displayToast('User received file ' + e.detail.name); app.displayToast('User received file ' + e.detail.name);
}.bind(this), false); }.bind(this), false);
app.p2p.addEventListener('upload-error', function(e) { app.conn.addEventListener('upload-error', function(e) {
app.displayToast('The other device did not respond. Please try again.'); app.displayToast('The other device did not respond. Please try again.');
}.bind(this), false); }.bind(this), false);
}, 200); }, 200);
@ -70,10 +70,10 @@
this.downloadURI(file); this.downloadURI(file);
}, },
_decline: function() { _decline: function() {
app.p2p.decline(this.file); app.conn.decline(this.file);
}, },
_accept: function() { _accept: function() {
app.p2p.accept(this.file); app.conn.accept(this.file);
}, },
downloadURI: function(file) { downloadURI: function(file) {
var link = document.createElement('a'); var link = document.createElement('a');

View file

@ -31,7 +31,7 @@
// have resolved and content has been stamped to the page // have resolved and content has been stamped to the page
app.addEventListener('dom-change', function() { app.addEventListener('dom-change', function() {
console.log('Our app is ready to rock!'); console.log('Our app is ready to rock!');
app.p2p = document.querySelector('connection-wrapper'); app.conn = document.querySelector('connection-wrapper');
}); });
// See https://github.com/Polymer/polymer/issues/1381 // See https://github.com/Polymer/polymer/issues/1381