Advertisement
Guest User

wsh_run

a guest
Mar 3rd, 2011
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. // RUN
  2. //=================================================// Images directory
  3. var bt_dir = fb.FoobarPath+"skins\\eini\\bt\\run\\";
  4.  
  5. //=================================================// Tools
  6. function RGB(r, g, b) {
  7. return (0xff000000 | (r << 16) | (g << 8) | (b));
  8. }
  9.  
  10. //=================================================// OBJECT button
  11. button = function () {
  12. this._attrb = {};
  13.  
  14. this.create = function (path_normal, path_hover, path_down) {
  15. this._attrb.normal = gdi.Image(path_normal);
  16. this._attrb.hover = gdi.Image(path_hover);
  17. this._attrb.down= gdi.Image(path_down);
  18. if (typeof this._attrb.x == "undefined") this._attrb.x= 0;
  19. if (typeof this._attrb.y == "undefined") this._attrb.y= 0;
  20. this._attrb.w = this._attrb.normal.Width;
  21. this._attrb.h= this._attrb.normal.Height;
  22. if (typeof this._attrb.state == "undefined") this._attrb.state=0;
  23. }
  24.  
  25. this.draw = function (gr, bx, by, alpha) {
  26. var image;
  27. this._attrb.x = bx;
  28. this._attrb.y = by;
  29. switch(this._attrb.state)
  30. {
  31. case 0:
  32. image = this._attrb.normal;
  33. break;
  34. case 1:
  35. image = this._attrb.hover;
  36. break;
  37. case 2:
  38. image = this._attrb.down;
  39. break;
  40. }
  41. gr.DrawImage(image, bx, by, this._attrb.w, this._attrb.h, 0, 0, this._attrb.w, this._attrb.h, 0, alpha);
  42. }
  43.  
  44. this.checkstate = function (action, x, y) {
  45. switch(action)
  46. {
  47. case "down":
  48. if (x>this._attrb.x && x<this._attrb.x+this._attrb.w && y>this._attrb.y && y<this._attrb.y+this._attrb.h)
  49. {
  50. this._attrb.state=2;
  51. window.Repaint();
  52. } else if (this._attrb.state==2){
  53. this._attrb.state=0;
  54. window.Repaint();
  55. }
  56. break;
  57. case "move":
  58. if (x>this._attrb.x && x<this._attrb.x+this._attrb.w && y>this._attrb.y && y<this._attrb.y+this._attrb.h)
  59. {
  60. this._attrb.state=1;
  61. window.Repaint();
  62. } else if (this._attrb.state==1){
  63. this._attrb.state=0;
  64. window.Repaint();
  65. }
  66. break;
  67. case "up":
  68. if (x>this._attrb.x && x<this._attrb.x+this._attrb.w && y>this._attrb.y && y<this._attrb.y+this._attrb.h)
  69. {
  70. this._attrb.state=1;
  71. } else {
  72. this._attrb.state=0;
  73. }
  74. break;
  75. }
  76. return this._attrb.state;
  77. }
  78.  
  79. }
  80.  
  81. //=================================================// generate new OBJECTs
  82. var bouton01 = new button;
  83. var bouton02 = new button;
  84. var bouton03 = new button;
  85. var bouton04 = new button;
  86. var bouton05 = new button;
  87.  
  88. //=================================================// Global Variables
  89. var ButtonStates = {normal: 0,hover: 1,down: 2};
  90. var g_font = gdi.Font("Tahoma", 8, 1);
  91. var ww;
  92. var wh;
  93. var WshShell = new ActiveXObject("WScript.Shell");
  94.  
  95. //==========================================================================/ on_paint
  96. function on_paint(gr){
  97.  
  98. //draw button 01
  99. bouton01.draw(gr,0,1,255);
  100. //draw button 02
  101. bouton02.draw(gr,23,1,255);
  102. //draw button 03
  103. bouton03.draw(gr,44,0,255);
  104. //draw button 04
  105. bouton04.draw(gr,66,1,255);
  106. //draw button 05
  107. bouton05.draw(gr,88,0,255);
  108.  
  109. }
  110.  
  111. //==========================================================================/ on_size
  112. function on_size() {
  113. ww = window.Width;
  114. wh = window.Height;
  115. bouton01.create(bt_dir+"google_artist0.png", bt_dir+"google_artist1.png", bt_dir+"google_artist1.png");
  116. bouton02.create(bt_dir+"google_album0.png", bt_dir+"google_album1.png", bt_dir+"google_album1.png");
  117. bouton03.create(bt_dir+"wiki0.png", bt_dir+"wiki1.png", bt_dir+"wiki1.png");
  118. bouton04.create(bt_dir+"yt0.png", bt_dir+"yt1.png", bt_dir+"yt1.png");
  119. bouton05.create(bt_dir+"as0.png", bt_dir+"as1.png", bt_dir+"as1.png");
  120. }
  121.  
  122. //==========================================================================/ lbtn_down
  123. function on_mouse_lbtn_down(x,y){
  124. var state;
  125. if (bouton01.checkstate("down",x,y)==ButtonStates.down) {
  126. WshShell.run("http://images.google.com/images?hl=en&q="+fb.TitleFormat("$replace(%artist%,' ','+','&','and')").Eval(true)+"&btnG=Recherche+d%27images&gbv=2");
  127. }
  128. if (bouton02.checkstate("down",x,y)==ButtonStates.down) {
  129. WshShell.run("http://images.google.com/images?hl=en&q="+fb.TitleFormat("$replace(%artist%,' ','+','&','and')").Eval(true)+"%20"+fb.TitleFormat("$replace(%album%,' ','+','&','and')").Eval(true)+"&btnG=Recherche+d%27images&gbv=2");
  130. }
  131. if (bouton03.checkstate("down",x,y)==ButtonStates.down) {
  132. WshShell.run("http://en.wikipedia.org/wiki/"+fb.TitleFormat("$replace(%artist%,' ','_','&','and')").Eval(true));
  133. }
  134. if (bouton04.checkstate("down",x,y)==ButtonStates.down) {
  135. WshShell.run("http://www.youtube.com/results?search_type=&search_query="+fb.TitleFormat("$replace(%artist%+%title%,' ','+','&','and')").Eval(true)+"&aq=2&oq");
  136. }
  137. if (bouton05.checkstate("down",x,y)==ButtonStates.down) {
  138. WshShell.run("http://www.last.fm/music/"+fb.TitleFormat("$replace(%artist%,' ','+','&','and','/','%252F')").Eval(true));
  139. }
  140. window.Repaint();
  141. }
  142.  
  143. //==========================================================================/ lbtn_up
  144. function on_mouse_lbtn_up(x,y) {
  145. bouton01.checkstate("up",x,y);
  146. bouton02.checkstate("up",x,y);
  147. bouton03.checkstate("up",x,y);
  148. bouton04.checkstate("up",x,y);
  149. bouton05.checkstate("up",x,y);
  150. window.Repaint();
  151. }
  152.  
  153. //==========================================================================/ mouse_move
  154. function on_mouse_move(x,y) {
  155. bouton01.checkstate("move",x,y);
  156. bouton02.checkstate("move",x,y);
  157. bouton03.checkstate("move",x,y);
  158. bouton04.checkstate("move",x,y);
  159. bouton05.checkstate("move",x,y);
  160. window.Repaint();
  161. }
  162.  
  163. //==========================================================================/ mouse_leave
  164. function on_mouse_leave() {
  165. bouton01.checkstate("up",0,0);
  166. bouton02.checkstate("up",0,0);
  167. bouton03.checkstate("up",0,0);
  168. bouton04.checkstate("up",0,0);
  169. bouton05.checkstate("up",0,0);
  170. window.Repaint();
  171. }
  172.  
  173. function on_mouse_wheel(delta){
  174. }
  175.  
  176. function on_volume_change(val){
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement