diff --git a/sharepointplus-3.0.11.js b/sharepointplus-3.0.11.js index adbaf11..82d8f12 100644 --- a/sharepointplus-3.0.11.js +++ b/sharepointplus-3.0.11.js @@ -1,9 +1,9 @@ /*! * SharepointPlus v3.0.11 - * Copyright 2014, Aymeric (@aymkdn) + * Copyright 2016, Aymeric (@aymkdn) * Contact: http://kodono.info * Documentation: http://aymkdn.github.com/SharepointPlus/ - * License: GPL v2 (http://aymkdn.github.com/SharepointPlus/license.txt) + * License: GPL-3 (http://aymkdn.github.com/SharepointPlus/license.md) */ if (!Array.prototype.indexOf) { /** diff --git a/sharepointplus-3.0.11.min.js b/sharepointplus-3.0.11.min.js new file mode 100644 index 0000000..06baad9 --- /dev/null +++ b/sharepointplus-3.0.11.min.js @@ -0,0 +1,10 @@ +/*! + * SharepointPlus v3.0.11 + * Copyright 2016, Aymeric (@aymkdn) + * Contact: http://kodono.info + * Documentation: http://aymkdn.github.com/SharepointPlus/ + * License: GPL-3 (http://aymkdn.github.com/SharepointPlus/license.md) + */ +Array.prototype.indexOf||(Array.prototype.indexOf=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),r=t.length>>>0;if(0===r)return-1;var n=0;if(arguments.length>1&&(n=Number(arguments[1]),n!=n?n=0:0!=n&&n!=1/0&&n!=-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=r)return-1;for(var s=n>=0?n:Math.max(r-Math.abs(n),0);r>s;s++)if(s in t&&t[s]===e)return s;return-1}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});var _SP_b64_encode=function(e,t,r,n,s,i){for(t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="=",n=i="";s&=3,e.charAt(n++)||(t="=",s);i+=t.charAt(63&r>>2*++s))r=r<<8|e.charCodeAt(n-=!s);return i};_SP_APPROVED=0,_SP_REJECTED=1,_SP_PENDING=2,_SP_DRAFT=3,_SP_SCHEDULED=4,_SP_CACHE_FORMFIELDS=null,_SP_CACHE_CONTENTTYPES=[],_SP_CACHE_CONTENTTYPE=[],__SP_NOTIFY_READY=!1,__SP_NOTIFY_QUEUE=[],__SP_NOTIFY=[],"function"==typeof jQuery&&$(".ms-lookuptypeintextbox").each(function(){for(var e=$(this),t=$("#"+e.attr("optHid")).val(),r=e.attr("choices").split("|"),n='",e.closest("span").hide().before(n),$("#"+e.attr("id")+"_Lookup").on("change",function(){var e=$("#"+$(this).attr("id").slice(0,-7)),t=$("#"+e.attr("optHid")),r=$(this).val();t.val(r),e.val($(this).find("option[value='"+("0"!==r?r:"")+"']").text())}).trigger("change")}),function(window,document,undefined){function SharepointPlus(){return this instanceof arguments.callee?void 0:new arguments.callee}var fastMap=function(e,t){for(var r=e.length,n=new Array(r),s=r/8,i=r%8,o=r-1;o>-1;o--){var a=s,l=i;do{switch(l){case 0:n[o]=t(e[o]),o--;case 7:n[o]=t(e[o]),o--;case 6:n[o]=t(e[o]),o--;case 5:n[o]=t(e[o]),o--;case 4:n[o]=t(e[o]),o--;case 3:n[o]=t(e[o]),o--;case 2:n[o]=t(e[o]),o--;case 1:n[o]=t(e[o]),o--}l=0}while(--a>0)}return n},decode_b64=function(e,t,r,n,s,i,o){for(t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=i=o="";r=e.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)r=t.indexOf(r);return s},encode_b64=function(e,t,r,n,s,i){for(t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="=",n=i="";s&=3,e.charAt(n++)||(t="=",s);i+=t.charAt(63&r>>2*++s))r=r<<8|e.charCodeAt(n-=!s);return i};SharepointPlus.prototype={data:[],length:0,listQueue:[],needQueue:!1,getVersion:function(){return"3.0.11"},list:function(e,t){return this.reset(),t?("/"===t.substring(t.length-1,t.length)&&(t=t.substring(0,t.length-1)),this.url=t):this._getURL(),this.listID=e.replace(/&/g,"&"),this},_getURL:function(){if(this.url===undefined&&"undefined"==typeof L_Menu_BaseUrl&&jQuery("body").data("sp-currenturl")===undefined){this.needQueue=!0;var e=this,t=""+window.location.href.replace(/&/g,"&")+"",r=window.location.protocol+"//"+window.location.host+"/_vti_bin/Webs.asmx";jQuery.ajax({type:"POST",cache:!1,async:!0,url:r,data:t,contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(t){var r=t.getElementsByTagName("WebUrlFromPageUrlResult");r.length&&(e.url=r[0].firstChild.nodeValue.toLowerCase(),jQuery("body").data("sp-currenturl",e.url)),e.needQueue=!1}})}else this.url=this.url||jQuery("body").data("sp-currenturl")||window.location.protocol+"//"+window.location.host+L_Menu_BaseUrl;return this},_addInQueue:function(e){return this.listQueue.push(e),1===this.listQueue.length&&this._testQueue(),this},_testQueue:function(){if(this.needQueue){var e=this;setTimeout(function(){e._testQueue.call(e)},25)}else{if(this.listQueue.length>0){var t=this.listQueue.shift();t.callee.apply(this,Array.prototype.slice.call(t))}if(this.needQueue=this.listQueue.length>0,this.needQueue){var e=this;setTimeout(function(){e._testQueue.call(e)},25)}}},parse:function(e,t){var r=e.replace(/(\s+)?(=|~=|<=|>=|<>|<|>| LIKE | like )(\s+)?/g,"$2").replace(/""|''/g,"Null").replace(/==/g,"="),n=[];t=t===!1?!1:!0;for(var s=e.length,i="",o="",a=!1,l="",u={open:0},c=!1,h=0;hh;)h++,u.open++;for(;u.open>0&&s>h;){h++;var m=r.charAt(h);"\\"==m?a=!0:a||"'"!=m&&'"'!=m?a||")"!=m||d?a=!1:u.open--:d=!d}var g=n.length-1;g>=0?(""!=i&&(n[0]="<"+i+">"+n[0]),n[0]+=this.parse(r.substring(f+1,h)),""!=i&&(n[0]+=""),i=""):n[0]=this.parse(r.substring(f+1,h));break;case">":case"<":h++,"="==r.charAt(h)?(n.push("<"+(">"==p?"G":"L")+"eq>"),o=""==p?"G":"L")+"eq>"):"<"==p&&">"==r.charAt(h)?(n.push(""),o=""):(h--,n.push("<"+(">"==p?"G":"L")+"t>"),o=""==p?"G":"L")+"t>");break;case"~":"="==r.charAt(h+1)&&(c=!0);break;case"=":n.push(""),o="";break;case" ":" AND "==r.substring(h,h+5).toUpperCase()?(i="And",h+=4):" OR "==r.substring(h,h+4).toUpperCase()?(i="Or",h+=3):" LIKE "==r.slice(h,h+6).toUpperCase()?(h+=5,n.push(""),o=""):l+=p;break;case'"':case"'":for(var y=p,v="",w="";(p=r.charAt(++h))!=y&&s>h;)"\\"==p&&(p=r.charAt(++h)),v+=p;g=n.length-1,n[g]+='",l="";var b="Text";/\d{4}-\d\d?-\d\d?((T| )\d{2}:\d{2}:\d{2})?/.test(v)&&(b="DateTime",/\d{4}-\d\d?-\d\d?((T| )\d{2}:\d{2}:\d{2})/.test(v)&&(w=' IncludeTimeValue="TRUE"')),t&&(v=this._cleanString(v)),"[Me]"===v?(v='',b="Integer"):"[Today"==v.slice(0,6)&&(b="DateTime",v=''),n[g]+='"+v+"",n[g]+=o,o="",g>0&&(""!=i&&(n[0]="<"+i+">"+n[0]),n[0]+=n[g],""!=i&&(n[0]+=""),delete n[g],i="");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":if(""!=o){for(var x=p;!isNaN(p=r.charAt(++h))&&s>h;)x+=""+p;g=n.length-1,n[g]+='",l="",n[g]+=''+x.replace(/ $/,"")+"",n[g]+=o,o="",g>0&&(""!=i&&(n[0]="<"+i+">"+n[0]),n[0]+=n[g],""!=i&&(n[0]+=""),delete n[g],i=""),h-=2;break}default:""==o?l+=p:"n"==p.toLowerCase()&&"null"==r.substring(h,h+4).toLowerCase()&&(g=n.length-1,""==o?(n[g]="",o=""):""==o&&(n[g]="",o=""),h+=3,n[g]+='',l="",n[g]+=o,o="",g>0&&(""!=i&&(n[0]="<"+i+">"+n[0]),n[0]+=n[g],""!=i&&(n[0]+=""),delete n[g],i=""))}}return n.join("")},_parseOn:function(e){for(var t=[],r=e.replace(/(\s+)?(=)(\s+)?/g,"$2").replace(/==/g,"=").split(" AND "),n=0;n/g,">")},cleanResult:function(e,t){return null===e||"undefined"==typeof e?"":(t=t||";","string"==typeof e?e.replace(/;#[0-9]+;#/g,t).replace(/^[0-9]+;#/,"").replace(/^;#|;#$/g,"").replace(/;#/g,t).replace(/^(string;|float;)#?/,""):e)},get:function(e,t){if(this.needQueue)return this._addInQueue(arguments);if(this.listID==undefined)throw"Error 'get': you have to define the list ID/Name";if(1===arguments.length&&"function"==typeof e)return this.get({},e);if(e=e||{},this.url==undefined)throw"Error 'get': not able to find the URL!";if(e.fields=e.fields||"",e.where=e.where||"",e.whereFct=e.whereFct||function(e){return e},e.orderby=e.orderby||"",e.useIndexForOrderBy=e.useIndexForOrderBy===!0?!0:!1,e.groupby=e.groupby||"",e.rowlimit=e.rowlimit||0,e.whereEscapeChar=e.whereEscapeChar===!1?!1:!0,e.paging=e.paging===!0?!0:!1,e.page=e.paging===!1||isNaN(e.page)?5e3:e.page,e.paging&&0===e.rowlimit&&(e.rowlimit=5e3),e.expandUserField=e.expandUserField===!0||"True"===e.expandUserField?"True":"False",e.dateInUTC=e.dateInUTC===!0?"True":"False",e.folderOptions=e.folderOptions||null,e.view=e.view||"",e.calendar=e.calendar===!0?!0:!1,e.calendar===!0&&(e.calendarOptions=e.calendarOptions||{},e.calendarOptions.referenceDate=e.calendarOptions.referenceDate||new Date,"string"!=typeof e.calendarOptions.referenceDate&&(e.calendarOptions.referenceDate=this.toSPDate(e.calendarOptions.referenceDate)),e.calendarOptions.splitRecurrence=e.calendarOptions.splitRecurrence===!1?"FALSE":"TRUE",e.calendarOptions.range=e.calendarOptions.range||"Month"),e.results=e.results||[],e.listItemCollectionPositionNext=e.listItemCollectionPositionNext||"","object"==typeof e.where?(e.where=e.where.slice(0),e.originalWhere==undefined&&(e.originalWhere=e.where.slice(0)),e.nextWhere=e.where.slice(1),e.where=e.where.shift()):(e.originalWhere=e.where,e.nextWhere=[]),e.progress=e.progress||function(){},""!==e.view){var r=this;return r.view(e.view,function(n,s){e.view=s,e.fields;var i=e.whereCAML?e.where:r.parse(e.where),o=n.whereCAML.match(/^(.*<\/DateRangesOverlap>)(.*)<\/And>$/);return o&&3===o.length&&(n.whereCAML=""+o[2]+o[1]+""),i+=n.whereCAML,""!==e.where&&""!==n.whereCAML&&(i=""+i+""),e.where=i,e.fields+=(""===e.fields?"":",")+n.fields.join(","),e.orderby+=(""===e.orderby?"":",")+n.orderby,e.whereCAML=!0,e.useOWS=!0,e.calendarViaView=e.calendar,e.calendar=!1,delete e.view,r.get.call(r,e,t)}),this}var n=!0,s="";if(""==e.fields||e.fields==[])s="";else{"string"==typeof e.fields&&(e.fields=e.fields.replace(/^\s+/,"").replace(/\s+$/,"").replace(/( )?,( )?/g,",").split(","));for(var i=0;i'}var o="";if(""!=e.orderby){var a=e.orderby.split(",");for(i=0;i0&&(2==u.length&&(l=u[1].toUpperCase()),o+=n?'':'')}}e.calendar!==!0&&e.calendarViaView!==!0||""!==o||(o='');var c="";if(""!=e.groupby){var h=e.groupby.split(",");for(i=0;i'}if(e.calendar===!0||e.calendarViaView===!0){var p=["Title","EventDate","EndDate","Duration","fAllDayEvent","fRecurrence","RecurrenceData","ID"];for(i=0;i'}var f="",d=[];if(e.queryOptions===undefined)if(e._queryOptions=""+e.dateInUTC+'True'+(""===s?"":"False")+""+e.expandUserField+"",e.folderOptions){var m;switch(e.folderOptions.show){case"FilesAndFolders_Recursive":m="RecursiveAll";break;case"FilesOnly_InFolder":m="FilesOnly";break;case"FilesAndFolders_InFolder":m="";break;case"FilesOnly_Recursive":default:m="Recursive"}e._queryOptions+='',e.folderOptions.path&&(e._queryOptions+=""+this.url+"/"+this.listID+"/"+e.folderOptions.path+"")}else e._queryOptions+='';else e._queryOptions=e.queryOptions;e.calendarOptions&&(e._queryOptions+=""+e.calendarOptions.referenceDate+"v3"+e.calendarOptions.splitRecurrence+"");var g="";if(""!==e.where&&(g=e.whereCAML?e.where:this.parse(e.where)),e.calendar===!0){var y="<"+e.calendarOptions.range+" />";g=""!==g?""+g+y+"":y}g=e.whereFct(g);var r=this;if(n){f=''+this.listID+""+e.view+""+(""!=g?""+g+"":"")+(""!=c?""+c+"":"")+(""!=o?""+o+"":"")+""+s+""+e.rowlimit+""+e._queryOptions+"";var v=this.url+"/_vti_bin/Lists.asmx";jQuery.ajax({type:"POST",cache:!1,async:!0,url:v,data:f,contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(n){var s=n.getElementsByTagName("z:row");if(0==s.length&&(s=n.getElementsByTagName("row")),d=fastMap(s,function(e){return myElem(e)}),e.joinData){var i=e.joinData.noindex,o=[],a="",l={length:0};i.length||alert("$SP.get() -- Error 'get': you must define the ON clause with JOIN is used.");for(var u=0,c=d.length;c>u;u++){for(var h="",p=0;pp;p++){for(var m=[],g=d[u].getAttributes(),y=g.length;y--;)m[r.listID+"."+g[y].nodeName.slice(4)]=g[y].nodeValue;var v=e.joinData[h][p].getAttributes();for(var y in v)m[y]=e.joinData[h][p].getAttribute(y);o.push(new extendMyObject(m))}}e.innerjoin&&(e.join=e.innerjoin),e.outerjoin&&(e.join=e.outerjoin,e.join.outer=!0)}if(d=o,e.outer){var w=e.joinIndex.length;if(l.lengthu;u++)if(l[u]!==!0){var b=e.joinIndex[u];if(b===undefined||e.joinData[b]===undefined)continue;for(var p=0,f=e.joinData[b].length;f>p;p++){var m=[],v=e.joinData[b][p].getAttributes();for(var y in v)m[y]=e.joinData[b][p].getAttribute(y);o.push(new extendMyObject(m))}}}}if(e.outerjoin?(e.join=e.outerjoin,e.join.outer=!0):e.innerjoin&&(e.join=e.innerjoin),e.join){var x=[],T=[],i=r._parseOn(e.join.on);x.noindex=i;for(var u=0,c=d.length;c>u;u++){for(var h="",m=[],p=0;p0)for(var u=0,c=d.length;c>u;u++)e.results.push(d[u]);if("string"!=typeof e.originalWhere&&e.progress(e.originalWhere.length-e.nextWhere.length,e.originalWhere.length),e.paging){var I=n.getElementsByTagName("rs:data")[0];("undefined"==typeof I||0==I.length)&&(I=n.getElementsByTagName("data")[0]),I&&(E=I.getAttribute("ListItemCollectionPositionNext"))}e.paging&&--e.page>0?(0===e.results.length&&(e.results=d),e.progress(e.results.length),E?(e.listItemCollectionPositionNext=r._cleanString(E),r.get(e,t)):"function"==typeof t&&t.call(r,e.results,E)):e.nextWhere.length>0?(0===e.results.length&&(e.results=d),e.where=e.nextWhere.slice(0),r.get(e,t)):"function"==typeof t&&(e.where=e.originalWhere,t.call(r,e.results.length>0?e.results:d,E))}},error:function(e,n,s){var i=e.responseXML,o=i.getElementsByTagName("errorstring");o&&o[0]?t.call(r,[],"Error: "+o[0].firstChild.nodeValue):t.call(r,[],n+": "+s)}})}return this},createFile:function(e){if(e=e||{},e.content==undefined)throw"Error 'createFile': not able to find the file content.";if(e.destination==undefined)throw"Error 'createFile': not able to find the file destination path.";if(e.url=e.url||this.url,!e.url)return this._getURL(),this._addInQueue(arguments);if(e.url==undefined)throw"Error 'createFile': not able to find the URL!";e.after=e.after||function(){},e.encoded=e.encoded==undefined?!1:e.encoded;var t=this,r='http://null'+e.destination+""+(e.encoded?e.content:encode_b64(e.content))+"";return jQuery.ajax({url:e.url+"/_vti_bin/copy.asmx",type:"POST",dataType:"xml",data:r,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems")},contentType:'text/xml; charset="utf-8"',success:function(r){var n=r.getElementsByTagName("CopyResult");if(n&&n[0]&&"Success"!=n[0].getAttribute("ErrorCode"))throw"Error 'createFile': "+n[0].getAttribute("ErrorCode")+" - "+n[0].getAttribute("ErrorMessage");"function"==typeof e.after&&e.after.call(t)}}),this},createFolder:function(e){if(e=e||{},e.path==undefined)throw"Error 'createFolder': please provide the 'path'.";if(e.library==undefined)throw"Error 'createFolder': please provide the library name.";if(e.url=e.url||this.url,!e.url)return this._getURL(),this._addInQueue(arguments);if(e.url==undefined)throw"Error 'createFolder': not able to find the URL!";e.after=e.after||function(){};for(var t=e.path.split("/"),r=[],n="",s=0;s0?"/":"")+t[s],r.push({FSObjType:1,BaseName:n});return this.list(e.library,e.url).add(r,{after:e.after}),this},checkin:function(e){if(e=e||{},e.destination==undefined)throw"Error 'checkin': not able to find the file destination path.";if(e.url=e.url||this.url,!e.url)return this._getURL(),this._addInQueue(arguments);if(this.url==undefined)throw"Error 'checkin': not able to find the URL!";e.url=this.url,e.comments=e.comments||"",e.success=e.success||function(){},e.error=e.error||function(){},e.after=e.after||function(){};var t=this,r=''+e.destination+""+e.comments+"1";jQuery.ajax({url:e.url+"/_vti_bin/Lists.asmx",type:"POST",dataType:"xml",data:r,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/CheckInFile")},contentType:"text/xml; charset=utf-8",success:function(r){var n=r.getElementsByTagName("CheckInFileResult");n&&n[0]&&"true"!=n[0].firstChild.nodeValue?e.error.call(t):e.success.call(t),e.after.call(t)}})},getAttachment:function(e,t,r){if(this.needQueue)return this._addInQueue(arguments);if(this.listID==undefined)throw"Error 'getAttachment': you have to define the list ID/Name";if(1===arguments.length&&"function"==typeof e)throw"Error 'getAttachment': you have to define the item ID";if(this.url==undefined)throw"Error 'getAttachment': not able to find the URL!";"object"!=typeof e&&(e=e.split(",")),r=r||[];var n=' '+this.listID+" "+e.shift()+" ",s=this,i=this.url+"/_vti_bin/lists.asmx",o=[];return jQuery.ajax({type:"POST",cache:!1,async:!0,url:i,data:n,contentType:"text/xml; charset=utf-8",beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetAttachmentCollection")},dataType:"xml",success:function(n){for(var i=n.getElementsByTagName("Attachment"),a=0;a",n+=" ",n+=" ",n+="";var s=this,i=this.url+"/_vti_bin/lists.asmx",o=[];return jQuery.ajax({type:"POST",cache:!1,async:!0,url:i,data:n,contentType:"text/xml; charset=utf-8",beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetListContentTypes")},dataType:"xml",success:function(e){for(var r,n=e.getElementsByTagName("ContentType"),i=0;i=1&&"string"!=typeof e)throw"Error 'getContentTypeInfo': you have to provide the Content Type Name/ID";if(2===arguments.length&&"function"==typeof t)return this.getContentTypeInfo(e,null,t);if(this.url==undefined)throw"Error 'getContentTypeInfo': not able to find the URL!";if(t||(t={cache:!0}),t.cache)for(var n=0;n<_SP_CACHE_CONTENTTYPE.length;n++)if(_SP_CACHE_CONTENTTYPE[n].list===this.listID&&_SP_CACHE_CONTENTTYPE[n].url===this.url&&_SP_CACHE_CONTENTTYPE[n].contentType===e)return"function"==typeof r&&r.call(this,_SP_CACHE_CONTENTTYPE[n].info),this;if("0x"!==e.slice(0,2))return this.getContentTypes(t,function(n){for(var s=!1,i=n.length;i--;)if(n[i].Name===e){this.getContentTypeInfo(n[i].ID,t,r),s=!0;break}if(!s)throw"Error 'getContentTypeInfo': not able to find the Content Type called '"+e+"' at "+this.url}),this;var s='';s+='',s+=" ",s+=' ',s+=" "+this.listID+"",s+=" "+e+"",s+=" ",s+=" ",s+="";var i=this,o=this.url+"/_vti_bin/lists.asmx",a=[];return jQuery.ajax({type:"POST",cache:!1,async:!0,url:o,data:s,contentType:"text/xml; charset=utf-8",beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetListContentType")},dataType:"xml",success:function(t){for(var n,s,o,l,u=t.getElementsByTagName("Field"),c=0,h=0;h0){nodeDefault=u[h].getElementsByTagName("Default"),a[c].DefaultValue=[];for(var g=0;l>g;g++)nodeDefault[g].firstChild&&a[c].DefaultValue.push(nodeDefault[g].firstChild.nodeValue);1===l&&(a[c].DefaultValue=a[c].DefaultValue[0])}else a[c].DefaultValue=null;c++}_SP_CACHE_CONTENTTYPE.push({list:i.listID,url:i.url,contentType:e,info:a}),"function"==typeof r&&r.call(i,a)}}),this},info:function(e){if(this.needQueue)return this._addInQueue(arguments);if(this.listID==undefined)throw"Error 'info': you have to define the list ID";if(this.url==undefined)throw"Error 'info': not able to find the URL!";var t='';t+='',t+=" ",t+=' ',t+=" "+this.listID+"",t+=" ",t+=" ",t+="";var r=this,n=this.url+"/_vti_bin/lists.asmx",s=[];return jQuery.ajax({type:"POST",cache:!1,async:!0,url:n,data:t,contentType:"text/xml; charset=utf-8",beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetList")},dataType:"xml",success:function(t){for(var n,i,o,a,l=t.getElementsByTagName("Field"),u=0,c=0;c0){nodeDefault=l[c].getElementsByTagName("Default"),s[u].DefaultValue=[];for(var m=0;a>m;m++)nodeDefault[m].firstChild&&s[u].DefaultValue.push(nodeDefault[m].firstChild.nodeValue);1===a&&(s[u].DefaultValue=s[u].DefaultValue[0])}else s[u].DefaultValue=null;u++}"function"==typeof e&&e.call(r,s)}}),this},view:function(e,t){if(this.needQueue)return this._addInQueue(arguments);if(this.listID==undefined)throw"Error 'view': you have to define the list ID/Name";if(1===arguments.length&&"function"==typeof e)return this.view("",e);if(list=this.listID,this.url==undefined)throw"Error 'view': not able to find the URL!";e=e||"";var r=arguments[2]||e;r=r.toLowerCase();var n=jQuery("body").data("sp-view");if(n!=undefined){for(var s=n.length;s--;)if(n[s].url===this.url&&n[s].list===list&&(n[s].viewID===e||n[s].viewName===r))return t.call(this,n[s].data,e),this}else n=[];if("{"!==e.charAt(0))return this.views(function(r){for(var n=!1,s=r.length;s--;)if(r[s].Name===e){this.view(r[s].ID,t,e),n=!0;break}if(!n)throw"Error 'view': not able to find the view called '"+e+"' at "+this.url}),this;var i='';i+='',i+=" ",i+=' ',i+=" "+this.listID+"",i+=" "+e+"",i+=" ",i+=" ",i+="";var o=this.url+"/_vti_bin/Views.asmx",a=["fields","orderby","whereCAML"],l=this;return jQuery.ajax({type:"POST",cache:!1,async:!0,url:o,data:i,contentType:"text/xml; charset=utf-8",beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetView")},dataType:"xml",success:function(s){a.fields=[];for(var i=s.getElementsByTagName("ViewFields")[0].getElementsByTagName("FieldRef"),o=0;o]+>(.*)<\/Where>/),2==c.length&&(a.whereCAML=c[1])),n.push({url:l.url,list:list,data:a,viewID:e,viewName:r}),jQuery("body").data("sp-view",n),"function"==typeof t&&t.call(l,a,e)}}),this},views:function(e,t){if("function"==typeof e)return this.views({},e);if(e.cache=e.cache===!1?!1:!0,this.needQueue)return this._addInQueue(arguments);if(this.listID==undefined)throw"Error 'views': you have to define the list ID";if(this.url==undefined)throw"Error 'views': not able to find the URL!";t=t||function(){};var r=jQuery("body").data("sp-views");if(r!=undefined&&e.cache){for(var n=r.length;n--;)if(r[n].url==this.url&&r[n].listID===this.listID)return t.call(this,r[n].data),this}else r=[];var s='';s+='',s+=" ",s+=' ',s+=" "+this.listID+"",s+=" ",s+=" ",s+="";var i=this.url+"/_vti_bin/Views.asmx",o=[],a=this;return jQuery.ajax({type:"POST",cache:!1,async:!0,url:i,data:s,contentType:"text/xml; charset=utf-8",beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetViewCollection")},dataType:"xml",success:function(n){for(var s=n.getElementsByTagName("View"),i=0;i15){var n=e.slice(0),s=n.splice(0,15),i=this;return jQuery(document).on(t.progressVar.eventID,function(e){jQuery(document).off(t.progressVar.eventID),i.add(n,e.setup)}),this.add(s,t),this}if(0==r)return t.progress(1,1),t.error([]),t.success([]),t.after(),this;t.progressVar.current+=r;for(var o='',i=this,a=0;a',o+="New",jQuery.each(e[a],function(e,r){"object"==typeof r&&r.items!=undefined&&(r=";#"+r.join(";#")+";#"),t.escapeChar&&"string"==typeof r&&(r=i._cleanString(r)),o+=""+r+""}),o+="";o+="";var l=''+this.listID+""+o+"",u=this.url+"/_vti_bin/lists.asmx",i=this;return jQuery.ajax({type:"POST",cache:!1,async:!0,url:u,data:l,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(r){for(var n=r.getElementsByTagName("Result"),s=n.length,o=t.progressVar.passed,a=t.progressVar.failed,l=0;s>l;l++)if("0x00000000"==n[l].getElementsByTagName("ErrorCode")[0].firstChild.nodeValue){var u=n[l].getElementsByTagName("z:row");0==u.length&&(u=n[l].getElementsByTagName("row")),e[l]&&(e[l].ID=u[0].getAttribute("ows_ID"),o.push(e[l]))}else e[l]&&(e[l].errorMessage=n[l].getElementsByTagName("ErrorText")[0].firstChild.nodeValue,a.push(e[l]));t.progress(t.progressVar.current,t.progressVar.max),t.progressVar.current0&&t.error.call(i,a),o.length>0&&t.success.call(i,o),t.after.call(i))}}),this},update:function(e,t){if(this.needQueue)return this._addInQueue(arguments);if(this.listID===undefined)throw"Error 'update': you need to use list() to define the list name.";if(t=t||{},this.url==undefined)throw"Error 'update': not able to find the URL!";t.where=t.where||"",t.success=t.success||function(){},t.error=t.error||function(){},t.after=t.after||function(){},t.escapeChar=t.escapeChar==undefined?!0:t.escapeChar,t.progress=t.progress||function(){},"object"==typeof e&&e.length==undefined&&(e=[e]);var r=e.length;if(1==r&&t.where){delete e[0].ID;var n=this;return this.get({fields:"ID",where:t.where},function(r){for(var s=function(e){var t={};for(var r in e)t[r]=e[r];return t},i=[],o=r.length;o--;){var a=s(e[0]);a.ID=r[o].getAttribute("ID"),i.push(a)}delete t.where,n.update(i,t)}),this}if(t.progressVar=t.progressVar||{current:0,max:r,passed:[],failed:[],eventID:"spUpdate"+(""+Math.random()).slice(2)},r>15){var s=e.slice(0),i=s.splice(0,15),n=this;return jQuery(document).on(t.progressVar.eventID,function(e){jQuery(document).off(t.progressVar.eventID),n.update(s,e.setup)}),this.update(i,t),this}if(0==r)return t.progress(1,1),t.error([]),t.success([]),t.after(),this;t.progressVar.current+=r;for(var o='',n=this,a=0;r>a;a++){if(o+='',e[a].ID==undefined)throw"Error 'update': you have to provide the item ID called 'ID'";jQuery.each(e[a],function(e,r){"object"==typeof r&&r.length!=undefined&&(r=";#"+r.join(";#")+";#"),t.escapeChar&&"string"==typeof r&&(r=n._cleanString(r)),o+=""+r+""}),o+=""}o+="";var l=''+this.listID+""+o+"",u=this.url+"/_vti_bin/lists.asmx",n=this;return jQuery.ajax({type:"POST",cache:!1,async:!0,url:u,data:l,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(r){for(var s=r.getElementsByTagName("Result"),i=s.length,o=t.progressVar.passed,a=t.progressVar.failed,l=0;i>l;l++)"0x00000000"==s[l].getElementsByTagName("ErrorCode")[0].firstChild.nodeValue&&e[l]?o.push(e[l]):e[l]&&(e[l].errorMessage=s[l].getElementsByTagName("ErrorText")[0].firstChild.nodeValue,a.push(e[l]));t.progress(t.progressVar.current,t.progressVar.max),t.progressVar.current0&&t.error.call(n,a),o.length>0&&t.success.call(n,o),t.after.call(n))}}),this},history:function(e,t){if(this.needQueue)return this._addInQueue(arguments);if(this.listID===undefined)throw"Error 'history': you need to use list() to define the list name.";if(2!==arguments.length)throw"Error 'history': you need to provide two parameters.";if("object"!=typeof e)throw"Error 'history': the first parameter must be an object.";if(e.ID===undefined||e.Name===undefined)throw"Error 'history': the first parameter must be an object with ID and Name.";if("function"!=typeof t)throw"Error 'history': the second parameter must be a function.";var r=''+this.listID+""+e.ID+""+e.Name+"",n=this.url+"/_vti_bin/lists.asmx",s=this;return jQuery.ajax({type:"POST",cache:!1,async:!0,url:n,data:r,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetVersionCollection")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(e){t.call(s,e.getElementsByTagName("Version"))}}),this},moderate:function(e,t){if(this.needQueue)return this._addInQueue(arguments);if(0===arguments.length||1===arguments.length&&"object"==typeof e&&e.length===undefined)throw"Error 'moderate': you need to define the list of items";if(this.listID===undefined)throw"Error 'moderate': you need to use list() to define the list name.";if(t=t||{},this.url==undefined)throw"Error 'moderate': not able to find the URL!";t.async=t.async==undefined?!0:t.async,t.success=t.success||function(){},t.error=t.error||function(){},t.after=t.after||function(){},t.progress=t.progress||function(){},"object"==typeof e&&e.length==undefined&&(e=[e]);var r=e.length;if(t.progressVar=t.progressVar||{current:0,max:r,passed:[],failed:[],eventID:"spModerate"+(""+Math.random()).slice(2)},r>15){var n=e.slice(0),s=n.splice(0,15),i=this;return jQuery(document).on(t.progressVar.eventID,function(e){jQuery(document).off(t.progressVar.eventID),i.moderate(n,e.setup)}),this.moderate(s,t),this}if(0==r)return t.progress(1,1),t.success([]),t.error([]),t.after(),this;t.progressVar.current+=r;for(var o='',a=0;r>a;a++){if(o+='',e[a].ID==undefined)throw"Error 'moderate': you have to provide the item ID called 'ID'";if(e[a].ApprovalStatus==undefined)throw"Error 'moderate': you have to provide the approval status 'ApprovalStatus' (Approved, Rejected, Pending, Draft or Scheduled)";jQuery.each(e[a],function(e,t){if("ApprovalStatus"==e)switch(e="_ModerationStatus",t.toLowerCase()){case"approve":case"approved":t=0;break;case"reject":case"deny":case"denied":case"rejected":t=1;break;case"pending":t=2;break;case"draft":t=3;break;case"scheduled":t=4;break;default:t=2}o+=""+t+""}),o+=""}o+="";var l=''+this.listID+""+o+"",u=this.url+"/_vti_bin/lists.asmx",i=this;return jQuery.ajax({type:"POST",cache:!1,async:!0,url:u,data:l,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(r){for(var n,s=r.getElementsByTagName("Result"),o=s.length,a=t.progressVar.passed,l=t.progressVar.failed,u=0;o>u;u++){n=s[u].getElementsByTagName("z:row"),0==n.length&&(n=r.getElementsByTagName("row"));var c=myElem(n[0]);"0x00000000"==s[u].getElementsByTagName("ErrorCode")[0].firstChild.nodeValue?a.push(c):(e[u].errorMessage=s[u].getElementsByTagName("ErrorText")[0].firstChild.nodeValue,l.push(e[u]))}t.progress(t.progressVar.current,t.progressVar.max),t.progressVar.current0&&t.success.call(i,a),l.length>0&&t.error.call(i,l),t.after.call(i))}}),this},remove:function(e,t){if(this.needQueue)return this._addInQueue(arguments);var r=this;if(!t&&e.where&&(t=e,e=[]),t=t||{},this.url==undefined)throw"Error 'remove': not able to find the URL!";t.error=t.error||function(){},t.success=t.success||function(){},t.after=t.after||function(){},t.progress=t.progress||function(){},"object"==typeof e&&e.length==undefined&&(e=[e]);var n=e.length;if(t.where)return 1==n&&delete e[0].ID,this.get({fields:"ID,FileRef",where:t.where},function(n){for(var s,i=function(e){var t={};for(var r in e)t[r]=e[r];return t},o=[],a=n.length;a--;){var l=i(e[0]);l.ID=n[a].getAttribute("ID"),s=n[a].getAttribute("FileRef"),s&&(l.FileRef=$SP().cleanResult(s)),o.push(l)}delete t.where,r.remove(o,t)}),r;if(0==n)return t.progress(1,1),t.error.call(r,[]),t.success.call(r,[]),t.after.call(r),r;if(t.progressVar=t.progressVar||{current:0,max:n,passed:[],failed:[],eventID:"spRemove"+(""+Math.random()).slice(2)},n>15){var s=e.slice(0),i=s.splice(0,15),r=this;return jQuery(document).on(t.progressVar.eventID,function(e){jQuery(document).off(t.progressVar.eventID),r.remove(s,e.setup)}),this.remove(i,t),this}t.progressVar.current+=n;for(var o='',a=0;a',e[a].ID==undefined)throw"Error 'delete': you have to provide the item ID called 'ID'";o+=""+e[a].ID+"",e[a].FileRef!=undefined&&(o+=""+e[a].FileRef+""),o+=""}o+="";var l=''+this.listID+""+o+"",r=this,u=this.url+"/_vti_bin/lists.asmx";return jQuery.ajax({type:"POST",cache:!1,async:!0,url:u,data:l,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(n){for(var s=n.getElementsByTagName("Result"),i=s.length,o=t.progressVar.passed,a=t.progressVar.failed,l=0;i>l;l++)"0x00000000"==s[l].getElementsByTagName("ErrorCode")[0].firstChild.nodeValue?o.push(e[l]):(e[l].errorMessage=s[l].getElementsByTagName("ErrorText")[0].firstChild.nodeValue,a.push(e[l]));t.progress(t.progressVar.current,t.progressVar.max),t.progressVar.current0&&t.error.call(r,a),o.length>0&&t.success.call(r,o),t.after.call(r))}}),this},del:function(e,t){return this.remove(e,t)},usergroups:function(e,t,r){switch(arguments.length){case 1:if("object"==typeof e)return this.usergroups("",e,function(){});if("function"==typeof e)return this.usergroups("",{},e);break;case 2:if("string"==typeof e&&"function"==typeof t)return this.usergroups(e,{},t);if("object"==typeof e&&"function"==typeof t)return this.usergroups("",e,t)}if(t=t||{},t.cache=t.cache===!1?!1:!0,t.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);t.url=this.url}else this.url=t.url;if(r=r||function(){},!e)throw"Error 'usergroups': you have to set an username.";e=e.toLowerCase(),t.url=t.url.toLowerCase();var n=jQuery("body").data("sp-usergroups")||[];if(t.cache)for(var s=n.length;s--;)if(n[s].user.toLowerCase()==e&&n[s].url.toLowerCase()==t.url)return r.call(this,n[s].data),this;var i=""+e+"",o=this,a=t.url+"/_vti_bin/usergroup.asmx";return jQuery.ajax({type:"POST",cache:!1,url:a,data:i,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/directory/GetGroupCollectionFromUser")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(s){var i=[];s=s.getElementsByTagName("Group");for(var a=0,l=s.length;l>a;a++)i.push(s[a].getAttribute("Name"));n.push({user:e,url:t.url,data:i}),jQuery("body").data("sp-usergroups",n),r.call(o,i)},error:function(e,n,s){if(t.error===!1)r.call(o,[]);else{var i=e.responseXML.getElementsByTagName("errorstring");"object"==typeof console&&console.error("Error 'usergroups': "+i[0].firstChild.nodeValue)}}}),this},workflowStatusToText:function(e){switch(e=1*e){case 0:return"Not Started";case 1:return"Failed On Start";case 2:return"In Progress";case 3:return"Error Occurred";case 4:return"Stopped By User";case 5:return"Completed";case 6:return"Failed On Start Retrying";case 7:return"Error Occurred Retrying";case 8:return"View Query Overflow";case 15:return"Canceled";case 16:return"Approved";case 17:return"Rejected";default:return"Unknown"}},getWorkflowID:function(e){if(this.needQueue)return this._addInQueue(arguments);if(this.listID==undefined)throw"Error 'getWorkflowID': you have to define the list ID/Name";if(this.url==undefined)throw"Error 'getWorkflowID': not able to find the URL!";if(e=e||{},e.ID==undefined||e.workflowName==undefined||e.after==undefined)throw"Error 'getWorkflowID': all parameters are mandatory";return this.get({fields:"FieldRef",where:"ID = "+e.ID},function(t){if(0===t.length)throw"Error 'getWorkflowID': I'm not able to find the item ID "+e.ID;var r=this.cleanResult(t[0].getAttribute("FileRef")),n=r.substring(0,r.indexOf("/Lists")),t=this.url.substring(0,this.url.indexOf(n));r=t+r;var s=''+r+"",i=this;jQuery.ajax({type:"POST",cache:!1,async:!0,url:this.url+"/_vti_bin/Workflow.asmx",data:s,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/workflow/GetWorkflowDataForItem")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(t){var n,s,o={},a=t.getElementsByTagName("WorkflowTemplate");if(0===a.length){var l=SP.ClientContext.get_current(),u=l.get_web().get_lists(),c=u.getByTitle(i.listID),h=c.getItemById(e.ID);h.get_file();l.load(c),l.load(h);var p=c.get_workflowAssociations();l.load(p),l.executeQueryAsync(function(){for(var t=p.getEnumerator();t.moveNext();){var n=t.get_current();if(n.get_name()===e.workflowName){o={fileRef:r,description:n.get_description(),workflowID:"{"+n.get_id().toString()+"}",instances:[]};break}}e.after.call(i,o)},function(){throw"Error 'getWorkflowID': Problem while dealing with SP.ClientContext.get_current()"})}else{for(n=a.length;n--;)a[n].getAttribute("Name")==e.workflowName&&(o={fileRef:r,description:a[n].getAttribute("Description"),workflowID:"{"+a[n].getElementsByTagName("WorkflowTemplateIdSet")[0].getAttribute("TemplateId")+"}",instances:[]});if(!o.fileRef)throw"Error 'getWorkflowID': it seems the requested workflow ('"+e.workflowName+"') doesn't exist!";for(a=t.getElementsByTagName("Workflow"),n=0;n";for(var n=0;n"+r[n].value+"";t+=""}var s=''+e.fileRef+""+e.workflowID+""+t+"",i=this,o=this.url+"/_vti_bin/Workflow.asmx";jQuery.ajax({type:"POST",cache:!1,async:!0,url:o,data:s,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/workflow/StartWorkflow")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(t){e.after.call(i)},error:function(t,r,n){e.after.call(i,n)}})}else this.getWorkflowID({ID:e.ID,workflowName:e.workflowName,after:function(t){e.fileRef=t.fileRef,e.workflowID=t.workflowID,this.startWorkflow(e)}});return this},distributionLists:function(e,t,r){switch(arguments.length){case 1:if("object"==typeof e)return this.distributionLists("",e,function(){});if("function"==typeof e)return this.distributionLists("",{},e);break;case 2:if("string"==typeof e&&"function"==typeof t)return this.distributionLists(e,{},t);if("object"==typeof e&&"function"==typeof t)return this.distributionLists("",e,t)}if(t=t||{},t.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);t.url=this.url}else this.url=t.url;if(r=r||function(){},!e)throw"Error 'distributionLists': you have to set an username.";e=e.toLowerCase(),t.url=t.url.toLowerCase(),t.cache=t.cache===!1?!1:!0;var n=jQuery("body").data("sp-distributionLists")||[];if(t.cache)for(var s=n.length;s--;)if(n[s].user===e&&n[s].url===t.url)return r.call(this,n[s].data),this;var i=""+e+"",o=this,a=t.url+"/_vti_bin/UserProfileService.asmx";return jQuery.ajax({type:"POST",cache:!1,url:a,data:i,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://microsoft.com/webservices/SharePointPortalServer/UserProfileService/GetUserMemberships")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(s){var i=[];s=s.getElementsByTagName("MembershipData");for(var a=0,l=s.length;l>a;a++)"DistributionList"===s[a].getElementsByTagName("Source")[0].firstChild.nodeValue&&i.push({SourceReference:s[a].getElementsByTagName("SourceReference")[0].firstChild.nodeValue,DisplayName:s[a].getElementsByTagName("DisplayName")[0].firstChild.nodeValue,MailNickname:s[a].getElementsByTagName("MailNickname")[0].firstChild.nodeValue,Url:s[a].getElementsByTagName("Url")[0].firstChild.nodeValue});n.push({user:e,url:t.url,data:i}),jQuery("body").data("sp-distributionLists",n),r.call(o,i)},error:function(e,t,n){r.call(o,[])}}),this},groupMembers:function(e,t,r){switch(arguments.length){case 1:if("object"==typeof e)return this.groupMembers("",e,function(){});if("function"==typeof e)return this.groupMembers("",{},e);break;case 2:if("string"==typeof e&&"function"==typeof t)return this.groupMembers(e,{},t);if("object"==typeof e&&"function"==typeof t)return this.groupMembers("",e,t)}if(t=t||{},t.cache=t.cache===undefined?!0:t.cache,t.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);t.url=this.url}else this.url=t.url;if(r=r||function(){},!e)throw"Error 'groupMembers': you have to set an groupname.";e=e.toLowerCase(),t.url=t.url.toLowerCase();var n=[];if(t.cache){n=jQuery("body").data("sp-groupMembers")||[];for(var s=n.length;s--;)if(n[s].group===e&&n[s].url===t.url)return r.call(this,n[s].data),this}var i=""+this._cleanString(e)+"",o=this,a=t.url+"/_vti_bin/usergroup.asmx";return jQuery.ajax({type:"POST",cache:!1,url:a,data:i,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/directory/GetUserCollectionFromGroup")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(s){var i=[];s=s.getElementsByTagName("User");for(var a=0,l=s.length;l>a;a++)i.push({ID:s[a].getAttribute("ID"),Name:s[a].getAttribute("Name"),LoginName:s[a].getAttribute("LoginName"),Email:s[a].getAttribute("Email")});n.push({group:e,url:t.url,data:i}),jQuery("body").data("sp-groupMembers",n),r.call(o,i)},error:function(e,n,s){if(t.error===!1)r.call(o,[]);else{var i=e.responseXML.getElementsByTagName("errorstring");"object"==typeof console&&console.error("Error 'groupMembers': "+i[0].firstChild.nodeValue)}}}),this},isMember:function(e,t){if(e=e||{},e.cache=e.cache===!1?!1:!0,e.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);e.url=this.url}else this.url=e.url;if(t=t||function(){},!e.user)throw"Error 'isMember': you have to set an user.";if(!e.group)throw"Error 'isMember': you have to set a group.";return e.group=e.group.toLowerCase(),this.usergroups(e.user,{cache:e.cache,error:!1},function(r){for(var n=r.length;n--;)if(r[n].toLowerCase()===e.group)return t.call(this,!0),this;this.groupMembers(e.group,{cache:e.cache,error:!1},function(r){for(var n=[],s=r.length;s--;)n.push(r[s].Name.toLowerCase());this.distributionLists(e.user,{cache:e.cache},function(e){for(var r=e.length;r--;)if(n.indexOf(e[r].DisplayName.toLowerCase())>-1)return t.call(this,!0),this;return t.call(this,!1),this})})}),this},people:function(e,t,r){switch(arguments.length){case 1:if("object"==typeof e)return this.people("",e,function(){});if("function"==typeof e)return this.people("",{},e);e=undefined;break;case 2:if("string"==typeof e&&"function"==typeof t)return this.people(e,{},t);if("object"==typeof e&&"function"==typeof t)return this.people("",e,t)}if(t=t||{},t.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);t.url=this.url}else this.url=t.url;r=r||function(){},e=e||"";var n=""+e+"",s=this,i=t.url+"/_vti_bin/UserProfileService.asmx";return jQuery.ajax({type:"POST",cache:!1,url:i,data:n,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://microsoft.com/webservices/SharePointPortalServer/UserProfileService/GetUserProfileByName")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(e){var t=[];e=e.getElementsByTagName("PropertyData");for(var n=0,i=e.length;i>n;n++){var o=e[n].getElementsByTagName("Name")[0].firstChild.nodeValue,a=e[n].getElementsByTagName("Value");a=a&&a.length>=1&&a[0].firstChild?a[0].firstChild.nodeValue:"No Value",t.push(o),t[o]=a}r.call(s,t)},error:function(e,t,n){var i=e.responseXML.getElementsByTagName("faultstring");r.call(s,"Error 'people': "+i[0].firstChild.nodeValue)}}),this},getUserInfo:function(e,t,r){if("string"!=typeof e)throw"Error 'getUserInfo': the first argument must be the username";switch(arguments.length){case 2:if("function"==typeof t)return this.getUserInfo(e,{},t);if("object"==typeof t)return this.getUserInfo(e,t,function(){});break;case 3:if("object"!=typeof t&&"function"!=typeof r)throw"Error 'getUserInfo': incorrect arguments, please review the documentation"}if(t=t||{},t.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);t.url=this.url}else this.url=t.url;r=r||function(){};var n=''+e+"",s=this,i=t.url+"/_vti_bin/usergroup.asmx";return jQuery.ajax({type:"POST",cache:!1,url:i,data:n,contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(e){e=e.getElementsByTagName("User"),0===e.length?r.call(s,"Error 'getUserInfo': nothing returned?!"):r.call(s,{ID:e[0].getAttribute("ID"),Sid:e[0].getAttribute("Sid"),Name:e[0].getAttribute("Name"),LoginName:e[0].getAttribute("LoginName"),Email:e[0].getAttribute("Email"),Notes:e[0].getAttribute("Notes"),IsSiteAdmin:e[0].getAttribute("IsSiteAdmin"),IsDomainGroup:e[0].getAttribute("IsDomainGroup"),Flags:e[0].getAttribute("Flags")})},error:function(e,t,n){var i=e.responseXML.getElementsByTagName("errorstring");r.call(s,"Error 'getUserInfo': "+i[0].firstChild.nodeValue)}}),this},whoami:function(e,t){return"function"==typeof e&&(t=e,e={}),this.people("",e,t)},addressbook:function(e,t,r){switch(arguments.length){case 1:if("object"==typeof e)return this.addressbook("",e,function(){});if("function"==typeof e)return this.addressbook("",{},e);if("string"==typeof e)return this.addressbook(e,{},function(){});e=undefined;break;case 2:if("string"==typeof e&&"function"==typeof t)return this.addressbook(e,{},t);if("object"==typeof e&&"function"==typeof t)return this.addressbook("",e,t)}if(t=t||{},t.url==undefined){if(!this.url)return this._getURL(),this._addInQueue(arguments);t.url=this.url}else this.url=t.url;t.limit=t.limit||10,t.type=t.type||"User",r=r||function(){},e=e||"";var n=""+e+""+t.limit+""+t.type+"",s=this,i=t.url+"/_vti_bin/People.asmx";return jQuery.ajax({type:"POST",cache:!1,url:i,data:n,beforeSend:function(e){e.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/SearchPrincipals")},contentType:"text/xml; charset=utf-8",dataType:"xml",success:function(e){var t=[];e=e.getElementsByTagName("PrincipalInfo");for(var n=0,i=e.length;i>n;n++){var o=e[n].childNodes;t[n]=[];for(var a=0,l=o.length;l>a;a++){var u=o[a].nodeName,c=o[a].firstChild;c&&(c=c.nodeValue),t[n].push(u),t[n][u]=c}}r.call(s,t)}}),this},reset:function(){this.data=[],this.length=0,this.listID="",this.needQueue=!1,this.listQueue=[],delete this.url},toDate:function(e,t){if(e instanceof Date)return e;if(19!=e.length&&20!=e.length)throw"toDate: '"+e+"' is invalid.";var r=e.substring(0,4),n=e.substring(5,7),s=e.substring(8,10),i=e.substring(11,13),o=e.substring(14,16),a=e.substring(17,19);return e.indexOf("Z")>-1||t?new Date(Date.UTC(r,n-1,s,i,o,a)):new Date(r,n-1,s,i,o,a)},toSPDate:function(e,t){var r=function(e){return 1==e.toString().length&&(e="0"+e), +e},n=r(e.getMonth()+1),s=r(e.getDate()),i=e.getFullYear(),o=r(e.getHours()),a=r(e.getMinutes()),l=r(e.getSeconds());return i+"-"+n+"-"+s+(t?" "+o+":"+a+":"+l:"")},toCurrency:function(e,t,r){e=Number(e),t===undefined&&(t=-1),r===undefined&&(r="$");var n="";0>e&&(n="-",e*=-1);var s=e;s=-1===t?s.toFixed(2).replace(".00",""):s.toFixed(t);for(var i=(Math.floor(e)+"").length,o=0,a=0,l=i%3;i>o;o++)0!=o&&o%3==l&&(s=s.substr(0,o+a)+","+s.substr(o+a),a++);return(""!=r?r:"")+n+s+(""!=r?"":" "+r)},getLookup:function(e){if(!e)return{id:"",value:""};var t=e.split(";#");return{id:t[0],value:t[1]}},toXSLString:function(e){if("string"!=typeof e)throw"Error 'toXLSString': '"+e+"' is not a string....";var t=function(e,t){t=t||!1;for(var r=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"),n="",s=0;s=16;)a=o%16,o=Math.floor(o/16),l+=r[a];l+=r[o];for(var u="",c=l.length-1;c>=0;c--)u+=l.charAt(c);n+="%"+u}return n},r=e.split(" "),n="";/^[0-9]/.test(r[0])&&r[0].length<5&&(n=t(e.charAt(0)),e=e.substring(1));for(var s=0;s0?fields.length:bigLimit;if(limit!==bigLimit||settings.mandatory||(settings.includeAll=!0),settings.cache&&null!==_SP_CACHE_FORMFIELDS){var allFields=_SP_CACHE_FORMFIELDS.slice(0);if(settings.includeAll)return this.length=allFields.length,this.data=allFields,this;var done=0,i,len=allFields.length,idx,fieldNames=[];for(i=0;len>i;i++)fieldNames.push(allFields[i]._name);for(i=0;limit>i;i++)idx=fieldNames.indexOf(fields[i]),idx>-1&&aReturn.push(allFields[idx]);for(i=0,len=settings.mandatory?allFields.length:0;len>i;i++)allFields[i]._isMandatory&&-1===fields.indexOf(allFields[i]._name)&&aReturn.push(allFields[i]);return this.length=aReturn.length,this.data=aReturn,this}settings.cache&&(settings.includeAll=!0);var selectorSupported="undefined"!=typeof document.querySelector,table=null;if(selectorSupported)table=document.querySelector("table.ms-formtable");else for(var a=document.getElementsByTagName("table"),i=0,len=a.length;len>i;i++)if(a[i].className.indexOf("ms-formtable")>-1){table=a[i];break}if(!table)throw"Error: unable to find the table.ms-formtable!";var closestTR=function(e){var t=e;do t=t.parentNode;while("tr"!==t.tagName.toLowerCase());return t},getText=function(e){var t,r,n=e.nodeType,s="";if(n){if(1===n||9===n||11===n){if("string"==typeof e.textContent)return e.textContent;if("string"==typeof e.innerText)return e.innerText.replace(/\r/g,"");for(e=e.firstChild;e;e=e.nextSibling)s+=getText(e)}else if(3===n||4===n)return e.nodeValue}else for(t=0;r=e[t];t++)8!==r.nodeType&&(s+=getText(r));return s};settings.includeAll&&(limit=bigLimit);for(var a=table.getElementsByTagName("nobr"),i=-1,len=a.length,done=0;len>i&&limit>done;i++){var nobr,tr,isMandatory=!1,html,txt,includeThisField=!1,search;if(settings.includeAll&&(includeThisField=!0),-1===i)(includeThisField||fields.indexOf("Content Type")>-1)&&(txt=html="Content Type",includeThisField=!0);else{if(tr=undefined,nobr=a[i],"H3"!==nobr.parentNode.tagName.toUpperCase())continue;if(html=nobr.innerHTML,txt=getText(nobr),(html.indexOf("ms-formvalidation")>-1||html.indexOf("ms-accentText")>-1)&&(html=html.slice(0,-39),"<"!=html.charAt(html.length-2)||"s"!=html.charAt(html.length-1)&&"S"!=html.charAt(html.length-1)||(html=html.slice(0,-2)),settings.mandatory&&(includeThisField=!0),txt=txt.slice(0,-2),isMandatory=!0),limit!==bigLimit)for(var k=0,lenk=limit;lenk>k;k++)if(fields[k].trim()===txt){includeThisField=!0,done++;break}}if(includeThisField){var fieldName=txt,obj={_name:fieldName,_isMandatory:isMandatory,_description:"",_elements:null,_tr:null,_type:null};if("Content Type"===fieldName){if(selectorSupported)obj._elements=document.querySelector('.ms-formbody select[title="Content Type"]');else for(var a=document.getElementsByTagName("td"),aa=0;aa-1)for(var b=document.getElementsByTagName("select"),bb=0;bb1&&(td=td[1].getElementsByTagName("span"))&&td.length>0&&(td=td[0]),0===td.length&&(obj._type="Error");var elem=[];if("Attachments"===obj._name)obj._type="attachments",elem=td.getElementsByTagName("tr");else if("Content Type"===obj._name)elem=[obj._elements];else if("Error"===obj._type)elem=tr.getElementsByTagName("td");else{for(var input=td.getElementsByTagName("input"),continueToSearch=!1,inp=0;inp-1||input[inp].className.indexOf("ms-long")>-1?(elem.push(input[inp]),obj._type||(obj._type="text"),input[inp].id.search(/DateTimeFieldDate$/)>-1?(continueToSearch=!0,obj._type="date"):input[inp].id.search(/_UrlFieldUrl$|_UrlFieldDescription$/)>-1?(obj._type="url",elem.pop(),elem.push(input[inp].previousElementSibling||input[inp].previousSibling),elem.push(input[inp])):inp=input.length):input[inp].title.indexOf("Specify your own value:")>-1&&(elem.push(input[inp]),"choices"===obj._type.slice(0,7)&&(obj._type+=" plus"));break;case"radio":if(input[inp].id.search(/_DropDownButton$/)>-1){obj._type="choices plus";do elem.push(input[inp]),inp||elem.push("");while(++inp-1?obj._type="boolean":obj._type="choices checkbox","boolean"!==obj._type&&elem.push(input[inp].nextSibling)}}if(0===elem.length||continueToSearch){var select=td.getElementsByTagName("select");for(inp=0;inp-1||select[inp].id.search(/_cbRate$|_Lookup$|_SelectResult$|_SelectCandidate$|_DateTimeFieldDateHours$|_DateTimeFieldDateMinutes$/)>-1){if(!(select[inp].id.search(/_SelectCandidate$|_SelectResult$|_DateTimeFieldDateHours$|_DateTimeFieldDateMinutes$/)>-1)){continueToSearch?"choices plus"===obj._type?elem[1]=select[inp]:elem.push(select[inp]):(elem.push(select[inp]),select[inp].id.search(/_Lookup$/)>-1?obj._type="lookup":obj._type||(obj._type="choices"));break}if(select[inp].id.indexOf("DateTimeField")>-1&&(obj._type="date time"),elem.push(select[inp]),select[inp].id.indexOf("_SelectCandidate")>-1){var buttons=td.getElementsByTagName("button");2===buttons.length&&(elem.push(buttons[0]),elem.push(buttons[1]),obj._type="lookup multiple")}}}if(0===elem.length){var other=td.getElementsByTagName("div");for(inp=0;inp-1){elem.push(other[inp]),obj._type="people";break}if(other[inp].className.indexOf("ms-rtestate-field")>-1){elem.push(other[inp]),obj._type="html multiple";break}}for(other=td.getElementsByTagName("textarea"),inp=0;inp-1||other[inp].className.indexOf("ms-input")>-1){if(elem.push(other[inp]),obj._type){if("people"===obj._type){for(other=td.getElementsByTagName("a"),inp=0;inp-1)){for(other=td.getElementsByTagName("span"),inp=other.length;inp--;)if(other[inp].className.indexOf("ms-formdescription")>-1){elem.push(other[inp]);break}break}elem=td.getElementsByTagName("iframe")}}if(td.nextSibling){var descro=td.nextSibling;3==descro.nodeType&&(obj._description=getText(descro).trim())}}switch(obj._elements=elem,obj.type()){case"attachments":obj.val=function(e){if(!e){var t=this.elem(),r=[];for(e=0;e([\s\S]*)<\/div>$/i,"$1").replace(/<\/span>]+)?><\/span>/gi,"").replace(/^

?<\/p>$/,"");t.innerHTML=e}return e!==undefined?this:null};break;case"date time":obj.val=function(e){var t=[],r=this.elem();if(e===undefined){for(var n=0;no;o++)if(e[o])for(var s=r[o].getElementsByTagName("option"),n=s.length;n--;)s[n].value===e[o]&&(s[n].selected=!0);return this};break;case"url":obj.val=function(e){e!==undefined&&("string"==typeof e?e=[e,e]:1===e.length&&(e=[e[0],e[0]]));for(var t=[],r=this.elem(),n=0,s=0;n]+)>)/gi,"").replace(/^\s+|\s+$| /g,"").replace(/
| /g,"").replace(/;$/,"").split(";");for(var r=[],n=0;n-1){if(t[i-1].checked=!0,s.push(t[i].innerHTML),"choices radio"===r.slice(0,13))return this}else if(e!==undefined&&"label"===t[i].tagName.toLowerCase())t[i-1].checked=!1;else if(e===undefined&&t[i].checked){if("choices radio plus"===r)return"Specify your own value:"===t[i+1].innerHTML?t[i+2].value:t[i+1].innerHTML;n.push("Specify your own value:"===t[i+1].innerHTML?t[i+2].value:t[i+1].innerHTML)}if(e===undefined)return n;if(e!==undefined){if("choices radio plus"===r)t[t.length-3].checked=!0,t[t.length-1].value=e;else if("choices checkbox plus"===r){for(var o=[],i=e.length;i--;)-1===s.indexOf(e[i])&&o.push(e[i]);o.length>0&&(t[t.length-3].checked=!0,t[t.length-1].value=o.join(" "))}return this}},obj.options=function(){for(var e=this.elem(),t=[],r=this.type().slice(-4),n=0;nt;t++)e.call(this.data[t]);return this},val:function(e){if("object"==typeof e&&e.identity!==undefined?(identity=e.identity,e=undefined):identity=!1,e===undefined){var t=[];return this.each(function(){identity?t[this.name()]=this.val():t.push(this.val())}),0===t.length?"":1===t.length?t[0]:t}if("object"!=typeof e)this.each(function(){this.val(e)});else{var r=0;if(this.length>1){if(e.length!==this.length)throw new Error("$SP.formfields.val: the array passed for val() must have the same size as the number of fields in formfields()");this.each(function(){this.val(e[r++])})}else this.each(function(){this.val(e)})}return this},elem:function(){var e=[],t="function"==typeof jQuery;switch(this.each(function(){var t=this.elem();t instanceof jQuery==!0&&(t=t.toArray()),e=e.concat(t)}),e.length){case 0:return t?jQuery():null;case 1:return t?jQuery(e[0]):e[0];default:return t?jQuery(e):e}},row:function(){var e=[],t="function"==typeof jQuery;switch(this.each(function(){var t=this.row();t instanceof jQuery==!0&&(t=t[0]),e.push(t)}),e.length){case 0:return t?jQuery():null;case 1:return t?jQuery(e[0]):e[0];default:return t?jQuery(e):e}},type:function(){var e=[];switch(this.each(function(){e.push(this.type())}),e.length){case 0:return"";case 1:return e[0];default:return e}},description:function(){var e=[];switch(this.each(function(){e.push(this.description())}),e.length){case 0:return"";case 1:return e[0];default:return e}},isMandatory:function(){var e=[];switch(this.each(function(){e.push(this.isMandatory())}),e.length){case 0:return!1;case 1:return e[0];default:return e}},name:function(){var e=[];switch(this.each(function(){e.push(this.name())}),e.length){case 0:return"";case 1:return e[0];default:return e}},notify:function(e,t){if(e===undefined)throw"Error 'notify': you must provide the message to show.";if("string"!=typeof e)throw"Error 'notify': you must provide a string for the message to show.";if(t=t||{},t.timeout=isNaN(t.timeout)?5:t.timeout,t.override=t.override===!0?!0:!1,t.overrideAll=t.overrideAll===!0?!0:!1,t.overrideSticky=t.overrideSticky===!1?!1:!0,t.sticky=t.sticky===!0?!0:!1,t.name=t.name||(new Date).getTime(),t.after=t.after||function(){},t.fake=t.fake===!0?!0:!1,t.ignoreQueue=t.ignoreQueue===!0?!0:!1,__SP_NOTIFY_READY===!1)return __SP_NOTIFY_QUEUE.push({message:e,options:t}),$(document).ready(function(){ExecuteOrDelayUntilScriptLoaded(function(){ExecuteOrDelayUntilScriptLoaded(function(){__SP_NOTIFY_READY=!0,$SP().notify("fake",{fake:!0})},"core.js")},"sp.js")}),this;if(t.ignoreQueue!==!0)for(;__SP_NOTIFY_QUEUE.length>0;){var r=__SP_NOTIFY_QUEUE.shift();r.options.ignoreQueue=!0,$SP().notify(r.message,r.options)}if(t.fake!==!0){if(__SP_NOTIFY.length>0&&(t.overrideAll?$SP().removeNotify({all:!0,includeSticky:t.overrideSticky}):t.override&&$SP().removeNotify(__SP_NOTIFY[__SP_NOTIFY.length-1].name)),__SP_NOTIFY.push({name:t.name,id:SP.UI.Notify.addNotification(e,!0),options:t}),!t.sticky){setTimeout(function(){$SP().removeNotify(t.name,{timeout:!0})},1e3*t.timeout)}return this}},removeNotify:function(e,t){switch(arguments.length){case 0:throw"Error 'removeNotify': you must provide 'name' or 'options'.";case 2:if("object"!=typeof t)throw"Error 'removeNotify': you must provide an object for 'options'."}if(1===arguments.length&&"object"==typeof e&&(t=e,e=undefined),t=t||{all:!1},t.timeout=t.timeout===!0?!0:!1,__SP_NOTIFY_READY===!1&&__SP_NOTIFY_QUEUE.length>0)return setTimeout(function(){$SP().removeNotify(e,t)},150),this;var r,n=this;if(t.all===!0){for(var s=[];__SP_NOTIFY.length>0;)r=__SP_NOTIFY.shift(),t.includeSticky===!1&&r.options.sticky===!0?s.push(r):(SP.UI.Notify.removeNotification(r.id),setTimeout(function(){r.options.after.call(n,r.name,!1)},150));__SP_NOTIFY=s.slice(0)}else if(e!==undefined)for(var i=0,o=__SP_NOTIFY.length;o>i;i++)if(__SP_NOTIFY[i].name==e)return r=__SP_NOTIFY.splice(i,1)[0],SP.UI.Notify.removeNotification(r.id),setTimeout(function(){r.options.after.call(n,r.name,t.timeout)},150),this;return this},registerPlugin:function(e,t){var r=$("html"),n=r.data("sp-plugins")||[];if("undefined"!=typeof n[e])throw"Error 'registerPlugin': '"+e+"' is already registered.";return n[e]=t,r.data("sp-plugins",n),!0},plugin:function(e,t){var r=$("html").data("sp-plugins")||[];if(t=t||{},"function"!=typeof r[e])throw"Error $SP().plugin: the plugin '"+e+"' is not registered.";return r[e].call(this,t),this}};var myElem=function(){var e=function(e){return new t(e)},t=function(e){return this.mynode=e,this.singleList=!0,this};return e.fn=t.prototype={getAttribute:function(e){return this.mynode.getAttribute("ows_"+e.replace(/ /g,""))},getAttributes:function(){return this.mynode.attributes}},e}(),extendMyObject=function(e){this.attributes=e};return extendMyObject.prototype.getAttribute=function(e){return this.attributes[e]},extendMyObject.prototype.getAttributes=function(){return this.attributes},SharepointPlus.prototype.noConflict=function(){window._$SP=window._SharepointPlus=window.$SP},window.$SP=window.SharepointPlus=SharepointPlus}(this,document); \ No newline at end of file