Commit 662e3aac43128d758c1709ba48911d55db5dad95
1 parent
78ee46aa
move jquery init into separate js file and server action
Showing
3 changed files
with
38 additions
and
32 deletions
@@ -8,38 +8,7 @@ | @@ -8,38 +8,7 @@ | ||
8 | <script type="text/javascript" src="/assets/js/jquery"></script> | 8 | <script type="text/javascript" src="/assets/js/jquery"></script> |
9 | <script type="text/javascript" src="/assets/js/serverval"></script> | 9 | <script type="text/javascript" src="/assets/js/serverval"></script> |
10 | <script type="text/javascript" src="/assets/js/session"></script> | 10 | <script type="text/javascript" src="/assets/js/session"></script> |
11 | - <script> | ||
12 | - //<![CDATA[ | ||
13 | - var sess = null; | ||
14 | - | ||
15 | - $(document).ready(function() { | ||
16 | - var sval = new ServerVal("#randval"); | ||
17 | - | ||
18 | - sess = new Session("#sessinfo"); | ||
19 | - $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); | ||
20 | - | ||
21 | - $("ul#menu li:eq(0)").click(function() { | ||
22 | - sval.start(); | ||
23 | - }); | ||
24 | - | ||
25 | - $("ul#menu li:eq(1)").click(function() { | ||
26 | - $("#login").removeClass("hide"); | ||
27 | - }); | ||
28 | - | ||
29 | - $("#randval").click(function() { | ||
30 | - sval.stop(); | ||
31 | - }); | ||
32 | - | ||
33 | - $("#login form").submit(function(event) { | ||
34 | - event.preventDefault(); | ||
35 | - $.post("/login/", | ||
36 | - $("#login form").serialize(), | ||
37 | - $.proxy(sess.loadJSON, sess)); | ||
38 | - $("#login").addClass("hide"); | ||
39 | - }); | ||
40 | - }); | ||
41 | - //]]> | ||
42 | - </script> | 11 | + <script type="text/javascript" src="/assets/js/init"></script> |
43 | </head> | 12 | </head> |
44 | <body> | 13 | <body> |
45 | <ul id="menu"> | 14 | <ul id="menu"> |
assets/js/init.js
0 → 100644
1 | +var sess = null; | ||
2 | + | ||
3 | +$(document).ready(function() { | ||
4 | + var sval = new ServerVal("#randval"); | ||
5 | + | ||
6 | + sess = new Session("#sessinfo"); | ||
7 | + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); | ||
8 | + | ||
9 | + $("ul#menu li:eq(0)").click(function() { | ||
10 | + sval.start(); | ||
11 | + }); | ||
12 | + | ||
13 | + $("ul#menu li:eq(1)").click(function() { | ||
14 | + $("#login").removeClass("hide"); | ||
15 | + }); | ||
16 | + | ||
17 | + $("#randval").click(function() { | ||
18 | + sval.stop(); | ||
19 | + }); | ||
20 | + | ||
21 | + $("#login form").submit(function(event) { | ||
22 | + event.preventDefault(); | ||
23 | + $.post("/login/", | ||
24 | + $("#login form").serialize(), | ||
25 | + $.proxy(sess.loadJSON, sess)); | ||
26 | + $("#login").addClass("hide"); | ||
27 | + }); | ||
28 | +}); | ||
29 | + | ||
30 | +// vim: set ts=4 sw=4: |
@@ -168,6 +168,13 @@ httpWorkerProcess(HttpWorker this, Stream st) | @@ -168,6 +168,13 @@ httpWorkerProcess(HttpWorker this, Stream st) | ||
168 | CSTRA("text/javascript")); | 168 | CSTRA("text/javascript")); |
169 | } | 169 | } |
170 | 170 | ||
171 | + if (0 == strcmp("/assets/js/init", request->uri)) { | ||
172 | + response = httpWorkerGetAsset( | ||
173 | + request, | ||
174 | + "./assets/js/init.js", | ||
175 | + CSTRA("text/javascript")); | ||
176 | + } | ||
177 | + | ||
171 | if (0 == strcmp("/assets/style/common", request->uri)) { | 178 | if (0 == strcmp("/assets/style/common", request->uri)) { |
172 | response = httpWorkerGetAsset( | 179 | response = httpWorkerGetAsset( |
173 | request, | 180 | request, |
Please
register
or
login
to post a comment