Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 window.onload = function() { | |
| 6 window.addEventListener('popstate', onPopstate); | |
| 7 window.addEventListener('hashchange', onHashChange); | |
| 8 updateOnLoadText('OnLoadText'); | |
| 9 }; | |
| 10 | |
| 11 var onPopstate = function(e) { | |
| 12 updatePopStateReceivedText(true); | |
| 13 updateStateObjectText(e.state); | |
| 14 }; | |
| 15 | |
| 16 var onHashChange = function(e) { | |
| 17 updateHashChangeReceivedText(true); | |
| 18 } | |
| 19 | |
| 20 var updateOnLoadText = function(text) { | |
| 21 document.getElementById('onLoadDiv').innerHTML = text; | |
| 22 } | |
| 23 | |
| 24 var updateNoOpText = function(text) { | |
| 25 document.getElementById('noOpDiv').innerHTML = text; | |
| 26 } | |
| 27 | |
| 28 var updatePopStateReceivedText = function(received) { | |
| 29 var text = received ? 'PopStateReceived' : ''; | |
| 30 document.getElementById('popStateReceivedDiv').innerHTML = text; | |
| 31 } | |
| 32 | |
| 33 var updateStateObjectText = function(state) { | |
| 34 document.getElementById('stateObjectDiv').innerHTML = state; | |
| 35 } | |
| 36 | |
| 37 var updateHashChangeReceivedText = function(received) { | |
| 38 var text = received ? 'HashChangeReceived' : ''; | |
| 39 document.getElementById('hashChangeReceivedDiv').innerHTML = text; | |
| 40 } | |
| 41 | |
| 42 var buttonWasTapped = function() { | |
|
Eugene But (OOO till 7-30)
2016/12/09 23:02:16
s/buttonWasTapped/onButtonTap ?
Eugene But (OOO till 7-30)
2016/12/09 23:02:16
Please add comments to all non-trivial functions
kkhorimoto
2016/12/13 00:29:10
Done.
| |
| 43 updateOnLoadText(''); | |
| 44 updateNoOpText(''); | |
| 45 updatePopStateReceivedText(false); | |
| 46 updateStateObjectText(''); | |
| 47 updateHashChangeReceivedText(false); | |
| 48 setTimeout("updateNoOpText('NoOpText')", 1000); | |
| 49 } | |
| 50 | |
| 51 var goNoParameter = function() { | |
| 52 buttonWasTapped(); | |
| 53 window.history.go(); | |
| 54 } | |
| 55 | |
| 56 var goZero = function() { | |
| 57 buttonWasTapped(); | |
| 58 window.history.go(0); | |
| 59 } | |
| 60 | |
| 61 var go2 = function() { | |
| 62 buttonWasTapped(); | |
| 63 window.history.go(2); | |
| 64 } | |
| 65 | |
| 66 var goBack2 = function() { | |
| 67 buttonWasTapped(); | |
| 68 window.history.go(-1); | |
| 69 } | |
| OLD | NEW |