Browse Source

Generalize hash affectation

master
Étienne Deparis 10 years ago
parent
commit
0ea050571a
  1. 26
      js/interface_common.js

26
js/interface_common.js

@ -133,6 +133,7 @@ function openProfileModalWithUsername(username)
$(".tox-ctc").attr("title", polyglot.t("Copy to clipboard")); $(".tox-ctc").attr("title", polyglot.t("Copy to clipboard"));
$(".bitmessage-ctc").attr("title", polyglot.t("Copy to clipboard")); $(".bitmessage-ctc").attr("title", polyglot.t("Copy to clipboard"));
window.location.hash = '#profile?user=' + username;
} }
function newHashtagModal(hashtag) { function newHashtagModal(hashtag) {
@ -155,16 +156,7 @@ function openHashtagModal(e)
var $this = $( this ); var $this = $( this );
var hashtag = $this.text().substring(1).toLowerCase(); var hashtag = $this.text().substring(1).toLowerCase();
openHashtagModalFromSearch(hashtag);
var hashtagModalClass = "hashtag-modal";
openModal( hashtagModalClass );
$( "."+hashtagModalClass ).attr("data-resource","hashtag");
var hashtagModalContent = newHashtagModal( hashtag );
hashtagModalContent.appendTo("." +hashtagModalClass + " .modal-content");
//título do modal
$( "."+hashtagModalClass + " h3" ).text( "#" + hashtag );
} }
function openHashtagModalFromSearch(hashtag) function openHashtagModalFromSearch(hashtag)
@ -178,6 +170,7 @@ function openHashtagModalFromSearch(hashtag)
//título do modal //título do modal
$( "."+hashtagModalClass + " h3" ).text( "#" + hashtag ); $( "."+hashtagModalClass + " h3" ).text( "#" + hashtag );
window.location.hash = '#hashtag?hashtag=' + hashtag;
} }
function updateHashtagModal(postboard,hashtag) { function updateHashtagModal(postboard,hashtag) {
@ -361,11 +354,16 @@ function openConversationModal(e)
function watchHashChange(e){ function watchHashChange(e){
if(/user=(.+)/.test(window.location.hash)) var hashdata = window.location.hash.match(/(hashtag|profile)\?(?:user|hashtag)=(.+)/);
if (hashdata && hashdata[1] != undefined && hashdata[2] != undefined)
{ {
var username = location.hash.match(/user=(.+)/); if(hashdata[1] == 'profile')
if(username[1] != undefined) {
openProfileModalWithUsername(username[1]); openProfileModalWithUsername(hashdata[2]);
}else if (hashdata[2] == 'hashtag'){
openHashtagModalFromSearch(username[2]);
}
} }
} }

Loading…
Cancel
Save