default.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. function getCookie(c_name)
  2. {
  3. // From http://www.w3schools.com/js/js_cookies.asp
  4. var c_value = document.cookie;
  5. var c_start = c_value.indexOf(" " + c_name + "=");
  6. if (c_start == -1) {
  7. c_start = c_value.indexOf(c_name + "=");
  8. }
  9. if (c_start == -1) {
  10. c_value = null;
  11. } else {
  12. c_start = c_value.indexOf("=", c_start) + 1;
  13. var c_end = c_value.indexOf(";", c_start);
  14. if (c_end == -1) {
  15. c_end = c_value.length;
  16. }
  17. c_value = unescape(c_value.substring(c_start,c_end));
  18. }
  19. return c_value;
  20. }
  21. // JSON highlighting.
  22. prettyPrint();
  23. // Bootstrap tooltips.
  24. $('.js-tooltip').tooltip({
  25. delay: 1000,
  26. container: 'body'
  27. });
  28. // Deal with rounded tab styling after tab clicks.
  29. $('a[data-toggle="tab"]:first').on('shown', function (e) {
  30. $(e.target).parents('.tabbable').addClass('first-tab-active');
  31. });
  32. $('a[data-toggle="tab"]:not(:first)').on('shown', function (e) {
  33. $(e.target).parents('.tabbable').removeClass('first-tab-active');
  34. });
  35. $('a[data-toggle="tab"]').click(function(){
  36. document.cookie="tabstyle=" + this.name + "; path=/";
  37. });
  38. // Store tab preference in cookies & display appropriate tab on load.
  39. var selectedTab = null;
  40. var selectedTabName = getCookie('tabstyle');
  41. if (selectedTabName) {
  42. selectedTabName = selectedTabName.replace(/[^a-z-]/g, '');
  43. }
  44. if (selectedTabName) {
  45. selectedTab = $('.form-switcher a[name=' + selectedTabName + ']');
  46. }
  47. if (selectedTab && selectedTab.length > 0) {
  48. // Display whichever tab is selected.
  49. selectedTab.tab('show');
  50. } else {
  51. // If no tab selected, display rightmost tab.
  52. $('.form-switcher a:first').tab('show');
  53. }
  54. $(window).load(function(){
  55. $('#errorModal').modal('show');
  56. });