mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-03-12 13:31:14 +00:00
Fix hashtag watching bugs and add custom protocol handler support
This commit is contained in:
parent
0ea050571a
commit
46fc58f69e
@ -353,21 +353,39 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Post actions, submit, count characters
|
||||
// --------------------------------------
|
||||
|
@ -52,6 +52,7 @@ var InterfaceFunctions = function()
|
||||
initInterfaceDirectMsg();
|
||||
|
||||
initUser(initHome);
|
||||
initHashWatching();
|
||||
};
|
||||
|
||||
function initHome(cbFunc, cbArg) {
|
||||
@ -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…
x
Reference in New Issue
Block a user