You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 line
1.2 KiB

  1. // route urls to their virtual pages
  2. wn.route = function() {
  3. wn._cur_route = window.location.hash;
  4. route = wn.get_route();
  5. switch (route[0]) {
  6. case "List":
  7. wn.views.doclistview.show(route[1]);
  8. break;
  9. case "Form":
  10. if(route.length>3) {
  11. route[2] = route.splice(2).join('/');
  12. }
  13. wn.views.formview.show(route[1], route[2]);
  14. break;
  15. case "Report":
  16. wn.views.reportview.show(route[1], route[2]);
  17. break;
  18. default:
  19. wn.views.pageview.show(route[0]);
  20. }
  21. }
  22. wn.get_route = function(route) {
  23. if(!route)
  24. route = window.location.hash;
  25. if(route.substr(0,1)=='#') route = route.substr(1);
  26. if(route.substr(0,1)=='!') route = route.substr(1);
  27. return $.map(route.split('/'), function(r) { return decodeURIComponent(r); });
  28. }
  29. wn.set_route = function() {
  30. route = $.map(arguments, function(a) { return encodeURIComponent(a) }).join('/');
  31. window.location.hash = route;
  32. // Set favicon (app.js)
  33. wn.app.set_favicon();
  34. }
  35. wn._cur_route = null;
  36. $(window).bind('hashchange', function() {
  37. if(location.hash==wn._cur_route)
  38. return;
  39. wn.route();
  40. // analytics code
  41. if(wn.boot.analytics_code) {
  42. try {
  43. eval(wn.boot.analytics_code);
  44. } catch (e) {
  45. console.log(e);
  46. }
  47. }
  48. });