rem
stringlengths
0
126k
add
stringlengths
0
441k
context
stringlengths
15
136k
html.push('</head><body onload="printPage();" style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $elementToPrint.attr("class") + '">' + $elementToPrint.html() + '</div>'); html.push('<script type="text/javascript">function printPage() { focus();print();' + (opts.leaveOpen ? '' : 'close();') + '}</script></body></html>');
html.push('<base href="' + _getBaseHref() + '" />'); html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $element.attr('class') + '">' + elementHtml + '</div>'); html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>'); html.push('</body></html>');
function _getMarkup(element, opts) { var $elementToPrint = $(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS && opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { html.push('<link type="text/css" rel="stylesheet" href="' + opts.overrideElementCSS[x] + '" >'); } } else { $(document).find("link ") .filter(function() { return $(this).attr("rel").toLowerCase() == "stylesheet"; }) .each(function() { html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >'); }); } html.push('</head><body onload="printPage();" style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $elementToPrint.attr("class") + '">' + $elementToPrint.html() + '</div>'); html.push('<script type="text/javascript">function printPage() { focus();print();' + (opts.leaveOpen ? '' : 'close();') + '}</script></body></html>'); return html.join(''); };
html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS) { if (opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { var current = opts.overrideElementCSS[x]; if (typeof(current) == 'string')
html.push('<html><head><title>' + opts["pageTitle"] + '</title>'); if (opts["overrideElementCSS"]) { if (opts["overrideElementCSS"].length > 0) { for (var x = 0; x < opts["overrideElementCSS"].length; x++) { var current = opts["overrideElementCSS"][x]; if (typeof (current) == 'string')
function _getMarkup(element, opts){ var $element = $(element); var elementHtml = _getElementHTMLIncludingFormElements(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS) { if (opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { var current = opts.overrideElementCSS[x]; if (typeof(current) == 'string') html.push('<link type="text/css" rel="stylesheet" href="' + current + '" >'); else html.push('<link type="text/css" rel="stylesheet" href="' + current.href + '" media="' + current.media + '" >'); } } } else { $(document).find("link").filter(function(){ return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function(){ html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" media="' + $(this).attr('media') + '" >'); }); } //Ensure that relative links work html.push('<base href="' + _getBaseHref() + '" />'); html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $element.attr('class') + '">' + elementHtml + '</div>'); html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>'); html.push('</body></html>'); return html.join(''); };
else html.push('<link type="text/css" rel="stylesheet" href="' + current.href + '" media="' + current.media + '" >');
else html.push('<link type="text/css" rel="stylesheet" href="' + current["href"] + '" media="' + current["media"] + '" >');
function _getMarkup(element, opts){ var $element = $(element); var elementHtml = _getElementHTMLIncludingFormElements(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS) { if (opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { var current = opts.overrideElementCSS[x]; if (typeof(current) == 'string') html.push('<link type="text/css" rel="stylesheet" href="' + current + '" >'); else html.push('<link type="text/css" rel="stylesheet" href="' + current.href + '" media="' + current.media + '" >'); } } } else { $(document).find("link").filter(function(){ return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function(){ html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" media="' + $(this).attr('media') + '" >'); }); } //Ensure that relative links work html.push('<base href="' + _getBaseHref() + '" />'); html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $element.attr('class') + '">' + elementHtml + '</div>'); html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>'); html.push('</body></html>'); return html.join(''); };
$(document).find("link").filter(function(){
$("link", document).filter(function () {
function _getMarkup(element, opts){ var $element = $(element); var elementHtml = _getElementHTMLIncludingFormElements(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS) { if (opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { var current = opts.overrideElementCSS[x]; if (typeof(current) == 'string') html.push('<link type="text/css" rel="stylesheet" href="' + current + '" >'); else html.push('<link type="text/css" rel="stylesheet" href="' + current.href + '" media="' + current.media + '" >'); } } } else { $(document).find("link").filter(function(){ return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function(){ html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" media="' + $(this).attr('media') + '" >'); }); } //Ensure that relative links work html.push('<base href="' + _getBaseHref() + '" />'); html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $element.attr('class') + '">' + elementHtml + '</div>'); html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>'); html.push('</body></html>'); return html.join(''); };
html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">');
html.push('</head><body style="' + opts["printBodyOptions"]["styleToAdd"] + '" class="' + opts["printBodyOptions"]["classNameToAdd"] + '">');
function _getMarkup(element, opts){ var $element = $(element); var elementHtml = _getElementHTMLIncludingFormElements(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS) { if (opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { var current = opts.overrideElementCSS[x]; if (typeof(current) == 'string') html.push('<link type="text/css" rel="stylesheet" href="' + current + '" >'); else html.push('<link type="text/css" rel="stylesheet" href="' + current.href + '" media="' + current.media + '" >'); } } } else { $(document).find("link").filter(function(){ return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function(){ html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" media="' + $(this).attr('media') + '" >'); }); } //Ensure that relative links work html.push('<base href="' + _getBaseHref() + '" />'); html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $element.attr('class') + '">' + elementHtml + '</div>'); html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>'); html.push('</body></html>'); return html.join(''); };
html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>');
html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts["leaveOpen"] && opts["printMode"].toLowerCase() == 'popup') ? 'close();' : '') + '}</script>');
function _getMarkup(element, opts){ var $element = $(element); var elementHtml = _getElementHTMLIncludingFormElements(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS) { if (opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { var current = opts.overrideElementCSS[x]; if (typeof(current) == 'string') html.push('<link type="text/css" rel="stylesheet" href="' + current + '" >'); else html.push('<link type="text/css" rel="stylesheet" href="' + current.href + '" media="' + current.media + '" >'); } } } else { $(document).find("link").filter(function(){ return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function(){ html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" media="' + $(this).attr('media') + '" >'); }); } //Ensure that relative links work html.push('<base href="' + _getBaseHref() + '" />'); html.push('</head><body style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $element.attr('class') + '">' + elementHtml + '</div>'); html.push('<script type="text/javascript">function printPage(){focus();print();' + ((!$.browser.opera && !opts.leaveOpen && opts.printMode.toLowerCase() == 'popup') ? 'close();' : '') + '}</script>'); html.push('</body></html>'); return html.join(''); };
}; function _getMarkup(element, opts) { var $elementToPrint = $(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS && opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { html.push('<link type="text/css" rel="stylesheet" href="' + opts.overrideElementCSS[x] + '" >'); } } else { $(document).find("link ").filter(function() { return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function() { html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >'); }); } html.push('</head><body onload="printPage();" style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $elementToPrint.attr("class") + '">' + $elementToPrint.html() + '</div>'); html.push('<script type="text/javascript">function printPage() { focus();print();' + (opts.leaveOpen ? '' : 'close();') + '}</script></body></html>'); return html.join(''); };
function($){$.fn.printElement=function(options){var mainOptions=$.extend({},$.fn.printElement.defaults,options);if(mainOptions.printMode=='iframe'){if($.browser.opera||(/chrome/.test(navigator.userAgent.toLowerCase())))mainOptions.printMode='popup';}$("[id^='printElement_']").remove();return this.each(function(){var opts=$.meta?$.extend({},mainOptions,$this.data()):mainOptions;_printElement($(this),opts);});};$.fn.printElement.defaults={printMode:'iframe',pageTitle:'',overrideElementCSS:null,printBodyOptions:{styleToAdd:'padding:10px;margin:10px;',classNameToAdd:''},leaveOpen:false,iframeElementOptions:{styleToAdd:'border:none;position:absolute;width:0px;height:0px;bottom:0px;left:0px;',classNameToAdd:''}};$.fn.printElement.cssElement={href:'',media:''};function _printElement(element,opts){var html=_getMarkup(element,opts);var popupOrIframe=null;var documentToWriteTo=null;if(opts.printMode.toLowerCase()=='popup'){popupOrIframe=window.open('about:blank','printElementWindow','width=650,height=440,scrollbars=yes');documentToWriteTo=popupOrIframe.document;}else{var printElementID="printElement_"+(Math.round(Math.random()*99999)).toString();var iframe=document.createElement('IFRAME');$(iframe).attr({style:opts.iframeElementOptions.styleToAdd,id:printElementID,className:opts.iframeElementOptions.classNameToAdd,frameBorder:0,scrolling:'no',src:'about:blank'});document.body.appendChild(iframe);documentToWriteTo=(iframe.contentWindow||iframe.contentDocument);if(documentToWriteTo.document)documentToWriteTo=documentToWriteTo.document;iframe=document.frames?document.frames[printElementID]:document.getElementById(printElementID);popupOrIframe=iframe.contentWindow||iframe;}focus();documentToWriteTo.open();documentToWriteTo.write(html);documentToWriteTo.close();_callPrint(popupOrIframe);};function _callPrint(element){if(element&&element.printPage)element.printPage();else setTimeout(function(){_callPrint(element);},50);}function _getElementHTMLIncludingFormElements(element){var $element=$(element);$(":checked",$element).each(function(){this.setAttribute('checked','checked');});$("input[type='text']",$element).each(function(){this.setAttribute('value',$(this).val());});$("select",$element).each(function(){var $select=$(this);$("option",$select).each(function(){if($select.val()==$(this).val())this.setAttribute('selected','selected');});});$("textarea",$element).each(function(){var value=$(this).attr('value');if($.browser.mozilla)this.firstChild.textContent=value;else this.innerHTML=value;});var elementHtml=$('<div></div>').append($element.clone()).html();return elementHtml;}function _getBaseHref(){return window.location.protocol+"
}; function _getMarkup(element, opts) { var $elementToPrint = $(element); var html = new Array(); html.push('<html><head><title>' + opts.pageTitle + '</title>'); if (opts.overrideElementCSS && opts.overrideElementCSS.length > 0) { for (var x = 0; x < opts.overrideElementCSS.length; x++) { html.push('<link type="text/css" rel="stylesheet" href="' + opts.overrideElementCSS[x] + '" >'); } } else { $(document).find("link ").filter(function() { return $(this).attr("rel").toLowerCase() == "stylesheet"; }).each(function() { html.push('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >'); }); } html.push('</head><body onload="printPage();" style="' + opts.printBodyOptions.styleToAdd + '" class="' + opts.printBodyOptions.classNameToAdd + '">'); html.push('<div class="' + $elementToPrint.attr("class") + '">' + $elementToPrint.html() + '</div>'); html.push('<script type="text/javascript">function printPage() { focus();print();' + (opts.leaveOpen ? '' : 'close();') + '}</script></body></html>'); return html.join(''); };
for (i=0; i<numTypes; i++){
for (i=0; i<numTypes; i += 1){
function _getRowSchema(xmlDoc){ var types = _getElementsByTagNameNS(xmlDoc, _xmlnsSchema, _xmlnsSchemaPrefix, "complexType"), numTypes = types.length, type, i; for (i=0; i<numTypes; i++){ type = types.item(i); if (type.getAttribute("name")==="row"){ return type; } } return null;}
else if(a.textContent)return a.textContent;else{var b="";a=a.childNodes;for(var d=a.length,c=0;c<d;c++)b+=a.item(c).data;return b}},_getValueConverter:function(a){var b={};switch(a){case "xsd:boolean":b.func=this._boolConverter;b.jsType="boolean";break;case "xsd:decimal":case "xsd:double":case "xsd:float":b.func=this._floatConverter;b.jsType="number";break;case "xsd:int":case "xsd:integer":case "xsd:nonPositiveInteger":case "xsd:negativeInteger":case "xsd:nonNegativeInteger":case "xsd:positiveInteger":case "xsd:short":case "xsd:byte":case "xsd:long":case "xsd:unsignedLong":case "xsd:unsignedInt":case "xsd:unsignedShort":case "xsd:unsignedByte":b.func= this._intConverter;b.jsType="number";break;case "xsd:string":b.func=this._textConverter;b.jsType="string";break;case "Restrictions":b.func=this._restrictionsConverter;b.jsType="object";break;default:b.func=this._textConverter;b.jsType="object";break}return b},_createFieldGetter:function(a,b,d,c){if(d===null)d="1";if(c===null)c="1";var e=this,f;if(c==="1")if(d==="1")f=function(){var g=m(this.row,r,null,a);return b(e._elementText(g.item(0)))};else{if(d==="0")f=function(){var g=m(this.row,r,null,a);
else if(a.textContent)return a.textContent;else{var b="";a=a.childNodes;for(var d=a.length,c=0;c<d;c+=1)b+=a.item(c).data;return b}},_getValueConverter:function(a){var b={};switch(a){case "xsd:boolean":b.func=this._boolConverter;b.jsType="boolean";break;case "xsd:decimal":case "xsd:double":case "xsd:float":b.func=this._floatConverter;b.jsType="number";break;case "xsd:int":case "xsd:integer":case "xsd:nonPositiveInteger":case "xsd:negativeInteger":case "xsd:nonNegativeInteger":case "xsd:positiveInteger":case "xsd:short":case "xsd:byte":case "xsd:long":case "xsd:unsignedLong":case "xsd:unsignedInt":case "xsd:unsignedShort":case "xsd:unsignedByte":b.func= this._intConverter;b.jsType="number";break;case "xsd:string":b.func=this._textConverter;b.jsType="string";break;case "Restrictions":b.func=this._restrictionsConverter;b.jsType="object";break;default:b.func=this._textConverter;b.jsType="object";break}return b},_createFieldGetter:function(a,b,d,c){if(d===null)d="1";if(c===null)c="1";var e=this,h;if(c==="1")if(d==="1")h=function(){var f=o(this.row,s,null,a);return b(e._elementText(f.item(0)))};else{if(d==="0")h=function(){var f=o(this.row,s,null,a);
else if(a.textContent)return a.textContent;else{var b="";a=a.childNodes;for(var d=a.length,c=0;c<d;c++)b+=a.item(c).data;return b}},_getValueConverter:function(a){var b={};switch(a){case "xsd:boolean":b.func=this._boolConverter;b.jsType="boolean";break;case "xsd:decimal":case "xsd:double":case "xsd:float":b.func=this._floatConverter;b.jsType="number";break;case "xsd:int":case "xsd:integer":case "xsd:nonPositiveInteger":case "xsd:negativeInteger":case "xsd:nonNegativeInteger":case "xsd:positiveInteger":case "xsd:short":case "xsd:byte":case "xsd:long":case "xsd:unsignedLong":case "xsd:unsignedInt":case "xsd:unsignedShort":case "xsd:unsignedByte":b.func=this._intConverter;b.jsType="number";break;case "xsd:string":b.func=this._textConverter;b.jsType="string";break;case "Restrictions":b.func=this._restrictionsConverter;b.jsType="object";break;default:b.func=this._textConverter;b.jsType="object";break}return b},_createFieldGetter:function(a,b,d,c){if(d===null)d="1";if(c===null)c="1";var e=this,f;if(c==="1")if(d==="1")f=function(){var g=m(this.row,r,null,a);return b(e._elementText(g.item(0)))};else{if(d==="0")f=function(){var g=m(this.row,r,null,a);
var msg = "\n" + indent + "<" + container + ">";
var numItems, i, entry, property, item, msg = "\n" + indent + "<" + container + ">";
function _getXmlaSoapList(container, listType, items, indent){ if (!indent){ indent = ""; } var msg = "\n" + indent + "<" + container + ">"; if (items) { var item; msg += "\n" + indent + " <" + listType + ">"; for (var property in items){ if (items.hasOwnProperty(property)) { item = items[property]; msg += "\n" + indent + " <" + property + ">"; if (typeof(item)==="array"){ for (var entry, i=0, numItems = item.length; i<numItems; i++){ entry = item[i]; msg += "<Value>" + _xmlEncodeListEntry(entry) + "</Value>"; } } else { msg += _xmlEncodeListEntry(item); } msg += "</" + property + ">"; } } msg += "\n" + indent + " </" + listType + ">"; } msg += "\n" + indent + "</" + container + ">"; return msg;}
var item;
function _getXmlaSoapList(container, listType, items, indent){ if (!indent){ indent = ""; } var msg = "\n" + indent + "<" + container + ">"; if (items) { var item; msg += "\n" + indent + " <" + listType + ">"; for (var property in items){ if (items.hasOwnProperty(property)) { item = items[property]; msg += "\n" + indent + " <" + property + ">"; if (typeof(item)==="array"){ for (var entry, i=0, numItems = item.length; i<numItems; i++){ entry = item[i]; msg += "<Value>" + _xmlEncodeListEntry(entry) + "</Value>"; } } else { msg += _xmlEncodeListEntry(item); } msg += "</" + property + ">"; } } msg += "\n" + indent + " </" + listType + ">"; } msg += "\n" + indent + "</" + container + ">"; return msg;}
for (var property in items){
for (property in items){
function _getXmlaSoapList(container, listType, items, indent){ if (!indent){ indent = ""; } var msg = "\n" + indent + "<" + container + ">"; if (items) { var item; msg += "\n" + indent + " <" + listType + ">"; for (var property in items){ if (items.hasOwnProperty(property)) { item = items[property]; msg += "\n" + indent + " <" + property + ">"; if (typeof(item)==="array"){ for (var entry, i=0, numItems = item.length; i<numItems; i++){ entry = item[i]; msg += "<Value>" + _xmlEncodeListEntry(entry) + "</Value>"; } } else { msg += _xmlEncodeListEntry(item); } msg += "</" + property + ">"; } } msg += "\n" + indent + " </" + listType + ">"; } msg += "\n" + indent + "</" + container + ">"; return msg;}
for (var entry, i=0, numItems = item.length; i<numItems; i++){
for (entry, i=0, numItems = item.length; i<numItems; i += 1){
function _getXmlaSoapList(container, listType, items, indent){ if (!indent){ indent = ""; } var msg = "\n" + indent + "<" + container + ">"; if (items) { var item; msg += "\n" + indent + " <" + listType + ">"; for (var property in items){ if (items.hasOwnProperty(property)) { item = items[property]; msg += "\n" + indent + " <" + property + ">"; if (typeof(item)==="array"){ for (var entry, i=0, numItems = item.length; i<numItems; i++){ entry = item[i]; msg += "<Value>" + _xmlEncodeListEntry(entry) + "</Value>"; } } else { msg += _xmlEncodeListEntry(item); } msg += "</" + property + ">"; } } msg += "\n" + indent + " </" + listType + ">"; } msg += "\n" + indent + "</" + container + ">"; return msg;}
var msg = ""; var method = options.method;
var msg = "", method = options.method, exception = null;
function _getXmlaSoapMessage( options){ var msg = ""; var method = options.method; msg += "\n<" + _xmlnsSOAPenvelopePrefix + ":Envelope " + _xmlnsIsSOAPenvelope + " " + _SOAPencodingStyle + ">" + "\n <" + _xmlnsSOAPenvelopePrefix + ":Body>" + "\n <" + method + " " + _xmlnsIsXmla + " " + _SOAPencodingStyle + ">" ; var exception = null; switch(method){ case Xmla.METHOD_DISCOVER: if (_isUndefined(options.requestType)) { exception = Xmla.Exception._newError( "MISSING_REQUEST_TYPE", "Xmla._getXmlaSoapMessage", options ); } else { msg += "\n <" + _xmlRequestType + ">" + options.requestType + "</" + _xmlRequestType + ">" + _getXmlaSoapList("Restrictions", "RestrictionList", options.restrictions, " ") + _getXmlaSoapList("Properties", "PropertyList", options.properties, " ") ; } break; case Xmla.METHOD_EXECUTE: if (_isUndefined(options.statement)){ exception = Xmla.Exception._newError( "MISSING_REQUEST_TYPE", "Xmla._getXmlaSoapMessage", options ); } else { msg += "" + "\n <Command>" + "\n <Statement>" + options.statement + "</Statement>" + "\n </Command>" + _getXmlaSoapList("Properties", "PropertyList", options.properties, " ") ; } break; default: //we used to throw an exception here, //but this would make it impossible //to execute service or provider specific methods. } if (exception!==null){ exception._throw(); } msg += "\n </" + method + ">" + "\n </" + _xmlnsSOAPenvelopePrefix + ":Body>" + "\n</" + _xmlnsSOAPenvelopePrefix + ":Envelope>" ; return msg;}
var exception = null;
function _getXmlaSoapMessage( options){ var msg = ""; var method = options.method; msg += "\n<" + _xmlnsSOAPenvelopePrefix + ":Envelope " + _xmlnsIsSOAPenvelope + " " + _SOAPencodingStyle + ">" + "\n <" + _xmlnsSOAPenvelopePrefix + ":Body>" + "\n <" + method + " " + _xmlnsIsXmla + " " + _SOAPencodingStyle + ">" ; var exception = null; switch(method){ case Xmla.METHOD_DISCOVER: if (_isUndefined(options.requestType)) { exception = Xmla.Exception._newError( "MISSING_REQUEST_TYPE", "Xmla._getXmlaSoapMessage", options ); } else { msg += "\n <" + _xmlRequestType + ">" + options.requestType + "</" + _xmlRequestType + ">" + _getXmlaSoapList("Restrictions", "RestrictionList", options.restrictions, " ") + _getXmlaSoapList("Properties", "PropertyList", options.properties, " ") ; } break; case Xmla.METHOD_EXECUTE: if (_isUndefined(options.statement)){ exception = Xmla.Exception._newError( "MISSING_REQUEST_TYPE", "Xmla._getXmlaSoapMessage", options ); } else { msg += "" + "\n <Command>" + "\n <Statement>" + options.statement + "</Statement>" + "\n </Command>" + _getXmlaSoapList("Properties", "PropertyList", options.properties, " ") ; } break; default: //we used to throw an exception here, //but this would make it impossible //to execute service or provider specific methods. } if (exception!==null){ exception._throw(); } msg += "\n </" + method + ">" + "\n </" + _xmlnsSOAPenvelopePrefix + ":Body>" + "\n</" + _xmlnsSOAPenvelopePrefix + ":Envelope>" ; return msg;}
let selection = window.content.getSelection();
let selection = Buffer.focusedWindow.getSelection();
_handleModeChange: function (oldMode, newMode, oldExtended) { switch (oldMode) { case modes.TEXTAREA: case modes.INSERT: editor.unselectText(); break; case modes.VISUAL: if (newMode == modes.CARET) { try { // clear any selection made; a simple if (selection) does not work let selection = window.content.getSelection(); selection.collapseToStart(); } catch (e) {} } else editor.unselectText(); break; case modes.CUSTOM: plugins.stop(); break; case modes.COMMAND_LINE: // clean up for HINT mode if (oldExtended & modes.HINTS) hints.hide(); commandline.close(); break; } if (newMode == modes.NORMAL) { // disable caret mode when we want to switch to normal mode if (options.getPref("accessibility.browsewithcaret")) options.setPref("accessibility.browsewithcaret", false); statusline.updateUrl(); liberator.focusContent(true); } },
}};})();}if(!a.editor){a.ELEMENT_MODE_NONE=0;a.ELEMENT_MODE_REPLACE=1;a.ELEMENT_MODE_APPENDTO=2;a.editor=function(b,c,d,e){var f=this;f._={instanceConfig:b,element:c,data:e};f.elementMode=d||0;a.event.call(f);f._init();};a.editor.replace=function(b,c){var d=b;if(typeof d!='object'){d=document.getElementById(b);if(!d){var e=0,f=document.getElementsByName(b);while((d=f[e++])&&d.tagName.toLowerCase()!='textarea'){}}if(!d)throw '[CKEDITOR.editor.replace] The element with id or name "'+b+'" was not found.';}d.style.visibility='hidden';return new a.editor(c,d,1);};a.editor.appendTo=function(b,c,d){var e=b;if(typeof e!='object'){e=document.getElementById(b);if(!e)throw '[CKEDITOR.editor.appendTo] The element with id "'+b+'" was not found.';}return new a.editor(c,e,2,d);};a.editor.prototype={_init:function(){var b=a.editor._pending||(a.editor._pending=[]);b.push(this);},fire:function(b,c){return a.event.prototype.fire.call(this,b,c,this);},fireOnce:function(b,c){return a.event.prototype.fireOnce.call(this,b,c,this);}};a.event.implementOn(a.editor.prototype,true);}if(!a.env)a.env=(function(){var b=navigator.userAgent.toLowerCase(),c=window.opera,d={ie:false,opera:!!c&&c.version,webkit:b.indexOf(' applewebkit/')>-1,air:b.indexOf(' adobeair/')>-1,mac:b.indexOf('macintosh')>-1,quirks:document.compatMode=='BackCompat',mobile:b.indexOf('mobile')>-1,isCustomDomain:function(){return this.ie&&document.domain!=window.location.hostname;}};d.gecko=navigator.product=='Gecko'&&!d.webkit&&!d.opera;var e=0;if(d.ie){e=parseFloat(b.match(/msie (\d+)/)[1]);d.ie8=!!document.documentMode;d.ie8Compat=document.documentMode==8;d.ie7Compat=e==7&&!document.documentMode||document.documentMode==7;d.ie6Compat=e<7||d.quirks;}if(d.gecko){var f=b.match(/rv:([\d\.]+)/);if(f){f=f[1].split('.');e=f[0]*10000+(f[1]||0)*100+ +(f[2]||0);}}if(d.opera)e=parseFloat(c.version());if(d.air)e=parseFloat(b.match(/ adobeair\/(\d+)/)[1]);if(d.webkit)e=parseFloat(b.match(/ applewebkit\/(\d+)/)[1]);d.version=e;d.isCompatible=!d.mobile&&(d.ie&&e>=6||d.gecko&&e>=10801||d.opera&&e>=9.5||d.air&&e>=1||d.webkit&&e>=522||false);d.cssClass='cke_browser_'+(d.ie?'ie':d.gecko?'gecko':d.opera?'opera':d.air?'air':d.webkit?'webkit':'unknown');if(d.quirks)d.cssClass+=' cke_browser_quirks';if(d.ie){d.cssClass+=' cke_browser_ie'+(d.version<7?'6':d.version>=8?'8':'7');if(d.quirks)d.cssClass+=' cke_browser_iequirks';}if(d.gecko&&e<10900)d.cssClass+=' cke_browser_gecko18';return d;})();var b=a.env;var c=b.ie;
return e&&e.listeners.length>0;}};})();}if(!a.editor){a.ELEMENT_MODE_NONE=0;a.ELEMENT_MODE_REPLACE=1;a.ELEMENT_MODE_APPENDTO=2;a.editor=function(b,c,d,e){var f=this;f._={instanceConfig:b,element:c,data:e};f.elementMode=d||0;a.event.call(f);f._init();};a.editor.replace=function(b,c){var d=b;if(typeof d!='object'){d=document.getElementById(b);if(!d){var e=0,f=document.getElementsByName(b);while((d=f[e++])&&d.tagName.toLowerCase()!='textarea'){}}if(!d)throw '[CKEDITOR.editor.replace] The element with id or name "'+b+'" was not found.';}d.style.visibility='hidden';return new a.editor(c,d,1);};a.editor.appendTo=function(b,c,d){var e=b;if(typeof e!='object'){e=document.getElementById(b);if(!e)throw '[CKEDITOR.editor.appendTo] The element with id "'+b+'" was not found.';}return new a.editor(c,e,2,d);};a.editor.prototype={_init:function(){var b=a.editor._pending||(a.editor._pending=[]);b.push(this);},fire:function(b,c){return a.event.prototype.fire.call(this,b,c,this);},fireOnce:function(b,c){return a.event.prototype.fireOnce.call(this,b,c,this);}};a.event.implementOn(a.editor.prototype,true);}if(!a.env)a.env=(function(){var b=navigator.userAgent.toLowerCase(),c=window.opera,d={ie:false,opera:!!c&&c.version,webkit:b.indexOf(' applewebkit/')>-1,air:b.indexOf(' adobeair/')>-1,mac:b.indexOf('macintosh')>-1,quirks:document.compatMode=='BackCompat',mobile:b.indexOf('mobile')>-1,isCustomDomain:function(){if(!this.ie)return false;var g=document.domain,h=window.location.hostname;return g!=h&&g!='['+h+']';}};d.gecko=navigator.product=='Gecko'&&!d.webkit&&!d.opera;var e=0;if(d.ie){e=parseFloat(b.match(/msie (\d+)/)[1]);d.ie8=!!document.documentMode;d.ie8Compat=document.documentMode==8;d.ie7Compat=e==7&&!document.documentMode||document.documentMode==7;d.ie6Compat=e<7||d.quirks;}if(d.gecko){var f=b.match(/rv:([\d\.]+)/);if(f){f=f[1].split('.');e=f[0]*10000+(f[1]||0)*100+ +(f[2]||0);}}if(d.opera)e=parseFloat(c.version());if(d.air)e=parseFloat(b.match(/ adobeair\/(\d+)/)[1]);if(d.webkit)e=parseFloat(b.match(/ applewebkit\/(\d+)/)[1]);d.version=e;d.isCompatible=!d.mobile&&(d.ie&&e>=6||d.gecko&&e>=10801||d.opera&&e>=9.5||d.air&&e>=1||d.webkit&&e>=522||false);d.cssClass='cke_browser_'+(d.ie?'ie':d.gecko?'gecko':d.opera?'opera':d.air?'air':d.webkit?'webkit':'unknown');if(d.quirks)d.cssClass+=' cke_browser_quirks';if(d.ie){d.cssClass+=' cke_browser_ie'+(d.version<7?'6':d.version>=8?'8':'7');if(d.quirks)d.cssClass+=' cke_browser_iequirks';}if(d.gecko&&e<10900)d.cssClass+=' cke_browser_gecko18';
}};})();}if(!a.editor){a.ELEMENT_MODE_NONE=0;a.ELEMENT_MODE_REPLACE=1;a.ELEMENT_MODE_APPENDTO=2;a.editor=function(b,c,d,e){var f=this;f._={instanceConfig:b,element:c,data:e};f.elementMode=d||0;a.event.call(f);f._init();};a.editor.replace=function(b,c){var d=b;if(typeof d!='object'){d=document.getElementById(b);if(!d){var e=0,f=document.getElementsByName(b);while((d=f[e++])&&d.tagName.toLowerCase()!='textarea'){}}if(!d)throw '[CKEDITOR.editor.replace] The element with id or name "'+b+'" was not found.';}d.style.visibility='hidden';return new a.editor(c,d,1);};a.editor.appendTo=function(b,c,d){var e=b;if(typeof e!='object'){e=document.getElementById(b);if(!e)throw '[CKEDITOR.editor.appendTo] The element with id "'+b+'" was not found.';}return new a.editor(c,e,2,d);};a.editor.prototype={_init:function(){var b=a.editor._pending||(a.editor._pending=[]);b.push(this);},fire:function(b,c){return a.event.prototype.fire.call(this,b,c,this);},fireOnce:function(b,c){return a.event.prototype.fireOnce.call(this,b,c,this);}};a.event.implementOn(a.editor.prototype,true);}if(!a.env)a.env=(function(){var b=navigator.userAgent.toLowerCase(),c=window.opera,d={ie:/*@cc_on!@*/false,opera:!!c&&c.version,webkit:b.indexOf(' applewebkit/')>-1,air:b.indexOf(' adobeair/')>-1,mac:b.indexOf('macintosh')>-1,quirks:document.compatMode=='BackCompat',mobile:b.indexOf('mobile')>-1,isCustomDomain:function(){return this.ie&&document.domain!=window.location.hostname;}};d.gecko=navigator.product=='Gecko'&&!d.webkit&&!d.opera;var e=0;if(d.ie){e=parseFloat(b.match(/msie (\d+)/)[1]);d.ie8=!!document.documentMode;d.ie8Compat=document.documentMode==8;d.ie7Compat=e==7&&!document.documentMode||document.documentMode==7;d.ie6Compat=e<7||d.quirks;}if(d.gecko){var f=b.match(/rv:([\d\.]+)/);if(f){f=f[1].split('.');e=f[0]*10000+(f[1]||0)*100+ +(f[2]||0);}}if(d.opera)e=parseFloat(c.version());if(d.air)e=parseFloat(b.match(/ adobeair\/(\d+)/)[1]);if(d.webkit)e=parseFloat(b.match(/ applewebkit\/(\d+)/)[1]);d.version=e;d.isCompatible=!d.mobile&&(d.ie&&e>=6||d.gecko&&e>=10801||d.opera&&e>=9.5||d.air&&e>=1||d.webkit&&e>=522||false);d.cssClass='cke_browser_'+(d.ie?'ie':d.gecko?'gecko':d.opera?'opera':d.air?'air':d.webkit?'webkit':'unknown');if(d.quirks)d.cssClass+=' cke_browser_quirks';if(d.ie){d.cssClass+=' cke_browser_ie'+(d.version<7?'6':d.version>=8?'8':'7');if(d.quirks)d.cssClass+=' cke_browser_iequirks';}if(d.gecko&&e<10900)d.cssClass+=' cke_browser_gecko18';return d;})();var b=a.env;var c=b.ie;
[];Xmla.Rowset.KEYS[Xmla.MDSCHEMA_PROPERTIES]=[];Xmla.Rowset.KEYS[Xmla.MDSCHEMA_SETS]=[];Xmla.Rowset.prototype={_type:null,rows:null,numRows:null,fieldOrder:null,fields:null,_fieldCount:null,_initData:function(a,b){this._type=b;this.numRows=(this.rows=m(a,r,null,"row"))?this.rows.length:0;this.reset();this.fieldOrder=[];this.fields={};this._fieldCount=0;var d=R(a);if(d){a=m(d,A,B,"sequence").item(0);a=a.childNodes;d=a.length;for(var c,e,f,g,i,o,s=0;s<d;s++){c=a.item(s);if(c.nodeType==1){e=D(c,I,H, "field");f=c.getAttribute("name");i=c.getAttribute("type");if(i==null&&this.row){g=this.row.getElementsByTagName(f);if(g.length)i=D(g.item(0),J,K,"type")}if(!i&&b==Xmla.DISCOVER_SCHEMA_ROWSETS&&f=="Restrictions")i="Restrictions";g=c.getAttribute("minOccurs");c=c.getAttribute("maxOccurs");o=this._getValueConverter(i);this.fields[e]={name:f,label:e,index:this._fieldCount++,type:i,jsType:o.jsType,minOccurs:j(g)?1:g,maxOccurs:j(c)?1:c==="unbounded"?Infinity:c,getter:this._createFieldGetter(f,o.func,g, c)};this.fieldOrder.push(e)}}}else Xmla.Exception._newError("ERROR_PARSING_RESPONSE","Xmla.Rowset",a)._throw()},_boolConverter:function(a){return a==="true"?true:false},_intConverter:function(a){return parseInt(a,10)},_floatConverter:function(a){return parseFloat(a,10)},_textConverter:function(a){return a},_restrictionsConverter:function(a){return a},_arrayConverter:function(a,b){for(var d=[],c=a.length,e,f=0;f<c;f++){e=a.item(f);d.push(b(this._elementText(e)))}return d},_elementText:function(a){if(a.innerText)return a.innerText;
[];Xmla.Rowset.KEYS[Xmla.MDSCHEMA_PROPERTIES]=[];Xmla.Rowset.KEYS[Xmla.MDSCHEMA_SETS]=[];Xmla.Rowset.prototype={_type:null,rows:null,numRows:null,fieldOrder:null,fields:null,_fieldCount:null,_initData:function(a,b){this._type=b;this.numRows=(this.rows=o(a,s,null,"row"))?this.rows.length:0;this.reset();this.fieldOrder=[];this.fields={};this._fieldCount=0;var d=R(a);if(d){a=o(d,z,A,"sequence").item(0);a=a.childNodes;d=a.length;for(var c,e,h,f,i,n,k=0;k<d;k+=1){c=a.item(k);if(c.nodeType===1){e=C(c,H, G,"field");h=c.getAttribute("name");i=c.getAttribute("type");if(i===null&&this.row){f=this.row.getElementsByTagName(h);if(f.length)i=C(f.item(0),I,J,"type")}if(!i&&b==Xmla.DISCOVER_SCHEMA_ROWSETS&&h==="Restrictions")i="Restrictions";f=c.getAttribute("minOccurs");c=c.getAttribute("maxOccurs");n=this._getValueConverter(i);this.fields[e]={name:h,label:e,index:this._fieldCount+=1,type:i,jsType:n.jsType,minOccurs:j(f)?1:f,maxOccurs:j(c)?1:c==="unbounded"?Infinity:c,getter:this._createFieldGetter(h,n.func, f,c)};this.fieldOrder.push(e)}}}else Xmla.Exception._newError("ERROR_PARSING_RESPONSE","Xmla.Rowset",a)._throw()},_boolConverter:function(a){return a==="true"?true:false},_intConverter:function(a){return parseInt(a,10)},_floatConverter:function(a){return parseFloat(a,10)},_textConverter:function(a){return a},_restrictionsConverter:function(a){return a},_arrayConverter:function(a,b){for(var d=[],c=a.length,e,h=0;h<c;h+=1){e=a.item(h);d.push(b(this._elementText(e)))}return d},_elementText:function(a){if(a.innerText)return a.innerText;
[];Xmla.Rowset.KEYS[Xmla.MDSCHEMA_PROPERTIES]=[];Xmla.Rowset.KEYS[Xmla.MDSCHEMA_SETS]=[];Xmla.Rowset.prototype={_type:null,rows:null,numRows:null,fieldOrder:null,fields:null,_fieldCount:null,_initData:function(a,b){this._type=b;this.numRows=(this.rows=m(a,r,null,"row"))?this.rows.length:0;this.reset();this.fieldOrder=[];this.fields={};this._fieldCount=0;var d=R(a);if(d){a=m(d,A,B,"sequence").item(0);a=a.childNodes;d=a.length;for(var c,e,f,g,i,o,s=0;s<d;s++){c=a.item(s);if(c.nodeType==1){e=D(c,I,H,"field");f=c.getAttribute("name");i=c.getAttribute("type");if(i==null&&this.row){g=this.row.getElementsByTagName(f);if(g.length)i=D(g.item(0),J,K,"type")}if(!i&&b==Xmla.DISCOVER_SCHEMA_ROWSETS&&f=="Restrictions")i="Restrictions";g=c.getAttribute("minOccurs");c=c.getAttribute("maxOccurs");o=this._getValueConverter(i);this.fields[e]={name:f,label:e,index:this._fieldCount++,type:i,jsType:o.jsType,minOccurs:j(g)?1:g,maxOccurs:j(c)?1:c==="unbounded"?Infinity:c,getter:this._createFieldGetter(f,o.func,g,c)};this.fieldOrder.push(e)}}}else Xmla.Exception._newError("ERROR_PARSING_RESPONSE","Xmla.Rowset",a)._throw()},_boolConverter:function(a){return a==="true"?true:false},_intConverter:function(a){return parseInt(a,10)},_floatConverter:function(a){return parseFloat(a,10)},_textConverter:function(a){return a},_restrictionsConverter:function(a){return a},_arrayConverter:function(a,b){for(var d=[],c=a.length,e,f=0;f<c;f++){e=a.item(f);d.push(b(this._elementText(e)))}return d},_elementText:function(a){if(a.innerText)return a.innerText;
a(),p=history.length;G&&clearInterval(G);G=setInterval(function(){var r,y;r=a();y=history.length;if(r!==l){l=r;p=y;e(l);b()}else if(y!==p&&u){l=r;p=y;r=M[p-1];e(r);b()}},50)}}function K(){var l;l=F.value.split("|");if(l.length>1){L=l[0];E=l[1]}if(l.length>2)M=l[2].split(",");if(q)i();else{n();I=true;x!=null&&x()}}var u=false,q=false,D=false,x=null,A=null,F=null,I=false,G=null,M=[],L,E,N=function(){};return{onReady:function(l){if(I)setTimeout(function(){l()},0);else x=l},_initialize:function(){F!= null&&K()},_initTimeout:function(){n()},register:function(l,p){if(!I){E=L=escape(l);N=p}},initialize:function(l,p){if(!I){var r=navigator.vendor||"";if(r!=="KDE")if(typeof window.opera!=="undefined")D=true;else if(typeof document.all!=="undefined")q=true;else if(r.indexOf("Apple Computer, Inc.")>-1)u=true;if(typeof l==="string")l=document.getElementById(l);if(!(!l||l.tagName.toUpperCase()!=="TEXTAREA"&&(l.tagName.toUpperCase()!=="INPUT"||l.type!=="hidden"&&l.type!=="text"))){F=l;if(q){if(typeof p===
0);else w=l},_initialize:function(){E!=null&&J()},_initTimeout:function(){n()},register:function(l,p){if(!H){D=K=escape(l);M=p}},initialize:function(l,p){if(!H){var r=navigator.vendor||"";if(r!=="KDE")if(typeof window.opera!=="undefined")C=true;else if(typeof document.all!=="undefined")q=true;else if(r.indexOf("Apple Computer, Inc.")>-1)u=true;if(typeof l==="string")l=document.getElementById(l);if(!(!l||l.tagName.toUpperCase()!=="TEXTAREA"&&(l.tagName.toUpperCase()!=="INPUT"||l.type!=="hidden"&&l.type!==
a(),p=history.length;G&&clearInterval(G);G=setInterval(function(){var r,y;r=a();y=history.length;if(r!==l){l=r;p=y;e(l);b()}else if(y!==p&&u){l=r;p=y;r=M[p-1];e(r);b()}},50)}}function K(){var l;l=F.value.split("|");if(l.length>1){L=l[0];E=l[1]}if(l.length>2)M=l[2].split(",");if(q)i();else{n();I=true;x!=null&&x()}}var u=false,q=false,D=false,x=null,A=null,F=null,I=false,G=null,M=[],L,E,N=function(){};return{onReady:function(l){if(I)setTimeout(function(){l()},0);else x=l},_initialize:function(){F!=null&&K()},_initTimeout:function(){n()},register:function(l,p){if(!I){E=L=escape(l);N=p}},initialize:function(l,p){if(!I){var r=navigator.vendor||"";if(r!=="KDE")if(typeof window.opera!=="undefined")D=true;else if(typeof document.all!=="undefined")q=true;else if(r.indexOf("Apple Computer, Inc.")>-1)u=true;if(typeof l==="string")l=document.getElementById(l);if(!(!l||l.tagName.toUpperCase()!=="TEXTAREA"&&(l.tagName.toUpperCase()!=="INPUT"||l.type!=="hidden"&&l.type!=="text"))){F=l;if(q){if(typeof p===
null&&K()},_initTimeout:function(){n()},register:function(l,p){if(!I){E=L=escape(l);N=p}},initialize:function(l,p){if(!I){var r=navigator.vendor||"";if(r!=="KDE")if(typeof window.opera!=="undefined")D=true;else if(typeof document.all!=="undefined")q=true;else if(r.indexOf("Apple Computer, Inc.")>-1)u=true;if(typeof l==="string")l=document.getElementById(l);if(!(!l||l.tagName.toUpperCase()!=="TEXTAREA"&&(l.tagName.toUpperCase()!=="INPUT"||l.type!=="hidden"&&l.type!=="text"))){F=l;if(q){if(typeof p===
0);else w=l},_initialize:function(){E!=null&&J()},_initTimeout:function(){n()},register:function(l,p){if(!H){D=K=escape(l);M=p}},initialize:function(l,p){if(!H){var r=navigator.vendor||"";if(r!=="KDE")if(typeof window.opera!=="undefined")C=true;else if(typeof document.all!=="undefined")q=true;else if(r.indexOf("Apple Computer, Inc.")>-1)u=true;if(typeof l==="string")l=document.getElementById(l);if(!(!l||l.tagName.toUpperCase()!=="TEXTAREA"&&(l.tagName.toUpperCase()!=="INPUT"||l.type!=="hidden"&&l.type!==
null&&K()},_initTimeout:function(){n()},register:function(l,p){if(!I){E=L=escape(l);N=p}},initialize:function(l,p){if(!I){var r=navigator.vendor||"";if(r!=="KDE")if(typeof window.opera!=="undefined")D=true;else if(typeof document.all!=="undefined")q=true;else if(r.indexOf("Apple Computer, Inc.")>-1)u=true;if(typeof l==="string")l=document.getElementById(l);if(!(!l||l.tagName.toUpperCase()!=="TEXTAREA"&&(l.tagName.toUpperCase()!=="INPUT"||l.type!=="hidden"&&l.type!=="text"))){F=l;if(q){if(typeof p===
_keeFoxBrowserStartup: function(currentKFToolbar, currentWindow)
_keeFoxBrowserStartup: function()
_keeFoxBrowserStartup: function(currentKFToolbar, currentWindow) { this._KFLog.debug("Testing to see if KeeFox has already been setup (e.g. just a second ago by a different window scope)"); //TODO: confirm multi-threading setup. I assume firefox has // one event dispatcher thread so seperate windows can't be calling // this function concurrently. if that's wrong, need to rethink // or at least lock from here onwards if (this._keeFoxStorage.get("KeePassRPCActive", false)) { this._KFLog.debug("Setup has already been done but we will make sure that the window that this scope is a part of has been set up to properly reflect KeeFox status"); currentKFToolbar.setupButton_ready(currentWindow); currentKFToolbar.setAllLogins(); currentWindow.addEventListener("TabSelect", this._onTabSelected, false); return; } this._KFLog.info("KeeFox initialising"); // Set up UI (TODO: Pre-KeePassRPC system did this after attempting // a connection so test that this has no bad side-effects) this._keeFoxVariableInit(currentKFToolbar, currentWindow); this._keeFoxInitialToolBarSetup(currentKFToolbar, currentWindow); this.KeePassRPC = new jsonrpcClient(); if (this._keeFoxExtension.prefs.has("KeePassRPC.port")) this.KeePassRPC.port = this._keeFoxExtension.prefs.getValue("KeePassRPC.port",12536); // make the initial connection to KeePassRPC // (fails silently if KeePassRPC is not reachable) this.KeePassRPC.connect(); // start regular attempts to reconnect to KeePassRPC // NB: overheads here include a test whether a socket is alive // and regular timer scheduling overheads - hopefully that's insignificant // but if not we can try more complicated connection strategies this.KeePassRPC.reconnectSoon(); this._KFLog.info("KeeFox initialised OK although the connection to KeePass may not be established just yet..."); },
this._KFLog.debug("Testing to see if KeeFox has already been setup (e.g. just a second ago by a different window scope)");
_keeFoxBrowserStartup: function(currentKFToolbar, currentWindow) { this._KFLog.debug("Testing to see if KeeFox has already been setup (e.g. just a second ago by a different window scope)"); //TODO: confirm multi-threading setup. I assume firefox has // one event dispatcher thread so seperate windows can't be calling // this function concurrently. if that's wrong, need to rethink // or at least lock from here onwards if (this._keeFoxStorage.get("KeePassRPCActive", false)) { this._KFLog.debug("Setup has already been done but we will make sure that the window that this scope is a part of has been set up to properly reflect KeeFox status"); currentKFToolbar.setupButton_ready(currentWindow); currentKFToolbar.setAllLogins(); currentWindow.addEventListener("TabSelect", this._onTabSelected, false); return; } this._KFLog.info("KeeFox initialising"); // Set up UI (TODO: Pre-KeePassRPC system did this after attempting // a connection so test that this has no bad side-effects) this._keeFoxVariableInit(currentKFToolbar, currentWindow); this._keeFoxInitialToolBarSetup(currentKFToolbar, currentWindow); this.KeePassRPC = new jsonrpcClient(); if (this._keeFoxExtension.prefs.has("KeePassRPC.port")) this.KeePassRPC.port = this._keeFoxExtension.prefs.getValue("KeePassRPC.port",12536); // make the initial connection to KeePassRPC // (fails silently if KeePassRPC is not reachable) this.KeePassRPC.connect(); // start regular attempts to reconnect to KeePassRPC // NB: overheads here include a test whether a socket is alive // and regular timer scheduling overheads - hopefully that's insignificant // but if not we can try more complicated connection strategies this.KeePassRPC.reconnectSoon(); this._KFLog.info("KeeFox initialised OK although the connection to KeePass may not be established just yet..."); },
if (this._keeFoxStorage.get("KeePassRPCActive", false)) { this._KFLog.debug("Setup has already been done but we will make sure that the window that this scope is a part of has been set up to properly reflect KeeFox status"); currentKFToolbar.setupButton_ready(currentWindow); currentKFToolbar.setAllLogins(); currentWindow.addEventListener("TabSelect", this._onTabSelected, false); return; }
_keeFoxBrowserStartup: function(currentKFToolbar, currentWindow) { this._KFLog.debug("Testing to see if KeeFox has already been setup (e.g. just a second ago by a different window scope)"); //TODO: confirm multi-threading setup. I assume firefox has // one event dispatcher thread so seperate windows can't be calling // this function concurrently. if that's wrong, need to rethink // or at least lock from here onwards if (this._keeFoxStorage.get("KeePassRPCActive", false)) { this._KFLog.debug("Setup has already been done but we will make sure that the window that this scope is a part of has been set up to properly reflect KeeFox status"); currentKFToolbar.setupButton_ready(currentWindow); currentKFToolbar.setAllLogins(); currentWindow.addEventListener("TabSelect", this._onTabSelected, false); return; } this._KFLog.info("KeeFox initialising"); // Set up UI (TODO: Pre-KeePassRPC system did this after attempting // a connection so test that this has no bad side-effects) this._keeFoxVariableInit(currentKFToolbar, currentWindow); this._keeFoxInitialToolBarSetup(currentKFToolbar, currentWindow); this.KeePassRPC = new jsonrpcClient(); if (this._keeFoxExtension.prefs.has("KeePassRPC.port")) this.KeePassRPC.port = this._keeFoxExtension.prefs.getValue("KeePassRPC.port",12536); // make the initial connection to KeePassRPC // (fails silently if KeePassRPC is not reachable) this.KeePassRPC.connect(); // start regular attempts to reconnect to KeePassRPC // NB: overheads here include a test whether a socket is alive // and regular timer scheduling overheads - hopefully that's insignificant // but if not we can try more complicated connection strategies this.KeePassRPC.reconnectSoon(); this._KFLog.info("KeeFox initialised OK although the connection to KeePass may not be established just yet..."); },
this._keeFoxVariableInit(currentKFToolbar, currentWindow); this._keeFoxInitialToolBarSetup(currentKFToolbar, currentWindow);
this._keeFoxVariableInit();
_keeFoxBrowserStartup: function(currentKFToolbar, currentWindow) { this._KFLog.debug("Testing to see if KeeFox has already been setup (e.g. just a second ago by a different window scope)"); //TODO: confirm multi-threading setup. I assume firefox has // one event dispatcher thread so seperate windows can't be calling // this function concurrently. if that's wrong, need to rethink // or at least lock from here onwards if (this._keeFoxStorage.get("KeePassRPCActive", false)) { this._KFLog.debug("Setup has already been done but we will make sure that the window that this scope is a part of has been set up to properly reflect KeeFox status"); currentKFToolbar.setupButton_ready(currentWindow); currentKFToolbar.setAllLogins(); currentWindow.addEventListener("TabSelect", this._onTabSelected, false); return; } this._KFLog.info("KeeFox initialising"); // Set up UI (TODO: Pre-KeePassRPC system did this after attempting // a connection so test that this has no bad side-effects) this._keeFoxVariableInit(currentKFToolbar, currentWindow); this._keeFoxInitialToolBarSetup(currentKFToolbar, currentWindow); this.KeePassRPC = new jsonrpcClient(); if (this._keeFoxExtension.prefs.has("KeePassRPC.port")) this.KeePassRPC.port = this._keeFoxExtension.prefs.getValue("KeePassRPC.port",12536); // make the initial connection to KeePassRPC // (fails silently if KeePassRPC is not reachable) this.KeePassRPC.connect(); // start regular attempts to reconnect to KeePassRPC // NB: overheads here include a test whether a socket is alive // and regular timer scheduling overheads - hopefully that's insignificant // but if not we can try more complicated connection strategies this.KeePassRPC.reconnectSoon(); this._KFLog.info("KeeFox initialised OK although the connection to KeePass may not be established just yet..."); },
_keeFoxVariableInit : function(currentKFToolbar, currentWindow)
_keeFoxVariableInit : function()
_keeFoxVariableInit : function(currentKFToolbar, currentWindow) { var KeePassEXEfound; var KeePassRPCfound; var keePassLocation; keePassLocation = "not installed"; var keePassRPCLocation; keePassRPCLocation = "not installed"; var keePassRememberInstalledLocation = this._keeFoxExtension.prefs.getValue("keePassRememberInstalledLocation",false); if (!keePassRememberInstalledLocation) { keePassLocation = this._discoverKeePassInstallLocation(); if (keePassLocation != "not installed") { KeePassEXEfound = this._confirmKeePassInstallLocation(keePassLocation); if (KeePassEXEfound) { keePassRPCLocation = this._discoverKeePassRPCInstallLocation(); KeePassRPCfound = this._confirmKeePassRPCInstallLocation(keePassRPCLocation); if (!KeePassRPCfound) this._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); //TODO: set this to "not installed"? } else { this._keeFoxExtension.prefs.setValue("keePassInstalledLocation",""); //TODO: set this to "not installed"? } } } if (keePassRememberInstalledLocation) { this._keeFoxStorage.set("KeePassRPCInstalled", true); } else { this._KFLog.info("Checking and updating KeePassRPC installation settings"); if (keePassRPCLocation == "not installed") { this._KFLog.info("KeePassRPC location was not found"); this._launchInstaller(currentKFToolbar,currentWindow); } else { if (!KeePassEXEfound) { this._KFLog.info("KeePass EXE not present in expected location"); this._launchInstaller(currentKFToolbar,currentWindow); } else { if (!KeePassRPCfound) { this._KFLog.info("KeePassRPC plugin DLL not present in KeePass plugins directory so needs to be installed"); this._launchInstaller(currentKFToolbar,currentWindow); } else { this._KFLog.info("KeePass is not running or the connection might be established in a second..."); this._keeFoxStorage.set("KeePassRPCInstalled", true); } } } } },
this._launchInstaller(currentKFToolbar,currentWindow);
this._launchInstaller();
_keeFoxVariableInit : function(currentKFToolbar, currentWindow) { var KeePassEXEfound; var KeePassRPCfound; var keePassLocation; keePassLocation = "not installed"; var keePassRPCLocation; keePassRPCLocation = "not installed"; var keePassRememberInstalledLocation = this._keeFoxExtension.prefs.getValue("keePassRememberInstalledLocation",false); if (!keePassRememberInstalledLocation) { keePassLocation = this._discoverKeePassInstallLocation(); if (keePassLocation != "not installed") { KeePassEXEfound = this._confirmKeePassInstallLocation(keePassLocation); if (KeePassEXEfound) { keePassRPCLocation = this._discoverKeePassRPCInstallLocation(); KeePassRPCfound = this._confirmKeePassRPCInstallLocation(keePassRPCLocation); if (!KeePassRPCfound) this._keeFoxExtension.prefs.setValue("keePassRPCInstalledLocation",""); //TODO: set this to "not installed"? } else { this._keeFoxExtension.prefs.setValue("keePassInstalledLocation",""); //TODO: set this to "not installed"? } } } if (keePassRememberInstalledLocation) { this._keeFoxStorage.set("KeePassRPCInstalled", true); } else { this._KFLog.info("Checking and updating KeePassRPC installation settings"); if (keePassRPCLocation == "not installed") { this._KFLog.info("KeePassRPC location was not found"); this._launchInstaller(currentKFToolbar,currentWindow); } else { if (!KeePassEXEfound) { this._KFLog.info("KeePass EXE not present in expected location"); this._launchInstaller(currentKFToolbar,currentWindow); } else { if (!KeePassRPCfound) { this._KFLog.info("KeePassRPC plugin DLL not present in KeePass plugins directory so needs to be installed"); this._launchInstaller(currentKFToolbar,currentWindow); } else { this._KFLog.info("KeePass is not running or the connection might be established in a second..."); this._keeFoxStorage.set("KeePassRPCInstalled", true); } } } } },
this._KFLog.debug("Setting up a button for user to launch installer (also make a massive one on page in future)"); currentKFToolbar.setupButton_install(currentWindow);
_launchInstaller: function(currentKFToolbar,currentWindow, upgrade) { if (this._installerTabLoaded) return; // only want to do this once per session to avoid irritation! this._installerTabLoaded = true; if (upgrade) { this._KFLog.info("KeeFox not installed correctly. Going to try to launch the upgrade page."); installTab = this._openAndReuseOneTabPerURL("chrome://keefox/content/install.xul?upgrade=1"); } else { this._KFLog.info("KeeFox not installed correctly. Going to try to launch the install page."); installTab = this._openAndReuseOneTabPerURL("chrome://keefox/content/install.xul"); } //NB: FF < 3.0.5 may fail to open the tab due to bug where "session loaded" event fires too soon. // remember the installation state (until it might have changed...) this._keeFoxStorage.set("KeePassRPCInstalled", false); this._KFLog.debug("Setting up a button for user to launch installer (also make a massive one on page in future)"); currentKFToolbar.setupButton_install(currentWindow); },
if (this.methodFile) this._logToFile(message+"\n"); if (this.methodStdOut) dump(message+"\n"); if (this.methodConsole) this._logService.logStringMessage(message); if (this.methodAlert) this._alert(message);
try { var pbs = Components.classes["@mozilla.org/privatebrowsing;1"] .getService(Components.interfaces.nsIPrivateBrowsingService); if (pbs.privateBrowsingEnabled) return; } catch (nothing) { } try { if (this.methodFile) this._logToFile(message+"\n"); if (this.methodStdOut) dump(message+"\n"); if (this.methodConsole) this._logService.logStringMessage(message); if (this.methodAlert) this._alert(message); } catch (nothing) { }
_log : function (message) { if (this.methodFile) this._logToFile(message+"\n"); if (this.methodStdOut) dump(message+"\n"); if (this.methodConsole) this._logService.logStringMessage(message); if (this.methodAlert) this._alert(message); },
} catch (nothing) { } try {
_log : function (message) { // Don't log anything if user is in private browsing mode, just in case! try { var pbs = Components.classes["@mozilla.org/privatebrowsing;1"] .getService(Components.interfaces.nsIPrivateBrowsingService); if (pbs.privateBrowsingEnabled) return; } catch (nothing) { // log if private browsing feature is unavailable } try { if (this.methodFile) this._logToFile(message+"\n"); if (this.methodStdOut) dump(message+"\n"); if (this.methodConsole) this._logService.logStringMessage(message); if (this.methodAlert) this._alert(message); } catch (nothing) { // don't let failed logging break anything else } },
var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID); file.initWithPath(dir.path); file.append("log.txt");
_logToFile : function(msg) { var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID); file.initWithPath(dir.path); file.append("log.txt"); var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]. createInstance(Components.interfaces.nsIFileOutputStream); foStream.init(file, 0x02 | 0x08 | 0x10, 0666, 0); // write, create if doesn't already exist, append to end var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"]. createInstance(Components.interfaces.nsIConverterOutputStream); converter.init(foStream, "UTF-8", 0, 0); converter.writeString(msg); converter.close(); // this closes foStream },
var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID); file.initWithPath(dir.path); file.append("log.txt");
_logToFile : function(msg) { //this._logService.logStringMessage("logginga"); var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]. createInstance(Components.interfaces.nsIFileOutputStream);var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID); //var dir = directoryService.get("ProfD", Components.interfaces.nsIFile); // this._logService.logStringMessage("logging3"); file.initWithPath(dir.path); //file.append("keefox"); file.append("log.txt"); //foStream.init(this._logFile, 0x02 | 0x08 | 0x10, 0666, 0); foStream.init(file, 0x02 | 0x08 | 0x10, 0666, 0); // write, create if doesn't already exist, append to end//this._logService.logStringMessage("loggingb"); var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"]. createInstance(Components.interfaces.nsIConverterOutputStream); converter.init(foStream, "UTF-8", 0, 0); converter.writeString(msg); converter.close(); // this closes foStream // this._logService.logStringMessage("loggingc"); },
foStream.init(file, 0x02 | 0x08 | 0x10, 0666, 0);
foStream.init(this._logFile, 0x02 | 0x08 | 0x10, 0666, 0);
_logToFile : function(msg) { //this._logService.logStringMessage("logginga"); var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]. createInstance(Components.interfaces.nsIFileOutputStream);var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID); //var dir = directoryService.get("ProfD", Components.interfaces.nsIFile); // this._logService.logStringMessage("logging3"); file.initWithPath(dir.path); //file.append("keefox"); file.append("log.txt"); //foStream.init(this._logFile, 0x02 | 0x08 | 0x10, 0666, 0); foStream.init(file, 0x02 | 0x08 | 0x10, 0666, 0); // write, create if doesn't already exist, append to end//this._logService.logStringMessage("loggingb"); var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"]. createInstance(Components.interfaces.nsIConverterOutputStream); converter.init(foStream, "UTF-8", 0, 0); converter.writeString(msg); converter.close(); // this closes foStream // this._logService.logStringMessage("loggingc"); },
var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID);
var directoryService = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties); var dir = directoryService.get("ProfD", Components.interfaces.nsIFile); dir.append("extensions"); dir.append("[email protected]");
_myInstalledDir: function() { this._KFLog.debug("establishing the directory that KeeFox is installed in"); var MY_ID = "[email protected]"; var em = Components.classes["@mozilla.org/extensions/manager;1"]. getService(Components.interfaces.nsIExtensionManager); // the path may use forward slash ("/") as the delimiter var dir = em.getInstallLocation(MY_ID).getItemLocation(MY_ID); if (this._KFLog.logSensitiveData) this._KFLog.debug("installed in this directory: " + dir.path); else this._KFLog.debug("Found installation directory"); return dir.path; },
"_"+Xmla.Exception.ERROR_PARSING_RESPONSE_MSG;Xmla.Exception.INVALID_FIELD_CDE=-9;Xmla.Exception.INVALID_FIELD_MSG="Invalid_Field";Xmla.Exception.INVALID_FIELD_HLP=l+"#"+Xmla.Exception.INVALID_FIELD_CDE+"_"+Xmla.Exception.INVALID_FIELD_MSG;Xmla.Exception.HTTP_ERROR_CDE=-10;Xmla.Exception.HTTP_ERROR_MSG="HTTP Error";Xmla.Exception.HTTP_ERROR_HLP=l+"#"+Xmla.Exception.INVALID_FIELD_CDE+"_"+Xmla.Exception.INVALID_FIELD_MSG;Xmla.Exception._newError=function(a,b,d){return new Xmla.Exception(Xmla.Exception.TYPE_ERROR,
"_"+Xmla.Exception.ERROR_PARSING_RESPONSE_MSG;Xmla.Exception.INVALID_FIELD_CDE=-9;Xmla.Exception.INVALID_FIELD_MSG="Invalid_Field";Xmla.Exception.INVALID_FIELD_HLP=m+"#"+Xmla.Exception.INVALID_FIELD_CDE+"_"+Xmla.Exception.INVALID_FIELD_MSG;Xmla.Exception.HTTP_ERROR_CDE=-10;Xmla.Exception.HTTP_ERROR_MSG="HTTP Error";Xmla.Exception.HTTP_ERROR_HLP=m+"#"+Xmla.Exception.INVALID_FIELD_CDE+"_"+Xmla.Exception.INVALID_FIELD_MSG;Xmla.Exception._newError=function(a,b,d){return new Xmla.Exception(Xmla.Exception.TYPE_ERROR,
"_"+Xmla.Exception.ERROR_PARSING_RESPONSE_MSG;Xmla.Exception.INVALID_FIELD_CDE=-9;Xmla.Exception.INVALID_FIELD_MSG="Invalid_Field";Xmla.Exception.INVALID_FIELD_HLP=l+"#"+Xmla.Exception.INVALID_FIELD_CDE+"_"+Xmla.Exception.INVALID_FIELD_MSG;Xmla.Exception.HTTP_ERROR_CDE=-10;Xmla.Exception.HTTP_ERROR_MSG="HTTP Error";Xmla.Exception.HTTP_ERROR_HLP=l+"#"+Xmla.Exception.INVALID_FIELD_CDE+"_"+Xmla.Exception.INVALID_FIELD_MSG;Xmla.Exception._newError=function(a,b,d){return new Xmla.Exception(Xmla.Exception.TYPE_ERROR,Xmla.Exception[a+"_CDE"],Xmla.Exception[a+"_MSG"],Xmla.Exception[a+"_HLP"],b,d)};Xmla.Exception.prototype={type:null,code:null,message:null,source:null,helpfile:null,data:null,_throw:function(){throw this;}}})();
event.target.ownerDocument.defaultView.keefox_org.toolbar.setLogins(null, null); event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.contentWindow,false);
event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected:" + event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); if (event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin != undefined && event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin != null) { event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin = null; } else { event.target.ownerDocument.defaultView.keefox_org.toolbar.setLogins(null, null); event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.contentWindow,false); }
_onTabSelected: function(event) { event.target.ownerDocument.defaultView.keefox_org.toolbar.setLogins(null, null); event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.contentWindow,false); },
_onTabSelected: function(event) { event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected:" + event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin);
_onTabSelected: function(event) { if (event.target.ownerDocument.defaultView.keefox_org.Logger.logSensitiveData) event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected:" + event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); else event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected.");
_onTabSelected: function(event) { event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected:" + event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); if (event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin != undefined && event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin != null) {// event.target.addEventListener("load", function () {// event.target.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin);//}, true);// event.target.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); //event.target.ownerDocument.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); //event.target.ownerDocument.defaultView.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin);// event.target.KF_uniqueID = event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin; //event.target.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); //event.target.setAttribute("KF_autoSubmit", "yes"); event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin = null; } else { event.target.ownerDocument.defaultView.keefox_org.toolbar.setLogins(null, null); event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.contentWindow,false); } },
event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.contentWindow,false);
event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.linkedBrowser.contentWindow,false);
_onTabSelected: function(event) { if (event.target.ownerDocument.defaultView.keefox_org.Logger.logSensitiveData) event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected:" + event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); else event.target.ownerDocument.defaultView.keefox_org.Logger.debug("_onTabSelected."); if (event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin != undefined && event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin != null) {// event.target.addEventListener("load", function () {// event.target.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin);//}, true);// event.target.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); //event.target.ownerDocument.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); //event.target.ownerDocument.defaultView.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin);// event.target.KF_uniqueID = event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin; //event.target.setAttribute("KF_uniqueID", event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin); //event.target.setAttribute("KF_autoSubmit", "yes"); event.target.ownerDocument.defaultView.keefox_org.ILM._loadingKeeFoxLogin = null; } else { event.target.ownerDocument.defaultView.keefox_org.toolbar.setLogins(null, null); event.target.ownerDocument.defaultView.keefox_org.ILM._fillAllFrames(event.target.contentWindow,false); } },
found = false;
var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); found = false; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); found = false; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now"); var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
try { var browserEnumerator = wm.getEnumerator("navigator:browser");
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
while (!found && browserEnumerator.hasMoreElements()) { var browserWin = browserEnumerator.getNext(); var tabbrowser = browserWin.gBrowser;
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
var numTabs = tabbrowser.browsers.length; for (var index = 0; index < numTabs; index++) { var currentBrowser = tabbrowser.getBrowserAtIndex(index); if (url == currentBrowser.currentURI.spec) { tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
browserWin.focus();
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
found = true; break; } } }
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
try { var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex)
if (!found)
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
this._KFLog.debug("browser window not ready yet");
this._KFLog.debug("tab with this URL not already open so opening one and focussing it now"); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } } catch (ex) { this._KFLog.debug("browser window not ready yet: " + ex); this.urlToOpenOnStartup = url; var currentWindow = wm.getMostRecentWindow("navigator:browser"); if (currentWindow == null) { this._KFLog.error("No windows open yet");
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { Application.activeWindow.tabs.forEach(function(t) { if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); t.focus(); found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now"); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab;
return;
_openAndReuseOneTabPerURL: function(url) { if (this._KFLog.logSensitiveData) this._KFLog.debug("trying to find an already open tab with this url:" + url); else this._KFLog.debug("trying to find an already open tab with the requested url"); var found = false; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator);// var browserEnumerator = wm.getEnumerator("navigator:browser");// // Check each browser instance for our URL// while (!found && browserEnumerator.hasMoreElements())// {// var browserWin = browserEnumerator.getNext();// var tabbrowser = browserWin.gBrowser;// // Check each tab of this browser instance// var numTabs = tabbrowser.browsers.length;// for (var index = 0; index < numTabs; index++) {// var currentBrowser = tabbrowser.getBrowserAtIndex(index);// if (url == currentBrowser.currentURI.spec) {// // The URL is already opened. Select this tab.// tabbrowser.selectedTab = tabbrowser.tabContainer.childNodes[index];// // Focus *this* browser-window// browserWin.focus();// found = true;// break;// }// }// }try {var ttt = wm.getMostRecentWindow("navigator:browser"); var bbb = ttt.getBrowser(); } catch (ex) { this._KFLog.debug("browser window not ready yet"); return; } this._KFLog.debug("browser window ready"); return; Application.windows.forEach(function(b) { // look at each open browser window (not tab) Application.activeWindow.tabs.forEach(function(t) { // look at each open tab in browser window b if (url == t.uri.spec) { this._KFLog.debug("suitable tab already open - focussing it now"); // The URL is already opened. Select this tab. t.focus(); // TODO: Focus *this* browser-window? found = true; return t; } }); }); if (!found) { this._KFLog.debug("tab with this URL not already open so opening one and focussing it now");// var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]// .getService(Components.interfaces.nsIWindowMediator); var newWindow = wm.getMostRecentWindow("navigator:browser"); var b = newWindow.getBrowser(); var newTab = b.loadOneTab( url, null, null, null, false, null ); return newTab; } },
win.keefox_org.UI._removeOLDKFNotifications();
win.keefox_org.UI._removeOLDKFNotifications(true);
_pauseKeeFox: function() { this._KFLog.debug("Pausing KeeFox."); this._keeFoxStorage.set("KeePassRPCActive", false); this._keeFoxStorage.set("KeePassDatabaseOpen", false); // grrr. This was HOPEFULLY the missing statement that led to the deadlocks (actually a slowly executing infinite recursive loop that would take a long time to exhast the stack - win.keeFoxToolbar.setupButton_ready calls KF.getSatabaseName calls KF._pauseKeeFox). This note remains as a painful reminder and maybe a clue for future debugging! var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); // remove matched logins win.keefox_org.toolbar.setAllLogins(); // remove list of all logins //win.keefox_org.toolbar.setupButton_loadKeePass(win); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.removeEventListener("TabSelect", this._onTabSelected, false); //TODO: try this. will it know the DB is offline already? win.keefox_org.toolbar.setAllLogins(); } this.KeePassRPC.disconnect(); this._KFLog.info("KeeFox paused."); },
win.removeEventListener("TabOpen", this._onTabOpened, false);
_pauseKeeFox: function() { this._KFLog.debug("Pausing KeeFox."); //var wasConnected = this._keeFoxStorage.get("KeePassRPCActive", false); //var wasLoggedIn = this._keeFoxStorage.get("KeePassDatabaseOpen", false); this._keeFoxStorage.set("KeePassRPCActive", false); this._keeFoxStorage.set("KeePassDatabaseOpen", false); // grrr. This was HOPEFULLY the missing statement that led to the deadlocks (actually a slowly executing infinite recursive loop that would take a long time to exhast the stack - win.keeFoxToolbar.setupButton_ready calls KF.getSatabaseName calls KF._pauseKeeFox). This note remains as a painful reminder and maybe a clue for future debugging! var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); // remove matched logins win.keefox_org.toolbar.setAllLogins(); // remove list of all logins //win.keefox_org.toolbar.setupButton_loadKeePass(win); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(true); win.removeEventListener("TabSelect", this._onTabSelected, false); //TODO: try this. will it know the DB is offline already? win.keefox_org.toolbar.setAllLogins(); } this.KeePassRPC.disconnect(); this._KFLog.info("KeeFox paused."); },
win.removeEventListener("TabSelect", this._onTabSelected, false); win.removeEventListener("TabOpen", this._onTabOpened, false);
win.gBrowser.tabContainer.removeEventListener("TabSelect", this._onTabSelected, false); win.gBrowser.tabContainer.removeEventListener("TabOpen", this._onTabOpened, false);
_pauseKeeFox: function() { this._KFLog.debug("Pausing KeeFox."); this._keeFoxStorage.set("KeePassRPCActive", false); this._keeFoxStorage.set("KeePassDatabaseOpen", false); // grrr. This was HOPEFULLY the missing statement that led to the deadlocks (actually a slowly executing infinite recursive loop that would take a long time to exhast the stack - win.keeFoxToolbar.setupButton_ready calls KF.getSatabaseName calls KF._pauseKeeFox). This note remains as a painful reminder and maybe a clue for future debugging! this.KeePassDatabases = null; this.ActiveKeePassDatabaseIndex = 0; var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { try { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); // remove matched logins win.keefox_org.toolbar.setAllLogins(); // remove list of all logins //win.keefox_org.toolbar.setupButton_loadKeePass(win); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(true); win.removeEventListener("TabSelect", this._onTabSelected, false); win.removeEventListener("TabOpen", this._onTabOpened, false); //TODO: try this. will it know the DB is offline already? win.keefox_org.toolbar.setAllLogins(); } catch (exception) { this._KFLog.warn("Could not pause KeeFox in a window. Maybe it is not correctly set-up yet? " + exception); } } this.KeePassRPC.disconnect(); this._KFLog.info("KeeFox paused."); },
win.keeFoxToolbar.removeLogins();
win.keeFoxToolbar.removeLogins(); win.keeFoxToolbar.setAllLogins();
_pauseKeeFox: function() { this._KFLog.debug("Pausing KeeFox."); this._keeFoxStorage.set("KeePassRPCActive", false); this._keeFoxStorage.set("KeePassDatabaseOpen", false); // grrr. This was HOPEFULLY the missing statement that led to the deadlocks (actually a slowly executing infinite recursive loop that would take a long time to exhast the stack - win.keeFoxToolbar.setupButton_ready calls KF.getSatabaseName calls KF._pauseKeeFox). This note remains as a painful reminder and maybe a clue for future debugging! var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keeFoxToolbar.removeLogins(); //win.keeFoxToolbar.setupButton_loadKeePass(win); win.keeFoxToolbar.setupButton_ready(win); win.keeFoxUI._removeOLDKFNotifications(); win.removeEventListener("TabSelect", this._onTabSelected, false); //TODO: try this. will it know the DB is offline already? win.keeFoxToolbar.setAllLogins(); } this.KeePassRPC.disconnect(); this._KFLog.info("KeeFox paused."); },
var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(true); win.removeEventListener("TabSelect", this._onTabSelected, false); win.removeEventListener("TabOpen", this._onTabOpened, false);
try { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(true); win.removeEventListener("TabSelect", this._onTabSelected, false); win.removeEventListener("TabOpen", this._onTabOpened, false); } catch (exception) { this._KFLog.warn("Could not pause KeeFox in a window. Maybe it is not correctly set-up yet? " + exception); }
_pauseKeeFox: function() { this._KFLog.debug("Pausing KeeFox."); //var wasConnected = this._keeFoxStorage.get("KeePassRPCActive", false); //var wasLoggedIn = this._keeFoxStorage.get("KeePassDatabaseOpen", false); this._keeFoxStorage.set("KeePassRPCActive", false); this._keeFoxStorage.set("KeePassDatabaseOpen", false); // grrr. This was HOPEFULLY the missing statement that led to the deadlocks (actually a slowly executing infinite recursive loop that would take a long time to exhast the stack - win.keeFoxToolbar.setupButton_ready calls KF.getSatabaseName calls KF._pauseKeeFox). This note remains as a painful reminder and maybe a clue for future debugging! var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); // remove matched logins win.keefox_org.toolbar.setAllLogins(); // remove list of all logins //win.keefox_org.toolbar.setupButton_loadKeePass(win); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(true); win.removeEventListener("TabSelect", this._onTabSelected, false); win.removeEventListener("TabOpen", this._onTabOpened, false); //TODO: try this. will it know the DB is offline already? win.keefox_org.toolbar.setAllLogins(); } this.KeePassRPC.disconnect(); this._KFLog.info("KeeFox paused."); },
if (fromStack.length == 0) { return false; }
if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; }
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; }
fromIndex = fromStack.items.length - 1 - fromIndex;
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
fromIndex = fromStack.items.length - 1 - fromIndex;
var editPos = fromStack.items[fromIndex];
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
var editPos = fromStack.items[fromIndex];
if (!editPos) { return false; }
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
if (!editPos) { return false; }
if (saveCurrent && toStack.length == 0){ if (!this.isEditOnCurrentView(fromStack.peek())) { var currentView = ko.views.manager.currentView; this.addPositionToStack(toStack, currentView, currentView.scimoz.currentPos); } }
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); }
var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); }
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position);
fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scimoz;
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
this.updateCommands();
var line = scimoz.markerLineFromHandle(editPos.marker); if (line == -1) { scimoz.setSel(-1, editPos.position); } else { scimoz.gotoPos(scimoz.positionAtColumn(line, editPos.col)); }
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
} catch(e) { DafizillaCommon.log("_popEditPosition err " + e);
this.updateCommands(); } catch (err) { DafizillaCommon.exception(err);
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
_popEditPosition : function(fromStack, fromIndex, toStack) {
_popEditPosition : function(fromStack, fromIndex, toStack, saveCurrent) {
_popEditPosition : function(fromStack, fromIndex, toStack) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
if (saveCurrent && toStack.length == 0){ this.addPositionToStack(toStack); }
_popEditPosition : function(fromStack, fromIndex, toStack) { try { if (fromStack.length == 0) { return false; } if (fromIndex == 0 && this.isEditOnCurrentView(fromStack.peek())) { fromIndex = 1; } // elements are retrieved starting from end of array // if fromIndex < 0 editPos is undefined fromIndex = fromStack.items.length - 1 - fromIndex; var editPos = fromStack.items[fromIndex]; if (!editPos) { return false; } var elementToMoveCount = fromStack.items.length; for (var i = elementToMoveCount - 1; i >= fromIndex ; i--) { toStack.push(fromStack.items[i]); } fromStack.items.splice(fromIndex, elementToMoveCount - fromIndex); editPos.view.makeCurrent(); var scimoz = editPos.view.scintilla.scimoz; scimoz.setSel(-1, editPos.position); this.updateCommands(); } catch(e) { DafizillaCommon.log("_popEditPosition err " + e); } return true; },
function _printElement(element, opts) { var $elementToPrint = $(element);
function _printElement(element, opts){
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
var html = _getMarkup($elementToPrint, opts);
var html = _getMarkup(element, opts);
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes');
popupOrIframe = window.open('about:blank', 'printElementWindow', 'width=650,height=440,scrollbars=yes');
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd,
var printElementID = "printElement_" + (Math.round(Math.random() * 99999)).toString(); var iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd,
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document;
className: opts.iframeElementOptions.classNameToAdd, frameBorder: 0, scrolling: 'no', src: 'about:blank' }); document.body.appendChild(iframe); documentToWriteTo = (iframe.contentWindow || iframe.contentDocument); if (documentToWriteTo.document) documentToWriteTo = documentToWriteTo.document; iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe;
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
window.focus();
focus();
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
popupOrIframe.focus();
_callPrint(popupOrIframe);
function _printElement(element, opts) { var $elementToPrint = $(element); //Create markup to be printed var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); popupOrIframe = $('<iframe />').attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }).appendTo('body')[0].contentWindow; documentToWriteTo = popupOrIframe.document; } window.focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); };
if (opts.printMode.toLowerCase() == 'popup') {
if (opts["printMode"].toLowerCase() == 'popup') {
function _printElement(element, opts){ //Create markup to be printed var html = _getMarkup(element, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('about:blank', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { //The random ID is to overcome a safari bug http://www.cjboco.com.sharedcopy.com/post.cfm/442dc92cd1c0ca10a5c35210b8166882.html var printElementID = "printElement_" + (Math.round(Math.random() * 99999)).toString(); //Native creation of the element is faster.. var iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd, frameBorder: 0, scrolling: 'no', src: 'about:blank' }); document.body.appendChild(iframe); documentToWriteTo = (iframe.contentWindow || iframe.contentDocument); if (documentToWriteTo.document) documentToWriteTo = documentToWriteTo.document; iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe; } focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); _callPrint(popupOrIframe); };
style: opts.iframeElementOptions.styleToAdd,
style: opts["iframeElementOptions"]["styleToAdd"],
function _printElement(element, opts){ //Create markup to be printed var html = _getMarkup(element, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('about:blank', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { //The random ID is to overcome a safari bug http://www.cjboco.com.sharedcopy.com/post.cfm/442dc92cd1c0ca10a5c35210b8166882.html var printElementID = "printElement_" + (Math.round(Math.random() * 99999)).toString(); //Native creation of the element is faster.. var iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd, frameBorder: 0, scrolling: 'no', src: 'about:blank' }); document.body.appendChild(iframe); documentToWriteTo = (iframe.contentWindow || iframe.contentDocument); if (documentToWriteTo.document) documentToWriteTo = documentToWriteTo.document; iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe; } focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); _callPrint(popupOrIframe); };
className: opts.iframeElementOptions.classNameToAdd,
className: opts["iframeElementOptions"]["classNameToAdd"],
function _printElement(element, opts){ //Create markup to be printed var html = _getMarkup(element, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('about:blank', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popupOrIframe.document; } else { //The random ID is to overcome a safari bug http://www.cjboco.com.sharedcopy.com/post.cfm/442dc92cd1c0ca10a5c35210b8166882.html var printElementID = "printElement_" + (Math.round(Math.random() * 99999)).toString(); //Native creation of the element is faster.. var iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd, frameBorder: 0, scrolling: 'no', src: 'about:blank' }); document.body.appendChild(iframe); documentToWriteTo = (iframe.contentWindow || iframe.contentDocument); if (documentToWriteTo.document) documentToWriteTo = documentToWriteTo.document; iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe; } focus(); documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); _callPrint(popupOrIframe); };
$.fn.printElement = function(options) { var mainOptions = $.extend({}, $.fn.printElement.defaults, options); $("[id^='printElement_']").remove(); return this.each(function() { var opts = $.meta ? $.extend({}, mainOptions, $this.data()) : mainOptions; _printElement($(this), opts); }); }; $.fn.printElement.defaults = { printMode: 'iframe', pageTitle: '', overrideElementCSS: [], printBodyOptions: { styleToAdd: 'padding:10px;margin:10px;', classNameToAdd: '' }, leaveOpen: false, iframeElementOptions: { styleToAdd: 'position:absolute;width:0px;height:0px;', classNameToAdd: ''} }; function _printElement(element, opts) { var $elementToPrint = $(element); var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popup.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }); document.body.appendChild(iframe); documentToWriteTo = iframe.contentWindow.document; var iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe; } documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); }; function _getMarkup(element, opts) {
function($){$.fn.printElement=function(options){var mainOptions=$.extend({},$.fn.printElement.defaults,options);if(mainOptions.printMode=='iframe'){if($.browser.opera||(/chrome/.test(navigator.userAgent.toLowerCase())))mainOptions.printMode='popup';}$("[id^='printElement_']").remove();return this.each(function(){var opts=$.meta?$.extend({},mainOptions,$this.data()):mainOptions;_printElement($(this),opts);});};$.fn.printElement.defaults={printMode:'iframe',pageTitle:'',overrideElementCSS:null,printBodyOptions:{styleToAdd:'padding:10px;margin:10px;',classNameToAdd:''},leaveOpen:false,iframeElementOptions:{styleToAdd:'border:none;position:absolute;width:0px;height:0px;bottom:0px;left:0px;',classNameToAdd:''}};$.fn.printElement.cssElement={href:'',media:''};function _printElement(element,opts){var html=_getMarkup(element,opts);var popupOrIframe=null;var documentToWriteTo=null;if(opts.printMode.toLowerCase()=='popup'){popupOrIframe=window.open('about:blank','printElementWindow','width=650,height=440,scrollbars=yes');documentToWriteTo=popupOrIframe.document;}else{var printElementID="printElement_"+(Math.round(Math.random()*99999)).toString();var iframe=document.createElement('IFRAME');$(iframe).attr({style:opts.iframeElementOptions.styleToAdd,id:printElementID,className:opts.iframeElementOptions.classNameToAdd,frameBorder:0,scrolling:'no',src:'about:blank'});document.body.appendChild(iframe);documentToWriteTo=(iframe.contentWindow||iframe.contentDocument);if(documentToWriteTo.document)documentToWriteTo=documentToWriteTo.document;iframe=document.frames?document.frames[printElementID]:document.getElementById(printElementID);popupOrIframe=iframe.contentWindow||iframe;}focus();documentToWriteTo.open();documentToWriteTo.write(html);documentToWriteTo.close();_callPrint(popupOrIframe);};function _callPrint(element){if(element&&element.printPage)element.printPage();else setTimeout(function(){_callPrint(element);},50);}function _getElementHTMLIncludingFormElements(element){var $element=$(element);$(":checked",$element).each(function(){this.setAttribute('checked','checked');});$("input[type='text']",$element).each(function(){this.setAttribute('value',$(this).val());});$("select",$element).each(function(){var $select=$(this);$("option",$select).each(function(){if($select.val()==$(this).val())this.setAttribute('selected','selected');});});$("textarea",$element).each(function(){var value=$(this).attr('value');if($.browser.mozilla)this.firstChild.textContent=value;else this.innerHTML=value;});var elementHtml=$('<div></div>').append($element.clone()).html();return elementHtml;}function _getBaseHref(){return window.location.protocol+"
$.fn.printElement = function(options) { var mainOptions = $.extend({}, $.fn.printElement.defaults, options); $("[id^='printElement_']").remove(); return this.each(function() { var opts = $.meta ? $.extend({}, mainOptions, $this.data()) : mainOptions; _printElement($(this), opts); }); }; $.fn.printElement.defaults = { printMode: 'iframe', pageTitle: '', overrideElementCSS: [], printBodyOptions: { styleToAdd: 'padding:10px;margin:10px;', classNameToAdd: '' }, leaveOpen: false, iframeElementOptions: { styleToAdd: 'position:absolute;width:0px;height:0px;', classNameToAdd: ''} }; function _printElement(element, opts) { var $elementToPrint = $(element); var html = _getMarkup($elementToPrint, opts); var popupOrIframe = null; var documentToWriteTo = null; if (opts.printMode.toLowerCase() == 'popup') { popupOrIframe = window.open('', 'printElementWindow', 'width=650,height=440,scrollbars=yes'); documentToWriteTo = popup.document; } else { var printElementID = "printElement_" + (Math.random() * 99999).toString(); iframe = document.createElement('IFRAME'); $(iframe).attr({ style: opts.iframeElementOptions.styleToAdd, id: printElementID, className: opts.iframeElementOptions.classNameToAdd }); document.body.appendChild(iframe); documentToWriteTo = iframe.contentWindow.document; var iframe = document.frames ? document.frames[printElementID] : document.getElementById(printElementID); popupOrIframe = iframe.contentWindow || iframe; } documentToWriteTo.open(); documentToWriteTo.write(html); documentToWriteTo.close(); popupOrIframe.focus(); }; function _getMarkup(element, opts) {
win.addEventListener("TabOpen", this._onTabOpened, false);
_refreshKPDB: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName.constructor.name == "Error") // Can't use instanceof here becuase the Error object was created in a different scope { this._pauseKeeFox(); return; } else if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keefox_org.ILM._fillDocument(win.content.document,false); } } if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error)) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
var dbName = this.getDatabaseName(); if (dbName == "")
var dbName = this.getDatabaseName(); if (dbName.constructor.name == "Error") { this._pauseKeeFox(); return; } else if (dbName == "")
_refreshKPDB: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keeFoxToolbar.removeLogins(); win.keeFoxToolbar.setAllLogins(); win.keeFoxToolbar.setupButton_ready(win); win.keeFoxUI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keeFoxILM._fillDocument(win.content.document,false); } } if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
if (MRUFN != null && MRUFN != undefined)
if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error))
_refreshKPDB: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keeFoxToolbar.removeLogins(); win.keeFoxToolbar.setAllLogins(); win.keeFoxToolbar.setupButton_ready(win); win.keeFoxUI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keeFoxILM._fillDocument(win.content.document,false); } } if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false);
try { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false);
_refreshKPDB: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName.constructor.name == "Error") // Can't use instanceof here becuase the Error object was created in a different scope { this._pauseKeeFox(); return; } else if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keefox_org.ILM._fillDocument(win.content.document,false); } } if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error)) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
if (this._keeFoxStorage.get("KeePassDatabaseOpen",false))
if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keefox_org.ILM._fillDocument(win.content.document,false); } } catch (exception)
_refreshKPDB: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName.constructor.name == "Error") // Can't use instanceof here becuase the Error object was created in a different scope { this._pauseKeeFox(); return; } else if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keefox_org.ILM._fillDocument(win.content.document,false); } } if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error)) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
win.keefox_org.ILM._fillDocument(win.content.document,false);
this._KFLog.warn("Could not refresh KeeFox in a window. Maybe it is not correctly set-up yet? " + exception);
_refreshKPDB: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName.constructor.name == "Error") // Can't use instanceof here becuase the Error object was created in a different scope { this._pauseKeeFox(); return; } else if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { win.keefox_org.ILM._fillDocument(win.content.document,false); } } if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error)) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
if (dbName.constructor.name == "Error") { this._pauseKeeFox(); return; } else if (dbName == "")
if (dbName === null)
_refreshKPDBCallback: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); if (dbName.constructor.name == "Error") // Can't use instanceof here becuase the Error object was created in a different scope { //TODO: Don't think this can ever happen anymore - verify that's OK then remove... this._pauseKeeFox(); return; } else if (dbName == "") { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { try { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { //TODO: test this with new async setup... win.keefox_org.ILM._fillDocument(win.content.document,false); } } catch (exception) { this._KFLog.warn("Could not refresh KeeFox in a window. Maybe it is not correctly set-up yet? " + exception); } } //TODO:? this can be done in the getalldatabases callback surely? if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error)) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false);
win.gBrowser.tabContainer.addEventListener("TabSelect", this._onTabSelected, false); win.gBrowser.tabContainer.addEventListener("TabOpen", this._onTabOpened, false);
_refreshKPDBCallback: function () { this._KFLog.debug("Refreshing KeeFox's view of the KeePass database."); var dbName = this.getDatabaseName(); //if (dbName.constructor.name == "Error") // Can't use instanceof here becuase the Error object was created in a different scope //{ //TODO: Don't think this can ever happen anymore - verify that's OK then remove... // this._pauseKeeFox(); // return; //} if (dbName === null) { this._KFLog.debug("No database is currently open."); this._keeFoxStorage.set("KeePassDatabaseOpen", false); } else { if (this._KFLog.logSensitiveData) this._KFLog.info("The '" + dbName + "' database is open."); else this._KFLog.info("The database is open."); this._keeFoxStorage.set("KeePassDatabaseOpen", true); } var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator); var enumerator = wm.getEnumerator("navigator:browser"); var tabbrowser = null; while (enumerator.hasMoreElements()) { try { var win = enumerator.getNext(); win.keefox_org.toolbar.removeLogins(); win.keefox_org.toolbar.setAllLogins(); win.keefox_org.toolbar.setupButton_ready(win); win.keefox_org.UI._removeOLDKFNotifications(); win.addEventListener("TabSelect", this._onTabSelected, false); win.addEventListener("TabOpen", this._onTabOpened, false); if (this._keeFoxStorage.get("KeePassDatabaseOpen",false)) { //TODO: test this with new async setup... win.keefox_org.ILM._fillDocument(win.content.document,false); } } catch (exception) { this._KFLog.warn("Could not refresh KeeFox in a window. Maybe it is not correctly set-up yet? " + exception); } } //TODO:? this can be done in the getalldatabases callback surely? if (this._keeFoxStorage.get("KeePassDatabaseOpen",false) && this._keeFoxExtension.prefs.getValue("rememberMRUDB",false)) { var MRUFN = this.getDatabaseFileName(); if (MRUFN != null && MRUFN != undefined && !(MRUFN instanceof Error)) this._keeFoxExtension.prefs.setValue("keePassMRUDB",MRUFN); } this._KFLog.info("KeeFox feels very refreshed now."); },
_removeOLDKFNotifications : function ()
_removeOLDKFNotifications : function (keepLaunchBar)
_removeOLDKFNotifications : function () { var notifyBox = this._getNotifyBox(); if (notifyBox) { var oldBar = notifyBox.getNotificationWithValue("password-save"); if (oldBar) { KFLog.debug("Removing save-password notification bar."); notifyBox.removeNotification(oldBar); } oldBar = notifyBox.getNotificationWithValue("keefox-login"); if (oldBar) { KFLog.debug("Removing keefox-login notification bar."); notifyBox.removeNotification(oldBar); } oldBar = notifyBox.getNotificationWithValue("keefox-launch"); if (oldBar) { KFLog.debug("Removing keefox-launch notification bar."); notifyBox.removeNotification(oldBar); } } },
oldBar = notifyBox.getNotificationWithValue("keefox-launch");
if (!keepLaunchBar) { oldBar = notifyBox.getNotificationWithValue("keefox-launch");
_removeOLDKFNotifications : function () { var notifyBox = this._getNotifyBox(); if (notifyBox) { var oldBar = notifyBox.getNotificationWithValue("password-save"); if (oldBar) { KFLog.debug("Removing save-password notification bar."); notifyBox.removeNotification(oldBar); } oldBar = notifyBox.getNotificationWithValue("keefox-login"); if (oldBar) { KFLog.debug("Removing keefox-login notification bar."); notifyBox.removeNotification(oldBar); } oldBar = notifyBox.getNotificationWithValue("keefox-launch"); if (oldBar) { KFLog.debug("Removing keefox-launch notification bar."); notifyBox.removeNotification(oldBar); } } },
if (oldBar) { KFLog.debug("Removing keefox-launch notification bar."); notifyBox.removeNotification(oldBar);
if (oldBar) { KFLog.debug("Removing keefox-launch notification bar."); notifyBox.removeNotification(oldBar); }
_removeOLDKFNotifications : function () { var notifyBox = this._getNotifyBox(); if (notifyBox) { var oldBar = notifyBox.getNotificationWithValue("password-save"); if (oldBar) { KFLog.debug("Removing save-password notification bar."); notifyBox.removeNotification(oldBar); } oldBar = notifyBox.getNotificationWithValue("keefox-login"); if (oldBar) { KFLog.debug("Removing keefox-login notification bar."); notifyBox.removeNotification(oldBar); } oldBar = notifyBox.getNotificationWithValue("keefox-launch"); if (oldBar) { KFLog.debug("Removing keefox-launch notification bar."); notifyBox.removeNotification(oldBar); } } },
a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))d=M(d);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=m(this.responseXML,w,n,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,
a)||a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))b=L(b);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=o(this.responseXML,v,p,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,
a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))d=M(d);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=m(this.responseXML,w,n,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,
a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))d=M(d);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=m(this.responseXML,w,n,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,
a)||a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))b=L(b);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=o(this.responseXML,v,p,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,
a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))d=M(d);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=m(this.responseXML,w,n,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,null,"_requestSuccess",a);switch(b){case Xmla.METHOD_DISCOVER:this._fireEvent(Xmla.EVENT_DISCOVER_ERROR,a);break;case Xmla.METHOD_EXECUTE:this._fireEvent(Xmla.EVENT_EXECUTE_ERROR,a);break}this._fireEvent(Xmla.EVENT_ERROR,a)}else{switch(b){case Xmla.METHOD_DISCOVER:var c=new Xmla.Rowset(this.responseXML,a.requestType);this.response=a.rowset=c;this._fireEvent(Xmla.EVENT_DISCOVER_SUCCESS,a);break;case Xmla.METHOD_EXECUTE:b=a.properties[Xmla.PROP_FORMAT];switch(b){case Xmla.PROP_FORMAT_TABULAR:c=new Xmla.Rowset(this.responseXML);break;case Xmla.PROP_FORMAT_MULTIDIMENSIONAL:break}this.response=a.resultset=c;this._fireEvent(Xmla.EVENT_EXECUTE_SUCCESS,a);break}this._fireEvent(Xmla.EVENT_SUCCESS,a)}},execute:function(a){var b=a.properties;if(j(b)){b={};a.properties=b}if(j(b[Xmla.PROP_CONTENT]))b[Xmla.PROP_CONTENT]=Xmla.PROP_CONTENT_SCHEMADATA;if(j(b[Xmla.PROP_FORMAT]))a.properties[Xmla.PROP_FORMAT]=Xmla.PROP_FORMAT_MULTIDIMENSIONAL;a=h(a,{method:Xmla.METHOD_EXECUTE},true);return this.request(a)},executeTabular:function(a){if(!a.properties)a.properties=
break;case Xmla.PROP_FORMAT_MULTIDIMENSIONAL:break}this.response=a.resultset=c;this._fireEvent(Xmla.EVENT_EXECUTE_SUCCESS,a);break}this._fireEvent(Xmla.EVENT_SUCCESS,a)}},execute:function(a){var b=a.properties;if(j(b)){b={};a.properties=b}if(j(b[Xmla.PROP_CONTENT]))b[Xmla.PROP_CONTENT]=Xmla.PROP_CONTENT_SCHEMADATA;if(j(b[Xmla.PROP_FORMAT]))a.properties[Xmla.PROP_FORMAT]=Xmla.PROP_FORMAT_MULTIDIMENSIONAL;a=h(a,{method:Xmla.METHOD_EXECUTE},true);return this.request(a)},executeTabular:function(a){if(!a.properties)a.properties=
break;case Xmla.PROP_FORMAT_MULTIDIMENSIONAL:break}this.response=a.resultset=c;this._fireEvent(Xmla.EVENT_EXECUTE_SUCCESS,a);break}this._fireEvent(Xmla.EVENT_SUCCESS,a)}},execute:function(a){var b=a.properties;if(j(b)){b={};a.properties=b}if(j(b[Xmla.PROP_CONTENT]))b[Xmla.PROP_CONTENT]=Xmla.PROP_CONTENT_SCHEMADATA;if(j(b[Xmla.PROP_FORMAT]))a.properties[Xmla.PROP_FORMAT]=Xmla.PROP_FORMAT_MULTIDIMENSIONAL;a=g(a,{method:Xmla.METHOD_EXECUTE},true);return this.request(a)},executeTabular:function(a){if(!a.properties)a.properties=
a.method==Xmla.METHOD_EXECUTE&&this._fireEvent(Xmla.EVENT_EXECUTE,a)))d=M(d);return this.response},_requestError:function(a){this._fireEvent("error",a)},_requestSuccess:function(a){var b=a.xhr;this.responseXML=b.responseXML;this.responseText=b.responseText;b=a.method;var d=m(this.responseXML,w,n,"Fault");if(d.length){d=d.item(0);a.exception=new Xmla.Exception(Xmla.Exception.TYPE_ERROR,d.getElementsByTagName("faultcode").item(0).childNodes.item(0).data,d.getElementsByTagName("faultstring").item(0).childNodes.item(0).data,null,"_requestSuccess",a);switch(b){case Xmla.METHOD_DISCOVER:this._fireEvent(Xmla.EVENT_DISCOVER_ERROR,a);break;case Xmla.METHOD_EXECUTE:this._fireEvent(Xmla.EVENT_EXECUTE_ERROR,a);break}this._fireEvent(Xmla.EVENT_ERROR,a)}else{switch(b){case Xmla.METHOD_DISCOVER:var c=new Xmla.Rowset(this.responseXML,a.requestType);this.response=a.rowset=c;this._fireEvent(Xmla.EVENT_DISCOVER_SUCCESS,a);break;case Xmla.METHOD_EXECUTE:b=a.properties[Xmla.PROP_FORMAT];switch(b){case Xmla.PROP_FORMAT_TABULAR:c=new Xmla.Rowset(this.responseXML);break;case Xmla.PROP_FORMAT_MULTIDIMENSIONAL:break}this.response=a.resultset=c;this._fireEvent(Xmla.EVENT_EXECUTE_SUCCESS,a);break}this._fireEvent(Xmla.EVENT_SUCCESS,a)}},execute:function(a){var b=a.properties;if(j(b)){b={};a.properties=b}if(j(b[Xmla.PROP_CONTENT]))b[Xmla.PROP_CONTENT]=Xmla.PROP_CONTENT_SCHEMADATA;if(j(b[Xmla.PROP_FORMAT]))a.properties[Xmla.PROP_FORMAT]=Xmla.PROP_FORMAT_MULTIDIMENSIONAL;a=h(a,{method:Xmla.METHOD_EXECUTE},true);return this.request(a)},executeTabular:function(a){if(!a.properties)a.properties=
this._promptWidget.style.maxWidth = "-moz-calc(1em * " + val.length + ")";
_setPrompt: function (val, highlightGroup) { this._promptWidget.value = val; this._promptWidget.collapsed = (val == ""); // we need this explicit width setting to show our slide in animation // let computedWidth = document.defaultView.getComputedStyle(document.getElementById('liberator-commandline-prompt-text'), null).getPropertyValue('width'); },
path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i;
path += path ? typeof i === 'number' ? '[' + i + ']' : typeof i === 'undefined' ? '' : '.' + i : i;
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){
if((typeof schema !== 'object' || schema instanceof Array) && (path || typeof schema !== 'function')){ if(typeof schema === 'function'){
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){
if(typeof type === 'string' && type !== 'any' && (type === 'null' ? value !== null : typeof value !== type) && !(value instanceof Array && type === 'array') && !(type === 'integer' && value%1===0)){
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
}else if(typeof type == 'object'){
}else if(typeof type === 'object'){
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(value.hasOwnProperty(i)) {
if(value.hasOwnProperty(i) && typeof value[i] !== 'function') {
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
addError((typeof i) + " The property " + i +
addError((typeof value[i]) + " The property " + i +
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){
if(schema.pattern && typeof value === 'string' && !value.match(schema.pattern)){
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){
if(schema.maxLength && typeof value === 'string' && value.length > schema.maxLength){
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){
if(schema.minLength && typeof value === 'string' && value.length < schema.minLength){
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum &&
if(typeof schema.minimum !== undefined && typeof value === typeof schema.minimum &&
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }
if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum &&
if(typeof schema.maximum !== undefined && typeof value === typeof schema.maximum &&
_validate : function(/*Any*/instance,/*Object*/schema,/*Boolean*/ _changing) { var recursion = -1; var errors = []; var prettyPrint = []; function addPrint(indent, message){ var str = ""; for (var i = 0; i < indent; i++) str += "\t"; prettyPrint.push(str + message); } function appendPrint(message){ if (prettyPrint.length > 0) prettyPrint[prettyPrint.length-1] += " " + message; } // validate a value against a property definition function checkProp(value, schema, path,i, recursion){ var l; path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message){ errors.push({property:path,message:message}); } if((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function')){ if(typeof schema == 'function'){ if(!(value instanceof schema)){ addError("is not an instance of the class/constructor " + schema.name); } }else if(schema){ addError("Invalid schema/property definition " + schema); } return null; } if(_changing && schema.readonly){ addError("is a readonly field, it can not be changed"); } if(schema['extends']){ // if it extends another schema, it must pass that schema as well checkProp(value,schema['extends'],path,i, recursion); } // validate a value against a type definition function checkType(type,value){ if(type){ if(typeof type == 'string' && type != 'any' && (type == 'null' ? value !== null : typeof value != type) && !(value instanceof Array && type == 'array') && !(type == 'integer' && value%1===0)){ return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}]; } if(type instanceof Array){ var unionErrors=[]; for(var j = 0; j < type.length; j++){ // a union type if(!(unionErrors=checkType(type[j],value)).length){ break; } } if(unionErrors.length){ return unionErrors; } }else if(typeof type == 'object'){ var priorErrors = errors; errors = []; checkProp(value,type,path, recursion); var theseErrors = errors; errors = priorErrors; return theseErrors; } } return []; } if(value === undefined){ if(!schema.optional){ addError("is missing and it is not optional"); } }else{ if (schema.type === 'union') { var enumField = value[schema.field]; if (enumField === undefined) addError("Expected " + schema.field + " field in " + path); else { addPrint(recursion, enumField+':'); var ttFound = false; for (var tt = 0; tt < schema.types.length; tt++) { if (enumField === schema.types[tt].value) { if (schema.types[tt].properties[schema.field] === undefined) // Don't throw an error when we encounter the original enum field schema.types[tt].properties[schema.field] = { type: "string", output: "hidden" }; errors.concat(checkObj(value,schema.types[tt].properties,path+"."+schema.field+'='+enumField,schema.additionalProperties, recursion+1)); ttFound = true; break; } } if (ttFound === false) { addError("Unknown type " + enumField + " in " + path); } } } else errors = errors.concat(checkType(schema.type,value)); if(schema.disallow && !checkType(schema.disallow,value).length){ addError(" disallowed value was matched"); } if(value !== null){ if(value instanceof Array){ if(schema.items){ if(schema.items instanceof Array){ for(i=0,l=value.length; i<l; i++){ errors.concat(checkProp(value[i],schema.items[i],path,i, recursion)); } }else{ var thisRecursion = (recursion===0)?1:recursion; // TODO-PER-HACK: Not sure why the first case is different. Figure it out someday. for(i=0,l=value.length; i<l; i++){ var nextRecursion = recursion; if (schema.output !== 'noindex') { nextRecursion++; if (typeof value[i] !== 'object') { if (schema.output === 'join') appendPrint(value[i]===null?'null':value[i]); else addPrint(thisRecursion, (value[i]===null?'null':value[i])); } else addPrint(thisRecursion, path.substring(path.lastIndexOf('.')+1) + " " + (i+1)); } errors.concat(checkProp(value[i],schema.items,path,i, nextRecursion)); } } } if(schema.minItems && value.length < schema.minItems){ addError("There must be a minimum of " + schema.minItems + " in the array"); } if(schema.maxItems && value.length > schema.maxItems){ addError("There must be a maximum of " + schema.maxItems + " in the array"); } if (schema.additionalProperties !== true) { for(i in value){ if(value.hasOwnProperty(i)) { var num = parseInt(i); var index = "" + num; var isNum = i === index; if(!isNum ){ addError((typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"); } } } } }else if(schema.properties){ errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties, recursion+1)); } if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){ addError("does not match the regex pattern " + schema.pattern); } if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){ addError("may only be " + schema.maxLength + " characters long"); } if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); } if(schema['Enum']){ var enumer = schema['Enum']; l = enumer.length; var found; for(var j = 0; j < l; j++){ if(enumer[j]===value){ found=1; break; } } if(!found){ addError(value + " does not have a value in the enumeration " + enumer.join(", ")); } } if(typeof schema.maxDecimal == 'number' && (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){ addError("may only have " + schema.maxDecimal + " digits of decimal places"); } } } return null; } function checkAllProps(instance,objTypeDef,path,recursion) { for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; var propDef = objTypeDef[i]; if (propDef.output !== 'hidden' && value !== undefined) { if (value === null) addPrint(recursion, i+": null"); else if (typeof value === 'object') addPrint(recursion, i+":"); else addPrint(recursion, i+": "+value); } checkProp(value,propDef,path,i, recursion); } } } // validate an object against a schema function checkObj(instance,objTypeDef,path,additionalProp, recursion){ checkAllProps(instance,objTypeDef,path,recursion); for(i in instance){ if(instance.hasOwnProperty(i)) { if (objTypeDef[i]) { var requires = objTypeDef[i].requires; if(requires && !(requires in instance)){ errors.push({property:path,message:"the presence of the property " + i + " requires that " + requires + " also be present"}); } var prohibits = objTypeDef[i].prohibits; if(prohibits && (prohibits in instance)){ errors.push({property:path,message:"the presence of the property " + i + " prohibits " + requires + " from being present"}); } var value = instance[i]; if(!(i in objTypeDef)){ checkProp(value,additionalProp,path,i, recursion); } if(!_changing && value && value.$schema){ errors = errors.concat(checkProp(value,value.$schema,path,i, recursion)); } } else if (additionalProp!==true){ errors.push({property:path+' '+i,message:(typeof i) + " The property " + i + " is not defined in the schema and the schema does not allow additional properties"}); } } } return errors; } if(schema){ checkProp(instance,schema,'',_changing || '', recursion); } if(!_changing && instance && instance.$schema){ checkProp(instance,instance.$schema,'','', recursion); } return {valid:!errors.length,errors:errors, output: prettyPrint}; }