Debian Codegraph @

closure-library/closure/goog/demos/history3js.html

raw
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright 2010 The Closure Library Authors. All Rights Reserved.
5
6 Use of this source code is governed by the Apache License, Version 2.0.
7 See the COPYING file for details.
8 -->
9 <head>
10 <title>History Demo JavaScript Page</title>
11 </head>
12 <body>
13 <script src="../base.js"></script>
14 <script>
15 goog.require('goog.History');
16 goog.require('goog.debug.DivConsole');
17 goog.require('goog.dom');
18 goog.require('goog.events');
19 goog.require('goog.history.EventType');
20 goog.require('goog.log');
21 </script>
22 <script>
23 var logger = goog.log.getLogger('demo');
24 var logconsole = new goog.debug.DivConsole(top.document.getElementById('log'));
25 logconsole.setCapturing(true);
26
27 var events = goog.object.getValues(goog.history.EventType);
28 goog.log.info(logger, 'Listening for: ' + events.join(', ') + '.');
29
30 var googHist = new goog.History(
31 false, 'history_blank.html', top.document.getElementById('hist_state'));
32 goog.events.listen(googHist, events, function(e) {
33 goog.log.info(logger, goog.string.subs('dispatched: %s (token="%s", isNavigation=%s)',
34 e.type, e.token, e.isNavigation));
35 });
36 goog.events.listen(googHist, goog.History.EventType.NAVIGATE, navCallback);
37 googHist.setEnabled(true);
38
39 function navCallback(e) {
40 var output = top.document.getElementById('token_output');
41 if (output) {
42 var token = (e.token == null) ? 'null' : '\u201C' + e.token + '\u201D';
43 goog.dom.setTextContent(output, token);
44 }
45 }
46 </script>
47 </body>
48 </html>