Created
October 15, 2011 21:07
-
-
Save kmaglione/1290148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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