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
/** | |
* The command supertype, which is inherited by subtype commands. | |
* @constructor | |
* @param {type} normalAction The normal action. | |
* @param {type} undoAction The opposite of the normal action. | |
* @param {type} actionValue The value, which will get passed to the action. | |
* @returns {Command} | |
*/ | |
function Command(normalAction, undoAction, actionValue) { | |
this.execute = normalAction; |
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
function xpath(el) { | |
if (typeof el == "string") return document.evaluate(el, document, null, 0, null) | |
if (!el || el.nodeType != 1) return '' | |
if (el.id) return "//*[@id='" + el.id + "']" | |
var sames = [].filter.call(el.parentNode.children, function (x) { return x.tagName == el.tagName }) | |
return xpath(el.parentNode) + '/' + el.tagName.toLowerCase() + (sames.length > 1 ? '['+([].indexOf.call(sames, el)+1)+']' : '') | |
} | |
// Usage: |