Skip to content

Instantly share code, notes, and snippets.

@fahmi182
Created August 7, 2016 02:58
Show Gist options
  • Save fahmi182/a81b4d499f97db94521ef8fb94e7398c to your computer and use it in GitHub Desktop.
Save fahmi182/a81b4d499f97db94521ef8fb94e7398c to your computer and use it in GitHub Desktop.
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
universalLinks.subscribe('openNewsDetailedPage', app.onNewsDetailedPageRequested);
universalLinks.subscribe('launchedAppFromLink', app.onApplicationDidLaunchFromLink);
},
// openNewsDetailedPage Event Handler
onNewsDetailedPageRequested: function(eventData) {
var ori_url = eventData.url;
var base_url = cordova.file.applicationDirectory+'www/';
var urls = purl(ori_url);
var file_url = urls.attr('file');
var new_file_url = file_url.substring(0, file_url.lastIndexOf("."));
var target_url = 'launch.html?slug=';
var finished = base_url + target_url + new_file_url;
// Bagaimana cara redirect habis alert ini pakdeh?....
alert('Showing after to user details page for some news ' + finished);
//window.location.href= finished;
},
// launchedAppFromLink Event Handler
onApplicationDidLaunchFromLink: function(eventData) {
alert('Did launch app from the link: ' + eventData.url);
}
};
app.initialize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment