|
|
|
var app = { |
|
initialize: function() { |
|
this.bindEvents(); |
|
}, |
|
bindEvents: function() { |
|
document.addEventListener('deviceready', this.onDeviceReady, false); |
|
}, |
|
onDeviceReady: function() { |
|
app.receivedEvent('deviceready'); |
|
setupShareTarget(); |
|
}, |
|
receivedEvent: function(id) { |
|
var parentElement = document.getElementById(id); |
|
var listeningElement = parentElement.querySelector('.listening'); |
|
var receivedElement = parentElement.querySelector('.received'); |
|
|
|
listeningElement.setAttribute('style', 'display:none;'); |
|
receivedElement.setAttribute('style', 'display:block;'); |
|
console.log('Received Event: ' + id); |
|
} |
|
}; |
|
|
|
app.initialize(); |
|
|
|
|
|
|
|
function setupShareTarget() { |
|
console.debug("setupShareTarget"); |
|
|
|
var shareOperation = null; |
|
function shareReady(args) { |
|
console.debug("shareReady"); |
|
if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.uri)) { |
|
console.debug("shareOperation"); |
|
shareOperation.data.getUriAsync().done(function (uri) { |
|
console.debug("getUriAsync"); |
|
}); |
|
} |
|
} |
|
|
|
WinJS.Application.onactivated = function (args) { |
|
console.debug("onactivated"); |
|
if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) { |
|
console.debug("launch"); |
|
args.setPromise(WinJS.UI.processAll()); |
|
} |
|
else if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.shareTarget) { |
|
console.debug("share target"); |
|
args.setPromise(WinJS.UI.processAll()); |
|
shareOperation = args.detail.shareOperation; |
|
WinJS.Application.addEventListener("shareready", shareReady, false); |
|
WinJS.Application.queueEvent({ type: "shareready" }); |
|
} |
|
else { |
|
console.debug("else"); |
|
} |
|
}; |
|
} |