Skip to content

Instantly share code, notes, and snippets.

@kmaglione

kmaglione/stdin.js

Created Oct 15, 2011
Embed
What would you like to do?
"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
You can’t perform that action at this time.