A requirement is to execute a function that prompts the user for input and then navigates to that specified value. For instance, if the inserted value is:
https://www.youtube.com/watch?v=_ZiN_NqT-Us
The intended destination URL should be:
download?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_ZiN_NqT-Us
I've attempted to retrieve the value using Set.session to retrieve the session in the Router, but it's not returning any value as expected.
Template.inputBar.events({
'click #download':function(event, template) {
var url = template.find('.url').value;
if (url.value != "") {
Session.set('url', url);
}
else {
alert('paste link');
}
}
});
This will navigate to the provided value and trigger a call to the server:
Router.map(function(){
this.route('frontPage', {path: '/'} );
this.route('downloadLinks', {
path: '/download?link=:url',
data: function() {
var url = Session.get('url');
Meteor.call('command', url, function(error, result) {
if(result.stdout) {
console.log(result.stdout)
}
else {
alert("Not supported site");
}
});
}
});
});