Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #142 from shimomura1004/id/141
Browse files Browse the repository at this point in the history
replace history only when unload event happens refs #141
  • Loading branch information
mallowlabs committed Oct 2, 2013
2 parents 221f55d + cbac7a0 commit fdd4979
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 13 additions & 0 deletions app/assets/javascripts/jquery-replacestate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* update browser history before leaving the page
* @author codefirst
*/
(function($, document, undefined) {
if (window.history && window.history.replaceState) {
$(window).on("unload", function(){
var latestId = $(".message:last").attr("message-id");
window.history.replaceState(latestId ,"", location.pathname+"?latest="+latestId);
});
}
})(jQuery, document);

4 changes: 0 additions & 4 deletions app/assets/javascripts/jquery-websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@

target.trigger("websocket::"+name, data);

if (isMessageEvent(name) && window.history && window.history.replaceState) {
window.history.replaceState(data.id ,"", location.pathname+"?latest="+data.id);
}

if(window.postMessage) {
window.postMessage({ 'type': name,
'current': AsakusaSatellite.current,
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//= require "jquery-multiline"
//= require "jquery-onthespot"
//= require "jquery-textcomplete"
//= require "jquery-replacestate"

$(function() {
// on the spot
Expand Down

0 comments on commit fdd4979

Please sign in to comment.