Omnom_Misc.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. OmnomIRC COPYRIGHT 2010,2011 Netham45
  3. This file is part of OmnomIRC.
  4. OmnomIRC is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. OmnomIRC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with OmnomIRC. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. (function(window,undefined){
  16. //******************************
  17. // Start Indicator functions *
  18. //******************************
  19. var indicatorTimer = false,
  20. oldMessages = [],
  21. messageCounter = 1,
  22. currentMessage,
  23. startIndicator = window.startIndicator = function(){
  24. if(!indicatorTimer){
  25. indicatorTimer = setInterval(updateIndicator,50);
  26. indicatorPixels = Array(true,true,true,true,true,false,false,false);
  27. }
  28. },
  29. stopIndicator = window.stopIndicator = function() {
  30. clearInterval(indicatorTimer);
  31. document.getElementById('indicator').innerHTML = '';
  32. indicatorTimer = false;
  33. };
  34. function updateIndicator() {
  35. var indicator = document.getElementById('indicator'),
  36. div,
  37. temp = indicatorPixels[7];
  38. indicator.innerHTML = "";
  39. for (var i=0;i<8;i++){
  40. div = document.createElement('div');
  41. div.style.padding = 0;
  42. div.style.margin = 0;
  43. div.style.width = '3px';
  44. div.style.height = '3px';
  45. if (indicatorPixels[i]){
  46. div.style.backgroundColor = 'black';
  47. }
  48. indicator.appendChild(div);
  49. }
  50. for(i=6;i>=0;i--){
  51. indicatorPixels[(i+1)] = indicatorPixels[i];
  52. }
  53. indicatorPixels[0] = temp;
  54. }
  55. //******************************
  56. // End Indicator functions *
  57. //******************************
  58. //******************************
  59. // Start old messages functions*
  60. //******************************
  61. window.addEventListener('keydown',function(e) {
  62. if (document.activeElement.id=="message") {
  63. var messageBoxElement = document.getElementById("message");
  64. if (messageCounter==oldMessages.length)currentMessage=messageBoxElement.value;
  65. if (oldMessages.length!=0) {
  66. if (e.keyCode==38) { //up
  67. if (messageCounter!=0)messageCounter--;
  68. messageBoxElement.value = oldMessages[messageCounter];
  69. } else if (e.keyCode==40) { //down
  70. if (messageCounter!=oldMessages.length)messageCounter++;
  71. if (messageCounter==oldMessages.length) {
  72. messageBoxElement.value = currentMessage;
  73. } else {
  74. messageBoxElement.value = oldMessages[messageCounter];
  75. }
  76. }
  77. }
  78. }
  79. }, false);
  80. var readOldMessagesCookies = window.readOldMessagesCookies = function() {
  81. oldMessages = [];
  82. var temp = getCookie("oldMessages-"+getChannelEn());
  83. if (temp!=null)
  84. oldMessages = temp.split("\n");
  85. messageCounter = oldMessages.length;
  86. }
  87. //******************************
  88. // End old messages functions *
  89. //******************************
  90. })(window);