Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. var noun_type_color = new CmdUtils.NounType( "color", ["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "purple", "red", "silver", "teal", "white", "yellow"], "yellow" )
  2.  
  3. CmdUtils.CreateCommand({
  4. name: "high",
  5. author: {name:"Fernando Takai"},
  6. license:"GPL",
  7. icon: "chrome://ubiquity/skin/icons/textfield_rename.png",
  8. description: "Highlights with one of the 12 valid W3C colors!",
  9. takes: {"color": noun_type_color},
  10. preview: function( pblock, input) {
  11. var color = (input.text ? input.text : "yellow");
  12. pblock.innerHTML = "Highlights with this <span style='background-color:" + color + "'>color</span>"
  13. },
  14. execute: function(input) {
  15. var sel = context.focusedWindow.getSelection();
  16. var document = context.focusedWindow.document;
  17.  
  18. if (sel.rangeCount >= 1) {
  19. var range = sel.getRangeAt(0);
  20. var newNode = document.createElement("span");
  21. newNode.style.background = (input.text ? input.text : "yellow");
  22. range.surroundContents(newNode);
  23. }
  24. }
  25. });
Add Comment
Please, Sign In to add comment