Extends the Chrome Developer Tools, adding a new Network Panel in the Developer Tools window with better searching and response previews. https://leviolson.com/posts/chrome-ext-better-network-panel
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.

64 lines
1.6 KiB

4 years ago
  1. BNPChrome.factory('toolbar', function()
  2. {
  3. return {
  4. buttons: [],
  5. createButton: function(icon, name, input, callback)
  6. {
  7. this.buttons.push({
  8. icon: icon,
  9. name: name,
  10. input: input,
  11. callback: callback
  12. });
  13. },
  14. createToggleButton: function(icon, name, input, callback, selected)
  15. {
  16. this.buttons.push({
  17. icon: icon,
  18. name: name,
  19. input: input,
  20. toggle: true,
  21. callback: callback,
  22. selected: selected
  23. });
  24. },
  25. render: function()
  26. {
  27. var $html = $('<div class="toolbar"></div>');
  28. $.each(this.buttons, function(i, button)
  29. {
  30. var $button = $('<a class="icon" href="#" title="' + button.name + '"><i class="icon-' + button.icon + '"></i></a>');
  31. if (button.toggle === true) {
  32. $button.on('click', function() {
  33. if ($button.hasClass("selected")) {
  34. $button.removeClass("selected");
  35. } else {
  36. $button.addClass("selected");
  37. }
  38. });
  39. if (button.selected === true) {
  40. $button.addClass("selected");
  41. }
  42. }
  43. $button.on('click', button.callback);
  44. $html.append($button);
  45. if (button.input === true) {
  46. var $inputField = $('<input id="' + button.name + 'Input" type="file"/>');
  47. $html.append($inputField);
  48. }
  49. });
  50. return $html;
  51. }
  52. };
  53. });