Browse Source

Fix hashtag watching bugs and add custom protocol handler support

master
Étienne Deparis 10 years ago
parent
commit
46fc58f69e
  1. 30
      js/interface_common.js
  2. 2
      js/interface_home.js

30
js/interface_common.js

@ -353,18 +353,36 @@ function openConversationModal(e) @@ -353,18 +353,36 @@ function openConversationModal(e)
}
function watchHashChange(e){
var hashdata = window.location.hash.match(/(hashtag|profile)\?(?:user|hashtag)=(.+)/);
function watchHashChange(e)
{
var hashstring = window.location.hash
hashstring = decodeURIComponent(hashstring);
var hashdata = hashstring.split(':');
if (hashdata[0] != '#web+twister') {
hashdata = hashstring.match(/(hashtag|profile)\?(?:user|hashtag)=(.+)/);
}
if (hashdata && hashdata[1] != undefined && hashdata[2] != undefined)
{
if(hashdata[1] == 'profile')
{
if(hashdata[1] == 'profile') {
openProfileModalWithUsername(hashdata[2]);
}else if (hashdata[2] == 'hashtag'){
openHashtagModalFromSearch(username[2]);
}else if (hashdata[1] == 'hashtag') {
openHashtagModalFromSearch(hashdata[2]);
}
}
}
function initHashWatching()
{
// Register custom protocol handler
var local_twister_url = window.location.protocol + '//' + window.location.host + '/home.html#%s';
window.navigator.registerProtocolHandler('web+twister', local_twister_url, 'Twister');
// Register hash spy and launch it once
window.addEventListener('hashchange', watchHashChange, false);
watchHashChange(null);
}

2
js/interface_home.js

@ -52,6 +52,7 @@ var InterfaceFunctions = function() @@ -52,6 +52,7 @@ var InterfaceFunctions = function()
initInterfaceDirectMsg();
initUser(initHome);
initHashWatching();
};
function initHome(cbFunc, cbArg) {
@ -163,7 +164,6 @@ var InterfaceFunctions = function() @@ -163,7 +164,6 @@ var InterfaceFunctions = function()
var interfaceFunctions = new InterfaceFunctions;
$( document ).ready( interfaceFunctions.init );
$( window ).resize(replaceDashboards);
window.addEventListener('hashchange', watchHashChange, false);
//função no window que fixa o header das postagens
function fixDiv()

Loading…
Cancel
Save