rem
stringlengths
0
126k
add
stringlengths
0
441k
context
stringlengths
15
136k
endeffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
endeffect: function(element) { var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity});
endeffect: function(element) { new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0}); },
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity});
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, queue: {scope:'_draggable', position:'end'}, afterFinish: function(){ Draggable._dragging[element] = false } });
endeffect: function(element) { var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity}); },
var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0
var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
endeffect: function(element) { var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity}); },
var nodes = document.getElementsByClassName(accentClass); for (var i = 0; i < nodes.length; i++) { debug.print(label + " node for accent-color = " + nodes[i].nodeName); nodes[i].style.backgroundColor = this.accentColor;
var frames = new Array(document, parent.frames[1].document ); var nodes; debug.print(label + "frames " + frames.length); for (var i = 0; i < frames.length; i++) { debug.print(label + "frame " + i + " = " + frames[i]); nodes = frames[i].getElementsByClassName(accentClass); for (var j = 0; j < nodes.length; j++) { debug.print(label + "node for accent-color = " + nodes[j].nodeName); nodes[j].style.backgroundColor = this.accentColor; }
this.enforce = function() { var label = "PolicyClass.enforce: "; debug.print(label + "titleNode = " + this.titleNode) debug.print(label + "title = " + this.title) if (null != this.titleNode && null != this.title && "" != this.title) { // enforce title Element.update(this.titleNode, ''); this.titleNode.appendChild(document.createTextNode(this.title)); } if (null != this.accentColor && "" != this.accentColor) { // enforce accentColor, on accent class only var nodes = document.getElementsByClassName(accentClass); for (var i = 0; i < nodes.length; i++) { debug.print(label + " node for accent-color = " + nodes[i].nodeName); nodes[i].style.backgroundColor = this.accentColor; } } }
alert(data_str+", "+data_str.length);
function enforceLength(data_str, max_len){ alert(data_str+", "+data_str.length); if(data_str.length>max_len) { data_str = data_str.substring(0, max_len); } return data_str;}
!new GM_PrefManager().getValue("warnedWindowsEditor"))
!prefMan.getValue("warnedWindowsEditor"))
function ensureWindowsAssoc() { if (navigator.userAgent.match(/\bwindows\b/i) && !new GM_PrefManager().getValue("warnedWindowsEditor")) { alert("Hello! Looks like you're on Windows and that this is the your " + "first time editing a user script.\n\nTake this opportunity " + "to verify that you have associated either the .user.js or " + "the .js extension with a text editor on your computer. " + "Otherwise, you may get funny errors.\n\nWhen you're done, " + "come back here and press OK."); prefMan.setValue("warnedWindowsEditor", true); }}
this.form = this.getForm();
this.createForm();
enterEditMode: function() { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.form = this.getForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.focus(this.editField); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } },
if (arguments.length > 1) { Event.stop(arguments[0]); }
enterEditMode: function() { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.form = this.getForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.focus(this.editField); },
Field.scrollFreeActivate(this.editField);
if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
enterEditMode: function(evt) { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.scrollFreeActivate(this.editField); // stop the event to avoid a page refresh in Safari if (evt) { Event.stop(evt); } return false; },
enterEditMode: function() {
enterEditMode: function(evt) {
enterEditMode: function() { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.focus(this.editField); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } },
Field.focus(this.editField);
Field.scrollFreeActivate(this.editField);
enterEditMode: function() { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.focus(this.editField); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } },
if (arguments.length > 1) { Event.stop(arguments[0]);
if (evt) { Event.stop(evt);
enterEditMode: function() { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.focus(this.editField); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } },
return false;
enterEditMode: function() { if (this.saving) return; if (this.editing) return; this.editing = true; this.onEnterEditMode(); if (this.options.externalControl) { Element.hide(this.options.externalControl); } Element.hide(this.element); this.createForm(); this.element.parentNode.insertBefore(this.form, this.element); Field.focus(this.editField); // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } },
return e.innerHTML;
return e.firstChild.nodeValue;
entityDecode : function(s) { var e = document.createElement("div"); e.innerHTML = s; return e.innerHTML; },
var errors = this['errors']; var extra1 = this['extra'];
var errors = this.errors; var extra1 = this.extra;
function eob_as_array (extra2) { var errors = this['errors']; var extra1 = this['extra']; if (! extra2) extra2 = new Array(); var title = eob_get_val('as_array_title', extra2, extra1, 'Please correct the following items:'); /// if there are heading items then we may end up needing a prefix var has_headings; if (title) has_headings = 1; else { for (var i = 0; i < errors.length; i ++) { if (typeof(errors[i]) != 'string') continue; has_headings = 1; break; } } var prefix = eob_get_val('as_array_prefix', extra2, extra1, has_headings ? ' ' : ''); /// get the array ready var arr = new Array(); if (title && title.length) arr[arr.length] = title; /// add the errors var found = new Array(); for (var i = 0; i < errors.length; i ++) { if (typeof(errors[i]) == 'string') { arr[arr.length] = errors[i]; found = new Array(); } else { var text = this.get_error_text(errors[i]); if (found[text]) continue; found[text] = 1; arr[arr.length] = prefix + text; } } return arr;}
for (var key in ret) ret[key] = header + ret[key].join(joiner) + footer;
for (var key in ret) { if (key == 'extend') continue; ret[key] = header + ret[key].join(joiner) + footer; }
function eob_as_hash (extra2) { var errors = this.errors; var extra1 = this.extra; if (! extra2) extra2 = new Array(); var suffix = eob_get_val('as_hash_suffix', extra2, extra1, '_error'); var joiner = eob_get_val('as_hash_join', extra2, extra1, '<br />'); /// now add to the hash var found = new Array(); var ret = new Array(); for (var i = 0; i < errors.length; i ++) { if (typeof(errors[i]) == 'string') continue; if (! errors[i].length) continue; var field = errors[i][0]; var type = errors[i][1]; var field_val = errors[i][2]; var ifs_match = errors[i][3]; if (! field) return alert("Missing field name"); if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (all, N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } var text = this.get_error_text(errors[i]); if (! found[field]) found[field] = new Array(); if (found[field][text]) continue; found[field][text] = 1; field += suffix; if (! ret[field]) ret[field] = new Array(); ret[field].push(text); } /// allow for elements returned as if (joiner) { var header = eob_get_val('as_hash_header', extra2, extra1, ''); var footer = eob_get_val('as_hash_footer', extra2, extra1, ''); for (var key in ret) ret[key] = header + ret[key].join(joiner) + footer; } return ret;}
function eob_as_hash () { var errors = this['errors']; var extra1 = this['extra'];
function eob_as_hash (extra2) { var errors = this.errors; var extra1 = this.extra; if (! extra2) extra2 = new Array();
function eob_as_hash () { var errors = this['errors']; var extra1 = this['extra']; var suffix = eob_get_val('as_hash_suffix', extra2, extra1, '_error'); var joiner = eob_get_val('as_hash_join', extra2, extra1, '<br />'); /// now add to the hash var found = new Array(); var ret = new Array(); for (var i = 0; i < errors.length; i ++) { if (typeof(errors[i]) == 'string') continue; if (! errors[i].length) continue; var field = errors[i][0]; var type = errors[i][1]; var field_val = errors[i][2]; var ifs_match = errors[i][3]; if (! field) return alert("Missing field name"); if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } var text = this.get_error_text(errors[i]); if (! found[field]) found[field] = new Array(); if (found[field][text]) continue; found[field][text] = 1; field += suffix; if (ret[field]) ret[field] = new Array(); ret[field].push(text); } /// allow for elements returned as if (joiner) { var header = eob_get_val('as_hash_header', extra2, extra1, ''); var footer = eob_get_val('as_hash_footer', extra2, extra1, ''); for (var key in ret) ret[key] = header + ret[key].join(joiner) + footer; } return ret;}
if (ret[field]) ret[field] = new Array();
if (! ret[field]) ret[field] = new Array();
function eob_as_hash () { var errors = this['errors']; var extra1 = this['extra']; var suffix = eob_get_val('as_hash_suffix', extra2, extra1, '_error'); var joiner = eob_get_val('as_hash_join', extra2, extra1, '<br />'); /// now add to the hash var found = new Array(); var ret = new Array(); for (var i = 0; i < errors.length; i ++) { if (typeof(errors[i]) == 'string') continue; if (! errors[i].length) continue; var field = errors[i][0]; var type = errors[i][1]; var field_val = errors[i][2]; var ifs_match = errors[i][3]; if (! field) return alert("Missing field name"); if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } var text = this.get_error_text(errors[i]); if (! found[field]) found[field] = new Array(); if (found[field][text]) continue; found[field][text] = 1; field += suffix; if (ret[field]) ret[field] = new Array(); ret[field].push(text); } /// allow for elements returned as if (joiner) { var header = eob_get_val('as_hash_header', extra2, extra1, ''); var footer = eob_get_val('as_hash_footer', extra2, extra1, ''); for (var key in ret) ret[key] = header + ret[key].join(joiner) + footer; } return ret;}
field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) {
field = field.replace(new RegExp('\\$(\\d+)','g'), function (all, N) {
function eob_as_hash (extra2) { var errors = this.errors; var extra1 = this.extra; if (! extra2) extra2 = new Array(); var suffix = eob_get_val('as_hash_suffix', extra2, extra1, '_error'); var joiner = eob_get_val('as_hash_join', extra2, extra1, '<br />'); /// now add to the hash var found = new Array(); var ret = new Array(); for (var i = 0; i < errors.length; i ++) { if (typeof(errors[i]) == 'string') continue; if (! errors[i].length) continue; var field = errors[i][0]; var type = errors[i][1]; var field_val = errors[i][2]; var ifs_match = errors[i][3]; if (! field) return alert("Missing field name"); if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } var text = this.get_error_text(errors[i]); if (! found[field]) found[field] = new Array(); if (found[field][text]) continue; found[field][text] = 1; field += suffix; if (! ret[field]) ret[field] = new Array(); ret[field].push(text); } /// allow for elements returned as if (joiner) { var header = eob_get_val('as_hash_header', extra2, extra1, ''); var footer = eob_get_val('as_hash_footer', extra2, extra1, ''); for (var key in ret) ret[key] = header + ret[key].join(joiner) + footer; } return ret;}
var extra1 = this['extra'];
var extra1 = this.extra;
function eob_as_string (extra2) { var extra1 = this['extra']; if (! extra2) extra2 = new Array(); var joiner = eob_get_val('as_string_join', extra2, extra1, '\n'); var header = eob_get_val('as_string_header', extra2, extra1, ''); var footer = eob_get_val('as_string_footer', extra2, extra1, ''); return header + this.as_array(extra2).join(joiner) + footer;}
var extra = this['extra'];
var extra = this.extra;
function eob_get_error_text (err) { var extra = this['extra']; var field = err[0]; var type = err[1]; var field_val = err[2]; var ifs_match = err[3]; var m; var dig = (m = type.match('(_?\\d+)$')) ? m[1] : ''; var type_lc = type.toLowerCase(); /// allow for delegated field names - only used for defaults if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } /// the the name of this thing var name = (field_val['name']) ? field_val['name'] : "The field " +field; name = name.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); /// type can look like "required" or "required2" or "required100023" /// allow for fallback from required100023_error through required_error var possible_keys = new Array(type + '_error'); if (dig.length) possible_keys.unshift(type + dig + '_error'); /// look in the passed hash or self first for (var i = 0; i < possible_keys.length; i ++) { var key = possible_keys[i]; var ret = field_val[key]; if (! ret) { if (extra[key]) ret = extra[key]; else continue; } ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); ret = ret.replace(new RegExp('\\$field','g'), field); ret = ret.replace(new RegExp('\\$name' ,'g'), name); if (field_val[type + dig] && typeof(field_val[type + dig]) == 'string') ret = ret.replace(new RegExp('\\$value' ,'g'), field_val[type + dig]); return ret; } /// set default messages if (type == 'required' || type == 'required_if') { return name + " is required."; } else if (type == 'min_values') { var n = field_val["min_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had less than "+n+" "+values+"."; } else if (type == 'max_values') { var n = field_val["max_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had more than "+n+" "+values+"."; } else if (type == 'enum') { return name + " is not in the given list."; } else if (type == 'equals') { var field2 = field_val["equals" + dig]; var name2 = field_val["equals" +dig+ "_name"]; if (! name2) name2 = "the field " +field2; name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); return name + " did not equal " + name2 +"."; } else if (type == 'min_len') { var n = field_val["min_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was less than "+n+" "+chars+"."; } else if (type == 'max_len') { var n = field_val["max_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was more than "+n+" "+chars+"."; } else if (type == 'match') { return name + " contains invalid characters."; } else if (type == 'compare') { return name + " did not fit comparison."; } else if (type == 'type') { var _type = field_val["type"+dig]; return name + " did not match type "+_type+"."; } return alert("Missing error on field "+field+" for type "+type+dig);}
field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) {
field = field.replace(new RegExp('\\$(\\d+)','g'), function (all, N) {
function eob_get_error_text (err) { var extra = this.extra; var field = err[0]; var type = err[1]; var field_val = err[2]; var ifs_match = err[3]; var m; var dig = (m = type.match('(_?\\d+)$')) ? m[1] : ''; var type_lc = type.toLowerCase(); /// allow for delegated field names - only used for defaults if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } /// the the name of this thing var name = (field_val['name']) ? field_val['name'] : "The field " +field; name = name.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); /// type can look like "required" or "required2" or "required100023" /// allow for fallback from required100023_error through required_error var possible_keys = new Array(type + '_error'); if (dig.length) possible_keys.unshift(type + dig + '_error'); /// look in the passed hash or self first for (var i = 0; i < possible_keys.length; i ++) { var key = possible_keys[i]; var ret = field_val[key]; if (! ret) { if (extra[key]) ret = extra[key]; else continue; } ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); ret = ret.replace(new RegExp('\\$field','g'), field); ret = ret.replace(new RegExp('\\$name' ,'g'), name); if (field_val[type + dig] && typeof(field_val[type + dig]) == 'string') ret = ret.replace(new RegExp('\\$value' ,'g'), field_val[type + dig]); return ret; } /// set default messages if (type == 'required' || type == 'required_if') { return name + " is required."; } else if (type == 'min_values') { var n = field_val["min_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had less than "+n+" "+values+"."; } else if (type == 'max_values') { var n = field_val["max_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had more than "+n+" "+values+"."; } else if (type == 'min_in_set') { var set = field_val["min_in_set" + dig]; return "Not enough fields were chosen from the set ("+set+")"; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'max_in_set') { var set = field_val["max_in_set" + dig]; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'enum') { return name + " is not in the given list."; } else if (type == 'equals') { var field2 = field_val["equals" + dig]; var name2 = field_val["equals" +dig+ "_name"]; if (! name2) name2 = "the field " +field2; name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); return name + " did not equal " + name2 +"."; } else if (type == 'min_len') { var n = field_val["min_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was less than "+n+" "+chars+"."; } else if (type == 'max_len') { var n = field_val["max_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was more than "+n+" "+chars+"."; } else if (type == 'match') { return name + " contains invalid characters."; } else if (type == 'compare') { return name + " did not fit comparison."; } else if (type == 'type') { var _type = field_val["type"+dig]; return name + " did not match type "+_type+"."; } else if (type == 'custom_js') { return name + " did not match custom_js"+dig+" check."; } return alert("Missing error on field "+field+" for type "+type+dig);}
name = name.replace(new RegExp('\\$(\\d+)','g'), function (N) {
name = name.replace(new RegExp('\\$(\\d+)','g'), function (all, N) {
function eob_get_error_text (err) { var extra = this.extra; var field = err[0]; var type = err[1]; var field_val = err[2]; var ifs_match = err[3]; var m; var dig = (m = type.match('(_?\\d+)$')) ? m[1] : ''; var type_lc = type.toLowerCase(); /// allow for delegated field names - only used for defaults if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } /// the the name of this thing var name = (field_val['name']) ? field_val['name'] : "The field " +field; name = name.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); /// type can look like "required" or "required2" or "required100023" /// allow for fallback from required100023_error through required_error var possible_keys = new Array(type + '_error'); if (dig.length) possible_keys.unshift(type + dig + '_error'); /// look in the passed hash or self first for (var i = 0; i < possible_keys.length; i ++) { var key = possible_keys[i]; var ret = field_val[key]; if (! ret) { if (extra[key]) ret = extra[key]; else continue; } ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); ret = ret.replace(new RegExp('\\$field','g'), field); ret = ret.replace(new RegExp('\\$name' ,'g'), name); if (field_val[type + dig] && typeof(field_val[type + dig]) == 'string') ret = ret.replace(new RegExp('\\$value' ,'g'), field_val[type + dig]); return ret; } /// set default messages if (type == 'required' || type == 'required_if') { return name + " is required."; } else if (type == 'min_values') { var n = field_val["min_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had less than "+n+" "+values+"."; } else if (type == 'max_values') { var n = field_val["max_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had more than "+n+" "+values+"."; } else if (type == 'min_in_set') { var set = field_val["min_in_set" + dig]; return "Not enough fields were chosen from the set ("+set+")"; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'max_in_set') { var set = field_val["max_in_set" + dig]; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'enum') { return name + " is not in the given list."; } else if (type == 'equals') { var field2 = field_val["equals" + dig]; var name2 = field_val["equals" +dig+ "_name"]; if (! name2) name2 = "the field " +field2; name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); return name + " did not equal " + name2 +"."; } else if (type == 'min_len') { var n = field_val["min_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was less than "+n+" "+chars+"."; } else if (type == 'max_len') { var n = field_val["max_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was more than "+n+" "+chars+"."; } else if (type == 'match') { return name + " contains invalid characters."; } else if (type == 'compare') { return name + " did not fit comparison."; } else if (type == 'type') { var _type = field_val["type"+dig]; return name + " did not match type "+_type+"."; } else if (type == 'custom_js') { return name + " did not match custom_js"+dig+" check."; } return alert("Missing error on field "+field+" for type "+type+dig);}
ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (N) {
ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (all, N) {
function eob_get_error_text (err) { var extra = this.extra; var field = err[0]; var type = err[1]; var field_val = err[2]; var ifs_match = err[3]; var m; var dig = (m = type.match('(_?\\d+)$')) ? m[1] : ''; var type_lc = type.toLowerCase(); /// allow for delegated field names - only used for defaults if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } /// the the name of this thing var name = (field_val['name']) ? field_val['name'] : "The field " +field; name = name.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); /// type can look like "required" or "required2" or "required100023" /// allow for fallback from required100023_error through required_error var possible_keys = new Array(type + '_error'); if (dig.length) possible_keys.unshift(type + dig + '_error'); /// look in the passed hash or self first for (var i = 0; i < possible_keys.length; i ++) { var key = possible_keys[i]; var ret = field_val[key]; if (! ret) { if (extra[key]) ret = extra[key]; else continue; } ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); ret = ret.replace(new RegExp('\\$field','g'), field); ret = ret.replace(new RegExp('\\$name' ,'g'), name); if (field_val[type + dig] && typeof(field_val[type + dig]) == 'string') ret = ret.replace(new RegExp('\\$value' ,'g'), field_val[type + dig]); return ret; } /// set default messages if (type == 'required' || type == 'required_if') { return name + " is required."; } else if (type == 'min_values') { var n = field_val["min_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had less than "+n+" "+values+"."; } else if (type == 'max_values') { var n = field_val["max_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had more than "+n+" "+values+"."; } else if (type == 'min_in_set') { var set = field_val["min_in_set" + dig]; return "Not enough fields were chosen from the set ("+set+")"; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'max_in_set') { var set = field_val["max_in_set" + dig]; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'enum') { return name + " is not in the given list."; } else if (type == 'equals') { var field2 = field_val["equals" + dig]; var name2 = field_val["equals" +dig+ "_name"]; if (! name2) name2 = "the field " +field2; name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); return name + " did not equal " + name2 +"."; } else if (type == 'min_len') { var n = field_val["min_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was less than "+n+" "+chars+"."; } else if (type == 'max_len') { var n = field_val["max_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was more than "+n+" "+chars+"."; } else if (type == 'match') { return name + " contains invalid characters."; } else if (type == 'compare') { return name + " did not fit comparison."; } else if (type == 'type') { var _type = field_val["type"+dig]; return name + " did not match type "+_type+"."; } else if (type == 'custom_js') { return name + " did not match custom_js"+dig+" check."; } return alert("Missing error on field "+field+" for type "+type+dig);}
name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (N) {
name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (all, N) {
function eob_get_error_text (err) { var extra = this.extra; var field = err[0]; var type = err[1]; var field_val = err[2]; var ifs_match = err[3]; var m; var dig = (m = type.match('(_?\\d+)$')) ? m[1] : ''; var type_lc = type.toLowerCase(); /// allow for delegated field names - only used for defaults if (field_val['delegate_error']) { field = field_val['delegate_error']; field = field.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); } /// the the name of this thing var name = (field_val['name']) ? field_val['name'] : "The field " +field; name = name.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); /// type can look like "required" or "required2" or "required100023" /// allow for fallback from required100023_error through required_error var possible_keys = new Array(type + '_error'); if (dig.length) possible_keys.unshift(type + dig + '_error'); /// look in the passed hash or self first for (var i = 0; i < possible_keys.length; i ++) { var key = possible_keys[i]; var ret = field_val[key]; if (! ret) { if (extra[key]) ret = extra[key]; else continue; } ret = ret.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); ret = ret.replace(new RegExp('\\$field','g'), field); ret = ret.replace(new RegExp('\\$name' ,'g'), name); if (field_val[type + dig] && typeof(field_val[type + dig]) == 'string') ret = ret.replace(new RegExp('\\$value' ,'g'), field_val[type + dig]); return ret; } /// set default messages if (type == 'required' || type == 'required_if') { return name + " is required."; } else if (type == 'min_values') { var n = field_val["min_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had less than "+n+" "+values+"."; } else if (type == 'max_values') { var n = field_val["max_values" + dig]; var values = (n == 1) ? 'value' : 'values'; return name + " had more than "+n+" "+values+"."; } else if (type == 'min_in_set') { var set = field_val["min_in_set" + dig]; return "Not enough fields were chosen from the set ("+set+")"; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'max_in_set') { var set = field_val["max_in_set" + dig]; return "Too many fields were chosen from the set ("+set+")"; } else if (type == 'enum') { return name + " is not in the given list."; } else if (type == 'equals') { var field2 = field_val["equals" + dig]; var name2 = field_val["equals" +dig+ "_name"]; if (! name2) name2 = "the field " +field2; name2 = name2.replace(new RegExp('\\$(\\d+)','g'), function (N) { if (typeof(ifs_match) != 'object' || typeof(ifs_match[N]) == 'undefined') return '' return ifs_match[N]; }); return name + " did not equal " + name2 +"."; } else if (type == 'min_len') { var n = field_val["min_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was less than "+n+" "+chars+"."; } else if (type == 'max_len') { var n = field_val["max_len"+dig]; var chars = (n == 1) ? 'character' : 'characters'; return name + " was more than "+n+" "+chars+"."; } else if (type == 'match') { return name + " contains invalid characters."; } else if (type == 'compare') { return name + " did not fit comparison."; } else if (type == 'type') { var _type = field_val["type"+dig]; return name + " did not match type "+_type+"."; } else if (type == 'custom_js') { return name + " did not match custom_js"+dig+" check."; } return alert("Missing error on field "+field+" for type "+type+dig);}
graphics_box_displayed=0;
function erase_graphic_box(){ draw_line(topline+graphics_box_displayed-edit_top);}
this.log(message, "error");
this.log("error", message);
error: function(message) { this.log(message, "error"); },
errorCallback = function (pb) { window.location = window.location.href.split('op=')[0] +'op=error';
var errorCallback = function (pb) { var div = document.createElement('p'); div.className = 'error'; div.innerHTML = 'An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the <a href="update.php?op=error">update summary</a>'; $('progress').insertBefore(div, $('progress').firstChild); $('wait').style.display = 'none';
errorCallback = function (pb) { window.location = window.location.href.split('op=')[0] +'op=error'; }
function escapebackslashes( str ){ return str.replace(/\\/g, '\\\\'); }
function escapebackslashes( str ){ return str.replace(/\\[^']/g, '\\\\'); }
function escapebackslashes( str ){ return str.replace(/\\/g, '\\\\'); }
function escapebackslashes( str ){ return str.replace(/\\[^']/g, '\\\\'); }
function escapebackslashes( str ){ return str.replace(/\\/g, '\\\\'); }
function escapebackslashes( str ){ return str.replace(/\\[^']/g, '\\\\'); }
tmp = tmp.replace("&", "&amp;"); tmp = tmp.replace("<", "&lt;"); tmp = tmp.replace(">", "&gt;"); tmp = tmp.replace(" ", "&nbsp;"); tmp = tmp.replace("\n", "<br />"); tmp = tmp.replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp");
tmp = tmp.replace(/&/g, "&amp;"); tmp = tmp.replace(/</g, "&lt;"); tmp = tmp.replace(/>/g, "&gt;"); tmp = tmp.replace(/ /g, "&nbsp;"); tmp = tmp.replace(/\n/g, "<br />"); tmp = tmp.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp");
function escapeHTML(s) { var tmp = s; tmp = tmp.replace("&", "&amp;"); tmp = tmp.replace("<", "&lt;"); tmp = tmp.replace(">", "&gt;"); tmp = tmp.replace(" ", "&nbsp;"); tmp = tmp.replace("\n", "<br />"); tmp = tmp.replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp"); return tmp; }
evalFunc : function(f, idx, a) {
evalFunc : function(f, idx, a, o) {
evalFunc : function(f, idx, a) { var s = '(', i; for (i=idx; i<a.length; i++) { s += 'a[' + i + ']'; if (i < a.length-1) s += ','; } s += ');'; return eval("f" + s); },
return eval("f" + s);
return o ? eval("o." + f + s) : eval("f" + s);
evalFunc : function(f, idx, a) { var s = '(', i; for (i=idx; i<a.length; i++) { s += 'a[' + i + ']'; if (i < a.length-1) s += ','; } s += ');'; return eval("f" + s); },
return eval(this.header('X-JSON'));
return eval('(' + this.header('X-JSON') + ')');
evalJSON: function() { try { return eval(this.header('X-JSON')); } catch (e) {} },
return this.extractScripts().map(eval);
return this.extractScripts().map(function(script) { return eval(script) });
evalScripts: function() { return this.extractScripts().map(eval); },
var scripts = this.transport.responseText.match(/<script[^>]*>([\s\S]*?)<\/script>/gi);
var scripts = this.response.text.match(/<script[^>]*>([\s\S]*?)<\/script>/gi);
evalScripts: function(){ var scripts = this.transport.responseText.match(/<script[^>]*>([\s\S]*?)<\/script>/gi); if (scripts) for (var i = 0; i < scripts.length; i++) eval(scripts[i]); }
}
},
event: function(eventName) { if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); if(this.options[eventName]) this.options[eventName](this); }
function eventHideMenu() { document.onclick = null; if (activeMenu != null) { obj = document.getElementById(activeMenu) obj.style.visibility = "hidden" } }
function eventHideMenu() { document.onclick = null; if (activeMenu != null) { obj = document.getElementById(activeMenu); obj.style.visibility = "hidden"; } }
function eventHideMenu() //hides nav menus and pop ups { document.onclick = null; if (activeMenu != null) { obj = document.getElementById(activeMenu) obj.style.visibility = "hidden" } }
this.getHrefXPathLocator,
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { callForWindow(new RegisterHandler(), contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); callForWindow(handler, browsers[i].contentWindow); } } } function callForWindow(handler, contentWindow) { var documents = getDocuments(contentWindow); for (var i = 0; i < documents.length; i++) { handler.handleDocument(documents[i], contentWindow); } } function RegisterHandler(w) { } RegisterHandler.prototype.handleDocument = function(document, window) { if (!document._Selenium_IDE_listeners) { log.debug("registering event listeners for " + document); function findClickableElement(e, window) { if (!e.tagName) return null; var tagName = e.tagName.toLowerCase(); var type = e.type; if (e.hasAttribute("onclick") || e.hasAttribute("href") || tagName == "button" || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { return e; } else { if (e.parentNode != null) { return findClickableElement(e.parentNode, window); } else { return null; } } } var listeners = { change: function(event) { if (!self.listener.recordingEnabled) return; var tagName = event.target.tagName.toLowerCase(); log.debug("change event: tagName=" + tagName); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label.replace(/^\s*(.*?)\s*$/, "$1"); self.listener.addCommand("select", self.getLocator(window, event.target), value, window); } else if (('input' == tagName && ('text' == type || 'password' == type || 'file' == type)) || 'textarea' == tagName) { self.listener.addCommand("type", self.getLocator(window, event.target), event.target.value, window); } else { log.debug("ignoring change event: tagName=" + tagName); } }, click: function(event) { if (!self.listener.recordingEnabled) return; if (event.button == 0) { var clickable = findClickableElement(event.target); if (clickable) { self.listener.addCommand("click", self.getLocator(window, clickable), '', window); } } }, mousedown: function(event) { self.listener.clickedElement = event.target; } } for (name in listeners) { document.addEventListener(name, listeners[name], false); } document._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.handleDocument = function(document, window) { //window.removeEventListener(window, e._changeEventListener, false); if (document._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = document._Selenium_IDE_listeners; for (name in listeners) { document.removeEventListener(name, listeners[name], false); } delete document._Selenium_IDE_listeners; } delete window._locator_pageBot; }; this.getLocator = function(window, e) { var locatorDetectors = [this.getLinkLocator, this.getIDLocator, this.getNameLocator, this.getLinkXPathLocator, this.getAttributesXPathLocator, this.getPositionXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = this.getPageBot(window); log.debug("getLocator for element " + e); for (var i = 0; i < locatorDetectors.length; i++) { locator = locatorDetectors[i].call(this, e, pageBot); if (locator) { log.debug("locator=" + locator); // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); } } } return "LOCATOR_DETECTION_FAILED"; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
new RegisterHandler().handleWindow(contentWindow);
callForWindow(new RegisterHandler(), contentWindow);
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
handler.handleWindow(browsers[i].contentWindow); } } }
callForWindow(handler, browsers[i].contentWindow); } } } function callForWindow(handler, contentWindow) { var documents = getDocuments(contentWindow); for (var i = 0; i < documents.length; i++) { handler.handleDocument(documents[i], contentWindow); } }
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners");
RegisterHandler.prototype.handleDocument = function(document, window) { if (!document._Selenium_IDE_listeners) { log.debug("registering event listeners for " + document); function findClickableElement(e, window) { var tagName = e.tagName.toLowerCase(); var type = e.type; if (e.hasAttribute("onclick") || e.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { return e; } else { if (e.parentNode != null) { return findClickableElement(e.parentNode, window); } else { return null; } } }
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } }
var clickable = findClickableElement(event.target); if (clickable) { self.listener.addCommand("click", getLocator(window, clickable), '', window); } },
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
window.addEventListener(name, listeners[name], false);
document.addEventListener(name, listeners[name], false);
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
window._Selenium_IDE_listeners = listeners;
document._Selenium_IDE_listeners = listeners;
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) {
DeregisterHandler.prototype.handleDocument = function(document, window) {
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
if (window._Selenium_IDE_listeners) {
if (document._Selenium_IDE_listeners) {
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
var listeners = window._Selenium_IDE_listeners;
var listeners = document._Selenium_IDE_listeners;
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners;
document.removeEventListener(name, listeners[name], false); } delete document._Selenium_IDE_listeners;
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { new RegisterHandler().handleWindow(contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { log.debug("forEachBrowser"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); log.debug("window=" + window); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { log.debug("browser=" + browsers[i]); handler.handleWindow(browsers[i].contentWindow); } } } function RegisterHandler(w) { } RegisterHandler.prototype.handleWindow = function(window) { if (!window._Selenium_IDE_listeners) { log.debug("registering event listeners"); var listeners = { change: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if ('select' == tagName) { var label = event.target.options[event.target.selectedIndex].innerHTML; var value = "label=" + label; self.listener.addCommand("select", getLocator(window, event.target), value, window); } else if ('text' == type || 'password' == type || 'file' == type) { self.listener.addCommand("type", getLocator(window, event.target), event.target.value, window); } }, click: function(event) { var tagName = event.target.tagName.toLowerCase(); var type = event.target.type; if (event.target.hasAttribute("onclick") || event.target.hasAttribute("href") || (tagName == "input" && (type == "submit" || type == "button" || type == "image" || type == "radio" || type == "checkbox"))) { self.listener.addCommand("click", getLocator(window, event.target), '', window); } } } for (name in listeners) { window.addEventListener(name, listeners[name], false); } window._Selenium_IDE_listeners = listeners; return true; } else { return false; } }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { //window.removeEventListener(window, e._changeEventListener, false); if (window._Selenium_IDE_listeners) { log.debug("unregistering event listeners"); var listeners = window._Selenium_IDE_listeners; for (name in listeners) { window.removeEventListener(window, listeners[name], false); } delete window._Selenium_IDE_listeners; } delete window._locator_pageBot; }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = [getLinkLocator, getIDLocator, getNameLocator, getOptimizedXPathLocator]; var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getLinkLocator(e) { if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } } return ""; } function getIDLocator(e) { if (e.id != '') { return "id=" + e.id; } return ''; } function getNameLocator(e) { if (e.name != '') { return e.name; } return ''; } function getOptimizedXPathLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if (e.type == 'checkbox' || e.type == 'radio') { return xpathLocator(e, 'name,value'); } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'A') { var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function elementXPath(node, conditions) { var i; if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
} catch (e) { log.warn("findElement error: " + e);
} catch (error) { log.warn("findElement error: " + error + ", node=" + e + ", locator=" + locator);
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { forEachInput(new RegisterHandler(), contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { handler.handleWindow(browsers[i].contentWindow); forEachInput(handler, browsers[i].contentWindow); } } } function forEachInput(handler, window) { const documents = getDocuments(window, new Array()); for (var i = 0; i < documents.length; i++) { if (handler.doHandleDocument(documents[i])) { parseDocument(documents[i], handler, window); } } } function parseDocument(doc, interceptor, window) { findElement(doc, "input", function(e) { if (e.type == 'text' || e.type == 'password') { interceptor.handleListener("change", "type", e, window); } if (e.type == 'submit' || e.type == 'button' || e.type == 'image' || e.type == 'radio' || e.type == 'checkbox') { interceptor.handleListener("click", "click", e, window); } }); findElement(doc, "textarea", function(e) { interceptor.handleListener("change", "type", e, window); }); findElement(doc, "select", function(e) { interceptor.handleListener("change", "select", e, window); }); findElement(doc, "a", function(e) { if (e.href != null) { interceptor.handleListener("click", "click", e, window); } }); } function findElement(doc, name, handler) { var elements = doc.getElementsByTagName(name); var e; for (var i = 0; i < elements.length; i++) { handler.apply(this, new Array(elements[i])); } } function RegisterHandler() { } RegisterHandler.prototype.doHandleDocument = function(doc) { if (!doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = true; return true; } else { return false; } }; RegisterHandler.prototype.handleWindow = function(window) { }; RegisterHandler.prototype.handleListener = function(event, command, e, window) { e._recorder_listener = function() { var value = ''; if (command == 'select') { var label = e.options[e.selectedIndex].innerHTML; value = "label=" + label; } else if (command == 'type') { value = e.value; } self.listener.addCommand(command, getLocator(window, e), value, window); }; e.addEventListener(event, e._recorder_listener, false); }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { window._locator_pageBot = null; }; DeregisterHandler.prototype.handleListener = function(event, command, e, window) { e.removeEventListener(event, e._recorder_listener, false); }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = new Array(getIDLocator, getVisibleLocator, getVisible2Locator, getNameLocator); var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (e) { log.warn("findElement error: " + e); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getVisibleLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if ((e.type == 'text' || e.type == 'password') && e.name != '') { return e.name; } else if (e.type == 'checkbox' || e.type == 'radio') { if (e.name != '' && e.value != '') { return xpathLocator(e, 'name,value'); } else if (e.name != '') { return e.name; } } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'TEXTAREA') { return e.name; } else if (e.nodeName == 'SELECT') { return e.name; } else if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } //return "//a[@href='" + e.href + "']"; } return ""; } function getVisible2Locator(e) { var i; if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function getNameLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.name != '') { return "name=" + e.name; } } return ""; } function getIDLocator(e) { var i; if (e.id != '') { return "id=" + e.id; } return ''; } function elementXPath(node, conditions) { var i; for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value;
if (node.attributes) { for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; }
function EventManager(listener) { this.listener = listener; var log = new Log("EventManager"); var self = this; this.startForAllBrowsers = function() { forEachBrowser(new RegisterHandler()); } this.startForContentWindow = function(contentWindow) { forEachInput(new RegisterHandler(), contentWindow); } this.stopForAllBrowsers = function() { forEachBrowser(new DeregisterHandler()); } function forEachBrowser(handler) { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var e = wm.getEnumerator("navigator:browser"); var window; var browsers; var i; while (e.hasMoreElements()) { window = e.getNext(); browsers = window.getBrowser().browsers; for (i = 0; i < browsers.length; i++) { handler.handleWindow(browsers[i].contentWindow); forEachInput(handler, browsers[i].contentWindow); } } } function forEachInput(handler, window) { const documents = getDocuments(window, new Array()); for (var i = 0; i < documents.length; i++) { if (handler.doHandleDocument(documents[i])) { parseDocument(documents[i], handler, window); } } } function parseDocument(doc, interceptor, window) { findElement(doc, "input", function(e) { if (e.type == 'text' || e.type == 'password') { interceptor.handleListener("change", "type", e, window); } if (e.type == 'submit' || e.type == 'button' || e.type == 'image' || e.type == 'radio' || e.type == 'checkbox') { interceptor.handleListener("click", "click", e, window); } }); findElement(doc, "textarea", function(e) { interceptor.handleListener("change", "type", e, window); }); findElement(doc, "select", function(e) { interceptor.handleListener("change", "select", e, window); }); findElement(doc, "a", function(e) { if (e.href != null) { interceptor.handleListener("click", "click", e, window); } }); } function findElement(doc, name, handler) { var elements = doc.getElementsByTagName(name); var e; for (var i = 0; i < elements.length; i++) { handler.apply(this, new Array(elements[i])); } } function RegisterHandler() { } RegisterHandler.prototype.doHandleDocument = function(doc) { if (!doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = true; return true; } else { return false; } }; RegisterHandler.prototype.handleWindow = function(window) { }; RegisterHandler.prototype.handleListener = function(event, command, e, window) { e._recorder_listener = function() { var value = ''; if (command == 'select') { var label = e.options[e.selectedIndex].innerHTML; value = "label=" + label; } else if (command == 'type') { value = e.value; } self.listener.addCommand(command, getLocator(window, e), value, window); }; e.addEventListener(event, e._recorder_listener, false); }; function DeregisterHandler() { } DeregisterHandler.prototype.doHandleDocument = function(doc) { if (doc.registeredSeleniumIDE) { doc.registeredSeleniumIDE = false; return true; } else { return false; } }; DeregisterHandler.prototype.handleWindow = function(window) { window._locator_pageBot = null; }; DeregisterHandler.prototype.handleListener = function(event, command, e, window) { e.removeEventListener(event, e._recorder_listener, false); }; function getPageBot(window) { var pageBot = window._locator_pageBot; if (pageBot == null) { pageBot = PageBot.createForWindow(window); window._locator_pageBot = pageBot; } return pageBot; } function getLocator(window, e) { var locatorDetectors = new Array(getIDLocator, getVisibleLocator, getVisible2Locator, getNameLocator); var i = 0; var xpathLevel = 0; var maxLevel = 10; var locator; var pageBot = getPageBot(window); while (true) { if (i < locatorDetectors.length) { locator = locatorDetectors[i].call(this, e); i++; } else { locator = getAbsoluteXPathLocator(e, xpathLevel); xpathLevel++; } log.debug("locator=" + locator); if (locator != '') { // test the locator try { if (e == pageBot.findElement(locator)) { return locator; } } catch (e) { log.warn("findElement error: " + e); //break; } } else if (xpathLevel > 0) { break; } if (xpathLevel >= maxLevel) { break; } } return "LOCATOR_DETECTION_FAILED"; } function xpathLocator(e, attributes) { var att; var locator = '//' + e.nodeName.toLowerCase() + '['; var first = true; var i; var attributeArray = attributes.split(','); for (i = 0; i < attributeArray.length; i++) { att = attributeArray[i]; if (!first) locator += ' and '; locator += '@' + att + "='" + e[att] + "'"; first = false; } locator += ']'; return locator; } function encodeConditions(atts) { var att; var result = ''; var first = true; var count = 0; for (att in atts) { if (!first) result += ' and '; result += att + '=\"' + atts[att].replace(/\"/g, "&quot;") + '\"'; first = false; count++; } if (result != '') { if (count == 1 && atts['position()'] != null) { return '[' + atts['position()'] + ']'; } else { return '[' + result + ']'; } } else { return ''; } } function getVisibleLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.type == 'button' || e.type == 'submit') { return xpathLocator(e, 'type,value'); } else if (e.type == 'image' && e.alt != '') { return xpathLocator(e, 'type,alt'); } else if ((e.type == 'text' || e.type == 'password') && e.name != '') { return e.name; } else if (e.type == 'checkbox' || e.type == 'radio') { if (e.name != '' && e.value != '') { return xpathLocator(e, 'name,value'); } else if (e.name != '') { return e.name; } } else { return "//input[@type='" + e.type + "']"; } } else if (e.nodeName == 'TEXTAREA') { return e.name; } else if (e.nodeName == 'SELECT') { return e.name; } else if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "link=" + e.textContent; } var nodeList = e.childNodes; for (i = 0; i < nodeList.length; i++) { var node = nodeList[i]; if (node.nodeName == 'IMG' && node.alt != '') { return "//a[img/@alt='" + node.alt + "']"; } } //return "//a[@href='" + e.href + "']"; } return ""; } function getVisible2Locator(e) { var i; if (e.nodeName == 'A') { var text = e.textContent; if (!text.match(/^\s*$/)) { return "//a[contains(text(),'" + text.replace(/^\s+/,'').replace(/\s+$/,'') + "')]"; } } return ""; } function getNameLocator(e) { var i; if (e.nodeName == 'INPUT') { if (e.name != '') { return "name=" + e.name; } } return ""; } function getIDLocator(e) { var i; if (e.id != '') { return "id=" + e.id; } return ''; } function elementXPath(node, conditions) { var i; for (i = 0; i < node.attributes.length; i++) { var att = node.attributes[i]; if (att.name == 'name' || att.name == 'value' || att.name == 'id' || att.name == 'style' || att.name == 'action' || att.name == 'onclick' || att.name == 'href') { conditions['@' + att.name] = att.value; } } return node.nodeName.toLowerCase() + encodeConditions(conditions); } function getAbsoluteXPathLocator(e, level) { var lastElementPath = elementXPath(e, new Object()); var prevPath = ''; var path = '/' + lastElementPath + prevPath; var node = e; var i, j; for (i = 0; i < level; i++) { var parent = node.parentNode; //sr_debug("parent=" + parent); if (parent == null) { return ""; } var conditions = new Object(); var childNodes = parent.getElementsByTagName(node.nodeName); if (childNodes.length > 1) { //sr_debug("childNodes.length=" + childNodes.length); for (j = 0; j < childNodes.length; j++) { if (childNodes[j] == node) { conditions['position()'] = '' + (j + 1); //sr_debug("position=" + j); } } } lastElementPath = elementXPath(node, conditions); prevPath = '/' + lastElementPath + prevPath; path = "/" + elementXPath(parent, new Object()) + prevPath; node = parent; } return "/" + path; } function getDocuments(frame) { var documents = new Array(); var frames = frame.frames; documents.push(frame.document); for (var i = 0; i < frames.length; i++) { documents = documents.concat(getDocuments(frames[i])); } return documents; } function getBrowser() { var browser = opener.getBrowser(); return browser; }}
function eventShowMenu(e) { if (activeMenu != null) eventHideMenu() activeMenu = "menu"+this.id.substring(3,this.id.length) obj = document.getElementById(activeMenu) if (obj) obj.style.visibility = "visible" if (document.all) document.onclick = eventHideMenu; event.cancelBubble=true }
function eventShowMenu(e) { if (activeMenu != null) eventHideMenu(); activeMenu = "menu"+this.id.substring(3,this.id.length) obj = document.getElementById(activeMenu); if (obj != null) obj.style.visibility = "visible"; if (document.all) document.onclick = eventHideMenu; if (window.event != null) window.event.cancelBubble=true; }
function eventShowMenu(e) //turns on the display for nav menus { if (activeMenu != null) eventHideMenu() activeMenu = "menu"+this.id.substring(3,this.id.length) obj = document.getElementById(activeMenu) if (obj) obj.style.visibility = "visible" if (document.all) document.onclick = eventHideMenu; event.cancelBubble=true }
willExecuteStatement(sourceId, line);
updateFunctionStack(); jumpToLine(sourceId, line);
function exceptionWasRaised(sourceId, line){ pause(); willExecuteStatement(sourceId, line);}
tinyMCE.importPluginLanguagePack('advhr','en,tr,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_AdvancedHRPlugin={getInfo:function(){return{longname:'Advanced HR',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('advhr');var TinyMCE_AdvancedHRPlugin={getInfo:function(){return{longname:'Advanced HR',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('advhr','en,tr,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_AdvancedHRPlugin={getInfo:function(){return{longname:'Advanced HR',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_advhr.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion}},getControlHTML:function(cn){switch(cn){case"advhr":return tinyMCE.getButtonHTML(cn,'lang_insert_advhr_desc','{$pluginurl}/images/advhr.gif','mceAdvancedHr');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceAdvancedHr":var template=new Array();template['file']='../../plugins/advhr/rule.htm';template['width']=250;template['height']=160;template['width']+=tinyMCE.getLang('lang_advhr_delta_width',0);template['height']+=tinyMCE.getLang('lang_advhr_delta_height',0);var size="",width="",noshade="";if(tinyMCE.selectedElement!=null&&tinyMCE.selectedElement.nodeName.toLowerCase()=="hr"){tinyMCE.hrElement=tinyMCE.selectedElement;if(tinyMCE.hrElement){size=tinyMCE.hrElement.getAttribute('size')?tinyMCE.hrElement.getAttribute('size'):"";width=tinyMCE.hrElement.getAttribute('width')?tinyMCE.hrElement.getAttribute('width'):"";noshade=tinyMCE.hrElement.getAttribute('noshade')?tinyMCE.hrElement.getAttribute('noshade'):"";}tinyMCE.openWindow(template,{editor_id:editor_id,size:size,width:width,noshade:noshade,mceDo:'update'});}else{if(tinyMCE.isMSIE){tinyMCE.execInstanceCommand(editor_id,'mceInsertContent',false,'<hr />');}else{tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",size:size,width:width,noshade:noshade,mceDo:'insert'});}}return true;}return false;},handleNodeChange:function(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){if(node==null)return;do{if(node.nodeName=="HR"){tinyMCE.switchClass(editor_id+'_advhr','mceButtonSelected');return true;}}while((node=node.parentNode));tinyMCE.switchClass(editor_id+'_advhr','mceButtonNormal');return true;}};tinyMCE.addPlugin("advhr",TinyMCE_AdvancedHRPlugin);
case "mceForeColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = tinyMCE.getAttrib(elm, "color"); if (inputColor == '') inputColor = elm.style.color; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
case "forecolor": var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm; TinyMCE_AdvancedTheme._hideMenus(editor_id); if (!fcp.exists()) { fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); elm = fcp.getElement(); elm._editor_id = editor_id; elm._command = "forecolor"; elm._switchId = editor_id + "_forecolor"; tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); } img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0]; p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); fcp.moveTo(p.absLeft, p.absTop); fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor; fcp.show(); return false; case "forecolorMenu": TinyMCE_AdvancedTheme._hideMenus(editor_id); var ml = new TinyMCE_Layer(editor_id + '_fcMenu'); if (!ml.exists()) ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor')); tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus'); ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl'); ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); if (tinyMCE.isOpera) ml.moveBy(0, -2); ml.show();
execCommand : function(editor_id, element, command, user_interface, value) { switch (command) { case "mceLink": var inst = tinyMCE.getInstanceById(editor_id); var doc = inst.getDoc(); var selectedText = ""; if (tinyMCE.isMSIE) { var rng = doc.selection.createRange(); selectedText = rng.text; } else selectedText = inst.getSel().toString(); if (!tinyMCE.linkElement) { if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) return true; } var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") tinyMCE.linkElement = tinyMCE.selectedElement; // Is anchor not a link if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") tinyMCE.linkElement = null; if (tinyMCE.linkElement) { href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); // Try old onclick to if copy/pasted content if (onclick == "") onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); onclick = tinyMCE.cleanupEventStr(onclick); href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); // Use mce_href if defined mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); if (mceRealHref != "") { href = mceRealHref; if (tinyMCE.getParam('convert_urls')) href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); } action = "update"; } var template = new Array(); template['file'] = 'link.htm'; template['width'] = 310; template['height'] = 200; // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); if (inst.settings['insertlink_callback']) { var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);"); if (returnVal && returnVal['href']) TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']); } else { tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"}); } return true; case "mceImage": var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; var title = "", onmouseover = "", onmouseout = "", action = "insert"; var img = tinyMCE.imgElement; var inst = tinyMCE.getInstanceById(editor_id); if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { img = tinyMCE.selectedElement; tinyMCE.imgElement = img; } if (img) { // Is it a internal MCE visual aid image, then skip this one. if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) return true; src = tinyMCE.getAttrib(img, 'src'); alt = tinyMCE.getAttrib(img, 'alt'); // Try polling out the title if (alt == "") alt = tinyMCE.getAttrib(img, 'title'); // Fix width/height attributes if the styles is specified if (tinyMCE.isGecko) { var w = img.style.width; if (w != null && w != "") img.setAttribute("width", w); var h = img.style.height; if (h != null && h != "") img.setAttribute("height", h); } border = tinyMCE.getAttrib(img, 'border'); hspace = tinyMCE.getAttrib(img, 'hspace'); vspace = tinyMCE.getAttrib(img, 'vspace'); width = tinyMCE.getAttrib(img, 'width'); height = tinyMCE.getAttrib(img, 'height'); align = tinyMCE.getAttrib(img, 'align'); onmouseover = tinyMCE.getAttrib(img, 'onmouseover'); onmouseout = tinyMCE.getAttrib(img, 'onmouseout'); title = tinyMCE.getAttrib(img, 'title'); // Is realy specified? if (tinyMCE.isMSIE) { width = img.attributes['width'].specified ? width : ""; height = img.attributes['height'].specified ? height : ""; } //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); // Use mce_src if defined mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); if (mceRealSrc != "") { src = mceRealSrc; if (tinyMCE.getParam('convert_urls')) src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); } //if (onmouseover != "") // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);"); //if (onmouseout != "") // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);"); action = "update"; } var template = new Array(); template['file'] = 'image.htm?src={$src}'; template['width'] = 355; template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0); // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); if (inst.settings['insertimage_callback']) { var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); if (returnVal && returnVal['src']) TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); } else tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"}); return true; case "mceForeColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = tinyMCE.getAttrib(elm, "color"); if (inputColor == '') inputColor = elm.style.color; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor}); return true; case "mceBackColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = elm.style.backgroundColor; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor}); //mceBackColor return true; case "mceColorPicker": if (user_interface) { var template = new Array(); var inputColor = value['document'].getElementById(value['element_id']).value; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; template['close_previous'] = "no"; template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); if (typeof(value['store_selection']) == "undefined") value['store_selection'] = true; tinyMCE.lastColorPickerValue = value; tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor}); } else { var savedVal = tinyMCE.lastColorPickerValue; var elm = savedVal['document'].getElementById(savedVal['element_id']); elm.value = value; if (elm.onchange != null && elm.onchange != '') eval('elm.onchange();'); } return true; case "mceCodeEditor": var template = new Array(); template['file'] = 'source_editor.htm'; template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720)); template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580)); tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); return true; case "mceCharMap": var template = new Array(); template['file'] = 'charmap.htm'; template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0); template['height'] = 250; template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; case "mceInsertAnchor": var template = new Array(); template['file'] = 'anchor.htm'; template['width'] = 320; template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0); template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; case "mceNewDocument": if (confirm(tinyMCE.getLang('lang_newdocument'))) tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' '); return true; } return false; },
case "mceBackColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = elm.style.backgroundColor; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
case "HiliteColor": var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img; TinyMCE_AdvancedTheme._hideMenus(editor_id); if (!bcp.exists()) { bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); elm = bcp.getElement(); elm._editor_id = editor_id; elm._command = "HiliteColor"; elm._switchId = editor_id + "_backcolor"; tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); } img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0]; p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); bcp.moveTo(p.absLeft, p.absTop); bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor; bcp.show(); return false; case "HiliteColorMenu": TinyMCE_AdvancedTheme._hideMenus(editor_id); var ml = new TinyMCE_Layer(editor_id + '_bcMenu'); if (!ml.exists()) ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor')); tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus'); ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl'); ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); if (tinyMCE.isOpera) ml.moveBy(0, -2); ml.show();
execCommand : function(editor_id, element, command, user_interface, value) { switch (command) { case "mceLink": var inst = tinyMCE.getInstanceById(editor_id); var doc = inst.getDoc(); var selectedText = ""; if (tinyMCE.isMSIE) { var rng = doc.selection.createRange(); selectedText = rng.text; } else selectedText = inst.getSel().toString(); if (!tinyMCE.linkElement) { if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) return true; } var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") tinyMCE.linkElement = tinyMCE.selectedElement; // Is anchor not a link if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") tinyMCE.linkElement = null; if (tinyMCE.linkElement) { href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); // Try old onclick to if copy/pasted content if (onclick == "") onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); onclick = tinyMCE.cleanupEventStr(onclick); href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); // Use mce_href if defined mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); if (mceRealHref != "") { href = mceRealHref; if (tinyMCE.getParam('convert_urls')) href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); } action = "update"; } var template = new Array(); template['file'] = 'link.htm'; template['width'] = 310; template['height'] = 200; // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); if (inst.settings['insertlink_callback']) { var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);"); if (returnVal && returnVal['href']) TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']); } else { tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"}); } return true; case "mceImage": var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; var title = "", onmouseover = "", onmouseout = "", action = "insert"; var img = tinyMCE.imgElement; var inst = tinyMCE.getInstanceById(editor_id); if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { img = tinyMCE.selectedElement; tinyMCE.imgElement = img; } if (img) { // Is it a internal MCE visual aid image, then skip this one. if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) return true; src = tinyMCE.getAttrib(img, 'src'); alt = tinyMCE.getAttrib(img, 'alt'); // Try polling out the title if (alt == "") alt = tinyMCE.getAttrib(img, 'title'); // Fix width/height attributes if the styles is specified if (tinyMCE.isGecko) { var w = img.style.width; if (w != null && w != "") img.setAttribute("width", w); var h = img.style.height; if (h != null && h != "") img.setAttribute("height", h); } border = tinyMCE.getAttrib(img, 'border'); hspace = tinyMCE.getAttrib(img, 'hspace'); vspace = tinyMCE.getAttrib(img, 'vspace'); width = tinyMCE.getAttrib(img, 'width'); height = tinyMCE.getAttrib(img, 'height'); align = tinyMCE.getAttrib(img, 'align'); onmouseover = tinyMCE.getAttrib(img, 'onmouseover'); onmouseout = tinyMCE.getAttrib(img, 'onmouseout'); title = tinyMCE.getAttrib(img, 'title'); // Is realy specified? if (tinyMCE.isMSIE) { width = img.attributes['width'].specified ? width : ""; height = img.attributes['height'].specified ? height : ""; } //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); // Use mce_src if defined mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); if (mceRealSrc != "") { src = mceRealSrc; if (tinyMCE.getParam('convert_urls')) src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); } //if (onmouseover != "") // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);"); //if (onmouseout != "") // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);"); action = "update"; } var template = new Array(); template['file'] = 'image.htm?src={$src}'; template['width'] = 355; template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0); // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); if (inst.settings['insertimage_callback']) { var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); if (returnVal && returnVal['src']) TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); } else tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"}); return true; case "mceForeColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = tinyMCE.getAttrib(elm, "color"); if (inputColor == '') inputColor = elm.style.color; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor}); return true; case "mceBackColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = elm.style.backgroundColor; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor}); //mceBackColor return true; case "mceColorPicker": if (user_interface) { var template = new Array(); var inputColor = value['document'].getElementById(value['element_id']).value; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; template['close_previous'] = "no"; template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); if (typeof(value['store_selection']) == "undefined") value['store_selection'] = true; tinyMCE.lastColorPickerValue = value; tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor}); } else { var savedVal = tinyMCE.lastColorPickerValue; var elm = savedVal['document'].getElementById(savedVal['element_id']); elm.value = value; if (elm.onchange != null && elm.onchange != '') eval('elm.onchange();'); } return true; case "mceCodeEditor": var template = new Array(); template['file'] = 'source_editor.htm'; template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720)); template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580)); tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); return true; case "mceCharMap": var template = new Array(); template['file'] = 'charmap.htm'; template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0); template['height'] = 250; template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; case "mceInsertAnchor": var template = new Array(); template['file'] = 'anchor.htm'; template['width'] = 320; template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0); template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; case "mceNewDocument": if (confirm(tinyMCE.getLang('lang_newdocument'))) tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' '); return true; } return false; },
if (tinyMCE.getParam('fullscreen_is_enabled')) { window.opener.tinyMCE.execInstanceCommand(tinyMCE.getParam('fullscreen_editor_id'), 'mceSetContent', false, tinyMCE.getContent(editor_id)); top.close(); } else { tinyMCE.setWindowArg('editor_id', editor_id); var win = window.open(tinyMCE.baseURL + "/plugins/fullscreen/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight); try { win.resizeTo(screen.availWidth, screen.availHeight); } catch (e) {} }
this._toggleFullscreen(tinyMCE.getInstanceById(editor_id));
execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mceFullScreen": if (tinyMCE.getParam('fullscreen_is_enabled')) { // In fullscreen mode window.opener.tinyMCE.execInstanceCommand(tinyMCE.getParam('fullscreen_editor_id'), 'mceSetContent', false, tinyMCE.getContent(editor_id)); top.close(); } else { tinyMCE.setWindowArg('editor_id', editor_id); var win = window.open(tinyMCE.baseURL + "/plugins/fullscreen/fullscreen.htm", "mceFullScreenPopup", "fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight); try { win.resizeTo(screen.availWidth, screen.availHeight); } catch (e) {} } return true; } // Pass to next handler in chain return false; },
tinyMCE.importPluginLanguagePack('fullscreen','en,tr,sv,cs,fr_ca,zh_cn,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_FullScreenPlugin={getInfo:function(){return{longname:'Fullscreen',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('fullscreen');var TinyMCE_FullScreenPlugin={getInfo:function(){return{longname:'Fullscreen',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('fullscreen','en,tr,sv,cs,fr_ca,zh_cn,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_FullScreenPlugin={getInfo:function(){return{longname:'Fullscreen',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_fullscreen.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},getControlHTML:function(cn){switch(cn){case"fullscreen":return tinyMCE.getButtonHTML(cn,'lang_fullscreen_desc','{$pluginurl}/images/fullscreen.gif','mceFullScreen');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceFullScreen":if(tinyMCE.getParam('fullscreen_is_enabled')){window.opener.tinyMCE.execInstanceCommand(tinyMCE.getParam('fullscreen_editor_id'),'mceSetContent',false,tinyMCE.getContent(editor_id));top.close();}else{tinyMCE.setWindowArg('editor_id',editor_id);var win=window.open(tinyMCE.baseURL+"/plugins/fullscreen/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{win.resizeTo(screen.availWidth,screen.availHeight);}catch(e){}}return true;}return false;},handleNodeChange:function(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){if(tinyMCE.getParam('fullscreen_is_enabled'))tinyMCE.switchClass(editor_id+'_fullscreen','mceButtonSelected');return true;}};tinyMCE.addPlugin("fullscreen",TinyMCE_FullScreenPlugin);
var TinyMCE_ZoomPlugin={getInfo:function(){return{longname:'Zoom',author:'Moxiecode Systems',authorurl:'http:
var TinyMCE_ZoomPlugin={getInfo:function(){return{longname:'Zoom',author:'Moxiecode Systems AB',authorurl:'http:
var TinyMCE_ZoomPlugin={getInfo:function(){return{longname:'Zoom',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_zoom.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},getControlHTML:function(control_name){if(!tinyMCE.isMSIE||tinyMCE.isMSIE5_0||tinyMCE.isOpera)return"";switch(control_name){case"zoom":return'<select id="{$editor_id}_zoomSelect" name="{$editor_id}_zoomSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceZoom\',false,this.options[this.selectedIndex].value);" class="mceSelectList">'+'<option value="100%">+ 100%</option>'+'<option value="150%">+ 150%</option>'+'<option value="200%">+ 200%</option>'+'<option value="250%">+ 250%</option>'+'</select>';}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceZoom":tinyMCE.getInstanceById(editor_id).contentDocument.body.style.zoom=value;tinyMCE.getInstanceById(editor_id).contentDocument.body.style.mozZoom=value;return true;}return false;}};tinyMCE.addPlugin("zoom",TinyMCE_ZoomPlugin);
tinyMCE.importPluginLanguagePack('save','en,tr,sv,zh_cn,cs,fa,fr_ca,fr,de,pl,pt_br,nl,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,da,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_SavePlugin={getInfo:function(){return{longname:'Save',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('save');var TinyMCE_SavePlugin={getInfo:function(){return{longname:'Save',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('save','en,tr,sv,zh_cn,cs,fa,fr_ca,fr,de,pl,pt_br,nl,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,da,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_SavePlugin={getInfo:function(){return{longname:'Save',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_save.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){inst.addShortcut('ctrl','s','lang_save_desc','mceSave');},getControlHTML:function(cn){switch(cn){case"save":return tinyMCE.getButtonHTML(cn,'lang_save_desc','{$pluginurl}/images/save.gif','mceSave');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceSave":if(tinyMCE.getParam("fullscreen_is_enabled"))return true;var inst=tinyMCE.selectedInstance;var formObj=inst.formElement.form;if(tinyMCE.getParam("save_enablewhendirty")&&!inst.isDirty())return true;if(formObj){tinyMCE.triggerSave();var os;if((os=tinyMCE.getParam("save_onsavecallback"))){if(eval(os+'(inst);')){inst.startContent=tinyMCE.trim(inst.getBody().innerHTML);tinyMCE.triggerNodeChange(false,true);}return true;}for(var i=0;i<formObj.elements.length;i++){var elementId=formObj.elements[i].name?formObj.elements[i].name:formObj.elements[i].id;if(elementId.indexOf('mce_editor_')==0)formObj.elements[i].disabled=true;}tinyMCE.isNotDirty=true;if(formObj.onsubmit==null||formObj.onsubmit()!=false)inst.formElement.form.submit();}else alert("Error: No form element found.");return true;}return false;},handleNodeChange:function(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){if(tinyMCE.getParam("fullscreen_is_enabled")){tinyMCE.switchClass(editor_id+'_save','mceButtonDisabled');return true;}if(tinyMCE.getParam("save_enablewhendirty")){var inst=tinyMCE.getInstanceById(editor_id);if(inst.isDirty()){tinyMCE.switchClass(editor_id+'_save','mceButtonNormal');return true;}tinyMCE.switchClass(editor_id+'_save','mceButtonDisabled');}return true;}};tinyMCE.addPlugin("save",TinyMCE_SavePlugin);
tinyMCE.importPluginLanguagePack('advlink','en,tr,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,he,nb,ru,ru_KOI8-R,ru_UTF-8,nn,cy,es,is,zh_tw,zh_tw_utf8,sk,da');var TinyMCE_AdvancedLinkPlugin={getInfo:function(){return{longname:'Advanced link',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('advlink');var TinyMCE_AdvancedLinkPlugin={getInfo:function(){return{longname:'Advanced link',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('advlink','en,tr,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl,he,nb,ru,ru_KOI8-R,ru_UTF-8,nn,cy,es,is,zh_tw,zh_tw_utf8,sk,da');var TinyMCE_AdvancedLinkPlugin={getInfo:function(){return{longname:'Advanced link',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_advlink.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){inst.addShortcut('ctrl','k','lang_advlink_desc','mceAdvLink');},getControlHTML:function(cn){switch(cn){case"link":return tinyMCE.getButtonHTML(cn,'lang_link_desc','{$themeurl}/images/link.gif','mceAdvLink');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceAdvLink":var anySelection=false;var inst=tinyMCE.getInstanceById(editor_id);var focusElm=inst.getFocusElement();var selectedText=inst.selection.getSelectedText();if(tinyMCE.selectedElement)anySelection=(tinyMCE.selectedElement.nodeName.toLowerCase()=="img")||(selectedText&&selectedText.length>0);if(anySelection||(focusElm!=null&&focusElm.nodeName=="A")){var template=new Array();template['file']='../../plugins/advlink/link.htm';template['width']=480;template['height']=400;template['width']+=tinyMCE.getLang('lang_advlink_delta_width',0);template['height']+=tinyMCE.getLang('lang_advlink_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});}return true;}return false;},handleNodeChange:function(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){if(node==null)return;do{if(node.nodeName=="A"&&tinyMCE.getAttrib(node,'href')!=""){tinyMCE.switchClass(editor_id+'_advlink','mceButtonSelected');return true;}}while((node=node.parentNode));if(any_selection){tinyMCE.switchClass(editor_id+'_advlink','mceButtonNormal');return true;}tinyMCE.switchClass(editor_id+'_advlink','mceButtonDisabled');return true;}};tinyMCE.addPlugin("advlink",TinyMCE_AdvancedLinkPlugin);
var html = TinyMCE_PastePlugin._clipboardHTML(); if (html && html.length > 0) TinyMCE_PastePlugin._insertWordContent(html);
TinyMCE_PastePlugin._insertWordContent(TinyMCE_PastePlugin._clipboardHTML());
execCommand : function(editor_id, element, command, user_interface, value) { switch (command) { case "mcePasteText": if (user_interface) { if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true); else { var template = new Array(); template['file'] = '../../plugins/paste/pastetext.htm'; // Relative to theme template['width'] = 450; template['height'] = 400; var plain_text = ""; tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); } } else TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']); return true; case "mcePasteWord": if (user_interface) { if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) { var html = TinyMCE_PastePlugin._clipboardHTML(); if (html && html.length > 0) TinyMCE_PastePlugin._insertWordContent(html); } else { var template = new Array(); template['file'] = '../../plugins/paste/pasteword.htm'; // Relative to theme template['width'] = 450; template['height'] = 400; var plain_text = ""; tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); } } else TinyMCE_PastePlugin._insertWordContent(value); return true; case "mceSelectAll": tinyMCE.execInstanceCommand(editor_id, 'selectall'); return true; } // Pass to next handler in chain return false; },
tinyMCE.importPluginLanguagePack('print','en,tr,sv,zh_cn,fa,fr_ca,fr,de,pl,pt_br,cs,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_PrintPlugin={getInfo:function(){return{longname:'Print',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('print');var TinyMCE_PrintPlugin={getInfo:function(){return{longname:'Print',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('print','en,tr,sv,zh_cn,fa,fr_ca,fr,de,pl,pt_br,cs,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_PrintPlugin={getInfo:function(){return{longname:'Print',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_print.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},getControlHTML:function(cn){switch(cn){case"print":return tinyMCE.getButtonHTML(cn,'lang_print_desc','{$pluginurl}/images/print.gif','mcePrint');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mcePrint":tinyMCE.getInstanceById(editor_id).contentWindow.print();return true;}return false;}};tinyMCE.addPlugin("print",TinyMCE_PrintPlugin);
var html = "";
var html = "", i;
execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mcePreview": var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); // Use a custom preview page if (previewPage) { var template = new Array(); template['file'] = previewPage; template['width'] = previewWidth; template['height'] = previewHeight; tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); } else { var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); var html = ""; var c = tinyMCE.getContent(); var pos = c.indexOf('<body'), pos2; if (pos != -1) { pos = c.indexOf('>', pos); pos2 = c.lastIndexOf('</body>'); c = c.substring(pos + 1, pos2); } html += tinyMCE.getParam('doctype'); html += '<html xmlns="http://www.w3.org/1999/xhtml">'; html += '<head>'; html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>'; html += '<base href="' + tinyMCE.settings['base_href'] + '" />'; html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css" />'; html += '</head>'; html += '<body dir="' + tinyMCE.getParam("directionality") + '">'; html += c; html += '</body>'; html += '</html>'; win.document.write(html); win.document.close(); } return true; } return false; }
var pos = c.indexOf('<body'), pos2;
var pos = c.indexOf('<body'), pos2, css = tinyMCE.getParam("content_css").split(',');
execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mcePreview": var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); // Use a custom preview page if (previewPage) { var template = new Array(); template['file'] = previewPage; template['width'] = previewWidth; template['height'] = previewHeight; tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); } else { var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); var html = ""; var c = tinyMCE.getContent(); var pos = c.indexOf('<body'), pos2; if (pos != -1) { pos = c.indexOf('>', pos); pos2 = c.lastIndexOf('</body>'); c = c.substring(pos + 1, pos2); } html += tinyMCE.getParam('doctype'); html += '<html xmlns="http://www.w3.org/1999/xhtml">'; html += '<head>'; html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>'; html += '<base href="' + tinyMCE.settings['base_href'] + '" />'; html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css" />'; html += '</head>'; html += '<body dir="' + tinyMCE.getParam("directionality") + '">'; html += c; html += '</body>'; html += '</html>'; win.document.write(html); win.document.close(); } return true; } return false; }
html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css" />';
for (i=0; i<css.length; i++) html += '<link href="' + css[i] + '" rel="stylesheet" type="text/css" />'; html += '<script type="text/javascript">'; html += 'window.opener.TinyMCE_PreviewPlugin._setDoc(document);'; html += 'window.opener.TinyMCE_PreviewPlugin._setWin(window);'; html += 'writeFlash = window.opener.TinyMCE_PreviewPlugin._writeFlash;'; html += 'writeShockWave = window.opener.TinyMCE_PreviewPlugin._writeShockWave;'; html += 'writeQuickTime = window.opener.TinyMCE_PreviewPlugin._writeQuickTime;'; html += 'writeRealMedia = window.opener.TinyMCE_PreviewPlugin._writeRealMedia;'; html += 'writeWindowsMedia = window.opener.TinyMCE_PreviewPlugin._writeWindowsMedia;'; html += 'writeEmbed = window.opener.TinyMCE_PreviewPlugin._writeEmbed;'; html += '</script>';
execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mcePreview": var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); // Use a custom preview page if (previewPage) { var template = new Array(); template['file'] = previewPage; template['width'] = previewWidth; template['height'] = previewHeight; tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); } else { var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); var html = ""; var c = tinyMCE.getContent(); var pos = c.indexOf('<body'), pos2; if (pos != -1) { pos = c.indexOf('>', pos); pos2 = c.lastIndexOf('</body>'); c = c.substring(pos + 1, pos2); } html += tinyMCE.getParam('doctype'); html += '<html xmlns="http://www.w3.org/1999/xhtml">'; html += '<head>'; html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>'; html += '<base href="' + tinyMCE.settings['base_href'] + '" />'; html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css" />'; html += '</head>'; html += '<body dir="' + tinyMCE.getParam("directionality") + '">'; html += c; html += '</body>'; html += '</html>'; win.document.write(html); win.document.close(); } return true; } return false; }
html += '<body dir="' + tinyMCE.getParam("directionality") + '">';
html += '<body dir="' + tinyMCE.getParam("directionality") + '" onload="window.opener.TinyMCE_PreviewPlugin._onLoad();">';
execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mcePreview": var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); // Use a custom preview page if (previewPage) { var template = new Array(); template['file'] = previewPage; template['width'] = previewWidth; template['height'] = previewHeight; tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); } else { var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); var html = ""; var c = tinyMCE.getContent(); var pos = c.indexOf('<body'), pos2; if (pos != -1) { pos = c.indexOf('>', pos); pos2 = c.lastIndexOf('</body>'); c = c.substring(pos + 1, pos2); } html += tinyMCE.getParam('doctype'); html += '<html xmlns="http://www.w3.org/1999/xhtml">'; html += '<head>'; html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>'; html += '<base href="' + tinyMCE.settings['base_href'] + '" />'; html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css" />'; html += '</head>'; html += '<body dir="' + tinyMCE.getParam("directionality") + '">'; html += c; html += '</body>'; html += '</html>'; win.document.write(html); win.document.close(); } return true; } return false; }
}
},
execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mcePreview": var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); // Use a custom preview page if (previewPage) { var template = new Array(); template['file'] = previewPage; template['width'] = previewWidth; template['height'] = previewHeight; tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); } else { var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); var html = ""; var c = tinyMCE.getContent(); var pos = c.indexOf('<body'), pos2; if (pos != -1) { pos = c.indexOf('>', pos); pos2 = c.lastIndexOf('</body>'); c = c.substring(pos + 1, pos2); } html += tinyMCE.getParam('doctype'); html += '<html xmlns="http://www.w3.org/1999/xhtml">'; html += '<head>'; html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>'; html += '<base href="' + tinyMCE.settings['base_href'] + '" />'; html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; html += '<link href="' + tinyMCE.getParam("content_css") + '" rel="stylesheet" type="text/css" />'; html += '</head>'; html += '<body dir="' + tinyMCE.getParam("directionality") + '">'; html += c; html += '</body>'; html += '</html>'; win.document.write(html); win.document.close(); } return true; } return false; }
tinyMCE.importPluginLanguagePack('preview','en,tr,cs,de,el,fr_ca,it,ko,pt,sv,zh_cn,fa,fr,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_PreviewPlugin={getInfo:function(){return{longname:'Preview',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('preview');var TinyMCE_PreviewPlugin={getInfo:function(){return{longname:'Preview',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('preview','en,tr,cs,de,el,fr_ca,it,ko,pt,sv,zh_cn,fa,fr,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_PreviewPlugin={getInfo:function(){return{longname:'Preview',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_preview.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},getControlHTML:function(cn){switch(cn){case"preview":return tinyMCE.getButtonHTML(cn,'lang_preview_desc','{$pluginurl}/images/preview.gif','mcePreview');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mcePreview":var previewPage=tinyMCE.getParam("plugin_preview_pageurl",null);var previewWidth=tinyMCE.getParam("plugin_preview_width","550");var previewHeight=tinyMCE.getParam("plugin_preview_height","600");if(previewPage){var template=new Array();template['file']=previewPage;template['width']=previewWidth;template['height']=previewHeight;tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"yes",inline:"yes",content:tinyMCE.getContent(),content_css:tinyMCE.getParam("content_css")});}else{var win=window.open("","mcePreview","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width="+previewWidth+",height="+previewHeight);var html="";var c=tinyMCE.getContent();var pos=c.indexOf('<body'),pos2;if(pos!=-1){pos=c.indexOf('>',pos);pos2=c.lastIndexOf('</body>');c=c.substring(pos+1,pos2);}html+=tinyMCE.getParam('doctype');html+='<html xmlns="http://www.w3.org/1999/xhtml">';html+='<head>';html+='<title>'+tinyMCE.getLang('lang_preview_desc')+'</title>';html+='<base href="'+tinyMCE.settings['base_href']+'" />';html+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';html+='<link href="'+tinyMCE.getParam("content_css")+'" rel="stylesheet" type="text/css" />';html+='</head>';html+='<body dir="'+tinyMCE.getParam("directionality")+'">';html+=c;html+='</body>';html+='</html>';win.document.write(html);win.document.close();}return true;}return false;}};tinyMCE.addPlugin("preview",TinyMCE_PreviewPlugin);
var self = TinyMCE_LayerPlugin;
execCommand : function(editor_id, element, command, user_interface, value) { var self = TinyMCE_LayerPlugin; // Handle commands switch (command) { case "mceInsertLayer": self._insertLayer(); return true; case "mceMoveForward": self._move(1); return true; case "mceMoveBackward": self._move(-1); return true; case "mceMakeAbsolute": self._toggleAbsolute(); return true; } // Pass to next handler in chain return false; },
self._insertLayer();
this._insertLayer();
execCommand : function(editor_id, element, command, user_interface, value) { var self = TinyMCE_LayerPlugin; // Handle commands switch (command) { case "mceInsertLayer": self._insertLayer(); return true; case "mceMoveForward": self._move(1); return true; case "mceMoveBackward": self._move(-1); return true; case "mceMakeAbsolute": self._toggleAbsolute(); return true; } // Pass to next handler in chain return false; },
self._move(1);
this._move(1);
execCommand : function(editor_id, element, command, user_interface, value) { var self = TinyMCE_LayerPlugin; // Handle commands switch (command) { case "mceInsertLayer": self._insertLayer(); return true; case "mceMoveForward": self._move(1); return true; case "mceMoveBackward": self._move(-1); return true; case "mceMakeAbsolute": self._toggleAbsolute(); return true; } // Pass to next handler in chain return false; },
self._move(-1);
this._move(-1);
execCommand : function(editor_id, element, command, user_interface, value) { var self = TinyMCE_LayerPlugin; // Handle commands switch (command) { case "mceInsertLayer": self._insertLayer(); return true; case "mceMoveForward": self._move(1); return true; case "mceMoveBackward": self._move(-1); return true; case "mceMakeAbsolute": self._toggleAbsolute(); return true; } // Pass to next handler in chain return false; },
self._toggleAbsolute();
this._toggleAbsolute();
execCommand : function(editor_id, element, command, user_interface, value) { var self = TinyMCE_LayerPlugin; // Handle commands switch (command) { case "mceInsertLayer": self._insertLayer(); return true; case "mceMoveForward": self._move(1); return true; case "mceMoveBackward": self._move(-1); return true; case "mceMakeAbsolute": self._toggleAbsolute(); return true; } // Pass to next handler in chain return false; },
case "mceForeColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = tinyMCE.getAttrib(elm, "color"); if (inputColor == '') inputColor = elm.style.color; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor}); return true; case "mceBackColor": var template = new Array(); var elm = tinyMCE.selectedInstance.getFocusElement(); var inputColor = elm.style.backgroundColor; if (!inputColor) inputColor = "#000000"; template['file'] = 'color_picker.htm'; template['width'] = 220; template['height'] = 190; template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor}); return true;
execCommand : function(editor_id, element, command, user_interface, value) { switch (command) { case "mceLink": var inst = tinyMCE.getInstanceById(editor_id); var doc = inst.getDoc(); var selectedText = ""; if (tinyMCE.isMSIE) { var rng = doc.selection.createRange(); selectedText = rng.text; } else selectedText = inst.getSel().toString(); if (!tinyMCE.linkElement) { if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) return true; } var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; var text = ""; if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length > 0)) text = selectedText; if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") tinyMCE.linkElement = tinyMCE.selectedElement; // Is anchor not a link if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") tinyMCE.linkElement = null; if (tinyMCE.linkElement) { if (tinyMCE.isMSIE) { text = tinyMCE.linkElement.innerHTML; } else text = tinyMCE.linkElement.text; href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); // Try old onclick to if copy/pasted content if (onclick == "") onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); onclick = tinyMCE.cleanupEventStr(onclick); href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); // Use mce_href if defined mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); if (mceRealHref != "") { href = mceRealHref; if (tinyMCE.getParam('convert_urls')) href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); } action = "update"; } var template = new Array(); template['file'] = 'link.htm'; template['width'] = 600; template['height'] = 450; // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); if (inst.settings['insertlink_callback']) { var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);"); if (returnVal && returnVal['href']) TinyMCE_WikieditorTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']); } else { tinyMCE.openWindow(template, {editor_id : editor_id, action : action, text : text, href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes", scrollbars : 'yes', resizable : 'no', mce_windowresize: false}); } return true; default : return wikiEditor.execCommand(editor_id, element, command, user_interface, value); } },
tinyMCE.importPluginLanguagePack('emotions','en,tr,sv,zh_cn,cs,fa,fr_ca,fr,de,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_EmotionsPlugin={getInfo:function(){return{longname:'Emotions',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('emotions');var TinyMCE_EmotionsPlugin={getInfo:function(){return{longname:'Emotions',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('emotions','en,tr,sv,zh_cn,cs,fa,fr_ca,fr,de,pl,pt_br,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_EmotionsPlugin={getInfo:function(){return{longname:'Emotions',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_emotions.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},getControlHTML:function(cn){switch(cn){case"emotions":return tinyMCE.getButtonHTML(cn,'lang_emotions_desc','{$pluginurl}/images/emotions.gif','mceEmotion');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceEmotion":var template=new Array();template['file']='../../plugins/emotions/emotions.htm';template['width']=160;template['height']=160;template['width']+=tinyMCE.getLang('lang_emotions_delta_width',0);template['height']+=tinyMCE.getLang('lang_emotions_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;}return false;}};tinyMCE.addPlugin('emotions',TinyMCE_EmotionsPlugin);
function getDateTime(date, format) { format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y"); format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p"); format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear()); format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear()); format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2)); format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2)); format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2)); format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2)); format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2)); format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1)); format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM")); format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]); format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]); format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]); format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]); format = tinyMCE.regexpReplace(format, "%%", "%");
function getDateTime(d, fmt) { fmt = fmt.replace("%D", "%m/%d/%y"); fmt = fmt.replace("%r", "%I:%M:%S %p"); fmt = fmt.replace("%Y", "" + d.getFullYear()); fmt = fmt.replace("%y", "" + d.getYear()); fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2)); fmt = fmt.replace("%d", addZeros(d.getDate(), 2)); fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2)); fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2)); fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2)); fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1)); fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM")); fmt = fmt.replace("%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[d.getMonth()]); fmt = fmt.replace("%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[d.getMonth()]); fmt = fmt.replace("%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[d.getDay()]); fmt = fmt.replace("%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[d.getDay()]); fmt = fmt.replace("%%", "%");
execCommand : function(editor_id, element, command, user_interface, value) { /* Adds zeros infront of value */ function addZeros(value, len) { value = "" + value; if (value.length < len) { for (var i=0; i<(len-value.length); i++) value = "0" + value; } return value; } /* Returns the date object in the specified format */ function getDateTime(date, format) { format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y"); format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p"); format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear()); format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear()); format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2)); format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2)); format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2)); format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2)); format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2)); format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1)); format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM")); format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]); format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]); format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]); format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]); format = tinyMCE.regexpReplace(format, "%%", "%"); return format; } // Handle commands switch (command) { case "mceInsertDate": tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt')))); return true; case "mceInsertTime": tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt')))); return true; } // Pass to next handler in chain return false; }
return format;
return fmt;
execCommand : function(editor_id, element, command, user_interface, value) { /* Adds zeros infront of value */ function addZeros(value, len) { value = "" + value; if (value.length < len) { for (var i=0; i<(len-value.length); i++) value = "0" + value; } return value; } /* Returns the date object in the specified format */ function getDateTime(date, format) { format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y"); format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p"); format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear()); format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear()); format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2)); format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2)); format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2)); format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2)); format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2)); format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1)); format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM")); format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]); format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]); format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]); format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]); format = tinyMCE.regexpReplace(format, "%%", "%"); return format; } // Handle commands switch (command) { case "mceInsertDate": tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt')))); return true; case "mceInsertTime": tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt')))); return true; } // Pass to next handler in chain return false; }
tinyMCE.importPluginLanguagePack('directionality','en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_DirectionalityPlugin={getInfo:function(){return{longname:'Directionality',author:'Moxiecode Systems',authorurl:'http:
tinyMCE.importPluginLanguagePack('directionality');var TinyMCE_DirectionalityPlugin={getInfo:function(){return{longname:'Directionality',author:'Moxiecode Systems AB',authorurl:'http:
tinyMCE.importPluginLanguagePack('directionality','en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_DirectionalityPlugin={getInfo:function(){return{longname:'Directionality',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},getControlHTML:function(cn){switch(cn){case"ltr":return tinyMCE.getButtonHTML(cn,'lang_directionality_ltr_desc','{$pluginurl}/images/ltr.gif','mceDirectionLTR');case"rtl":return tinyMCE.getButtonHTML(cn,'lang_directionality_rtl_desc','{$pluginurl}/images/rtl.gif','mceDirectionRTL');}return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceDirectionLTR":var inst=tinyMCE.getInstanceById(editor_id);var elm=tinyMCE.getParentElement(inst.getFocusElement(),"p,div,td,h1,h2,h3,h4,h5,h6,pre,address");if(elm)elm.setAttribute("dir","ltr");tinyMCE.triggerNodeChange(false);return true;case"mceDirectionRTL":var inst=tinyMCE.getInstanceById(editor_id);var elm=tinyMCE.getParentElement(inst.getFocusElement(),"p,div,td,h1,h2,h3,h4,h5,h6,pre,address");if(elm)elm.setAttribute("dir","rtl");tinyMCE.triggerNodeChange(false);return true;}return false;},handleNodeChange:function(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}if(node==null)return;var elm=tinyMCE.getParentElement(node,"p,div,td,h1,h2,h3,h4,h5,h6,pre,address");if(!elm){tinyMCE.switchClass(editor_id+'_ltr','mceButtonDisabled');tinyMCE.switchClass(editor_id+'_rtl','mceButtonDisabled');return true;}tinyMCE.switchClass(editor_id+'_ltr','mceButtonNormal');tinyMCE.switchClass(editor_id+'_rtl','mceButtonNormal');var dir=getAttrib(elm,"dir");if(dir=="ltr"||dir=="")tinyMCE.switchClass(editor_id+'_ltr','mceButtonSelected');else tinyMCE.switchClass(editor_id+'_rtl','mceButtonSelected');return true;}};tinyMCE.addPlugin("directionality",TinyMCE_DirectionalityPlugin);
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id);
execCommand : function (editor_id, element, command, user_interface, value) { var inst = tinyMCE.getInstanceById(editor_id), selectedText = inst.selection.getSelectedText(), rng;
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
instance.execCommand('mceInsertContent', false, str);
inst.execCommand('mceInsertContent', false, str);
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
value = new Array();
value = [];
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
defValue("searchstring", "");
defValue("searchstring", selectedText);
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); }
template['file'] = '../../plugins/searchreplace/searchreplace.htm'; template['width'] = 380; template['height'] = 155 + (tinyMCE.isNS7 ? 20 : 0) + (tinyMCE.isMSIE ? 15 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_delta_height', 0);
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
instance.execCommand('SelectAll');
inst.execCommand('SelectAll');
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
var r = instance.selection.getRng();
var r = inst.selection.getRng();
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
instance.selection.getSel().collapseToStart();
inst.selection.getSel().collapseToStart();
execCommand : function(editor_id, element, command, user_interface, value) { var instance = tinyMCE.getInstanceById(editor_id); function defValue(key, default_value) { value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; } function replaceSel(search_str, str, back) { instance.execCommand('mceInsertContent', false, str); } if (!value) value = new Array(); // Setup defualt values defValue("editor_id", editor_id); defValue("searchstring", ""); defValue("replacestring", null); defValue("replacemode", "none"); defValue("casesensitive", false); defValue("backwards", false); defValue("wrap", false); defValue("wholeword", false); defValue("inline", "yes"); // Handle commands switch (command) { case "mceResetSearch": tinyMCE.lastSearchRng = null; return true; case "mceSearch": if (user_interface) { // Open search dialog var template = new Array(); if (value['replacestring'] != null) { template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme template['width'] = 320; template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } else { template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme template['width'] = 310; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); } instance.execCommand('SelectAll'); if (tinyMCE.isMSIE) { var r = instance.selection.getRng(); r.collapse(true); r.select(); } else instance.selection.getSel().collapseToStart(); tinyMCE.openWindow(template, value); } else { var win = tinyMCE.getInstanceById(editor_id).contentWindow; var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; // Whats the point if (body.innerHTML == "") { alert(tinyMCE.getLang('lang_searchreplace_notfound')); return true; } // Handle replace current if (value['replacemode'] == "current") { replaceSel(value['string'], value['replacestring'], value['backwards']); // Search next one value['replacemode'] = "none"; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } if (tinyMCE.isMSIE) { var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); var flags = 0; if (value['wholeword']) flags = flags | 2; if (value['casesensitive']) flags = flags | 4; if (!rng.findText) { alert('This operation is currently not supported by this browser.'); return true; } // Handle replace all mode if (value['replacemode'] == "all") { while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(false); replaceSel(value['string'], value['replacestring'], value['backwards']); } alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { rng.scrollIntoView(); rng.select(); rng.collapse(value['backwards']); tinyMCE.lastSearchRng = rng; } else alert(tinyMCE.getLang('lang_searchreplace_notfound')); } else { if (value['replacemode'] == "all") { while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) replaceSel(value['string'], value['replacestring'], value['backwards']); alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); return true; } if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) alert(tinyMCE.getLang('lang_searchreplace_notfound')); } } return true; case "mceSearchReplace": value['replacestring'] = ""; tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); return true; } // Pass to next handler in chain return false; }
var inst = tinyMCE.getInstanceById(editor_id);
var inst = tinyMCE.getInstanceById(editor_id), r;
execInstanceCommand : function(editor_id, command, user_interface, value, focus) { var inst = tinyMCE.getInstanceById(editor_id); if (inst) { if (typeof(focus) == "undefined") focus = true; if (focus) inst.contentWindow.focus(); // Reset design mode if lost inst.autoResetDesignMode(); this.selectedElement = inst.getFocusElement(); this.selectedInstance = inst; tinyMCE.execCommand(command, user_interface, value); // Cancel event so it doesn't call onbeforeonunlaod if (tinyMCE.isMSIE && window.event != null) tinyMCE.cancelEvent(window.event); } },
if (focus)
if (focus && (!r || !r.item))
execInstanceCommand : function(editor_id, command, user_interface, value, focus) { var inst = tinyMCE.getInstanceById(editor_id); if (inst) { if (typeof(focus) == "undefined") focus = true; if (focus) inst.contentWindow.focus(); // Reset design mode if lost inst.autoResetDesignMode(); this.selectedElement = inst.getFocusElement(); this.selectedInstance = inst; tinyMCE.execCommand(command, user_interface, value); // Cancel event so it doesn't call onbeforeonunlaod if (tinyMCE.isMSIE && window.event != null) tinyMCE.cancelEvent(window.event); } },
this.selectedInstance = inst;
inst.select();
execInstanceCommand : function(editor_id, command, user_interface, value, focus) { var inst = tinyMCE.getInstanceById(editor_id); if (inst) { if (typeof(focus) == "undefined") focus = true; if (focus) inst.contentWindow.focus(); // Reset design mode if lost inst.autoResetDesignMode(); this.selectedElement = inst.getFocusElement(); this.selectedInstance = inst; tinyMCE.execCommand(command, user_interface, value); // Cancel event so it doesn't call onbeforeonunlaod if (tinyMCE.isMSIE && window.event != null) tinyMCE.cancelEvent(window.event); } },
if (tinyMCE.isMSIE && window.event != null)
if (tinyMCE.isIE && window.event != null)
execInstanceCommand : function(editor_id, command, user_interface, value, focus) { var inst = tinyMCE.getInstanceById(editor_id); if (inst) { if (typeof(focus) == "undefined") focus = true; if (focus) inst.contentWindow.focus(); // Reset design mode if lost inst.autoResetDesignMode(); this.selectedElement = inst.getFocusElement(); this.selectedInstance = inst; tinyMCE.execCommand(command, user_interface, value); // Cancel event so it doesn't call onbeforeonunlaod if (tinyMCE.isMSIE && window.event != null) tinyMCE.cancelEvent(window.event); } },
this.execute = function() { var baseFailureMessage = decoratedExecutor(baseHandler, arguments); var result = {}; if (!baseFailureMessage) { result.failed = true; result.failureMessage = "Expected " + errorType + " did not occur."; } else { if (! PatternMatcher.matches(expectedErrorMessage, baseFailureMessage)) { result.failed = true; result.failureMessage = "Expected " + errorType + " message '" + expectedErrorMessage + "' but was '" + baseFailureMessage + "'"; } else { result.passed = true; result.result = baseFailureMessage; } } currentTest.commandFactory = originalCommandFactory; return result; };
execute: function(selenium, command) { testLoop.pauseInterval = command.target; return {}; }
this.execute = function() { var baseFailureMessage = decoratedExecutor(baseHandler, arguments); var result = {}; if (!baseFailureMessage) { result.failed = true; result.failureMessage = "Expected " + errorType + " did not occur."; } else { if (! PatternMatcher.matches(expectedErrorMessage, baseFailureMessage)) { result.failed = true; result.failureMessage = "Expected " + errorType + " message '" + expectedErrorMessage + "' but was '" + baseFailureMessage + "'"; } else { result.passed = true; result.result = baseFailureMessage; } } currentTest.commandFactory = originalCommandFactory; return result; };
selenium = Selenium.createForFrame(window.getBrowser());
selenium = Selenium.createForFrame(window.getBrowser().selectedBrowser);
function executeCommand(baseURL, command) { if (!stopAndDo("executeCommand", baseURL, command)) return; // TODO refactor with start() var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var window = wm.getMostRecentWindow('navigator:browser'); selenium = Selenium.createForFrame(window.getBrowser()); selenium.browserbot.getCurrentPage(); selenium.baseURL = baseURL; commandFactory = new CommandHandlerFactory(); commandFactory.registerAll(selenium); testLoop = new TestLoop(commandFactory); testLoop.getCommandInterval = function() { return 0; } var first = true; testLoop.nextCommand = function() { if (first) { first = false; testCase.debugContext.debugIndex = testCase.commands.indexOf(command); return new SeleniumCommand(command.command, command.target, command.value); } else { return null; } } testLoop.firstCommand = testLoop.nextCommand; // Selenium <= 0.6 only testLoop.commandStarted = function() { editor.view.rowUpdated(testCase.commands.indexOf(command)); } testLoop.commandComplete = function(result) { if (result.failed) { command.result = 'failed'; } else if (result.passed) { command.result = 'passed'; } else { command.result = 'done'; } editor.view.rowUpdated(testCase.commands.indexOf(command)); } testLoop.commandError = function() { command.result = 'failed'; editor.view.rowUpdated(testCase.commands.indexOf(command)); } testLoop.testComplete = function() { testLoop = null; testCase.debugContext.reset(); editor.view.rowUpdated(testCase.commands.indexOf(command)); } testLoop.pause = function() { editor.setState("paused"); } testLoop.start();}
throw new Error("Unknown command: '" + command.command + "'");
throw new SeleniumError("Unknown command: '" + command.command + "'");
this.executeCurrentCommand = function() { var command = this.currentCommand; LOG.info("Executing: |" + command.command + " | " + command.target + " | " + command.value + " |"); var handler = this.commandFactory.getCommandHandler(command.command); if (handler == null) { throw new Error("Unknown command: '" + command.command + "'"); } command.target = selenium.preprocessParameter(command.target); command.value = selenium.preprocessParameter(command.value); var result = handler.execute(selenium, command); this.commandComplete(result); if (result.processState == SELENIUM_PROCESS_WAIT) { this.waitForCondition = function() { return selenium.browserbot.isNewPageLoaded(); }; } };
LOG.debug("Command complete");
this.executeCurrentCommand = function() { var command = this.currentCommand; LOG.info("Executing: |" + command.command + " | " + command.target + " | " + command.value + " |"); var handler = this.commandFactory.getCommandHandler(command.command); if (handler == null) { throw new SeleniumError("Unknown command: '" + command.command + "'"); } command.target = selenium.preprocessParameter(command.target); command.value = selenium.preprocessParameter(command.value); var result = handler.execute(selenium, command); this.commandComplete(result); if (result.processState == SELENIUM_PROCESS_WAIT) { this.waitForCondition = function() { return selenium.browserbot.isNewPageLoaded(); }; } };
LOG.debug("Checking condition: isNewPageLoaded?");
this.executeCurrentCommand = function() { var command = this.currentCommand; LOG.info("Executing: |" + command.command + " | " + command.target + " | " + command.value + " |"); var handler = this.commandFactory.getCommandHandler(command.command); if (handler == null) { throw new SeleniumError("Unknown command: '" + command.command + "'"); } command.target = selenium.preprocessParameter(command.target); command.value = selenium.preprocessParameter(command.value); var result = handler.execute(selenium, command); this.commandComplete(result); if (result.processState == SELENIUM_PROCESS_WAIT) { this.waitForCondition = function() { return selenium.browserbot.isNewPageLoaded(); }; } };
else { try { var processNext = handler.executor.call(selenium, command.target, command.value); if (handler.type == "assert") { this.assertionPassed(); } else { this.actionOK(); }
this.executeNextCommand = function() { var command = this.nextCommand(); if (!command) return SELENIUM_PROCESS_COMPLETE; handler = this.commandFactory.getCommandHandler(command.command); // Make the current row blue this.beginCommand(command); if(handler == null) { this.commandError("Unknown command", ERROR); return SELENIUM_PROCESS_COMPLETE; } else { try { var processNext = handler.executor.call(selenium, command.target, command.value); if (handler.type == "assert") { this.assertionPassed(); } else { this.actionOK(); } return processNext; } catch (e) { if (e.isJsUnitException && handler.type == "assert") { this.assertionFailed(e.jsUnitMessage); } else { this.commandError(e.message); } } } }
return processNext; } catch (e) { if (e.isJsUnitException && handler.type == "assert") { this.assertionFailed(e.jsUnitMessage); } else { this.commandError(e.message); }
try { var processNext = handler.executor.call(selenium, command.target, command.value); if (processNext == undefined && handler.wait) { processNext = SELENIUM_PROCESS_WAIT; } if (handler.type == "assert") { this.assertionPassed(); } else { this.actionOK(); } return processNext; } catch (e) { if (e.isJsUnitException && handler.type == "assert") { this.assertionFailed(e.jsUnitMessage); } else { this.commandError(e.message);
this.executeNextCommand = function() { var command = this.nextCommand(); if (!command) return SELENIUM_PROCESS_COMPLETE; handler = this.commandFactory.getCommandHandler(command.command); // Make the current row blue this.beginCommand(command); if(handler == null) { this.commandError("Unknown command", ERROR); return SELENIUM_PROCESS_COMPLETE; } else { try { var processNext = handler.executor.call(selenium, command.target, command.value); if (handler.type == "assert") { this.assertionPassed(); } else { this.actionOK(); } return processNext; } catch (e) { if (e.isJsUnitException && handler.type == "assert") { this.assertionFailed(e.jsUnitMessage); } else { this.commandError(e.message); } } } }
if (view.getViewURI()) {
if (view != null && view.getViewURI()) {
function executeUsecase() { var usecaseName; var usecase; // the Usecase object var proxy; // a UsecaseProxy to make the usecase state persistent across continuations var view; // the UsecaseView object that belongs to our usecase. var state; // the state of the usecase ("continue"|"success"|"cancel"); var targetUrl; // URL to redirect to after completion. var generic = new Object; // a generic helper object for custom flow code to preserve state information. try { usecaseName = cocoon.parameters["usecaseName"]; usecase = getUsecase(usecaseName); passRequestParameters(usecase); usecase.checkPreconditions(); usecase.lockInvolvedObjects(); // create proxy object to save usecase state proxy = new Packages.org.apache.lenya.cms.usecase.UsecaseProxy(usecase); view = usecase.getView(); log("debug", "Successfully prepared usecase.", usecaseName); } catch (exception) { log("error", "Could not prepare usecase: " + exception, usecaseName); throw exception; } finally { releaseUsecase(usecase); } loadCustomFlow(view); if (view.getViewURI()) { // If the usecase has a view uri, this means we want to display something // to the user before proceeding. This also means the usecase can consist // of several steps; repeated until the user chooses to submit or cancel. do { // show the view: try { loopFlow(view, proxy, generic); //usecase must be released here! } catch (exception) { // if something went wrong, try and rollback the usecase: log("error", "Exception during loopFlow(): " + exception, usecaseName); try { usecase = getUsecase(usecaseName); proxy.setup(usecase); usecase.cancel(); throw exception; } finally { releaseUsecase(usecase); } } log("debug", "Advancing in usecase.", usecaseName); // restore the usecase state and handle the user input: usecase = getUsecase(usecaseName); proxy.setup(usecase); passRequestParameters(usecase); state = submitFlow(usecase, generic); // create a new proxy with the updated usecase state proxy = new Packages.org.apache.lenya.cms.usecase.UsecaseProxy(usecase); releaseUsecase(usecase); } while (state == "continue"); // If the usecase does not have a view uri, we can directly jump to // executeFlow(). } else { usecase = getUsecase(usecaseName); proxy.setup(usecase); passRequestParameters(usecase); state = executeFlow(usecase); releaseUsecase(usecase); } //getTargetURL takes a boolean that is true on success: targetUrl = usecase.getTargetURL(state == "success"); log("debug", "Completed, redirecting to url = [context:/" + targetUrl + "]", usecaseName); // jump to the appropriate URL: redirect(targetUrl);}
} else if (typeof smartprefixes[nick] == 'object' && smartprefixes[nick].constructor == Function) {
} else if (typeof smartprefixes[nick] == 'function') {
function expand_smartprefix(context, current_url){ var match = context.url.match(/^([^:\s]+)(:|\s)\s*(.*)\s*$/) if (match && match[1] && match[3]) { var nick = match[1] var val = match[3] if (smartprefixes[nick]) { if (typeof smartprefixes[nick] == 'string') { context.url = smartprefixes[nick].replace(/%s/, escape(val)) return true } else if (typeof smartprefixes[nick] == 'object' && smartprefixes[nick].constructor == Function) { context.url = smartprefixes[nick](val) return true } else { ELinks.write('smartprefix "' + nick + '" has unsupported type "' + typeof smartprefixes[nick] + '".') return false } } } // Unmatched. return false}