").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
+
+ /*!
+ * jQuery Cookie Plugin v1.3.1
+ * https://github.com/carhartl/jquery-cookie
+ *
+ * Copyright 2013 Klaus Hartl
+ * Released under the MIT license
+ */
+(function ($, document, undefined) {
+
+ var pluses = /\+/g;
+
+ function raw(s) {
+ return s;
+ }
+
+ function decoded(s) {
+ return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
+ }
+
+ function unRfc2068(value) {
+ if (value.indexOf('"') === 0) {
+ // This is a quoted cookie as according to RFC2068, unescape
+ value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
+ }
+ return value;
+ }
+
+ function fromJSON(value) {
+ return config.json ? JSON.parse(value) : value;
+ }
+
+ var config = $.cookie = function (key, value, options) {
+
+ // write
+ if (value !== undefined) {
+ options = $.extend({}, config.defaults, options);
+
+ if (value === null) {
+ options.expires = -1;
+ }
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setDate(t.getDate() + days);
+ }
+
+ value = config.json ? JSON.stringify(value) : String(value);
+
+ return (document.cookie = [
+ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
+ }
+
+ // read
+ var decode = config.raw ? raw : decoded;
+ var cookies = document.cookie.split('; ');
+ var result = key ? null : {};
+ for (var i = 0, l = cookies.length; i < l; i++) {
+ var parts = cookies[i].split('=');
+ var name = decode(parts.shift());
+ var cookie = decode(parts.join('='));
+
+ if (key && key === name) {
+ result = fromJSON(cookie);
+ break;
+ }
+
+ if (!key) {
+ result[name] = fromJSON(cookie);
+ }
+ }
+
+ return result;
+ };
+
+ config.defaults = {};
+
+ $.removeCookie = function (key, options) {
+ if ($.cookie(key) !== null) {
+ $.cookie(key, null, options);
+ return true;
+ }
+ return false;
+ };
+
+})(jQuery, document);
+
+ /*!
+ * sprintf and vsprintf for jQuery
+ * somewhat based on http://jan.moesen.nu/code/javascript/sprintf-and-printf-in-javascript/
+ * Copyright (c) 2008 Sabin Iacob (m0n5t3r)
+ * @license http://www.gnu.org/licenses/gpl.html
+ * @project jquery.sprintf
+ */
+(function(d){var a={b:function(e){return parseInt(e,10).toString(2)},c:function(e){return String.fromCharCode(parseInt(e,10))},d:function(e){return parseInt(e,10)},u:function(e){return Math.abs(e)},f:function(f,e){e=parseInt(e,10);f=parseFloat(f);if(isNaN(e&&f)){return NaN}return e&&f.toFixed(e)||f},o:function(e){return parseInt(e,10).toString(8)},s:function(e){return e},x:function(e){return(""+parseInt(e,10).toString(16)).toLowerCase()},X:function(e){return(""+parseInt(e,10).toString(16)).toUpperCase()}};var c=/%(?:(\d+)?(?:\.(\d+))?|\(([^)]+)\))([%bcdufosxX])/g;var b=function(f){if(f.length==1&&typeof f[0]=="object"){f=f[0];return function(i,h,k,j,g,m,l){return a[g](f[j])}}else{var e=0;return function(i,h,k,j,g,m,l){if(g=="%"){return"%"}return a[g](f[e++],k)}}};d.extend({sprintf:function(f){var e=Array.apply(null,arguments).slice(1);return f.replace(c,b(e))},vsprintf:function(f,e){return f.replace(c,b(e))}})})(jQuery);
+
+ /*
+ * jQuery Autocomplete plugin 1.2.3
+ *
+ * Copyright (c) 2009 Jörn Zaefferer
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * With small modifications by Alfonso Gómez-Arzola.
+ * See changelog for details.
+ *
+ */
+
+;(function($) {
+
+$.fn.extend({
+ autocomplete: function(urlOrData, options) {
+ var isUrl = typeof urlOrData == "string";
+ options = $.extend({}, $.Autocompleter.defaults, {
+ url: isUrl ? urlOrData : null,
+ data: isUrl ? null : urlOrData,
+ delay: isUrl ? $.Autocompleter.defaults.delay : 10,
+ max: options && !options.scroll ? 10 : 150,
+ noRecord: "No Records."
+ }, options);
+
+ // if highlight is set to false, replace it with a do-nothing function
+ options.highlight = options.highlight || function(value) { return value; };
+
+ // if the formatMatch option is not specified, then use formatItem for backwards compatibility
+ options.formatMatch = options.formatMatch || options.formatItem;
+
+ return this.each(function() {
+ new $.Autocompleter(this, options);
+ });
+ },
+ result: function(handler) {
+ return this.bind("result", handler);
+ },
+ search: function(handler) {
+ return this.trigger("search", [handler]);
+ },
+ flushCache: function() {
+ return this.trigger("flushCache");
+ },
+ setOptions: function(options){
+ return this.trigger("setOptions", [options]);
+ },
+ unautocomplete: function() {
+ return this.trigger("unautocomplete");
+ }
+});
+
+$.Autocompleter = function(input, options) {
+
+ var KEY = {
+ UP: 38,
+ DOWN: 40,
+ DEL: 46,
+ TAB: 9,
+ RETURN: 13,
+ ESC: 27,
+ COMMA: 188,
+ PAGEUP: 33,
+ PAGEDOWN: 34,
+ BACKSPACE: 8
+ };
+
+ var globalFailure = null;
+ if(options.failure != null && typeof options.failure == "function") {
+ globalFailure = options.failure;
+ }
+
+ // Create $ object for input element
+ var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
+
+ var timeout;
+ var previousValue = "";
+ var cache = $.Autocompleter.Cache(options);
+ var hasFocus = 0;
+ var lastKeyPressCode;
+ var config = {
+ mouseDownOnSelect: false
+ };
+ var select = $.Autocompleter.Select(options, input, selectCurrent, config);
+
+ var blockSubmit;
+
+ // prevent form submit in opera when selecting with return key
+ navigator.userAgent.indexOf("Opera") != -1 && $(input.form).bind("submit.autocomplete", function() {
+ if (blockSubmit) {
+ blockSubmit = false;
+ return false;
+ }
+ });
+
+ // older versions of opera don't trigger keydown multiple times while pressed, others don't work with keypress at all
+ $input.bind((navigator.userAgent.indexOf("Opera") != -1 && !'KeyboardEvent' in window ? "keypress" : "keydown") + ".autocomplete", function(event) {
+ // a keypress means the input has focus
+ // avoids issue where input had focus before the autocomplete was applied
+ hasFocus = 1;
+ // track last key pressed
+ lastKeyPressCode = event.keyCode;
+ switch(event.keyCode) {
+
+ case KEY.UP:
+ if ( select.visible() ) {
+ event.preventDefault();
+ select.prev();
+ } else {
+ onChange(0, true);
+ }
+ break;
+
+ case KEY.DOWN:
+ if ( select.visible() ) {
+ event.preventDefault();
+ select.next();
+ } else {
+ onChange(0, true);
+ }
+ break;
+
+ case KEY.PAGEUP:
+ if ( select.visible() ) {
+ event.preventDefault();
+ select.pageUp();
+ } else {
+ onChange(0, true);
+ }
+ break;
+
+ case KEY.PAGEDOWN:
+ if ( select.visible() ) {
+ event.preventDefault();
+ select.pageDown();
+ } else {
+ onChange(0, true);
+ }
+ break;
+
+ // matches also semicolon
+ case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
+ case KEY.TAB:
+ case KEY.RETURN:
+ if( selectCurrent() ) {
+ // stop default to prevent a form submit, Opera needs special handling
+ event.preventDefault();
+ blockSubmit = true;
+ return false;
+ }
+ break;
+
+ case KEY.ESC:
+ select.hide();
+ break;
+
+ default:
+ clearTimeout(timeout);
+ timeout = setTimeout(onChange, options.delay);
+ break;
+ }
+ }).focus(function(){
+ // track whether the field has focus, we shouldn't process any
+ // results if the field no longer has focus
+ hasFocus++;
+ }).blur(function() {
+ hasFocus = 0;
+ if (!config.mouseDownOnSelect) {
+ hideResults();
+ }
+ }).click(function() {
+ // show select when clicking in a focused field
+ // but if clickFire is true, don't require field
+ // to be focused to begin with; just show select
+ if( options.clickFire ) {
+ if ( !select.visible() ) {
+ onChange(0, true);
+ }
+ } else {
+ if ( hasFocus++ > 1 && !select.visible() ) {
+ onChange(0, true);
+ }
+ }
+ }).bind("search", function() {
+ var fn = (arguments.length > 1) ? arguments[1] : null;
+ function findValueCallback(q, data) {
+ var result;
+ if( data && data.length ) {
+ for (var i=0; i < data.length; i++) {
+ if( data[i].result.toLowerCase() == q.toLowerCase() ) {
+ result = data[i];
+ break;
+ }
+ }
+ }
+ if( typeof fn == "function" ) fn(result);
+ else $input.trigger("result", result && [result.data, result.value]);
+ }
+ $.each(trimWords($input.val()), function(i, value) {
+ request(value, findValueCallback, findValueCallback);
+ });
+ }).bind("flushCache", function() {
+ cache.flush();
+ }).bind("setOptions", function() {
+ $.extend(true, options, arguments[1]);
+ // if we've updated the data, repopulate
+ if ( "data" in arguments[1] )
+ cache.populate();
+ }).bind("unautocomplete", function() {
+ select.unbind();
+ $input.unbind();
+ $(input.form).unbind(".autocomplete");
+ });
+
+
+ function selectCurrent() {
+ var selected = select.selected();
+ if( !selected )
+ return false;
+
+ var v = selected.result;
+ previousValue = v;
+
+ if ( options.multiple ) {
+ var words = trimWords($input.val());
+ if ( words.length > 1 ) {
+ var seperator = options.multipleSeparator.length;
+ var cursorAt = $(input).selection().start;
+ var wordAt, progress = 0;
+ $.each(words, function(i, word) {
+ progress += word.length;
+ if (cursorAt <= progress) {
+ wordAt = i;
+ return false;
+ }
+ progress += seperator;
+ });
+ words[wordAt] = v;
+ //$.Autocompleter.Selection(input, progress + seperator, progress + seperator);
+ v = words.join( options.multipleSeparator );
+ }
+ v += options.multipleSeparator;
+ }
+
+ $input.val(v);
+ hideResultsNow();
+ $input.trigger("result", [selected.data, selected.value]);
+ return true;
+ }
+
+ function onChange(crap, skipPrevCheck) {
+ if( lastKeyPressCode == KEY.DEL ) {
+ select.hide();
+ return;
+ }
+
+ var currentValue = $input.val();
+
+ if ( !skipPrevCheck && currentValue == previousValue )
+ return;
+
+ previousValue = currentValue;
+
+ currentValue = lastWord(currentValue);
+ if ( currentValue.length >= options.minChars) {
+ $input.addClass(options.loadingClass);
+ if (!options.matchCase)
+ currentValue = currentValue.toLowerCase();
+ request(currentValue, receiveData, hideResultsNow);
+ } else {
+ stopLoading();
+ select.hide();
+ }
+ };
+
+ function trimWords(value) {
+ if (!value)
+ return [""];
+ if (!options.multiple)
+ return [$.trim(value)];
+ return $.map(value.split(options.multipleSeparator), function(word) {
+ return $.trim(value).length ? $.trim(word) : null;
+ });
+ }
+
+ function lastWord(value) {
+ if ( !options.multiple )
+ return value;
+ var words = trimWords(value);
+ if (words.length == 1)
+ return words[0];
+ var cursorAt = $(input).selection().start;
+ if (cursorAt == value.length) {
+ words = trimWords(value)
+ } else {
+ words = trimWords(value.replace(value.substring(cursorAt), ""));
+ }
+ return words[words.length - 1];
+ }
+
+ // fills in the input box w/the first match (assumed to be the best match)
+ // q: the term entered
+ // sValue: the first matching result
+ function autoFill(q, sValue){
+ // autofill in the complete box w/the first match as long as the user hasn't entered in more data
+ // if the last user key pressed was backspace, don't autofill
+ if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
+ // fill in the value (keep the case the user has typed)
+ $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
+ // select the portion of the value not typed by the user (so the next character will erase)
+ $(input).selection(previousValue.length, previousValue.length + sValue.length);
+ }
+ };
+
+ function hideResults() {
+ clearTimeout(timeout);
+ timeout = setTimeout(hideResultsNow, 200);
+ };
+
+ function hideResultsNow() {
+ var wasVisible = select.visible();
+ select.hide();
+ clearTimeout(timeout);
+ stopLoading();
+ if (options.mustMatch) {
+ // call search and run callback
+ $input.search(
+ function (result){
+ // if no value found, clear the input box
+ if( !result ) {
+ if (options.multiple) {
+ var words = trimWords($input.val()).slice(0, -1);
+ $input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
+ }
+ else {
+ $input.val( "" );
+ $input.trigger("result", null);
+ }
+ }
+ }
+ );
+ }
+ };
+
+ function receiveData(q, data) {
+ if ( data && data.length && hasFocus ) {
+ stopLoading();
+ select.display(data, q);
+ autoFill(q, data[0].value);
+ select.show();
+ } else {
+ hideResultsNow();
+ }
+ };
+
+ function request(term, success, failure) {
+ if (!options.matchCase)
+ term = term.toLowerCase();
+ var data = cache.load(term);
+ // recieve the cached data
+ if (data) {
+ if(data.length) {
+ success(term, data);
+ }
+ else{
+ var parsed = options.parse && options.parse(options.noRecord) || parse(options.noRecord);
+ success(term,parsed);
+ }
+ // if an AJAX url has been supplied, try loading the data now
+ } else if( (typeof options.url == "string") && (options.url.length > 0) ){
+
+ var extraParams = {
+ timestamp: +new Date()
+ };
+ $.each(options.extraParams, function(key, param) {
+ extraParams[key] = typeof param == "function" ? param() : param;
+ });
+
+ $.ajax({
+ // try to leverage ajaxQueue plugin to abort previous requests
+ mode: "abort",
+ // limit abortion to this input
+ port: "autocomplete" + input.name,
+ dataType: options.dataType,
+ url: options.url,
+ data: $.extend({
+ q: lastWord(term),
+ limit: options.max
+ }, extraParams),
+ success: function(data) {
+ var parsed = options.parse && options.parse(data) || parse(data);
+ cache.add(term, parsed);
+ success(term, parsed);
+ }
+ });
+ } else {
+ // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
+ select.emptyList();
+ if(globalFailure != null) {
+ globalFailure();
+ }
+ else {
+ failure(term);
+ }
+ }
+ };
+
+ function parse(data) {
+ var parsed = [];
+ var rows = data.split("\n");
+ for (var i=0; i < rows.length; i++) {
+ var row = $.trim(rows[i]);
+ if (row) {
+ row = row.split("|");
+ parsed[parsed.length] = {
+ data: row,
+ value: row[0],
+ result: options.formatResult && options.formatResult(row, row[0]) || row[0]
+ };
+ }
+ }
+ return parsed;
+ };
+
+ function stopLoading() {
+ $input.removeClass(options.loadingClass);
+ };
+
+};
+
+$.Autocompleter.defaults = {
+ inputClass: "ac_input",
+ resultsClass: "ac_results",
+ loadingClass: "ac_loading",
+ minChars: 1,
+ delay: 400,
+ matchCase: false,
+ matchSubset: true,
+ matchContains: false,
+ cacheLength: 100,
+ max: 1000,
+ mustMatch: false,
+ extraParams: {},
+ selectFirst: true,
+ formatItem: function(row) { return row[0]; },
+ formatMatch: null,
+ autoFill: false,
+ width: 0,
+ multiple: false,
+ multipleSeparator: " ",
+ inputFocus: true,
+ clickFire: false,
+ highlight: function(value, term) {
+ return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "$1 ");
+ },
+ scroll: true,
+ scrollHeight: 180,
+ scrollJumpPosition: true
+};
+
+$.Autocompleter.Cache = function(options) {
+
+ var data = {};
+ var length = 0;
+
+ function matchSubset(s, sub) {
+ return (new RegExp(sub.toUpperCase().replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1").replace(/[A-Z0-9]/g, function(m, offset) {
+ return offset === 0 ? '(?:' + m + '|^' + m.toLowerCase() + ')' : '(?:.*' + m + '|' + m.toLowerCase() + ')';
+ }))).test(s); // find by initials
+ };
+
+ function add(q, value) {
+ if (length > options.cacheLength){
+ flush();
+ }
+ if (!data[q]){
+ length++;
+ }
+ data[q] = value;
+ }
+
+ function populate(){
+ if( !options.data ) return false;
+ // track the matches
+ var stMatchSets = {},
+ nullData = 0;
+
+ // no url was specified, we need to adjust the cache length to make sure it fits the local data store
+ if( !options.url ) options.cacheLength = 1;
+
+ // track all options for minChars = 0
+ stMatchSets[""] = [];
+
+ // loop through the array and create a lookup structure
+ for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
+ var rawValue = options.data[i];
+ // if rawValue is a string, make an array otherwise just reference the array
+ rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
+
+ var value = options.formatMatch(rawValue, i+1, options.data.length);
+ if ( typeof(value) === 'undefined' || value === false )
+ continue;
+
+ var firstChar = value.charAt(0).toLowerCase();
+ // if no lookup array for this character exists, look it up now
+ if( !stMatchSets[firstChar] )
+ stMatchSets[firstChar] = [];
+
+ // if the match is a string
+ var row = {
+ value: value,
+ data: rawValue,
+ result: options.formatResult && options.formatResult(rawValue) || value
+ };
+
+ // push the current match into the set list
+ stMatchSets[firstChar].push(row);
+
+ // keep track of minChars zero items
+ if ( nullData++ < options.max ) {
+ stMatchSets[""].push(row);
+ }
+ };
+
+ // add the data items to the cache
+ $.each(stMatchSets, function(i, value) {
+ // increase the cache size
+ options.cacheLength++;
+ // add to the cache
+ add(i, value);
+ });
+ }
+
+ // populate any existing data
+ setTimeout(populate, 25);
+
+ function flush(){
+ data = {};
+ length = 0;
+ }
+
+ return {
+ flush: flush,
+ add: add,
+ populate: populate,
+ load: function(q) {
+ if (!options.cacheLength || !length)
+ return null;
+ /*
+ * if dealing w/local data and matchContains than we must make sure
+ * to loop through all the data collections looking for matches
+ */
+ if( !options.url && options.matchContains ){
+ // track all matches
+ var csub = [];
+ // loop through all the data grids for matches
+ for( var k in data ){
+ // don't search through the stMatchSets[""] (minChars: 0) cache
+ // this prevents duplicates
+ if( k.length > 0 ){
+ var c = data[k];
+ $.each(c, function(i, x) {
+ // if we've got a match, add it to the array
+ if (matchSubset(x.value, q)) {
+ csub.push(x);
+ }
+ });
+ }
+ }
+ return csub;
+ } else
+ // if the exact item exists, use it
+ if (data[q]){
+ return data[q];
+ } else
+ if (options.matchSubset) {
+ for (var i = q.length - 1; i >= options.minChars; i--) {
+ var c = data[q.substr(0, i)];
+ if (c) {
+ var csub = [];
+ $.each(c, function(i, x) {
+ if (matchSubset(x.value, q)) {
+ csub[csub.length] = x;
+ }
+ });
+ return csub;
+ }
+ }
+ }
+ return null;
+ }
+ };
+};
+
+$.Autocompleter.Select = function (options, input, select, config) {
+ var CLASSES = {
+ ACTIVE: "ac_over"
+ };
+
+ var listItems,
+ active = -1,
+ data,
+ term = "",
+ needsInit = true,
+ element,
+ list;
+
+ // Create results
+ function init() {
+ if (!needsInit)
+ return;
+ element = $("
")
+ .hide()
+ .addClass(options.resultsClass)
+ .css("position", "absolute")
+ .appendTo(document.body)
+ .hover(function(event) {
+ // Browsers except FF do not fire mouseup event on scrollbars, resulting in mouseDownOnSelect remaining true, and results list not always hiding.
+ if($(this).is(":visible")) {
+ input.focus();
+ }
+ config.mouseDownOnSelect = false;
+ });
+
+ list = $("").appendTo(element).mouseover( function(event) {
+ if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
+ active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
+ $(target(event)).addClass(CLASSES.ACTIVE);
+ }
+ }).click(function(event) {
+ $(target(event)).addClass(CLASSES.ACTIVE);
+ select();
+ if( options.inputFocus )
+ input.focus();
+ return false;
+ }).mousedown(function() {
+ config.mouseDownOnSelect = true;
+ }).mouseup(function() {
+ config.mouseDownOnSelect = false;
+ });
+
+ if( options.width > 0 )
+ element.css("width", options.width);
+
+ needsInit = false;
+ }
+
+ function target(event) {
+ var element = event.target;
+ while(element && element.tagName != "LI")
+ element = element.parentNode;
+ // more fun with IE, sometimes event.target is empty, just ignore it then
+ if(!element)
+ return [];
+ return element;
+ }
+
+ function moveSelect(step) {
+ listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
+ movePosition(step);
+ var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
+ if(options.scroll) {
+ var offset = 0;
+ listItems.slice(0, active).each(function() {
+ offset += this.offsetHeight;
+ });
+ if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
+ list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
+ } else if(offset < list.scrollTop()) {
+ list.scrollTop(offset);
+ }
+ }
+ };
+
+ function movePosition(step) {
+ if (options.scrollJumpPosition || (!options.scrollJumpPosition && !((step < 0 && active == 0) || (step > 0 && active == listItems.size() - 1)) )) {
+ active += step;
+ if (active < 0) {
+ active = listItems.size() - 1;
+ } else if (active >= listItems.size()) {
+ active = 0;
+ }
+ }
+ }
+
+
+ function limitNumberOfItems(available) {
+ return options.max && options.max < available
+ ? options.max
+ : available;
+ }
+
+ function fillList() {
+ list.empty();
+ var max = limitNumberOfItems(data.length);
+ for (var i=0; i < max; i++) {
+ if (!data[i])
+ continue;
+ var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
+ if ( formatted === false )
+ continue;
+ var li = $(" ").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
+ $.data(li, "ac_data", data[i]);
+ }
+ listItems = list.find("li");
+ if ( options.selectFirst ) {
+ listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
+ active = 0;
+ }
+ // apply bgiframe if available
+ if ( $.fn.bgiframe )
+ list.bgiframe();
+ }
+
+ return {
+ display: function(d, q) {
+ init();
+ data = d;
+ term = q;
+ fillList();
+ },
+ next: function() {
+ moveSelect(1);
+ },
+ prev: function() {
+ moveSelect(-1);
+ },
+ pageUp: function() {
+ if (active != 0 && active - 8 < 0) {
+ moveSelect( -active );
+ } else {
+ moveSelect(-8);
+ }
+ },
+ pageDown: function() {
+ if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
+ moveSelect( listItems.size() - 1 - active );
+ } else {
+ moveSelect(8);
+ }
+ },
+ hide: function() {
+ element && element.hide();
+ listItems && listItems.removeClass(CLASSES.ACTIVE);
+ active = -1;
+ },
+ visible : function() {
+ return element && element.is(":visible");
+ },
+ current: function() {
+ return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
+ },
+ show: function() {
+ var offset = $(input).offset();
+ element.css({
+ width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
+ top: offset.top + input.offsetHeight,
+ left: offset.left
+ }).show();
+ if(options.scroll) {
+ list.scrollTop(0);
+ list.css({
+ maxHeight: options.scrollHeight,
+ overflow: 'auto'
+ });
+
+ if(navigator.userAgent.indexOf("MSIE") != -1 && typeof document.body.style.maxHeight === "undefined") {
+ var listHeight = 0;
+ listItems.each(function() {
+ listHeight += this.offsetHeight;
+ });
+ var scrollbarsVisible = listHeight > options.scrollHeight;
+ list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
+ if (!scrollbarsVisible) {
+ // IE doesn't recalculate width when scrollbar disappears
+ listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
+ }
+ }
+
+ }
+ },
+ selected: function() {
+ var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
+ return selected && selected.length && $.data(selected[0], "ac_data");
+ },
+ emptyList: function (){
+ list && list.empty();
+ },
+ unbind: function() {
+ element && element.remove();
+ }
+ };
+};
+
+$.fn.selection = function(start, end) {
+ if (start !== undefined) {
+ return this.each(function() {
+ if( this.createTextRange ){
+ var selRange = this.createTextRange();
+ if (end === undefined || start == end) {
+ selRange.move("character", start);
+ selRange.select();
+ } else {
+ selRange.collapse(true);
+ selRange.moveStart("character", start);
+ selRange.moveEnd("character", end);
+ selRange.select();
+ }
+ } else if( this.setSelectionRange ){
+ this.setSelectionRange(start, end);
+ } else if( this.selectionStart ){
+ this.selectionStart = start;
+ this.selectionEnd = end;
+ }
+ });
+ }
+ var field = this[0];
+ if ( field.createTextRange ) {
+ var range = document.selection.createRange(),
+ orig = field.value,
+ teststring = "<->",
+ textLength = range.text.length;
+ range.text = teststring;
+ var caretAt = field.value.indexOf(teststring);
+ field.value = orig;
+ this.selection(caretAt, caretAt + textLength);
+ return {
+ start: caretAt,
+ end: caretAt + textLength
+ }
+ } else if( field.selectionStart !== undefined ){
+ return {
+ start: field.selectionStart,
+ end: field.selectionEnd
+ }
+ }
+};
+
+})(jQuery);
+
+ /**
+ * jQuery.fn.sortElements
+ * --------------
+ * @author James Padolsey (http://james.padolsey.com)
+ * @version 0.11
+ * @updated 18-MAR-2010
+ * --------------
+ * @param Function comparator:
+ * Exactly the same behaviour as [1,2,3].sort(comparator)
+ *
+ * @param Function getSortable
+ * A function that should return the element that is
+ * to be sorted. The comparator will run on the
+ * current collection, but you may want the actual
+ * resulting sort to occur on a parent or another
+ * associated element.
+ *
+ * E.g. $('td').sortElements(comparator, function(){
+ * return this.parentNode;
+ * })
+ *
+ * The 's parent ( ) will be sorted instead
+ * of the itself.
+ */
+jQuery.fn.sortElements = (function(){
+
+ var sort = [].sort;
+
+ return function(comparator, getSortable) {
+
+ getSortable = getSortable || function(){return this;};
+
+ var placements = this.map(function(){
+
+ var sortElement = getSortable.call(this),
+ parentNode = sortElement.parentNode,
+
+ // Since the element itself will change position, we have
+ // to have some way of storing it's original position in
+ // the DOM. The easiest way is to have a 'flag' node:
+ nextSibling = parentNode.insertBefore(
+ document.createTextNode(''),
+ sortElement.nextSibling
+ );
+
+ return function() {
+
+ if (parentNode === this) {
+ throw new Error(
+ "You can't sort elements if any one is a descendant of another."
+ );
+ }
+
+ // Insert before flag:
+ parentNode.insertBefore(this, nextSibling);
+ // Remove flag:
+ parentNode.removeChild(nextSibling);
+
+ };
+
+ });
+
+ return sort.call(this, comparator).each(function(i){
+ placements[i].call(getSortable.call(this));
+ });
+
+ };
+
+})();
+ $(window).load(function() {
+ var $document = $(document);
+ var $left = $('#left');
+ var $right = $('#right');
+ var $rightInner = $('#rightInner');
+ var $splitter = $('#splitter');
+ var $groups = $('#groups');
+ var $content = $('#content');
+
+ // Menu
+
+ // Hide deep packages and namespaces
+ $('ul span', $groups).click(function(event) {
+ event.preventDefault();
+ event.stopPropagation();
+ $(this)
+ .toggleClass('collapsed')
+ .parent()
+ .next('ul')
+ .toggleClass('collapsed');
+ }).click();
+
+ $active = $('ul li.active', $groups);
+ if ($active.length > 0) {
+ // Open active
+ $('> a > span', $active).click();
+ } else {
+ $main = $('> ul > li.main', $groups);
+ if ($main.length > 0) {
+ // Open first level of the main project
+ $('> a > span', $main).click();
+ } else {
+ // Open first level of all
+ $('> ul > li > a > span', $groups).click();
+ }
+ }
+
+ // Content
+
+ // Search autocompletion
+ var autocompleteFound = false;
+ var autocompleteFiles = {'c': 'class', 'co': 'constant', 'f': 'function', 'm': 'class', 'mm': 'class', 'p': 'class', 'mp': 'class', 'cc': 'class'};
+ var $search = $('#search input[name=q]');
+ $search
+ .autocomplete(ApiGen.elements, {
+ matchContains: true,
+ scrollHeight: 200,
+ max: 20,
+ noRecord: '',
+ highlight: function(value, term) {
+ var term = term.toUpperCase().replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1").replace(/[A-Z0-9]/g, function(m, offset) {
+ return offset === 0 ? '(?:' + m + '|^' + m.toLowerCase() + ')' : '(?:(?:[^<>]|<[^<>]*>)*' + m + '|' + m.toLowerCase() + ')';
+ });
+ return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)"), "$1 ");
+ },
+ formatItem: function(data) {
+ return data.length > 1 ? data[1].replace(/^(.+\\)(.+)$/, '$1 $2 ') : data[0];
+ },
+ formatMatch: function(data) {
+ return data[1];
+ },
+ formatResult: function(data) {
+ return data[1];
+ },
+ show: function($list) {
+ var $items = $('li span', $list);
+ var maxWidth = Math.max.apply(null, $items.map(function() {
+ return $(this).width();
+ }));
+ // 10px padding
+ $list
+ .width(Math.max(maxWidth + 10, $search.innerWidth()))
+ .css('left', $search.offset().left + $search.outerWidth() - $list.outerWidth());
+ }
+ }).result(function(event, data) {
+ autocompleteFound = true;
+ var location = window.location.href.split('/');
+ location.pop();
+ var parts = data[1].split(/::|$/);
+ var file = $.sprintf(ApiGen.config.templates[autocompleteFiles[data[0]]].filename, parts[0].replace(/\(\)/, '').replace(/[^\w]/g, '.'));
+ if (parts[1]) {
+ file += '#' + ('mm' === data[0] || 'mp' === data[0] ? 'm' : '') + parts[1].replace(/([\w]+)\(\)/, '_$1');
+ }
+ location.push(file);
+ window.location = location.join('/');
+
+ // Workaround for Opera bug
+ $(this).closest('form').attr('action', location.join('/'));
+ }).closest('form')
+ .submit(function() {
+ var query = $search.val();
+ if ('' === query) {
+ return false;
+ }
+ return !autocompleteFound && '' !== $('#search input[name=cx]').val();
+ });
+
+ // Save natural order
+ $('table.summary tr[data-order]', $content).each(function(index) {
+ do {
+ index = '0' + index;
+ } while (index.length < 3);
+ $(this).attr('data-order-natural', index);
+ });
+
+ // Switch between natural and alphabetical order
+ var $caption = $('table.summary', $content)
+ .filter(':has(tr[data-order])')
+ .find('caption');
+ $caption
+ .click(function() {
+ var $this = $(this);
+ var order = $this.data('order') || 'natural';
+ order = 'natural' === order ? 'alphabetical' : 'natural';
+ $this.data('order', order);
+ $.cookie('order', order, {expires: 365});
+ var attr = 'alphabetical' === order ? 'data-order' : 'data-order-natural';
+ $this
+ .closest('table')
+ .find('tr').sortElements(function(a, b) {
+ return $(a).attr(attr) > $(b).attr(attr) ? 1 : -1;
+ });
+ return false;
+ })
+ .addClass('switchable')
+ .attr('title', 'Switch between natural and alphabetical order');
+ if ((null === $.cookie('order') && 'alphabetical' === ApiGen.config.options.elementsOrder) || 'alphabetical' === $.cookie('order')) {
+ $caption.click();
+ }
+
+ // Open details
+ if (ApiGen.config.options.elementDetailsCollapsed) {
+ $('tr', $content).filter(':has(.detailed)')
+ .click(function() {
+ var $this = $(this);
+ $('.short', $this).hide();
+ $('.detailed', $this).show();
+ });
+ }
+
+ // Splitter
+ var splitterWidth = $splitter.width();
+ var splitterPosition = $.cookie('splitter') ? parseInt($.cookie('splitter')) : null;
+ var splitterPositionBackup = $.cookie('splitterBackup') ? parseInt($.cookie('splitterBackup')) : null;
+ function setSplitterPosition(position)
+ {
+ splitterPosition = position;
+
+ $left.width(position);
+ $right.css('margin-left', position + splitterWidth);
+ $splitter.css('left', position);
+ }
+ function setContentWidth()
+ {
+ var width = $rightInner.width();
+ $rightInner
+ .toggleClass('medium', width <= 960)
+ .toggleClass('small', width <= 650);
+ }
+ $splitter.mousedown(function() {
+ $splitter.addClass('active');
+
+ $document.mousemove(function(event) {
+ if (event.pageX >= 230 && $document.width() - event.pageX >= 600 + splitterWidth) {
+ setSplitterPosition(event.pageX);
+ setContentWidth();
+ }
+ });
+
+ $()
+ .add($splitter)
+ .add($document)
+ .mouseup(function() {
+ $splitter
+ .removeClass('active')
+ .unbind('mouseup');
+ $document
+ .unbind('mousemove')
+ .unbind('mouseup');
+
+ $.cookie('splitter', splitterPosition, {expires: 365});
+ });
+
+ return false;
+ });
+ $splitter.dblclick(function() {
+ if (splitterPosition) {
+ splitterPositionBackup = $left.width();
+ setSplitterPosition(0);
+ } else {
+ setSplitterPosition(splitterPositionBackup);
+ splitterPositionBackup = null;
+ }
+
+ setContentWidth();
+
+ $.cookie('splitter', splitterPosition, {expires: 365});
+ $.cookie('splitterBackup', splitterPositionBackup, {expires: 365});
+ });
+ if (null !== splitterPosition) {
+ setSplitterPosition(splitterPosition);
+ }
+ setContentWidth();
+ $(window).resize(setContentWidth);
+
+ // Select selected lines
+ var matches = window.location.hash.substr(1).match(/^\d+(?:-\d+)?(?:,\d+(?:-\d+)?)*$/);
+ if (null !== matches) {
+ var lists = matches[0].split(',');
+ for (var i = 0; i < lists.length; i++) {
+ var lines = lists[i].split('-');
+ lines[0] = parseInt(lines[0]);
+ lines[1] = parseInt(lines[1] || lines[0]);
+ for (var j = lines[0]; j <= lines[1]; j++) {
+ $('#' + j).addClass('selected');
+ }
+ }
+
+ var $firstLine = $('#' + parseInt(matches[0]));
+ if ($firstLine.length > 0) {
+ $document.scrollTop($firstLine.offset().top);
+ }
+ }
+
+ // Save selected lines
+ var lastLine;
+ $('.l a').click(function(event) {
+ event.preventDefault();
+
+ var $selectedLine = $(this).parent();
+ var selectedLine = parseInt($selectedLine.attr('id'));
+
+ if (event.shiftKey) {
+ if (lastLine) {
+ for (var i = Math.min(selectedLine, lastLine); i <= Math.max(selectedLine, lastLine); i++) {
+ $('#' + i).addClass('selected');
+ }
+ } else {
+ $selectedLine.addClass('selected');
+ }
+ } else if (event.ctrlKey) {
+ $selectedLine.toggleClass('selected');
+ } else {
+ var $selected = $('.l.selected')
+ .not($selectedLine)
+ .removeClass('selected');
+ if ($selected.length > 0) {
+ $selectedLine.addClass('selected');
+ } else {
+ $selectedLine.toggleClass('selected');
+ }
+ }
+
+ lastLine = $selectedLine.hasClass('selected') ? selectedLine : null;
+
+ // Update hash
+ var lines = $('.l.selected')
+ .map(function() {
+ return parseInt($(this).attr('id'));
+ })
+ .get()
+ .sort(function(a, b) {
+ return a - b;
+ });
+
+ var hash = [];
+ var list = [];
+ for (var j = 0; j < lines.length; j++) {
+ if (0 === j && j + 1 === lines.length) {
+ hash.push(lines[j]);
+ } else if (0 === j) {
+ list[0] = lines[j];
+ } else if (lines[j - 1] + 1 !== lines[j] && j + 1 === lines.length) {
+ hash.push(list.join('-'));
+ hash.push(lines[j]);
+ } else if (lines[j - 1] + 1 !== lines[j]) {
+ hash.push(list.join('-'));
+ list = [lines[j]];
+ } else if (j + 1 === lines.length) {
+ list[1] = lines[j];
+ hash.push(list.join('-'));
+ } else {
+ list[1] = lines[j];
+ }
+ }
+
+ hash = hash.join(',');
+ $backup = $('#' + hash).removeAttr('id');
+ window.location.hash = hash;
+ $backup.attr('id', hash);
+ });
+});
+
diff --git a/documentation/resources/footer.png b/documentation/resources/footer.png
new file mode 100644
index 0000000..d99890c
Binary files /dev/null and b/documentation/resources/footer.png differ
diff --git a/documentation/resources/inherit.png b/documentation/resources/inherit.png
new file mode 100644
index 0000000..957079b
Binary files /dev/null and b/documentation/resources/inherit.png differ
diff --git a/documentation/resources/resize.png b/documentation/resources/resize.png
new file mode 100644
index 0000000..fb98a7a
Binary files /dev/null and b/documentation/resources/resize.png differ
diff --git a/documentation/resources/sort.png b/documentation/resources/sort.png
new file mode 100644
index 0000000..0d0fea1
Binary files /dev/null and b/documentation/resources/sort.png differ
diff --git a/documentation/resources/style.css b/documentation/resources/style.css
new file mode 100644
index 0000000..0d35c21
--- /dev/null
+++ b/documentation/resources/style.css
@@ -0,0 +1,614 @@
+body {
+ font: 13px/1.5 Verdana, 'Geneva CE', lucida, sans-serif;
+ margin: 0;
+ padding: 0;
+ background: #ffffff;
+ color: #333333;
+}
+
+h1, h2, h3, h4, caption {
+ font-family: 'Trebuchet MS', 'Geneva CE', lucida, sans-serif;
+ color: #053368;
+}
+
+h1 {
+ color: #1e5eb6;
+ font-size: 230%;
+ font-weight: normal;
+ margin: .3em 0;
+}
+
+h2 {
+ color: #1e5eb6;
+ font-size: 150%;
+ font-weight: normal;
+ margin: -.3em 0 .3em 0;
+}
+
+h3 {
+ font-size: 1.6em;
+ font-weight: normal;
+ margin-bottom: 2px;
+}
+
+h4 {
+ font-size: 100%;
+ font-weight: bold;
+ padding: 0;
+ margin: 0;
+}
+
+caption {
+ border: 1px solid #cccccc;
+ background: #ecede5;
+ font-weight: bold;
+ font-size: 1.2em;
+ padding: 3px 5px;
+ text-align: left;
+ margin-bottom: 0;
+}
+
+p {
+ margin: .7em 0 1em;
+ padding: 0;
+}
+
+hr {
+ margin: 2em 0 1em;
+ border: none;
+ border-top: 1px solid #cccccc;
+ height: 0;
+}
+
+a {
+ color: #006aeb;
+ padding: 3px 1px;
+ text-decoration: none;
+}
+
+h1 a {
+ color: #1e5eb6;
+}
+
+a:hover, a:active, a:focus, a:hover b, a:hover var {
+ background-color: #006aeb;
+ color: #ffffff !important;
+}
+
+code, var, pre {
+ font-family: monospace;
+}
+
+var {
+ font-weight: bold;
+ font-style: normal;
+ color: #ca8a04;
+}
+
+pre {
+ margin: 0;
+}
+
+code a b {
+ color: #000000;
+}
+
+.deprecated {
+ text-decoration: line-through;
+ opacity: .5;
+}
+
+.invalid {
+ color: #e71818;
+}
+
+.hidden {
+ display: none;
+}
+
+/* Left side */
+#left {
+ overflow: auto;
+ width: 270px;
+ height: 100%;
+ position: fixed;
+}
+
+/* Menu */
+#menu {
+ padding: 10px;
+}
+
+#menu ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+}
+
+#menu ul ul {
+ padding-left: 10px;
+}
+
+#menu li {
+ white-space: nowrap;
+ position: relative;
+}
+
+#menu a {
+ display: block;
+ padding: 0 2px;
+}
+
+#menu .active > a, #menu > span {
+ color: #333333;
+ background: none;
+ font-weight: bold;
+}
+
+#menu .active > a.invalid {
+ color: #e71818;
+}
+
+#menu .active > a:hover, #menu .active > a:active, #menu .active > a:focus {
+ background-color: #006aeb;
+}
+
+#menu #groups span {
+ position: absolute;
+ top: 4px;
+ right: 2px;
+ cursor: pointer;
+ display: block;
+ width: 12px;
+ height: 12px;
+ background: url('collapsed.png') transparent 0 0 no-repeat;
+}
+
+#menu #groups span:hover {
+ background-position: -12px 0;
+}
+
+#menu #groups span.collapsed {
+ background-position: 0 -12px;
+}
+
+#menu #groups span.collapsed:hover {
+ background-position: -12px -12px;
+}
+
+#menu #groups ul.collapsed {
+ display: none;
+}
+
+/* Right side */
+#right {
+ overflow: auto;
+ margin-left: 275px;
+ height: 100%;
+ position: relative;
+ left: 0;
+ right: 0;
+}
+
+#rightInner {
+ max-width: 1000px;
+ min-width: 350px;
+}
+
+/* Search */
+#search {
+ float: right;
+ margin: 3px 8px;
+}
+
+#search input.text {
+ padding: 3px 5px;
+ width: 250px;
+}
+
+/* Autocomplete */
+.ac_results {
+ padding: 0;
+ border: 1px solid #cccccc;
+ background-color: #ffffff;
+ overflow: hidden;
+ z-index: 99999;
+}
+
+.ac_results ul {
+ width: 100%;
+ list-style-position: outside;
+ list-style: none;
+ padding: 0;
+ margin: 0;
+}
+
+.ac_results li {
+ margin: 0;
+ padding: 2px 5px;
+ cursor: default;
+ display: block;
+ font: 12px 'Trebuchet MS', 'Geneva CE', lucida, sans-serif;
+ line-height: 16px;
+ overflow: hidden;
+ white-space: nowrap;
+}
+
+.ac_results li strong {
+ color: #000000;
+}
+
+.ac_odd {
+ background-color: #eeeeee;
+}
+
+.ac_over {
+ background-color: #006aeb;
+ color: #ffffff;
+}
+
+.ac_results li.ac_over strong {
+ color: #ffffff;
+}
+
+/* Navigation */
+#navigation {
+ padding: 3px 8px;
+ background-color: #f6f6f4;
+ height: 26px;
+}
+
+#navigation ul {
+ list-style: none;
+ margin: 0 8px 4px 0;
+ padding: 0;
+ overflow: hidden;
+ float: left;
+}
+
+#navigation ul + ul {
+ border-left: 1px solid #000000;
+ padding-left: 8px;
+}
+
+#navigation ul li {
+ float: left;
+ margin: 2px;
+ padding: 0 3px;
+ font-family: Verdana, 'Geneva CE', lucida, sans-serif;
+ color: #808080;
+}
+
+#navigation ul li.active {
+ background-color: #053368;
+ color: #ffffff;
+ font-weight: bold;
+}
+
+#navigation ul li a {
+ color: #000000;
+ font-weight: bold;
+ padding: 0;
+}
+
+#navigation ul li span {
+ float: left;
+ padding: 0 3px;
+}
+
+#navigation ul li a:hover span, #navigation ul li a:active span, #navigation ul li a:focus span {
+ background-color: #006aeb;
+}
+
+/* Content */
+#content {
+ clear: both;
+ padding: 5px 15px;
+}
+
+.description pre {
+ padding: .6em;
+ background: #fcfcf7;
+}
+
+#content > .description {
+ background: #ecede5;
+ padding: 1px 8px;
+ margin: 1.2em 0;
+}
+
+#content > .description pre {
+ margin: .5em 0;
+}
+
+dl.tree {
+ margin: 1.2em 0;
+}
+
+dl.tree dd {
+ margin: 0;
+ padding: 0;
+}
+
+.info {
+ margin: 1.2em 0;
+}
+
+.summary {
+ border: 1px solid #cccccc;
+ border-collapse: collapse;
+ font-size: 1em;
+ width: 100%;
+ margin: 1.2em 0 2.4em;
+}
+
+.summary caption {
+ border-width: 1px 1px 0;
+}
+
+.summary caption.switchable {
+ background: #ecede5 url('sort.png') no-repeat center right;
+ cursor: pointer;
+}
+
+.summary td {
+ border: 1px solid #cccccc;
+ margin: 0;
+ padding: 3px 10px;
+ font-size: 1em;
+ vertical-align: top;
+}
+
+.summary td:first-child {
+ text-align: right;
+}
+
+.summary td hr {
+ margin: 3px -10px;
+}
+
+#packages.summary td:first-child, #namespaces.summary td:first-child, .inherited.summary td:first-child, .used.summary td:first-child {
+ text-align: left;
+}
+
+.summary tr:hover td {
+ background: #f6f6f4;
+}
+
+.summary .description pre {
+ border: .5em solid #ecede5;
+}
+
+.summary .description p {
+ margin: 0;
+}
+
+.summary .description p + p, .summary .description ul {
+ margin: 3px 0 0 0;
+}
+
+.summary .description.detailed h4 {
+ margin-top: 3px;
+}
+
+.summary dl {
+ margin: 0;
+}
+
+.summary dd {
+ margin: 0 0 0 25px;
+}
+
+.name, .attributes {
+ white-space: nowrap;
+}
+
+.value code {
+ white-space: pre-wrap;
+}
+
+td.name, td.attributes {
+ width: 1%;
+}
+
+td.attributes {
+ width: 1%;
+}
+
+.class .methods .name, .class .properties .name, .class .constants .name {
+ width: auto;
+ white-space: normal;
+}
+
+.class .methods .name > div > code {
+ white-space: pre-wrap;
+}
+
+.class .methods .name > div > code span, .function .value > code {
+ white-space: nowrap;
+}
+
+.class .methods td.name > div, .class td.value > div {
+ position: relative;
+ padding-right: 1em;
+}
+
+.anchor {
+ position: absolute;
+ top: 0;
+ right: 0;
+ line-height: 1;
+ font-size: 85%;
+ margin: 0;
+ color: #006aeb !important;
+}
+
+.list {
+ margin: 0 0 5px 25px;
+}
+
+div.invalid {
+ background-color: #fae4e0;
+ padding: 10px;
+}
+
+/* Splitter */
+#splitter {
+ position: fixed;
+ height: 100%;
+ width: 5px;
+ left: 270px;
+ background: #1e5eb6 url('resize.png') left center no-repeat;
+ cursor: e-resize;
+}
+
+#splitter.active {
+ opacity: .5;
+}
+
+/* Footer */
+#footer {
+ border-top: 1px solid #e9eeef;
+ clear: both;
+ color: #a7a7a7;
+ font-size: 8pt;
+ text-align: center;
+ padding: 20px 0 0;
+ margin: 3em 0 0;
+ height: 90px;
+ background: #ffffff url('footer.png') no-repeat center top;
+}
+
+/* Tree */
+div.tree ul {
+ list-style: none;
+ background: url('tree-vertical.png') left repeat-y;
+ padding: 0;
+ margin-left: 20px;
+}
+
+div.tree li {
+ margin: 0;
+ padding: 0;
+}
+
+div.tree div {
+ padding-left: 30px;
+}
+
+div.tree div.notlast {
+ background: url('tree-hasnext.png') left 10px no-repeat;
+}
+
+div.tree div.last {
+ background: url('tree-last.png') left -240px no-repeat;
+}
+
+div.tree li.last {
+ background: url('tree-cleaner.png') left center repeat-y;
+}
+
+div.tree span.padding {
+ padding-left: 15px;
+}
+
+/* Source code */
+.php-keyword1 {
+ color: #e71818;
+ font-weight: bold;
+}
+
+.php-keyword2 {
+ font-weight: bold;
+}
+
+.php-var {
+ color: #d59401;
+ font-weight: bold;
+}
+
+.php-num {
+ color: #cd0673;
+}
+
+.php-quote {
+ color: #008000;
+}
+
+.php-comment {
+ color: #929292;
+}
+
+.xlang {
+ color: #ff0000;
+ font-weight: bold;
+}
+
+span.l {
+ display: block;
+}
+
+span.l.selected {
+ background: #f6f6f4;
+}
+
+span.l a {
+ color: #333333;
+}
+
+span.l a:hover, div.l a:active, div.l a:focus {
+ background: transparent;
+ color: #333333 !important;
+}
+
+span.l .php-var a {
+ color: #d59401;
+}
+
+span.l .php-var a:hover, span.l .php-var a:active, span.l .php-var a:focus {
+ color: #d59401 !important;
+}
+
+span.l a.l {
+ padding-left: 2px;
+ color: #c0c0c0;
+}
+
+span.l a.l:hover, span.l a.l:active, span.l a.l:focus {
+ background: transparent;
+ color: #c0c0c0 !important;
+}
+
+#rightInner.medium #navigation {
+ height: 52px;
+}
+
+#rightInner.medium #navigation ul:first-child + ul {
+ clear: left;
+ border: none;
+ padding: 0;
+}
+
+#rightInner.medium .name, #rightInner.medium .attributes {
+ white-space: normal;
+}
+
+#rightInner.small #search {
+ float: left;
+}
+
+#rightInner.small #navigation {
+ height: 78px;
+}
+
+#rightInner.small #navigation ul:first-child {
+ clear: both;
+}
+
+/* global style */
+.left, .summary td.left {
+ text-align: left;
+}
+.right, .summary td.right {
+ text-align: right;
+}
diff --git a/documentation/resources/tree-cleaner.png b/documentation/resources/tree-cleaner.png
new file mode 100644
index 0000000..2eb9085
Binary files /dev/null and b/documentation/resources/tree-cleaner.png differ
diff --git a/documentation/resources/tree-hasnext.png b/documentation/resources/tree-hasnext.png
new file mode 100644
index 0000000..91d6b79
Binary files /dev/null and b/documentation/resources/tree-hasnext.png differ
diff --git a/documentation/resources/tree-last.png b/documentation/resources/tree-last.png
new file mode 100644
index 0000000..7f319f8
Binary files /dev/null and b/documentation/resources/tree-last.png differ
diff --git a/documentation/resources/tree-vertical.png b/documentation/resources/tree-vertical.png
new file mode 100644
index 0000000..384908b
Binary files /dev/null and b/documentation/resources/tree-vertical.png differ
diff --git a/documentation/source-class-PhpGpio.Gpio.html b/documentation/source-class-PhpGpio.Gpio.html
new file mode 100644
index 0000000..ba0c550
--- /dev/null
+++ b/documentation/source-class-PhpGpio.Gpio.html
@@ -0,0 +1,372 @@
+
+
+
+
+
+
+ File PhpGpio/Gpio.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1: <?php
+ 2:
+ 3: namespace PhpGpio;
+ 4:
+ 5: class Gpio implements GpioInterface
+ 6: {
+ 7:
+ 8: private $pins ;
+ 9: private $hackablePins ;
+ 10:
+ 11: 12: 13:
+ 14: public function __construct()
+ 15: {
+ 16: $raspi = new Pi ;
+ 17: if ($raspi ->getVersion() < 4 ) {
+ 18: $this ->pins = array (
+ 19: 0 , 1 , 4 , 7 , 8 , 9 ,
+ 20: 10 , 11 , 14 , 15 , 17 , 18 ,
+ 21: 21 , 22 , 23 , 24 , 25
+ 22: );
+ 23: $this ->hackablePins = array (
+ 24: 4 , 7 , 8 , 9 ,
+ 25: 10 , 11 , 17 , 18 ,
+ 26: 21 , 22 , 23 , 24 , 25
+ 27: );
+ 28: } else if ($raspi ->getVersion() < 16 ) {
+ 29:
+ 30: $this ->pins = array (
+ 31: 2 , 3 , 4 , 7 , 8 , 9 ,
+ 32: 10 , 11 , 14 , 15 , 17 , 18 ,
+ 33: 22 , 23 , 24 , 25 , 27
+ 34: );
+ 35: $this ->hackablePins = array (
+ 36: 4 , 7 , 8 , 9 ,
+ 37: 10 , 11 , 17 , 18 ,
+ 38: 22 , 23 , 24 , 25 , 27
+ 39: );
+ 40: } else {
+ 41:
+ 42: $this ->pins = array (
+ 43: 2 , 3 , 4 , 5 , 6 , 7 ,
+ 44: 8 , 9 , 10 , 11 , 12 , 13 ,
+ 45: 14 , 15 , 16 , 17 , 18 , 19 ,
+ 46: 20 , 21 , 22 , 23 , 24 , 25 ,
+ 47: 26 , 27
+ 48: );
+ 49: $this ->hackablePins = array (
+ 50: 4 , 5 , 6 ,
+ 51: 12 , 13 , 16 , 17 , 18 , 19 ,
+ 52: 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27
+ 53: );
+ 54: }
+ 55: }
+ 56:
+ 57: 58: 59: 60: 61:
+ 62: public function getHackablePins()
+ 63: {
+ 64: return $this ->hackablePins;
+ 65: }
+ 66:
+ 67: private $directions = array (
+ 68: GpioInterface::DIRECTION_IN,
+ 69: GpioInterface::DIRECTION_OUT,
+ 70: );
+ 71:
+ 72: private $outputs = array (
+ 73: GpioInterface::IO_VALUE_ON,
+ 74: GpioInterface::IO_VALUE_OFF,
+ 75: );
+ 76:
+ 77:
+ 78: private $exportedPins = array ();
+ 79:
+ 80: 81: 82: 83: 84: 85: 86:
+ 87: public function setup($pinNo , $direction )
+ 88: {
+ 89: if (!$this ->isValidPin($pinNo )) {
+ 90: return false ;
+ 91: }
+ 92:
+ 93:
+ 94: if ($this ->isExported($pinNo )) {
+ 95: $this ->unexport($pinNo );
+ 96: }
+ 97:
+ 98:
+ 99: file_put_contents (GpioInterface::PATH_EXPORT, $pinNo );
+100:
+101:
+102: if ($this ->isValidDirection($direction )) {
+103: file_put_contents (GpioInterface::PATH_GPIO.$pinNo .'/direction' , $direction );
+104: }
+105:
+106:
+107: $this ->exportedPins[] = $pinNo ;
+108:
+109: return $this ;
+110: }
+111:
+112: 113: 114: 115: 116: 117:
+118: public function input($pinNo )
+119: {
+120: if (!$this ->isValidPin($pinNo )) {
+121: return false ;
+122: }
+123: if ($this ->isExported($pinNo )) {
+124: if ($this ->currentDirection($pinNo ) != "out" ) {
+125: return trim (file_get_contents (GpioInterface::PATH_GPIO.$pinNo .'/value' ));
+126: }
+127: throw new \Exception('Error!' . $this ->currentDirection($pinNo ) . ' is a wrong direction for this pin!' );
+128: }
+129:
+130: return false ;
+131: }
+132:
+133: 134: 135: 136: 137: 138: 139:
+140: public function output($pinNo , $value )
+141: {
+142: if (!$this ->isValidPin($pinNo )) {
+143: return false ;
+144: }
+145: if (!$this ->isValidOutput($value )) {
+146: return false ;
+147: }
+148: if ($this ->isExported($pinNo )) {
+149: if ($this ->currentDirection($pinNo ) != "in" ) {
+150: file_put_contents (GpioInterface::PATH_GPIO.$pinNo .'/value' , $value );
+151: } else {
+152: throw new \Exception('Error! Wrong Direction for this pin! Meant to be out while it is ' . $this ->currentDirection($pinNo ));
+153: }
+154: }
+155:
+156: return $this ;
+157: }
+158:
+159: 160: 161: 162: 163: 164:
+165: public function unexport($pinNo )
+166: {
+167: if (!$this ->isValidPin($pinNo )) {
+168: return false ;
+169: }
+170: if ($this ->isExported($pinNo )) {
+171: file_put_contents (GpioInterface::PATH_UNEXPORT, $pinNo );
+172: foreach ($this ->exportedPins as $key => $value ) {
+173: if ($value == $pinNo ) unset ($key );
+174: }
+175: }
+176:
+177: return $this ;
+178: }
+179:
+180: 181: 182: 183: 184:
+185: public function unexportAll()
+186: {
+187: foreach ($this ->exportedPins as $pinNo ) {
+188: file_put_contents (GpioInterface::PATH_UNEXPORT, $pinNo );
+189: }
+190: $this ->exportedPins = array ();
+191:
+192: return $this ;
+193: }
+194:
+195: 196: 197: 198: 199:
+200: public function isExported($pinNo )
+201: {
+202: if (!$this ->isValidPin($pinNo )) {
+203: return false ;
+204: }
+205:
+206: return file_exists (GpioInterface::PATH_GPIO.$pinNo );
+207: }
+208:
+209: 210: 211: 212: 213:
+214: public function currentDirection($pinNo )
+215: {
+216: if (!$this ->isValidPin($pinNo )) {
+217: return false ;
+218: }
+219:
+220: return trim (file_get_contents (GpioInterface::PATH_GPIO.$pinNo .'/direction' ));
+221: }
+222:
+223: 224: 225: 226: 227: 228:
+229: public function isValidDirection($direction )
+230: {
+231: if (!is_string ($direction ) || empty ($direction )) {
+232: throw new \InvalidArgumentException(sprintf ('Direction "%s" is invalid (string expected).' , $direction ));
+233: }
+234: if (!in_array ($direction , $this ->directions)) {
+235: throw new \InvalidArgumentException(sprintf ('Direction "%s" is invalid (unknown direction).' , $direction ));
+236: }
+237:
+238: return true ;
+239: }
+240:
+241: 242: 243: 244: 245: 246:
+247: public function isValidOutput($output )
+248: {
+249: if (!is_int ($output )) {
+250: throw new \InvalidArgumentException(sprintf ('Pin value "%s" is invalid (integer expected).' , $output ));
+251: }
+252: if (!in_array ($output , $this ->outputs)) {
+253: throw new \InvalidArgumentException(sprintf ('Output value "%s" is invalid (out of exepected range).' , $output ));
+254: }
+255:
+256: return true ;
+257: }
+258:
+259: 260: 261: 262: 263: 264:
+265: public function isValidPin($pinNo )
+266: {
+267: if (!is_int ($pinNo )) {
+268: throw new \InvalidArgumentException(sprintf ('Pin number "%s" is invalid (integer expected).' , $pinNo ));
+269: }
+270: if (!in_array ($pinNo , $this ->pins)) {
+271: throw new \InvalidArgumentException(sprintf ('Pin number "%s" is invalid (out of exepected range).' , $pinNo ));
+272: }
+273:
+274: return true ;
+275: }
+276: }
+277:
+
+
+
+
+
+
+
+
diff --git a/documentation/source-class-PhpGpio.GpioDevelop.html b/documentation/source-class-PhpGpio.GpioDevelop.html
new file mode 100644
index 0000000..1204af1
--- /dev/null
+++ b/documentation/source-class-PhpGpio.GpioDevelop.html
@@ -0,0 +1,259 @@
+
+
+
+
+
+
+ File PhpGpio/GpioDevelop.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1: <?php
+ 2:
+ 3: namespace PhpGpio;
+ 4:
+ 5: 6: 7: 8: 9: 10:
+ 11: class GpioDevelop implements GpioInterface
+ 12: {
+ 13: 14: 15:
+ 16: public $pins = array (14 , 15 , 17 , 18 );
+ 17:
+ 18: 19: 20:
+ 21: public $hackablePins = array (17 , 18 );
+ 22:
+ 23: 24: 25:
+ 26: public $inputValue = GpioInterface::IO_VALUE_OFF;
+ 27:
+ 28: 29: 30:
+ 31: public $direction = GpioInterface::DIRECTION_OUT;
+ 32:
+ 33: 34: 35: 36: 37: 38:
+ 39: public function getHackablePins()
+ 40: {
+ 41: return $this ->hackablePins;
+ 42: }
+ 43:
+ 44: 45: 46: 47: 48: 49: 50: 51:
+ 52: public function setup($pinNo , $direction )
+ 53: {
+ 54: return $this ;
+ 55: }
+ 56:
+ 57: 58: 59: 60: 61: 62: 63:
+ 64: public function input($pinNo )
+ 65: {
+ 66: return $this ->inputValue;
+ 67: }
+ 68:
+ 69: 70: 71: 72: 73: 74: 75: 76:
+ 77: public function output($pinNo , $value )
+ 78: {
+ 79: return $this ;
+ 80: }
+ 81:
+ 82: 83: 84: 85: 86: 87: 88:
+ 89: public function unexport($pinNo )
+ 90: {
+ 91: return $this ;
+ 92: }
+ 93:
+ 94: 95: 96: 97: 98:
+ 99: public function unexportAll()
+100: {
+101: return $this ;
+102: }
+103:
+104: 105: 106: 107: 108: 109: 110:
+111: public function isExported($pinNo )
+112: {
+113: return in_array ($pinNo , $this ->pins) || in_array ($pinNo , $this ->hackablePins);
+114: }
+115:
+116: 117: 118: 119: 120: 121: 122:
+123: public function currentDirection($pinNo )
+124: {
+125: return $this ->direction;
+126: }
+127:
+128: 129: 130: 131: 132: 133: 134:
+135: public function isValidDirection($direction )
+136: {
+137: return $direction == GpioInterface::DIRECTION_IN || $direction == GpioInterface::DIRECTION_OUT;
+138: }
+139:
+140: 141: 142: 143: 144: 145: 146:
+147: public function isValidOutput($output )
+148: {
+149: return $output == GpioInterface::IO_VALUE_ON || $output == GpioInterface::IO_VALUE_OFF;
+150: }
+151:
+152: 153: 154: 155: 156: 157: 158:
+159: public function isValidPin($pinNo )
+160: {
+161: return in_array ($pinNo , $this ->pins) || in_array ($pinNo , $this ->hackablePins);
+162: }
+163: }
+164:
+
+
+
+
+
+
+
+
diff --git a/documentation/source-class-PhpGpio.GpioInterface.html b/documentation/source-class-PhpGpio.GpioInterface.html
new file mode 100644
index 0000000..e1ddd1b
--- /dev/null
+++ b/documentation/source-class-PhpGpio.GpioInterface.html
@@ -0,0 +1,215 @@
+
+
+
+
+
+
+ File PhpGpio/GpioInterface.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/documentation/source-class-PhpGpio.Pi.html b/documentation/source-class-PhpGpio.Pi.html
new file mode 100644
index 0000000..1db2131
--- /dev/null
+++ b/documentation/source-class-PhpGpio.Pi.html
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+ File PhpGpio/Pi.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1: <?php
+ 2:
+ 3: namespace PhpGpio;
+ 4:
+ 5: class Pi
+ 6: {
+ 7: 8: 9: 10: 11: 12: 13: 14: 15:
+16: public function getVersion()
+17: {
+18: $cpuinfo = preg_split ("/\n/" , file_get_contents ('/proc/cpuinfo' ));
+19: foreach ($cpuinfo as $line ) {
+20: if (preg_match ('/Revision\s*:\s*([^\s]*)\s*/' , $line , $matches )) {
+21: return hexdec ($matches [1 ]);
+22: }
+23: }
+24:
+25: return 0 ;
+26: }
+27:
+28: 29: 30: 31: 32:
+33: public function getCpuLoad()
+34: {
+35: return sys_getloadavg();
+36: }
+37:
+38: 39: 40: 41: 42:
+43: public function getCpuTemp($fahrenheit = false )
+44: {
+45: $cputemp = floatval (file_get_contents ('/sys/class/thermal/thermal_zone0/temp' ))/1000 ;
+46:
+47: if ($fahrenheit )
+48: $cputemp = 1.8 * $cputemp +32 ;
+49:
+50: return $cputemp ;
+51: }
+52:
+53: 54: 55: 56: 57:
+58: public function getGpuTemp($fahrenheit = false )
+59: {
+60: $gputemp = floatval (str_replace (array ('temp=' , '\'C' ), '' , exec ('/opt/vc/bin/vcgencmd measure_temp' )));
+61:
+62: if ($fahrenheit )
+63: $gputemp = 1.8 * $gputemp +32 ;
+64:
+65: return $gputemp ;
+66: }
+67:
+68: 69: 70: 71: 72:
+73: public function getCpuFrequency()
+74: {
+75: $frequency = floatval (file_get_contents ('/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq' ))/1000 ;
+76:
+77: return $frequency ;
+78: }
+79: }
+80:
+
+
+
+
+
+
+
+
diff --git a/documentation/source-class-PhpGpio.Sensors.DS18B20.html b/documentation/source-class-PhpGpio.Sensors.DS18B20.html
new file mode 100644
index 0000000..3251ac1
--- /dev/null
+++ b/documentation/source-class-PhpGpio.Sensors.DS18B20.html
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+ File PhpGpio/Sensors/DS18B20.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1: <?php
+ 2:
+ 3: namespace PhpGpio\Sensors;
+ 4:
+ 5: 6: 7: 8: 9: 10: 11: 12:
+ 13: class DS18B20 implements SensorInterface
+ 14: {
+ 15:
+ 16: private $bus = null ;
+ 17: const BASEPATH = '/sys/bus/w1/devices/28-' ;
+ 18:
+ 19: 20: 21:
+ 22: public function getBus()
+ 23: {
+ 24: return $this ->bus;
+ 25: }
+ 26:
+ 27: 28: 29:
+ 30: public function setBus($value )
+ 31: {
+ 32:
+ 33: if (empty ($value ) || !is_string ($value ) || !file_exists ($value )) {
+ 34: throw new \InvalidArgumentException(" $value is not a valid w1 bus path" );
+ 35: }
+ 36:
+ 37:
+ 38: if (!strstr ($value , self::BASEPATH)) {
+ 39: throw new \InvalidArgumentException(" $value does not seem to be a regular w1 bus path" );
+ 40: }
+ 41:
+ 42: $this ->bus = $value ;
+ 43: }
+ 44:
+ 45: 46: 47: 48: 49:
+ 50: public function __construct()
+ 51: {
+ 52: $this ->bus = $this ->guessBus();
+ 53:
+ 54: return $this ;
+ 55: }
+ 56:
+ 57: 58: 59: 60: 61: 62: 63: 64:
+ 65: public function guessBus()
+ 66: {
+ 67: $busFolders = glob (self::BASEPATH . '*' );
+ 68: if (0 === count ($busFolders )) {
+ 69: return false ;
+ 70: }
+ 71: $busPath = $busFolders [0 ];
+ 72:
+ 73: return $busPath . '/w1_slave' ;
+ 74: }
+ 75:
+ 76: 77: 78: 79: 80: 81:
+ 82: public function read($args = array ())
+ 83: {
+ 84: if (!is_string ($this ->bus) || !file_exists ($this ->bus)) {
+ 85: throw new \Exception("No bus file found: please run sudo modprobe w1-gpio; sudo modprobe w1-therm & check the guessBus() method result" );
+ 86: }
+ 87: $raw = file_get_contents ($this ->bus);
+ 88: $raw = str_replace ("\n" , "" , $raw );
+ 89: $boom = explode ('t=' ,$raw );
+ 90:
+ 91: return floatval ($boom [1 ]/1000 );
+ 92: }
+ 93:
+ 94: 95: 96: 97: 98: 99:
+100: public function write($args = array ())
+101: {
+102: return false ;
+103: }
+104:
+105: }
+106:
+
+
+
+
+
+
+
+
diff --git a/documentation/source-class-PhpGpio.Sensors.MCP3002.html b/documentation/source-class-PhpGpio.Sensors.MCP3002.html
new file mode 100644
index 0000000..2ca00d8
--- /dev/null
+++ b/documentation/source-class-PhpGpio.Sensors.MCP3002.html
@@ -0,0 +1,192 @@
+
+
+
+
+
+
+ File PhpGpio/Sensors/MCP3002.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1: <?php
+ 2:
+ 3: namespace PhpGpio\Sensors;
+ 4:
+ 5: 6: 7: 8: 9:
+10: class MCP3002 implements SensorInterface {
+11:
+12: private $_clockpin ;
+13: private $_mosipin ;
+14: private $_misopin ;
+15: private $_cspin ;
+16:
+17: private $_gpio ;
+18:
+19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31:
+32: public function __construct($clockpin , $mosipin , $misopin , $cspin ) {
+33: $this ->_gpio = new GPIO();
+34:
+35: $this ->_clockpin = $clockpin ;
+36: $this ->_mosipin = $mosipin ;
+37: $this ->_misopin = $misopin ;
+38: $this ->_cspin = $cspin ;
+39:
+40: $this ->_gpio->setup($this ->_mosipin, "out" );
+41: $this ->_gpio->setup($this ->_misopin, "in" );
+42: $this ->_gpio->setup($this ->_clockpin, "out" );
+43: $this ->_gpio->setup($this ->_cspin, "out" );
+44: }
+45:
+46: 47: 48: 49: 50: 51: 52:
+53: public function read($args = array ()) {
+54: $channel = $args ['channel' ];
+55: if (!is_integer ($channel ) || !in_array ($channel , array (0 , 1 ))) {
+56: echo $msg = "Only 2 channels are available on a Mcp3002: 0 or 1" ;
+57: throw new \InvalidArgumentException($msg );
+58: }
+59:
+60:
+61: $this ->_gpio->output($this ->_cspin, 1 );
+62: $this ->_gpio->output($this ->_clockpin, 0 );
+63: $this ->_gpio->output($this ->_cspin, 0 );
+64:
+65:
+66: $cmdout = (6 + $channel ) << 5 ;
+67: for ($i = 0 ; $i < 3 ; $i ++) {
+68: if ($cmdout & 0x80 ) {
+69: $this ->_gpio->output($this ->_mosipin, 1 );
+70: } else {
+71: $this ->_gpio->output($this ->_mosipin, 0 );
+72: }
+73: $cmdout <<= 1 ;
+74: $this ->_gpio->output($this ->_clockpin, 1 );
+75: $this ->_gpio->output($this ->_clockpin, 0 );
+76: }
+77:
+78: $adcout = 0 ;
+79:
+80: for ($i = 0 ; $i < 12 ; $i ++) {
+81: $this ->_gpio->output($this ->_clockpin, 1 );
+82: $this ->_gpio->output($this ->_clockpin, 0 );
+83: $adcout <<= 1 ;
+84: if ($this ->_gpio->input($this ->_misopin)) {
+85: $adcout |= 0x1 ;
+86: }
+87: }
+88:
+89: $this ->_gpio->output($this ->_cspin, 1 );
+90: return $adcout >> 1 ;
+91: }
+92:
+93: public function write($args = array ()) {
+94: return false ;
+95: }
+96: }
+97:
+
+
+
+
+
+
+
+
diff --git a/documentation/source-class-PhpGpio.Sensors.SensorInterface.html b/documentation/source-class-PhpGpio.Sensors.SensorInterface.html
new file mode 100644
index 0000000..362112e
--- /dev/null
+++ b/documentation/source-class-PhpGpio.Sensors.SensorInterface.html
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+ File PhpGpio/Sensors/SensorInterface.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logs/.gitkeep b/logs/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/src/PhpGpio/Camera.php b/src/PhpGpio/Camera.php
new file mode 100644
index 0000000..b48bc60
--- /dev/null
+++ b/src/PhpGpio/Camera.php
@@ -0,0 +1,628 @@
+setCommand(sprintf(
+ "%s %s ",
+ 'raspistill --nopreview -o /opt/temp/test01.jpg'
+
+ $this->quality,
+ $this->width,
+ $this->height,
+ $this->verbose,
+ $this->timeout,
+ $this->encoding,
+ $this->timelapse,
+ $this->sharpness,
+ $this->contrast,
+ $this->saturation,
+ $this->ISO,
+ $this->vstab.$ev.$exposure.$awb.$imxfx.$colfx.$metering.$rotation.$hflip.$vflip.' 2>&1 ' ;
+
+ $escaped_command = escapeshellcmd($command);
+ exec($command, $test, $retval);
+ }
+
+ /**
+ * Gets the value of width.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getWidth()
+ {
+ return $this->width;
+ }
+
+ /**
+ * Sets the value of width.
+ *
+ * @access public
+ * @param mixed $width the width
+ *
+ * @return self
+ */
+ public function setWidth($width)
+ {
+ $this->width = $width;
+ return $this;
+ }
+
+ /**
+ * Gets the value of height.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getHeight()
+ {
+ return $this->height;
+ }
+
+ /**
+ * Sets the value of height.
+ *
+ * @access public
+ * @param mixed $height the height
+ *
+ * @return self
+ */
+ public function setHeight($height)
+ {
+ $this->height = $height;
+ return $this;
+ }
+
+ /**
+ * Gets the value of quality.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getQuality()
+ {
+ return $this->quality;
+ }
+
+ /**
+ * Sets the value of quality.
+ *
+ * @access public
+ * @param mixed $quality the quality
+ *
+ * @return self
+ */
+
+ public function setQuality($quality)
+ {
+ $this->quality = $quality;
+ return $this;
+ }
+ /**
+ * Gets the value of verbose.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getVerbose()
+ {
+ return $this->verbose;
+ }
+
+ /**
+ * Sets the value of verbose.
+ *
+ * @access public
+ * @param mixed $verbose the verbose
+ *
+ * @return self
+ */
+
+ public function setVerbose($verbose)
+ {
+ $this->verbose = $verbose;
+ return $this;
+ }
+ /**
+ * Gets the value of timeout.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getTimeout()
+ {
+ return $this->timeout;
+ }
+
+ /**
+ * Sets the value of timeout.
+ *
+ * @access public
+ * @param mixed $timeout the timeout
+ *
+ * @return self
+ */
+ public function setTimeout($timeout)
+ {
+ $this->timeout = $timeout;
+ return $this;
+ }
+ /**
+ * Gets the value of encoding.
+ *
+ * @access public
+ * @return mixed
+ */
+
+ public function getEncoding()
+ {
+ return $this->encoding;
+ }
+
+ /**
+ * Sets the value of encoding.
+ *
+ * @access public
+ * @param mixed $encoding the encoding
+ *
+ * @return self
+ */
+ public function setEncoding($encoding)
+ {
+ $this->encoding = $encoding;
+ return $this;
+ }
+
+ /**
+ * Gets the value of timelapse.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getTimelapse()
+ {
+ return $this->timelapse;
+ }
+
+ /**
+ * Sets the value of timelapse.
+ *
+ * @access public
+ * @param mixed $timelapse the timelapse
+ *
+ * @return self
+ */
+ public function setTimelapse($timelapse)
+ {
+ $this->timelapse = $timelapse;
+ return $this;
+ }
+
+ /**
+ * Gets the value of sharpness.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getSharpness()
+ {
+ return $this->sharpness;
+ }
+
+ /**
+ * Sets the value of sharpness.
+ *
+ * @access public
+ * @param mixed $sharpness the sharpness
+ *
+ * @return self
+ */
+ public function setSharpness($sharpness)
+ {
+ $this->sharpness = $sharpness;
+ return $this;
+ }
+ /**
+ * Gets the value of contrast.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getContrast()
+ {
+ return $this->contrast;
+ }
+
+ /**
+ * Sets the value of contrast.
+ *
+ * @access public
+ * @param mixed $contrast the contrast
+ *
+ * @return self
+ */
+ public function setContrast($contrast)
+ {
+ $this->contrast = $contrast;
+ return $this;
+ }
+
+ /**
+ * Gets the value of saturation.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getSaturation()
+ {
+ return $this->saturation;
+ }
+
+ /**
+ * Sets the value of saturation.
+ *
+ * @access public
+ * @param mixed $saturation the saturation
+ *
+ * @return self
+ */
+ public function setSaturation($saturation)
+ {
+ $this->saturation = $saturation;
+ return $this;
+ }
+
+ /**
+ * Gets the value of ISO.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getISO()
+ {
+ return $this->ISO;
+ }
+
+ /**
+ * Sets the value of ISO.
+ *
+ * @access public
+ * @param mixed $ISO the i s o
+ * @return self
+ */
+ public function setISO($ISO)
+ {
+ $this->ISO = $ISO;
+ return $this;
+ }
+
+ /**
+ * Gets the value of vstab.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getVstab()
+ {
+ return $this->vstab;
+ }
+
+ /**
+ * Sets the value of vstab.
+ *
+ * @access public
+ * @param mixed $vstab the vstab
+ *
+ * @return self
+ */
+ public function setVstab($vstab)
+ {
+ $this->vstab = $vstab;
+ return $this;
+ }
+
+ /**
+ * Gets the value of ev.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getEv()
+ {
+ return $this->ev;
+ }
+
+ /**
+ * Sets the value of ev.
+ *
+ * @access public
+ * @param mixed $ev the ev
+ *
+ * @return self
+ */
+ public function setEv($ev)
+ {
+ $this->ev = $ev;
+ return $this;
+ }
+
+ /**
+ * Gets the value of exposure.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getExposure()
+ {
+ return $this->exposure;
+ }
+
+ /**
+ * Sets the value of exposure.
+ *
+ * @access public
+ * @param mixed $exposure the exposure
+ *
+ * @return self
+ */
+ public function setExposure($exposure)
+ {
+ $this->exposure = $exposure;
+ return $this;
+ }
+
+ /**
+ * Gets the value of awb.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getAwb()
+ {
+ return $this->awb;
+ }
+
+ /**
+ * Sets the value of awb.
+ *
+ * @access public
+ * @param mixed $awb the awb
+ *
+ * @return self
+ */
+ public function setAwb($awb)
+ {
+ $this->awb = $awb;
+ return $this;
+ }
+
+ /**
+ * Gets the value of imxfx.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getImxfx()
+ {
+ return $this->imxfx;
+ }
+
+ /**
+ * Sets the value of imxfx.
+ *
+ * @access public
+ * @param mixed $imxfx the imxfx
+ *
+ * @return self
+ */
+ public function setImxfx($imxfx)
+ {
+ $this->imxfx = $imxfx;
+ return $this;
+ }
+
+ /**
+ * Gets the value of colfx.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getColfx()
+ {
+ return $this->colfx;
+ }
+
+ /**
+ * Sets the value of colfx.
+ *
+ * @access public
+ * @param mixed $colfx the colfx
+ *
+ * @return self
+ */
+ public function setColfx($colfx)
+ {
+ $this->colfx = $colfx;
+ return $this;
+ }
+
+ /**
+ * Gets the value of metering.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getMetering()
+ {
+ return $this->metering;
+ }
+
+ /**
+ * Sets the value of metering.
+ *
+ * @access public
+ * @param mixed $metering the metering
+ *
+ * @return self
+ */
+ public function setMetering($metering)
+ {
+ $this->metering = $metering;
+ return $this;
+ }
+
+ /**
+ * Gets the value of rotation.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getRotation()
+ {
+ return $this->rotation;
+ }
+
+ /**
+ * Sets the value of rotation.
+ *
+ * @access public
+ * @param mixed $rotation the rotation
+ *
+ * @return self
+ */
+ public function setRotation($rotation)
+ {
+ $this->rotation = $rotation;
+ return $this;
+ }
+
+ /**
+ * Gets the value of hflip.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getHflip()
+ {
+ return $this->hflip;
+ }
+
+ /**
+ * Sets the value of hflip.
+ *
+ * @access public
+ * @param mixed $hflip the hflip
+ *
+ * @return self
+ */
+ public function setHflip($hflip)
+ {
+ $this->hflip = $hflip;
+ return $this;
+ }
+
+ /**
+ * Gets the value of vflip.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getVflip()
+ {
+ return $this->vflip;
+ }
+
+ /**
+ * Sets the value of vflip.
+ *
+ * @access public
+ * @param mixed $vflip the vflip
+ *
+ * @return self
+ */
+ public function setVflip($vflip)
+ {
+ $this->vflip = $vflip;
+ return $this;
+ }
+
+ /**
+ * Gets the value of command.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getCommand()
+ {
+ return $this->command;
+ }
+
+ /**
+ * Sets the value of command.
+ *
+ * @access public
+ * @param mixed $command the command
+ *
+ * @return self
+ */
+ public function setCommand($command)
+ {
+ $this->command = $command;
+ return $this;
+ }
+
+ /**
+ * Gets the value of output.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getOutput()
+ {
+ return $this->output;
+ }
+
+ /**
+ * Sets the value of output.
+ *
+ * @access public
+ * @param mixed $output the output
+ *
+ * @return self
+ */
+ public function setOutput($output)
+ {
+ $this->output = $output;
+ return $this;
+ }
+}
diff --git a/src/PhpGpio/Gpio.php b/src/PhpGpio/Gpio.php
index eb79e1e..ea802a1 100644
--- a/src/PhpGpio/Gpio.php
+++ b/src/PhpGpio/Gpio.php
@@ -2,6 +2,9 @@
namespace PhpGpio;
+use Monolog\Logger;
+use Monolog\Handler\StreamHandler;
+
class Gpio implements GpioInterface
{
// Using BCM pin numbers.
@@ -9,54 +12,65 @@ class Gpio implements GpioInterface
private $hackablePins;
/**
- * @link http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
+ * Class constructor
+ *
+ * @access public
+ * @link http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
*/
public function __construct()
{
+ // Raspberry Pi utils?
$raspi = new Pi;
+
+ // Logger
+ $logger = new Logger('Raspberry Pi');
+ $logger->pushHandler(new StreamHandler('logs/'. date('d-m-Y') .'.log', Logger::WARNING));
+
if ($raspi->getVersion() < 4) {
- $this->pins = array(
+ $this->pins = [
0, 1, 4, 7, 8, 9,
10, 11, 14, 15, 17, 18,
21, 22, 23, 24, 25
- );
- $this->hackablePins = array(
+ ];
+ $this->hackablePins = [
4, 7, 8, 9,
10, 11, 17, 18,
21, 22, 23, 24, 25
- );
+ ];
} else if($raspi->getVersion() < 16) {
# new GPIO layout (REV2)
- $this->pins = array(
+ $this->pins = [
2, 3, 4, 7, 8, 9,
10, 11, 14, 15, 17, 18,
22, 23, 24, 25, 27
- );
- $this->hackablePins = array(
+ ];
+ $this->hackablePins = [
4, 7, 8, 9,
10, 11, 17, 18,
22, 23, 24, 25, 27
- );
+ ];
} else {
# new GPIO layout (B+)
- $this->pins = array(
+ $this->pins = [
2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25,
26, 27
- );
- $this->hackablePins = array(
+ ];
+ $this->hackablePins = [
4, 5, 6,
12, 13, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27
- );
+ ];
}
}
/**
* getHackablePins : the pins you can hack with.
- * @link http://elinux.org/RPi_Low-level_peripherals
+ *
+ * @access public
+ * @link http://elinux.org/RPi_Low-level_peripherals
* @return integer[]
*/
public function getHackablePins()
@@ -64,22 +78,23 @@ public function getHackablePins()
return $this->hackablePins;
}
- private $directions = array(
+ private $directions = [
GpioInterface::DIRECTION_IN,
GpioInterface::DIRECTION_OUT,
- );
+ ];
- private $outputs = array(
+ private $outputs = [
GpioInterface::IO_VALUE_ON,
GpioInterface::IO_VALUE_OFF,
- );
+ ];
// exported pins for when we unexport all
- private $exportedPins = array();
+ private $exportedPins = [ ];
/**
* Setup pin, takes pin number and direction (in or out)
*
+ * @access public
* @param int $pinNo
* @param string $direction
* @return mixed string GPIO value or boolean false
@@ -112,8 +127,10 @@ public function setup($pinNo, $direction)
/**
* Get input value
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
* @return false|string string GPIO value or boolean false
+ * @throws \Exception
*/
public function input($pinNo)
{
@@ -124,6 +141,8 @@ public function input($pinNo)
if ($this->currentDirection($pinNo) != "out") {
return trim(file_get_contents(GpioInterface::PATH_GPIO.$pinNo.'/value'));
}
+
+ $this->logger->addError('Error!' . $this->currentDirection($pinNo) . ' is a wrong direction for this pin!');
throw new \Exception('Error!' . $this->currentDirection($pinNo) . ' is a wrong direction for this pin!');
}
@@ -133,9 +152,11 @@ public function input($pinNo)
/**
* Set output value
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
* @param string $value
- * @return mixed Gpio current instance or boolean false
+ * @return mixed Gpio current instance or boolean false
+ * @throws \Exception
*/
public function output($pinNo, $value)
{
@@ -149,6 +170,7 @@ public function output($pinNo, $value)
if ($this->currentDirection($pinNo) != "in") {
file_put_contents(GpioInterface::PATH_GPIO.$pinNo.'/value', $value);
} else {
+ $this->logger->addError('Error! Wrong Direction for this pin! Meant to be out while it is ' . $this->currentDirection($pinNo));
throw new \Exception('Error! Wrong Direction for this pin! Meant to be out while it is ' . $this->currentDirection($pinNo));
}
}
@@ -159,6 +181,7 @@ public function output($pinNo, $value)
/**
* Unexport Pin
*
+ * @access public
* @param int $pinNo
* @return mixed Gpio current instance or boolean false
*/
@@ -180,6 +203,7 @@ public function unexport($pinNo)
/**
* Unexport all pins
*
+ * @access public
* @return Gpio Gpio current instance or boolean false
*/
public function unexportAll()
@@ -187,7 +211,7 @@ public function unexportAll()
foreach ($this->exportedPins as $pinNo) {
file_put_contents(GpioInterface::PATH_UNEXPORT, $pinNo);
}
- $this->exportedPins = array();
+ $this->exportedPins = [ ];
return $this;
}
@@ -195,6 +219,8 @@ public function unexportAll()
/**
* Check if pin is exported
*
+ * @access public
+ * @param int, $pinNo
* @return boolean
*/
public function isExported($pinNo)
@@ -209,6 +235,8 @@ public function isExported($pinNo)
/**
* get the pin's current direction
*
+ * @access public
+ * @param int, $pinNo
* @return false|string string pin's direction value or boolean false
*/
public function currentDirection($pinNo)
@@ -223,15 +251,19 @@ public function currentDirection($pinNo)
/**
* Check for valid direction, in or out
*
+ * @access public
+ * @param string, $direction
* @exception InvalidArgumentException
- * @return boolean true
+ * @return boolean true
*/
public function isValidDirection($direction)
{
if (!is_string($direction) || empty($direction)) {
+ $this->logger->addError('Direction "%s" is invalid (string expected).', $direction);
throw new \InvalidArgumentException(sprintf('Direction "%s" is invalid (string expected).', $direction));
}
if (!in_array($direction, $this->directions)) {
+ $this->logger->addError('Direction "%s" is invalid (unknown direction).', $direction);
throw new \InvalidArgumentException(sprintf('Direction "%s" is invalid (unknown direction).', $direction));
}
@@ -241,15 +273,19 @@ public function isValidDirection($direction)
/**
* Check for valid output value
*
- * @exception InvalidArgumentException
- * @return boolean true
+ * @access public
+ * @param mixed, $output
+ * @exception InvalidArgumentException.
+ * @return boolean true
*/
public function isValidOutput($output)
{
if (!is_int($output)) {
+ $logger->addError('Pin value "%s" is invalid (integer expected).', $output);
throw new \InvalidArgumentException(sprintf('Pin value "%s" is invalid (integer expected).', $output));
}
if (!in_array($output, $this->outputs)) {
+ $logger->addError('Output value "%s" is invalid (out of exepected range).', $output);
throw new \InvalidArgumentException(sprintf('Output value "%s" is invalid (out of exepected range).', $output));
}
@@ -259,18 +295,30 @@ public function isValidOutput($output)
/**
* Check for valid pin value
*
+ * @access public
+ * @param int, $pinNo
* @exception InvalidArgumentException
- * @return boolean true
+ * @return boolean true
*/
public function isValidPin($pinNo)
{
if (!is_int($pinNo)) {
+ $logger->addError('Pin number "%s" is invalid (integer expected).', $pinNo);
throw new \InvalidArgumentException(sprintf('Pin number "%s" is invalid (integer expected).', $pinNo));
}
if (!in_array($pinNo, $this->pins)) {
+ $logger->addError('Pin number "%s" is invalid (out of exepected range).', $pinNo);
throw new \InvalidArgumentException(sprintf('Pin number "%s" is invalid (out of exepected range).', $pinNo));
}
return true;
}
+
+ public function readValuePin($pinNo) {
+ if (!$this->isValidPin($pinNo)) {
+ return false;
+ }
+
+ return trim(file_get_contents(GpioInterface::PATH_GPIO.$pinNo.'/value'));;
+ }
}
diff --git a/src/PhpGpio/GpioDevelop.php b/src/PhpGpio/GpioDevelop.php
index 6a70305..29d893a 100644
--- a/src/PhpGpio/GpioDevelop.php
+++ b/src/PhpGpio/GpioDevelop.php
@@ -11,29 +11,34 @@
class GpioDevelop implements GpioInterface
{
/**
- * @var array
+ * @access public
+ * @var array
*/
- public $pins = array(14, 15, 17, 18);
+ public $pins = [14, 15, 17, 18];
/**
- * @var array
+ * @access public
+ * @var array
*/
- public $hackablePins = array(17, 18);
+ public $hackablePins = [17, 18];
/**
- * @var int
+ * @access public
+ * @var int
*/
public $inputValue = GpioInterface::IO_VALUE_OFF;
/**
- * @var string
+ * @access public
+ * @var string
*/
public $direction = GpioInterface::DIRECTION_OUT;
/**
* getHackablePins : the pins you can hack with.
- * @link http://elinux.org/RPi_Low-level_peripherals
*
+ * @link http://elinux.org/RPi_Low-level_peripherals
+ * @access public
* @return array
*/
public function getHackablePins()
@@ -44,6 +49,7 @@ public function getHackablePins()
/**
* Setup pin, takes pin number and direction (in or out)
*
+ * @access public
* @param int $pinNo
* @param string $direction
*
@@ -57,6 +63,7 @@ public function setup($pinNo, $direction)
/**
* Get input value
*
+ * @access public
* @param int $pinNo
*
* @return int GPIO value or boolean false
@@ -69,6 +76,7 @@ public function input($pinNo)
/**
* Set output value
*
+ * @access public
* @param int $pinNo
* @param string $value
*
@@ -82,6 +90,7 @@ public function output($pinNo, $value)
/**
* Unexport Pin
*
+ * @access public
* @param int $pinNo
*
* @return GpioDevelop or boolean false
@@ -94,6 +103,7 @@ public function unexport($pinNo)
/**
* Unexport all pins
*
+ * @access public
* @return GpioDevelop or boolean false
*/
public function unexportAll()
@@ -104,7 +114,8 @@ public function unexportAll()
/**
* Check if pin is exported
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
*
* @return boolean
*/
@@ -116,7 +127,8 @@ public function isExported($pinNo)
/**
* get the pin's current direction
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
*
* @return string pin's direction value or boolean false
*/
@@ -128,7 +140,8 @@ public function currentDirection($pinNo)
/**
* Check for valid direction, in or out
*
- * @param string $direction
+ * @access public
+ * @param string $direction
*
* @return boolean
*/
@@ -140,7 +153,8 @@ public function isValidDirection($direction)
/**
* Check for valid output value
*
- * @param mixed $output
+ * @access public
+ * @param mixed $output
*
* @return boolean
*/
@@ -152,7 +166,8 @@ public function isValidOutput($output)
/**
* Check for valid pin value
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
*
* @return boolean
*/
diff --git a/src/PhpGpio/GpioInterface.php b/src/PhpGpio/GpioInterface.php
index 8f07f89..e7508a9 100644
--- a/src/PhpGpio/GpioInterface.php
+++ b/src/PhpGpio/GpioInterface.php
@@ -9,20 +9,21 @@
*/
interface GpioInterface
{
- const DIRECTION_IN = 'in';
+ const DIRECTION_IN = 'in';
const DIRECTION_OUT = 'out';
- const IO_VALUE_ON = 1;
- const IO_VALUE_OFF = 0;
+ const IO_VALUE_ON = 1;
+ const IO_VALUE_OFF = 0;
- const PATH_GPIO = '/sys/class/gpio/gpio';
- const PATH_EXPORT = '/sys/class/gpio/export';
+ const PATH_GPIO = '/sys/class/gpio/gpio';
+ const PATH_EXPORT = '/sys/class/gpio/export';
const PATH_UNEXPORT = '/sys/class/gpio/unexport';
/**
* getHackablePins : the pins you can hack with.
- * @link http://elinux.org/RPi_Low-level_peripherals
*
+ * @access public
+ * @link http://elinux.org/RPi_Low-level_peripherals
* @return array
*/
public function getHackablePins();
@@ -30,6 +31,7 @@ public function getHackablePins();
/**
* Setup pin, takes pin number and direction (in or out)
*
+ * @access public
* @param int $pinNo
* @param string $direction
*
@@ -40,6 +42,7 @@ public function setup($pinNo, $direction);
/**
* Get input value
*
+ * @access public
* @param int $pinNo
*
* @return integer string GPIO value or boolean false
@@ -49,6 +52,7 @@ public function input($pinNo);
/**
* Set output value
*
+ * @access public
* @param int $pinNo
* @param string $value
*
@@ -59,6 +63,7 @@ public function output($pinNo, $value);
/**
* Unexport Pin
*
+ * @access public
* @param int $pinNo
*
* @return GpioDevelop Gpio current instance or boolean false
@@ -68,6 +73,7 @@ public function unexport($pinNo);
/**
* Unexport all pins
*
+ * @access public
* @return GpioDevelop Gpio current instance or boolean false
*/
public function unexportAll();
@@ -75,7 +81,8 @@ public function unexportAll();
/**
* Check if pin is exported
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
*
* @return boolean
*/
@@ -84,7 +91,8 @@ public function isExported($pinNo);
/**
* get the pin's current direction
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
*
* @return string string pin's direction value or boolean false
*/
@@ -93,7 +101,8 @@ public function currentDirection($pinNo);
/**
* Check for valid direction, in or out
*
- * @param string $direction
+ * @access public
+ * @param string $direction
*
* @return boolean
*/
@@ -102,7 +111,8 @@ public function isValidDirection($direction);
/**
* Check for valid output value
*
- * @param mixed $output
+ * @access public
+ * @param mixed $output
*
* @return boolean
*/
@@ -111,9 +121,12 @@ public function isValidOutput($output);
/**
* Check for valid pin value
*
- * @param int $pinNo
+ * @access public
+ * @param int $pinNo
*
* @return boolean
*/
public function isValidPin($pinNo);
+
+ public function readValuePin($pinNo);
}
diff --git a/src/PhpGpio/Pi.php b/src/PhpGpio/Pi.php
index 413d1e6..12ba2da 100644
--- a/src/PhpGpio/Pi.php
+++ b/src/PhpGpio/Pi.php
@@ -5,12 +5,13 @@
class Pi
{
/**
- *
+ *
* Get RaspberryPi version
- *
- * A list of Model and Pi Revision & Hardware Revision Code from '/proc/cpuinfo' is here:
- * @link http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/
- *
+ *
+ * A list of Model and Pi Revision & Hardware Revision Code from '/proc/cpuinfo' is here:
+ *
+ * @access public
+ * @link http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/
* @return decimal Raspi version
*/
public function getVersion()
@@ -24,36 +25,66 @@ public function getVersion()
return 0;
}
-
+
+ /**
+ * Get the CPu load of the Raspberry.
+ *
+ * @access public
+ * @return string.
+ */
public function getCpuLoad()
{
return sys_getloadavg();
}
-
+
+ /**
+ * Get the Cpu temperature
+ *
+ * @access public
+ * @param $fahrenheit, boolean
+ * @return integer.
+ */
public function getCpuTemp($fahrenheit = false)
{
$cputemp = floatval(file_get_contents('/sys/class/thermal/thermal_zone0/temp'))/1000;
-
- if($fahrenheit)
+
+ if($fahrenheit) {
$cputemp = 1.8* $cputemp+32;
-
+
return $cputemp;
+
+ }
}
-
+
+ /**
+ * Get the temperature of the Graphical Porcessing Unit.
+ *
+ * @access public
+ * @param $fahrenheit, boolean
+ * @return integer.
+ */
public function getGpuTemp($fahrenheit = false)
{
- $gputemp = floatval(str_replace(array('temp=', '\'C'), '', exec('/opt/vc/bin/vcgencmd measure_temp')));
-
- if($fahrenheit)
+ $gputemp = floatval(str_replace(['temp=', '\'C'], '', exec('/opt/vc/bin/vcgencmd measure_temp')));
+
+ if($fahrenheit) {
$gputemp = 1.8* $gputemp+32;
return $gputemp;
+
+ }
}
-
+
+ /**
+ * Get the frequency of the CPU.
+ *
+ * @access public
+ * @return integer
+ */
public function getCpuFrequency()
{
$frequency = floatval(file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq'))/1000;
-
+
return $frequency;
}
}
diff --git a/src/PhpGpio/Sensors/DS18B20.php b/src/PhpGpio/Sensors/DS18B20.php
index 203906d..4aa7735 100644
--- a/src/PhpGpio/Sensors/DS18B20.php
+++ b/src/PhpGpio/Sensors/DS18B20.php
@@ -2,6 +2,9 @@
namespace PhpGpio\Sensors;
+use Monolog\Logger;
+use Monolog\Handler\StreamHandler
+
/*
* 1-Wire is a device communications bus system designed by Dallas Semiconductor Corp.
* that provides low-speed data, signaling, and power over a single signal.
@@ -10,14 +13,28 @@
* such as digital thermometers and weather instruments.
* (source : http://en.wikipedia.org/wiki/1-Wire)
*/
+
class DS18B20 implements SensorInterface
{
private $bus = null; // ex: '/sys/bus/w1/devices/28-000003ced8f4/w1_slave'
const BASEPATH = '/sys/bus/w1/devices/28-';
+
/**
- * Get-Accesssor
+ * Class Constructor
+ */
+ public function __construct()
+ {
+ // Logger
+ $logger = new Logger('Raspberry Pi');
+ $logger->pushHandler(new StreamHandler('logs/'. date('d-m-Y') .'.log', Logger::WARNING));
+ }
+
+ /**
+ * Get-Accesssor
+ *
+ * @access public
*/
public function getBus()
{
@@ -25,17 +42,22 @@ public function getBus()
}
/**
- * Set-Accesssor
+ * Set-Accesssor
+ *
+ * @access public
+ * @param $value
*/
public function setBus($value)
{
// ? is a non empty string, & a valid file path
if (empty($value) || !is_string($value) || !file_exists($value)) {
+ $logger->addError("$value is not a valid w1 bus path.");
throw new \InvalidArgumentException("$value is not a valid w1 bus path");
}
// ? is a regular w1-bus path on a Raspbery ?
if (!strstr($value, self::BASEPATH)) {
+ $logger->addError("$value does not seem to be a regular w1 bus path");
throw new \InvalidArgumentException("$value does not seem to be a regular w1 bus path");
}
@@ -45,6 +67,7 @@ public function setBus($value)
/**
* Setup
*
+ * @access public
* @return $this
*/
public function __construct()
@@ -60,6 +83,7 @@ public function __construct()
* the directory 28-*** indicates the DS18B20 thermal sensor is wired to the bus
* (28 is the family ID) and the unique ID is a 12-chars numerical digit
*
+ * @access public
* @return string $busPath
*/
public function guessBus()
@@ -76,12 +100,14 @@ public function guessBus()
/**
* Read
*
+ * @access public
* @param array $args
* @return float $value
*/
- public function read($args = array())
+ public function read($args = [ ])
{
if (!is_string($this->bus) || !file_exists($this->bus)) {
+ $logger->addError('No bus file found: please run sudo modprobe w1-gpio; sudo modprobe w1-therm & check the guessBus() method result');
throw new \Exception("No bus file found: please run sudo modprobe w1-gpio; sudo modprobe w1-therm & check the guessBus() method result");
}
$raw = file_get_contents($this->bus);
@@ -94,10 +120,11 @@ public function read($args = array())
/**
* Write
*
- * @param array $args
+ * @access public
+ * @param array $args
* @return boolean
*/
- public function write($args = array())
+ public function write($args = [ ])
{
return false;
}
diff --git a/src/PhpGpio/Sensors/MCP3002.php b/src/PhpGpio/Sensors/MCP3002.php
index e19bf0a..2c8dc7c 100644
--- a/src/PhpGpio/Sensors/MCP3002.php
+++ b/src/PhpGpio/Sensors/MCP3002.php
@@ -13,7 +13,7 @@ class MCP3002 implements SensorInterface {
private $_mosipin;
private $_misopin;
private $_cspin;
-
+
private $_gpio;
/**
@@ -24,14 +24,15 @@ class MCP3002 implements SensorInterface {
* $value = adc->read(array('channel' => 0));
* echo $value;
*
- * @param integer $clockpin The clock (CLK) pin (ex. 11)
- * @param integer $mosipin The Master Out Slave In (MOSI) pin (ex. 10)
- * @param integer $misopin The Master In Slave Out (MISO) pin (ex. 9)
- * @param integer $cspin The Chip Select (CSna) pin (ex. 8)
+ * @access public
+ * @param integer $clockpin The clock (CLK) pin (ex. 11)
+ * @param integer $mosipin The Master Out Slave In (MOSI) pin (ex. 10)
+ * @param integer $misopin The Master In Slave Out (MISO) pin (ex. 9)
+ * @param integer $cspin The Chip Select (CSna) pin (ex. 8)
*/
public function __construct($clockpin, $mosipin, $misopin, $cspin) {
$this->_gpio = new GPIO();
-
+
$this->_clockpin = $clockpin;
$this->_mosipin = $mosipin;
$this->_misopin = $misopin;
@@ -47,21 +48,22 @@ public function __construct($clockpin, $mosipin, $misopin, $cspin) {
* Read the specified channel.
* You should specify the channel (0|1) to read with the channel argument.
*
- * @param array $args
+ * @access public
+ * @param array $args
* @return integer
*/
- public function read($args = array()) {
+ public function read($args = [ ]) {
$channel = $args['channel'];
- if (!is_integer($channel) || !in_array($channel, array(0, 1))) {
+ if (!is_integer($channel) || !in_array($channel, [0, 1])) {
echo $msg = "Only 2 channels are available on a Mcp3002: 0 or 1";
throw new \InvalidArgumentException($msg);
}
-
+
// init comm
$this->_gpio->output($this->_cspin, 1);
$this->_gpio->output($this->_clockpin, 0);
$this->_gpio->output($this->_cspin, 0);
-
+
// channel selection
$cmdout = (6 + $channel) << 5;
for ($i = 0; $i < 3; $i++) {
@@ -74,7 +76,7 @@ public function read($args = array()) {
$this->_gpio->output($this->_clockpin, 1);
$this->_gpio->output($this->_clockpin, 0);
}
-
+
$adcout = 0;
// read in one empty bit, one null bit and 10 ADC bits
for ($i = 0; $i < 12; $i++) {
@@ -85,12 +87,19 @@ public function read($args = array()) {
$adcout |= 0x1;
}
}
-
+
$this->_gpio->output($this->_cspin, 1);
return $adcout >> 1;
}
-
- public function write($args = array()) {
+
+ /**
+ * write
+ *
+ * @access public
+ * @param array, $args
+ * @return boolean
+ */
+ public function write($args = [ ]) {
return false;
}
}
diff --git a/src/PhpGpio/Sensors/SensorInterface.php b/src/PhpGpio/Sensors/SensorInterface.php
index 2d27e7b..decc5aa 100644
--- a/src/PhpGpio/Sensors/SensorInterface.php
+++ b/src/PhpGpio/Sensors/SensorInterface.php
@@ -11,17 +11,19 @@ interface SensorInterface
/**
* Read
*
- * @param array $args
+ * @access public
+ * @param array $args
* @return double
*/
- public function read($args = array());
+ public function read($args = [ ]);
/**
* Write
*
- * @param array $args
+ * @access public
+ * @param array $args
* @return $this
*/
- public function write($args = array());
+ public function write($args = [ ]);
}
diff --git a/tests/PhpGpio/Tests/GpioTest.php b/tests/PhpGpio/Tests/GpioTest.php
index 9e33b60..ca2e81b 100755
--- a/tests/PhpGpio/Tests/GpioTest.php
+++ b/tests/PhpGpio/Tests/GpioTest.php
@@ -4,9 +4,6 @@
use PhpGpio\Gpio;
-/**
- * @author Ronan Guilloux
- */
class GpioTest extends \PhpUnit_Framework_TestCase
{
private $gpio;
diff --git a/tests/PhpGpio/Tests/PiTest.php b/tests/PhpGpio/Tests/PiTest.php
index 04e0c1f..72829d7 100755
--- a/tests/PhpGpio/Tests/PiTest.php
+++ b/tests/PhpGpio/Tests/PiTest.php
@@ -4,9 +4,6 @@
use PhpGpio\Pi;
-/**
- * @author Ronan Guilloux , Bas Bloemsaat
- */
class PiTest extends \PhpUnit_Framework_TestCase
{
private $gpio;