PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/default/view-graph.js

http://epicnms.googlecode.com/
JavaScript | 146 lines | 108 code | 26 blank | 12 comment | 17 complexity | 95d8a25fd35061f59d373e6b8d1c0ee4 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT, AGPL-1.0, GPL-2.0
  1. <script src="/epic-<?php echo $instance ?>/default/ui-20110309.01/js/jquery-1.5.1.min.js"></script>
  2. <link rel="stylesheet" href="/epic-<?php echo $instance ?>/default/ui-20110309.01/css/jquery/cupertino/jquery-ui-1.8.13.custom.css">
  3. <!-- Click and Time Span Focusing -->
  4. <link rel='stylesheet' type='text/css' media='screen' href='/epic-<?php echo $instance ?>/default/ui-20110309.01/js/jquery.imgareaselect-0.9.6/css/imgareaselect-default.css' />
  5. <script type='text/javascript' src='/epic-<?php echo $instance ?>/default/ui-20110309.01/js/jquery.imgareaselect-0.9.6/scripts/jquery.imgareaselect.pack.js'></script>
  6. <script type='text/javascript'>
  7. $(document).ready(function () {
  8. $('#photo').imgAreaSelect({
  9. minHeight: <?php echo $h ?>,
  10. maxHeight: <?php echo $h ?>,
  11. onSelectEnd: function (img, selection) { window.location.href = '/epic-<?php print "{$instance}{$uipage}?$cgi_params_get" ?>&x1=' + selection.x1 + '&x2=' + selection.x2; }
  12. });
  13. });
  14. </script>
  15. <!-- Autocomplete ds_list -->
  16. <script src="/epic-<?php echo $instance ?>/default/ui-20110309.01/js/jquery-ui-1.8.13.custom.min.js"></script>
  17. <script>
  18. $(function() {
  19. var ds_list=new Array();
  20. $.getJSON("/<?php echo $instance ?>?a=query&ds_attrib_list=ds&n=<?php echo $_GET['n'] ?>&ng=<?php echo $_GET['ng'] ?>&ds=.*", function(json) {
  21. $.each(json.query, function(i, object) {
  22. $.each(object, function(c, ds) {
  23. ds_list.push(ds);
  24. });
  25. });
  26. });
  27. function split( val ) {
  28. return val.split( /,\s*/ );
  29. }
  30. function extractLast( term ) {
  31. return split( term ).pop();
  32. }
  33. $( "#ds_list" )
  34. // don't navigate away from the field on tab when selecting an item
  35. .bind( "keydown", function( event ) {
  36. if ( event.keyCode === $.ui.keyCode.TAB &&
  37. $( this ).data( "autocomplete" ).menu.active ) {
  38. event.preventDefault();
  39. }
  40. })
  41. .autocomplete({
  42. minLength: 0,
  43. source: function( request, response ) {
  44. // delegate back to autocomplete, but extract the last term
  45. response( $.ui.autocomplete.filter(
  46. ds_list, extractLast( request.term ) ) );
  47. },
  48. focus: function() {
  49. // prevent value inserted on focus
  50. return false;
  51. },
  52. select: function( event, ui ) {
  53. var terms = split( this.value );
  54. // remove the current input
  55. terms.pop();
  56. // add the selected item
  57. terms.push( ui.item.value );
  58. // add placeholder to get the comma-and-space at the end
  59. terms.push( "" );
  60. this.value = terms.join( "," );
  61. return false;
  62. }
  63. });
  64. });
  65. </script>
  66. <!-- time/query/parameter area hiding -->
  67. <!-- TODO - oh my god this is a lot of code for some simple div hiding and cookie setting -->
  68. <!-- TODO - rewrite this mess with a function like diveHideByCookie('div-name') or something -->
  69. <script>
  70. var timeToggle = getCookie('timeToggle');
  71. if (timeToggle == null) {
  72. setCookie('timeToggle', 'hidden', 1);
  73. timeToggle = 'hidden';
  74. }
  75. var queryToggle = getCookie('queryToggle');
  76. if (queryToggle == null) {
  77. setCookie('queryToggle', 'hidden', 1);
  78. queryToggle = 'hidden';
  79. }
  80. var parameterToggle = getCookie('parameterToggle');
  81. if (parameterToggle == null) {
  82. setCookie('parameterToggle', 'hidden', 1);
  83. parameterToggle = 'hidden';
  84. }
  85. $(document).ready(function() {
  86. // hides the time-div as soon as the DOM is ready
  87. if (timeToggle == 'hidden') {
  88. $('#time-div').hide();
  89. };
  90. // toggles the time-div on clicking the noted link
  91. $('#time-div-toggle').click(function() {
  92. $('#time-div').toggle(100);
  93. timeToggle = (timeToggle == 'hidden') ? 'exposed' : 'hidden';
  94. setCookie('timeToggle', timeToggle, 1);
  95. return false;
  96. });
  97. // hides the query-div as soon as the DOM is ready
  98. if (queryToggle == 'hidden') {
  99. $('#query-div').hide();
  100. };
  101. // toggles the query-div on clicking the noted link
  102. $('#query-div-toggle').click(function() {
  103. $('#query-div').toggle(100);
  104. queryToggle = (queryToggle == 'hidden') ? 'exposed' : 'hidden';
  105. setCookie('queryToggle', queryToggle, 1);
  106. return false;
  107. });
  108. // hides the parameter-div as soon as the DOM is ready
  109. if (parameterToggle == 'hidden') {
  110. $('#parameter-div').hide();
  111. };
  112. // toggles the parameter-div on clicking the noted link
  113. $('#parameter-div-toggle').click(function() {
  114. $('#parameter-div').toggle(100);
  115. parameterToggle = (parameterToggle == 'hidden') ? 'exposed' : 'hidden';
  116. setCookie('parameterToggle', parameterToggle, 1);
  117. return false;
  118. });
  119. });
  120. </script>