Skip to content

Instantly share code, notes, and snippets.

@kmaglione
Created October 15, 2011 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaglione/1290148 to your computer and use it in GitHub Desktop.
Save kmaglione/1290148 to your computer and use it in GitHub Desktop.
"use strict";
const MASK_CHAR = "×";
function passwordify(input, maskChar) {
maskChar = maskChar || MASK_CHAR;
function ignore() {}
function mask(node) {
node.textContent = node.textContent.replace(/./g, maskChar);
}
let editor = input.QueryInterface(Ci.nsIDOMNSEditableElement)
.editor;
editor.addEditActionListener({
QueryInterface: XPCOMUtils.generateQI([Ci.nsIEditActionListener]),
DidCreateNode: ignore,
DidDeleteNode: ignore,
DidDeleteSelection: ignore,
DidDeleteText: ignore,
DidInsertNode: ignore,
DidInsertText: mask,
DidJoinNodes: ignore,
DidSplitNode: ignore,
WillCreateNode: ignore,
WillDeleteNode: ignore,
WillDeleteSelection: ignore,
WillDeleteText: ignore,
WillInsertNode: mask,
WillInsertText: ignore,
WillJoinNodes: ignore,
WillSplitNode: ignore
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment