2780 lines
966 KiB
HTML
2780 lines
966 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
|
|||
|
<html>
|
|||
|
|
|||
|
<head>
|
|||
|
|
|||
|
<meta charset="utf-8" />
|
|||
|
<meta name="generator" content="pandoc" />
|
|||
|
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
|
|||
|
|
|||
|
|
|||
|
<meta name="author" content="Zuguang Gu (z.gu@dkfz.de)" />
|
|||
|
|
|||
|
<meta name="date" content="2020-12-15" />
|
|||
|
|
|||
|
<title>Parsing command-line arguments by Getopt::Long</title>
|
|||
|
|
|||
|
<script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
|||
|
// be compatible with the behavior of Pandoc < 2.8).
|
|||
|
document.addEventListener('DOMContentLoaded', function(e) {
|
|||
|
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
|
|||
|
var i, h, a;
|
|||
|
for (i = 0; i < hs.length; i++) {
|
|||
|
h = hs[i];
|
|||
|
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
|||
|
a = h.attributes;
|
|||
|
while (a.length > 0) h.removeAttribute(a[0].name);
|
|||
|
}
|
|||
|
});
|
|||
|
</script>
|
|||
|
<script>/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
|
|||
|
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each(
|
|||
|
|
|||
|
return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</tex
|
|||
|
return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h
|
|||
|
</script>
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|||
|
<style type="text/css">html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:0 0!important;-webkit-box-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}@font-face{font-family:'Glyphicons Halflings';src:url(data:application/vnd.ms-fontobject;base64,n04AAEFNAAACAAIABAAAAAAABQAAAAAAAAABAJABAAAEAExQAAAAAAAAAAIAAAAAAAAAAAEAAAAAAAAAJxJ/LAAAAAAAAAAAAAAAAAAAAAAAACgARwBMAFkAUABIAEkAQwBPAE4AUwAgAEgAYQBsAGYAbABpAG4AZwBzAAAADgBSAGUAZwB1AGwAYQByAAAAeABWAGUAcgBzAGkAbwBuACAAMQAuADAAMAA5ADsAUABTACAAMAAwADEALgAwADAAOQA7AGgAbwB0AGMAbwBuAHYAIAAxAC4AMAAuADcAMAA7AG0AYQBrAGUAbwB0AGYALgBsAGkAYgAyAC4ANQAuADUAOAAzADIAOQAAADgARwBMAFkAUABIAEkAQwBPAE4AUwAgAEgAYQBsAGYAbABpAG4AZwBzACAAUgBlAGcAdQBsAGEAcgAAAAAAQlNHUAAAAAAAAAAAAAAAAAAAAAADAKncAE0TAE0ZAEbuFM3pjM/SEdmjKHUbyow8ATBE40IvWA3vTu8LiABDQ+pexwUMcm1SMnNryctQSiI1K5ZnbOlXKmnVV5YvRe6RnNMFNCOs1KNVpn6yZhCJkRtVRNzEufeIq7HgSrcx4S8h/v4vnrrKc6oCNxmSk2uKlZQHBii6iKFoH0746ThvkO1kJHlxjrkxs+LWORaDQBEtiYJIR5IB9Bi1UyL4Rmr0BNigNkMzlKQmnofBHviqVzUxwdMb3NdCn69hy+pRYVKGVS/1tnsqv4LL7wCCPZZAZPT4aCShHjHJVNuXbmMrY5LeQaGnvAkXlVrJgKRAUdFjrWEah9XebPeQMj7KS7DIBAFt8ycgC5PLGUOHSE3ErGZCiViNLL5ZARfywnCoZaKQCu6NuFX42AEeKtKUGnr/Cm2Cy8tpFhBPMW5Fxi4Qm4TkDWh4IWFDClhU2hRWosUWqcKLlgyXB+lSHaWaHiWlBAR8SeSgSPCQxdVQgzUixWKSTrIQEbU94viDctkvX+VSjJuUmV8L4CXShI11esnp0pjWNZIyxKHS4wVQ2ime1P4RnhvGw0aDN1OLAXGERsB7buFpFGGBAre4QEQR0HOIO5oYH305G+KspT/FupEGGafCCwxSe6ZUa+073rXHnNdVXE6eW
|
|||
|
</style>
|
|||
|
<script>/*!
|
|||
|
* Bootstrap v3.3.5 (http://getbootstrap.com)
|
|||
|
* Copyright 2011-2015 Twitter, Inc.
|
|||
|
* Licensed under the MIT license
|
|||
|
*/
|
|||
|
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.5",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.5",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),a(c.target).is('input[type="radio"]')||a(c.target).is('input[type="checkbox"]')||c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==type
|
|||
|
d.trigger("activate.bs.scrollspy")},b.prototype.clear=function(){a(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var d=a.fn.scrollspy;a.fn.scrollspy=c,a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=d,this},a(window).on("load.bs.scrollspy.data-api",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);c.call(b,b.data())})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new c(this)),"string"==typeof b&&e[b]()})}var c=function(b){this.element=a(b)};c.VERSION="3.3.5",c.TRANSITION_DURATION=150,c.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.data("target");if(d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),!b.parent("li").hasClass("active")){var e=c.find(".active:last a"),f=a.Event("hide.bs.tab",{relatedTarget:b[0]}),g=a.Event("show.bs.tab",{relatedTarget:e[0]});if(e.trigger(f),b.trigger(g),!g.isDefaultPrevented()&&!f.isDefaultPrevented()){var h=a(d);this.activate(b.closest("li"),c),this.activate(h,h.parent(),function(){e.trigger({type:"hidden.bs.tab",relatedTarget:b[0]}),b.trigger({type:"shown.bs.tab",relatedTarget:e[0]})})}}},c.prototype.activate=function(b,d,e){function f(){g.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.5",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affi
|
|||
|
<script>/**
|
|||
|
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
|||
|
*/
|
|||
|
// Only run this code in IE 8
|
|||
|
if (!!window.navigator.userAgent.match("MSIE 8")) {
|
|||
|
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document);
|
|||
|
};
|
|||
|
</script>
|
|||
|
<script>/*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
|
|||
|
* Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
|
|||
|
* */
|
|||
|
|
|||
|
// Only run this code in IE 8
|
|||
|
if (!!window.navigator.userAgent.match("MSIE 8")) {
|
|||
|
!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmVal
|
|||
|
};
|
|||
|
</script>
|
|||
|
<script>/*! jQuery UI - v1.11.4 - 2016-01-05
|
|||
|
* http://jqueryui.com
|
|||
|
* Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, accordion.js, autocomplete.js, button.js, dialog.js, menu.js, progressbar.js, selectmenu.js, slider.js, spinner.js, tabs.js, tooltip.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js
|
|||
|
* Copyright jQuery Foundation and other contributors; Licensed MIT */
|
|||
|
|
|||
|
(function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/^(input|select|textarea|button|object)$/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}function s(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var n=0,a=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove
|
|||
|
})),n?(a.isOver||(a.isOver=1,s._parent=i.helper.parent(),a.currentItem=i.helper.appendTo(a.element).data("ui-sortable-item",!0),a.options._helper=a.options.helper,a.options.helper=function(){return i.helper[0]},t.target=a.currentItem[0],a._mouseCapture(t,!0),a._mouseStart(t,!0,!0),a.offset.click.top=s.offset.click.top,a.offset.click.left=s.offset.click.left,a.offset.parent.left-=s.offset.parent.left-a.offset.parent.left,a.offset.parent.top-=s.offset.parent.top-a.offset.parent.top,s._trigger("toSortable",t),s.dropped=a.element,e.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,a.fromOutside=s),a.currentItem&&(a._mouseDrag(t),i.position=a.position)):a.isOver&&(a.isOver=0,a.cancelHelperRemoval=!0,a.options._revert=a.options.revert,a.options.revert=!1,a._trigger("out",t,a._uiHash(a)),a._mouseStop(t,!0),a.options.revert=a.options._revert,a.options.helper=a.options._helper,a.placeholder&&a.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(t),i.position=s._generatePosition(t,!0),s._trigger("fromSortable",t),s.dropped=!1,e.each(s.sortables,function(){this.refreshPositions()}))})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,i,s){var n=e("body"),a=s.options;n.css("cursor")&&(a._cursor=n.css("cursor")),n.css("cursor",a.cursor)},stop:function(t,i,s){var n=s.options;n._cursor&&e("body").css("cursor",n._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("opacity")&&(a._opacity=n.css("opacity")),n.css("opacity",a.opacity)},stop:function(t,i,s){var n=s.options;n._opacity&&e(i.helper).css("opacity",n._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(e,t,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(t,i,s){var n=s.options,a=!1,o=s.scrollParentNotHidden[0],r=s.document[0];o!==r&&"HTML"!==o.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+o.offsetHeight-t.pageY<n.scrollSensitivity?o.scrollTop=a=o.scrollTop+n.scrollSpeed:t.pageY-s.overflowOffset.top<n.scrollSensitivity&&(o.scrollTop=a=o.scrollTop-n.scrollSpeed)),n.axis&&"y"===n.axis||(s.overflowOffset.left+o.offsetWidth-t.pageX<n.scrollSensitivity?o.scrollLeft=a=o.scrollLeft+n.scrollSpeed:t.pageX-s.overflowOffset.left<n.scrollSensitivity&&(o.scrollLeft=a=o.scrollLeft-n.scrollSpeed))):(n.axis&&"x"===n.axis||(t.pageY-e(r).scrollTop()<n.scrollSensitivity?a=e(r).scrollTop(e(r).scrollTop()-n.scrollSpeed):e(window).height()-(t.pageY-e(r).scrollTop())<n.scrollSensitivity&&(a=e(r).scrollTop(e(r).scrollTop()+n.scrollSpeed))),n.axis&&"y"===n.axis||(t.pageX-e(r).scrollLeft()<n.scrollSensitivity?a=e(r).scrollLeft(e(r).scrollLeft()-n.scrollSpeed):e(window).width()-(t.pageX-e(r).scrollLeft())<n.scrollSensitivity&&(a=e(r).scrollLeft(e(r).scrollLeft()+n.scrollSpeed)))),a!==!1&&e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(s,t)}}),e.ui.plugin.add("draggable","snap",{start:function(t,i,s){var n=s.options;s.snapElements=[],e(n.snap.constructor!==String?n.snap.items||":data(ui-draggable)":n.snap).each(function(){var t=e(this),i=t.offset();this!==s.element[0]&&s.snapElements.push({item:this,width:t.outerWidth(),height:t.outerHeight(),top:i.top,left:i.left})})},drag:function(t,i,s){var n,a,o,r,h,l,u,d,c,p,f=s.options,m=f.snapTolerance,g=i.offset.left,v=g+s.helperProportions.width,y=i.offset.top,b=y+s.helperProportions.height;for(c=s.snapElements.length-1;c>=0;c--)h=s.snapElements[c].left-s.margins.left,l=h+s.snapElements[c].width,u=s.snapElements[c].top-s.margins.top,d=u+s.snapElements[c].height,h-m>v||g>l+m||u-m>b||y>d+m||!e.contains(s.snapElements[c].item.ownerDocument,s.snapElements[c].item)?(s.snapElements[c].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=!1):("inner"!==f.snapMode&&(n=m>=Math.abs(u-b),a=m>=Math.abs(d-y),o=m>=Math.abs(h-v),r=m>=Math.abs(l-g),n&&
|
|||
|
i&&i.element!==s.element[0]&&("touch"===n.tolerance?l=!(i.left>r||a>i.right||i.top>h||o>i.bottom):"fit"===n.tolerance&&(l=i.left>a&&r>i.right&&i.top>o&&h>i.bottom),l?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,s._trigger("selecting",t,{selecting:i.element}))):(i.selecting&&((t.metaKey||t.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",t,{unselecting:i.element}))),i.selected&&(t.metaKey||t.ctrlKey||i.startselected||(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",t,{unselecting:i.element})))))}),!1}},_mouseStop:function(t){var i=this;return this.dragged=!1,e(".ui-unselecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",t,{unselected:s.element})}),e(".ui-selecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",t,{selected:s.element})}),this._trigger("stop",t),this.helper.remove(),!1}}),e.widget("ui.sortable",e.ui.mouse,{version:"1.11.4",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(e,t,i){return e>=t&&t+i>e},_isFloating:function(e){return/left|right/.test(e.css("float"))||/inline|table-cell/.test(e.css("display"))},_create:function(){this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(e,t){this._super(e,t),"handle"===e&&this._setHandleClassName()},_setHandleClassName:function(){this.element.find(".ui-sortable-handle").removeClass("ui-sortable-handle"),e.each(this.items,function(){(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item).addClass("ui-sortable-handle")})},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").find(".ui-sortable-handle").removeClass("ui-sortable-handle"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(t,i){var s=null,n=!1,a=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(t),e(t.target).parents().each(function(){return e.data(this,a.widgetName+"-item")===a?(s=e(this),!1):void 0}),e.data(t.target,a.widgetName+"-item")===a&&(s=e(t.target)),s?!this.options.handle||i||(e(this.options.handle,s).find("*").addBack().each(function(){this===t.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(t,i,s){var n,a,o=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffse
|
|||
|
t.preventDefault(),a&&!i.collapsible||this._trigger("beforeActivate",t,l)===!1||(i.active=o?!1:this.headers.index(n),this.active=a?e():n,this._toggle(l),s.removeClass("ui-accordion-header-active ui-state-active"),i.icons&&s.children(".ui-accordion-header-icon").removeClass(i.icons.activeHeader).addClass(i.icons.header),a||(n.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),i.icons&&n.children(".ui-accordion-header-icon").removeClass(i.icons.header).addClass(i.icons.activeHeader),n.next().addClass("ui-accordion-content-active")))},_toggle:function(t){var i=t.newPanel,s=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,t):(s.hide(),i.show(),this._toggleComplete(t)),s.attr({"aria-hidden":"true"}),s.prev().attr({"aria-selected":"false","aria-expanded":"false"}),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===parseInt(e(this).attr("tabIndex"),10)}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(e,t,i){var s,n,a,o=this,r=0,h=e.css("box-sizing"),l=e.length&&(!t.length||e.index()<t.index()),u=this.options.animate||{},d=l&&u.down||u,c=function(){o._toggleComplete(i)};return"number"==typeof d&&(a=d),"string"==typeof d&&(n=d),n=n||d.easing||u.easing,a=a||d.duration||u.duration,t.length?e.length?(s=e.show().outerHeight(),t.animate(this.hideProps,{duration:a,easing:n,step:function(e,t){t.now=Math.round(e)}}),e.hide().animate(this.showProps,{duration:a,easing:n,complete:c,step:function(e,i){i.now=Math.round(e),"height"!==i.prop?"content-box"===h&&(r+=i.now):"content"!==o.options.heightStyle&&(i.now=Math.round(s-t.outerHeight()-r),r=0)}}),void 0):t.animate(this.hideProps,a,n,c):e.animate(this.showProps,a,n,c)},_toggleComplete:function(e){var t=e.oldPanel;t.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),t.length&&(t.parent()[0].className=t.parent()[0].className),this._trigger("activate",null,e)}}),e.widget("ui.menu",{version:"1.11.4",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item":function(e){e.preventDefault()},"click .ui-menu-item":function(t){var i=e(t.target);!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&e(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){if(!this.previousFilter){var i=e(t.currentTarget);i.siblings(".ui-state-active").removeClass("ui-state-active"),this.focus(t,i)}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var i=this.active||this.element.find(this.options.items).eq(0);t||this.focus(e,i)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(e){this._closeOnDocumentClick(e)&&this.collapseAll(e),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAt
|
|||
|
},_createButtonPane:function(){this.uiDialogButtonPane=e("<div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),this.uiButtonSet=e("<div>").addClass("ui-dialog-buttonset").appendTo(this.uiDialogButtonPane),this._createButtons()},_createButtons:function(){var t=this,i=this.options.buttons;return this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),e.isEmptyObject(i)||e.isArray(i)&&!i.length?(this.uiDialog.removeClass("ui-dialog-buttons"),void 0):(e.each(i,function(i,s){var n,a;s=e.isFunction(s)?{click:s,text:i}:s,s=e.extend({type:"button"},s),n=s.click,s.click=function(){n.apply(t.element[0],arguments)},a={icons:s.icons,text:s.showText},delete s.icons,delete s.showText,e("<button></button>",s).button(a).appendTo(t.uiButtonSet)}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog),void 0)},_makeDraggable:function(){function t(e){return{position:e.position,offset:e.offset}}var i=this,s=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(s,n){e(this).addClass("ui-dialog-dragging"),i._blockFrames(),i._trigger("dragStart",s,t(n))},drag:function(e,s){i._trigger("drag",e,t(s))},stop:function(n,a){var o=a.offset.left-i.document.scrollLeft(),r=a.offset.top-i.document.scrollTop();s.position={my:"left top",at:"left"+(o>=0?"+":"")+o+" "+"top"+(r>=0?"+":"")+r,of:i.window},e(this).removeClass("ui-dialog-dragging"),i._unblockFrames(),i._trigger("dragStop",n,t(a))}})},_makeResizable:function(){function t(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}var i=this,s=this.options,n=s.resizable,a=this.uiDialog.css("position"),o="string"==typeof n?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:s.maxWidth,maxHeight:s.maxHeight,minWidth:s.minWidth,minHeight:this._minHeight(),handles:o,start:function(s,n){e(this).addClass("ui-dialog-resizing"),i._blockFrames(),i._trigger("resizeStart",s,t(n))},resize:function(e,s){i._trigger("resize",e,t(s))},stop:function(n,a){var o=i.uiDialog.offset(),r=o.left-i.document.scrollLeft(),h=o.top-i.document.scrollTop();s.height=i.uiDialog.height(),s.width=i.uiDialog.width(),s.position={my:"left top",at:"left"+(r>=0?"+":"")+r+" "+"top"+(h>=0?"+":"")+h,of:i.window},e(this).removeClass("ui-dialog-resizing"),i._unblockFrames(),i._trigger("resizeStop",n,t(a))}}).css("position",a)},_trackFocus:function(){this._on(this.widget(),{focusin:function(t){this._makeFocusTarget(),this._focusedElement=e(t.target)}})},_makeFocusTarget:function(){this._untrackInstance(),this._trackingInstances().unshift(this)},_untrackInstance:function(){var t=this._trackingInstances(),i=e.inArray(this,t);-1!==i&&t.splice(i,1)},_trackingInstances:function(){var e=this.document.data("ui-dialog-instances");return e||(e=[],this.document.data("ui-dialog-instances",e)),e},_minHeight:function(){var e=this.options;return"auto"===e.height?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(){var e=this.uiDialog.is(":visible");e||this.uiDialog.show(),this.uiDialog.position(this.options.position),e||this.uiDialog.hide()},_setOptions:function(t){var i=this,s=!1,n={};e.each(t,function(e,t){i._setOption(e,t),e in i.sizeRelatedOptions&&(s=!0),e in i.resizableRelatedOptions&&(n[e]=t)}),s&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",n)},_setOption:function(e,t){var i,s,n=this.uiDialog;"dialogClass"===e&&n.removeClass(this.options.dialogClass).addClass(t),"disabled"!==e&&(this._super(e,t),"appendTo"===e&&this.uiDialog.appendTo(this._appendTo()),"buttons"===e&&this._createButtons(),"closeText"===e&&this.uiDialogTitlebarClose.button({label:""+t}),"draggable"===e&&(i=n.is(":data(ui-draggable)"),i&&!t&&n.draggable("destroy"),!i&&t&&this._makeDraggable()),"position"===e&&this._position(),"resizable"===e&&(s=n.is(":data(ui-resizable)"),s&&!t&&n.resizable("destroy"),s&&"string"==typeo
|
|||
|
},_format:function(e){return""===e?"":window.Globalize&&this.options.numberFormat?Globalize.format(e,this.options.numberFormat,this.options.culture):e},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},isValid:function(){var e=this.value();return null===e?!1:e===this._adjustValue(e)},_value:function(e,t){var i;""!==e&&(i=this._parse(e),null!==i&&(t||(i=this._adjustValue(i)),e=this._format(i))),this.element.val(e),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:s(function(e){this._stepUp(e)}),_stepUp:function(e){this._start()&&(this._spin((e||1)*this.options.step),this._stop())},stepDown:s(function(e){this._stepDown(e)}),_stepDown:function(e){this._start()&&(this._spin((e||1)*-this.options.step),this._stop())},pageUp:s(function(e){this._stepUp((e||1)*this.options.page)}),pageDown:s(function(e){this._stepDown((e||1)*this.options.page)}),value:function(e){return arguments.length?(s(this._value).call(this,e),void 0):this._parse(this.element.val())},widget:function(){return this.uiSpinner}}),e.widget("ui.tabs",{version:"1.11.4",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_isLocal:function(){var e=/#.*$/;return function(t){var i,s;t=t.cloneNode(!1),i=t.href.replace(e,""),s=location.href.replace(e,"");try{i=decodeURIComponent(i)}catch(n){}try{s=decodeURIComponent(s)}catch(n){}return t.hash.length>1&&i===s}}(),_create:function(){var t=this,i=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",i.collapsible),this._processTabs(),i.active=this._initialActive(),e.isArray(i.disabled)&&(i.disabled=e.unique(i.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(i.active):e(),this._refresh(),this.active.length&&this.load(i.active)},_initialActive:function(){var t=this.options.active,i=this.options.collapsible,s=location.hash.substring(1);return null===t&&(s&&this.tabs.each(function(i,n){return e(n).attr("aria-controls")===s?(t=i,!1):void 0}),null===t&&(t=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===t||-1===t)&&(t=this.tabs.length?0:!1)),t!==!1&&(t=this.tabs.index(this.tabs.eq(t)),-1===t&&(t=i?!1:0)),!i&&t===!1&&this.anchors.length&&(t=0),t},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var i=e(this.document[0].activeElement).closest("li"),s=this.tabs.index(i),n=!0;if(!this._handlePageNav(t)){switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:s++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:n=!1,s--;break;case e.ui.keyCode.END:s=this.anchors.length-1;break;case e.ui.keyCode.HOME:s=0;break;case e.ui.keyCode.SPACE:return t.preventDefault(),clearTimeout(this.activating),this._activate(s),void 0;case e.ui.keyCode.ENTER:return t.preventDefault(),clearTimeout(this.activating),this._activate(s===this.options.active?!1:s),void 0;default:return}t.preventDefault(),clearTimeout(this.activating),s=this._focusNextTab(s,n),t.ctrlKey||t.metaKey||(i.attr("aria-selected","false"),this.tabs.eq(s).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",s)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){return t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options
|
|||
|
}})},e.effects.effect.bounce=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","height","width"],h=e.effects.setMode(o,t.mode||"effect"),l="hide"===h,u="show"===h,d=t.direction||"up",c=t.distance,p=t.times||5,f=2*p+(u||l?1:0),m=t.duration/f,g=t.easing,v="up"===d||"down"===d?"top":"left",y="up"===d||"left"===d,b=o.queue(),_=b.length;for((u||l)&&r.push("opacity"),e.effects.save(o,r),o.show(),e.effects.createWrapper(o),c||(c=o["top"===v?"outerHeight":"outerWidth"]()/3),u&&(a={opacity:1},a[v]=0,o.css("opacity",0).css(v,y?2*-c:2*c).animate(a,m,g)),l&&(c/=Math.pow(2,p-1)),a={},a[v]=0,s=0;p>s;s++)n={},n[v]=(y?"-=":"+=")+c,o.animate(n,m,g).animate(a,m,g),c=l?2*c:c/2;l&&(n={opacity:0},n[v]=(y?"-=":"+=")+c,o.animate(n,m,g)),o.queue(function(){l&&o.hide(),e.effects.restore(o,r),e.effects.removeWrapper(o),i()}),_>1&&b.splice.apply(b,[1,0].concat(b.splice(_,f+1))),o.dequeue()},e.effects.effect.clip=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","height","width"],h=e.effects.setMode(o,t.mode||"hide"),l="show"===h,u=t.direction||"vertical",d="vertical"===u,c=d?"height":"width",p=d?"top":"left",f={};e.effects.save(o,r),o.show(),s=e.effects.createWrapper(o).css({overflow:"hidden"}),n="IMG"===o[0].tagName?s:o,a=n[c](),l&&(n.css(c,0),n.css(p,a/2)),f[c]=l?a:0,f[p]=l?0:a/2,n.animate(f,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){l||o.hide(),e.effects.restore(o,r),e.effects.removeWrapper(o),i()}})},e.effects.effect.drop=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","opacity","height","width"],o=e.effects.setMode(n,t.mode||"hide"),r="show"===o,h=t.direction||"left",l="up"===h||"down"===h?"top":"left",u="up"===h||"left"===h?"pos":"neg",d={opacity:r?1:0};e.effects.save(n,a),n.show(),e.effects.createWrapper(n),s=t.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,r&&n.css("opacity",0).css(l,"pos"===u?-s:s),d[l]=(r?"pos"===u?"+=":"-=":"pos"===u?"-=":"+=")+s,n.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}})},e.effects.effect.explode=function(t,i){function s(){b.push(this),b.length===d*c&&n()}function n(){p.css({visibility:"visible"}),e(b).remove(),m||p.hide(),i()}var a,o,r,h,l,u,d=t.pieces?Math.round(Math.sqrt(t.pieces)):3,c=d,p=e(this),f=e.effects.setMode(p,t.mode||"hide"),m="show"===f,g=p.show().css("visibility","hidden").offset(),v=Math.ceil(p.outerWidth()/c),y=Math.ceil(p.outerHeight()/d),b=[];for(a=0;d>a;a++)for(h=g.top+a*y,u=a-(d-1)/2,o=0;c>o;o++)r=g.left+o*v,l=o-(c-1)/2,p.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-o*v,top:-a*y}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:v,height:y,left:r+(m?l*v:0),top:h+(m?u*y:0),opacity:m?0:1}).animate({left:r+(m?0:l*v),top:h+(m?0:u*y),opacity:m?1:0},t.duration||500,t.easing,s)},e.effects.effect.fade=function(t,i){var s=e(this),n=e.effects.setMode(s,t.mode||"toggle");s.animate({opacity:n},{queue:!1,duration:t.duration,easing:t.easing,complete:i})},e.effects.effect.fold=function(t,i){var s,n,a=e(this),o=["position","top","bottom","left","right","height","width"],r=e.effects.setMode(a,t.mode||"hide"),h="show"===r,l="hide"===r,u=t.size||15,d=/([0-9]+)%/.exec(u),c=!!t.horizFirst,p=h!==c,f=p?["width","height"]:["height","width"],m=t.duration/2,g={},v={};e.effects.save(a,o),a.show(),s=e.effects.createWrapper(a).css({overflow:"hidden"}),n=p?[s.width(),s.height()]:[s.height(),s.width()],d&&(u=parseInt(d[1],10)/100*n[l?0:1]),h&&s.css(c?{height:0,width:u}:{height:u,width:0}),g[f[0]]=h?n[0]:u,v[f[1]]=h?n[1]:0,s.animate(g,m,t.easing).animate(v,m,t.easing,function(){l&&a.hide(),e.effects.restore(a,o),e.effects.removeWrapper(a),i()})},e.effects.effect.highlight=function(t,i){var s=e(this),n=["backgroundImage","backgroundColor","opacity"],a=e.effects.setMode(s,t.mode||"show"),o={backgroundColor:s.css("backgroundColor")};"hide"===a&&(o.opacity=0),e.effects.save(s,n),s.show().css({backgroundImage:"none",back
|
|||
|
<style type="text/css">
|
|||
|
|
|||
|
.tocify {
|
|||
|
width: 20%;
|
|||
|
max-height: 90%;
|
|||
|
overflow: auto;
|
|||
|
margin-left: 2%;
|
|||
|
position: fixed;
|
|||
|
border: 1px solid #ccc;
|
|||
|
border-radius: 6px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify ul, .tocify li {
|
|||
|
list-style: none;
|
|||
|
margin: 0;
|
|||
|
padding: 0;
|
|||
|
border: none;
|
|||
|
line-height: 30px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify-header {
|
|||
|
text-indent: 10px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify-subheader {
|
|||
|
text-indent: 20px;
|
|||
|
display: none;
|
|||
|
}
|
|||
|
|
|||
|
.tocify-subheader li {
|
|||
|
font-size: 12px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify-subheader .tocify-subheader {
|
|||
|
text-indent: 30px;
|
|||
|
}
|
|||
|
.tocify-subheader .tocify-subheader .tocify-subheader {
|
|||
|
text-indent: 40px;
|
|||
|
}
|
|||
|
.tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader {
|
|||
|
text-indent: 50px;
|
|||
|
}
|
|||
|
.tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader {
|
|||
|
text-indent: 60px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify .tocify-item > a, .tocify .nav-list .nav-header {
|
|||
|
margin: 0px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify .tocify-item a, .tocify .list-group-item {
|
|||
|
padding: 5px;
|
|||
|
}
|
|||
|
.tocify .nav-pills > li {
|
|||
|
float: none;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
</style>
|
|||
|
<script>/* jquery Tocify - v1.9.1 - 2013-10-22
|
|||
|
* http://www.gregfranko.com/jquery.tocify.js/
|
|||
|
* Copyright (c) 2013 Greg Franko; Licensed MIT */
|
|||
|
|
|||
|
// Immediately-Invoked Function Expression (IIFE) [Ben Alman Blog Post](http://benalman.com/news/2010/11/immediately-invoked-function-expression/) that calls another IIFE that contains all of the plugin logic. I used this pattern so that anyone viewing this code would not have to scroll to the bottom of the page to view the local parameters that were passed to the main IIFE.
|
|||
|
(function(tocify) {
|
|||
|
|
|||
|
// ECMAScript 5 Strict Mode: [John Resig Blog Post](http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/)
|
|||
|
"use strict";
|
|||
|
|
|||
|
// Calls the second IIFE and locally passes in the global jQuery, window, and document objects
|
|||
|
tocify(window.jQuery, window, document);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Locally passes in `jQuery`, the `window` object, the `document` object, and an `undefined` variable. The `jQuery`, `window` and `document` objects are passed in locally, to improve performance, since javascript first searches for a variable match within the local variables set before searching the global variables set. All of the global variables are also passed in locally to be minifier friendly. `undefined` can be passed in locally, because it is not a reserved word in JavaScript.
|
|||
|
(function($, window, document, undefined) {
|
|||
|
|
|||
|
// ECMAScript 5 Strict Mode: [John Resig Blog Post](http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/)
|
|||
|
"use strict";
|
|||
|
|
|||
|
var tocClassName = "tocify",
|
|||
|
tocClass = "." + tocClassName,
|
|||
|
tocFocusClassName = "tocify-focus",
|
|||
|
tocHoverClassName = "tocify-hover",
|
|||
|
hideTocClassName = "tocify-hide",
|
|||
|
hideTocClass = "." + hideTocClassName,
|
|||
|
headerClassName = "tocify-header",
|
|||
|
headerClass = "." + headerClassName,
|
|||
|
subheaderClassName = "tocify-subheader",
|
|||
|
subheaderClass = "." + subheaderClassName,
|
|||
|
itemClassName = "tocify-item",
|
|||
|
itemClass = "." + itemClassName,
|
|||
|
extendPageClassName = "tocify-extend-page",
|
|||
|
extendPageClass = "." + extendPageClassName;
|
|||
|
|
|||
|
// Calling the jQueryUI Widget Factory Method
|
|||
|
$.widget("toc.tocify", {
|
|||
|
|
|||
|
//Plugin version
|
|||
|
version: "1.9.1",
|
|||
|
|
|||
|
// These options will be used as defaults
|
|||
|
options: {
|
|||
|
|
|||
|
// **context**: Accepts String: Any jQuery selector
|
|||
|
// The container element that holds all of the elements used to generate the table of contents
|
|||
|
context: "body",
|
|||
|
|
|||
|
// **ignoreSelector**: Accepts String: Any jQuery selector
|
|||
|
// A selector to any element that would be matched by selectors that you wish to be ignored
|
|||
|
ignoreSelector: null,
|
|||
|
|
|||
|
// **selectors**: Accepts an Array of Strings: Any jQuery selectors
|
|||
|
// The element's used to generate the table of contents. The order is very important since it will determine the table of content's nesting structure
|
|||
|
selectors: "h1, h2, h3",
|
|||
|
|
|||
|
// **showAndHide**: Accepts a boolean: true or false
|
|||
|
// Used to determine if elements should be shown and hidden
|
|||
|
showAndHide: true,
|
|||
|
|
|||
|
// **showEffect**: Accepts String: "none", "fadeIn", "show", or "slideDown"
|
|||
|
// Used to display any of the table of contents nested items
|
|||
|
showEffect: "slideDown",
|
|||
|
|
|||
|
// **showEffectSpeed**: Accepts Number (milliseconds) or String: "slow", "medium", or "fast"
|
|||
|
// The time duration of the show animation
|
|||
|
showEffectSpeed: "medium",
|
|||
|
|
|||
|
// **hideEffect**: Accepts String: "none", "fadeOut", "hide", or "slideUp"
|
|||
|
// Used to hide any of the table of contents nested items
|
|||
|
hideEffect: "slideUp",
|
|||
|
|
|||
|
// **hideEffectSpeed**: Accepts Number (milliseconds) or String: "slow", "medium", or "fast"
|
|||
|
// The time duration of the hide animation
|
|||
|
hideEffectSpeed: "medium",
|
|||
|
|
|||
|
// **smoothScroll**: Accepts a boolean: true or false
|
|||
|
// Determines if a jQuery animation should be used to scroll to specific table of contents items on the page
|
|||
|
smoothScroll: true,
|
|||
|
|
|||
|
// **smoothScrollSpeed**: Accepts Number (milliseconds) or String: "slow", "medium", or "fast"
|
|||
|
// The time duration of the smoothScroll animation
|
|||
|
smoothScrollSpeed: "medium",
|
|||
|
|
|||
|
// **scrollTo**: Accepts Number (pixels)
|
|||
|
// The amount of space between the top of page and the selected table of contents item after the page has been scrolled
|
|||
|
scrollTo: 0,
|
|||
|
|
|||
|
// **showAndHideOnScroll**: Accepts a boolean: true or false
|
|||
|
// Determines if table of contents nested items should be shown and hidden while scrolling
|
|||
|
showAndHideOnScroll: true,
|
|||
|
|
|||
|
// **highlightOnScroll**: Accepts a boolean: true or false
|
|||
|
// Determines if table of contents nested items should be highlighted (set to a different color) while scrolling
|
|||
|
highlightOnScroll: true,
|
|||
|
|
|||
|
// **highlightOffset**: Accepts a number
|
|||
|
// The offset distance in pixels to trigger the next active table of contents item
|
|||
|
highlightOffset: 40,
|
|||
|
|
|||
|
// **theme**: Accepts a string: "bootstrap", "jqueryui", or "none"
|
|||
|
// Determines if Twitter Bootstrap, jQueryUI, or Tocify classes should be added to the table of contents
|
|||
|
theme: "bootstrap",
|
|||
|
|
|||
|
// **extendPage**: Accepts a boolean: true or false
|
|||
|
// If a user scrolls to the bottom of the page and the page is not tall enough to scroll to the last table of contents item, then the page height is increased
|
|||
|
extendPage: true,
|
|||
|
|
|||
|
// **extendPageOffset**: Accepts a number: pixels
|
|||
|
// How close to the bottom of the page a user must scroll before the page is extended
|
|||
|
extendPageOffset: 100,
|
|||
|
|
|||
|
// **history**: Accepts a boolean: true or false
|
|||
|
// Adds a hash to the page url to maintain history
|
|||
|
history: true,
|
|||
|
|
|||
|
// **scrollHistory**: Accepts a boolean: true or false
|
|||
|
// Adds a hash to the page url, to maintain history, when scrolling to a TOC item
|
|||
|
scrollHistory: false,
|
|||
|
|
|||
|
// **hashGenerator**: How the hash value (the anchor segment of the URL, following the
|
|||
|
// # character) will be generated.
|
|||
|
//
|
|||
|
// "compact" (default) - #CompressesEverythingTogether
|
|||
|
// "pretty" - #looks-like-a-nice-url-and-is-easily-readable
|
|||
|
// function(text, element){} - Your own hash generation function that accepts the text as an
|
|||
|
// argument, and returns the hash value.
|
|||
|
hashGenerator: "compact",
|
|||
|
|
|||
|
// **highlightDefault**: Accepts a boolean: true or false
|
|||
|
// Set's the first TOC item as active if no other TOC item is active.
|
|||
|
highlightDefault: true
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _Create
|
|||
|
// -------
|
|||
|
// Constructs the plugin. Only called once.
|
|||
|
_create: function() {
|
|||
|
|
|||
|
var self = this;
|
|||
|
|
|||
|
self.extendPageScroll = true;
|
|||
|
|
|||
|
// Internal array that keeps track of all TOC items (Helps to recognize if there are duplicate TOC item strings)
|
|||
|
self.items = [];
|
|||
|
|
|||
|
// Generates the HTML for the dynamic table of contents
|
|||
|
self._generateToc();
|
|||
|
|
|||
|
// Adds CSS classes to the newly generated table of contents HTML
|
|||
|
self._addCSSClasses();
|
|||
|
|
|||
|
self.webkit = (function() {
|
|||
|
|
|||
|
for (var prop in window) {
|
|||
|
|
|||
|
if (prop) {
|
|||
|
|
|||
|
if (prop.toLowerCase().indexOf("webkit") !== -1) {
|
|||
|
|
|||
|
return true;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return false;
|
|||
|
|
|||
|
}());
|
|||
|
|
|||
|
// Adds jQuery event handlers to the newly generated table of contents
|
|||
|
self._setEventHandlers();
|
|||
|
|
|||
|
// Binding to the Window load event to make sure the correct scrollTop is calculated
|
|||
|
$(window).load(function() {
|
|||
|
|
|||
|
// Sets the active TOC item
|
|||
|
self._setActiveElement(true);
|
|||
|
|
|||
|
// Once all animations on the page are complete, this callback function will be called
|
|||
|
$("html, body").promise().done(function() {
|
|||
|
|
|||
|
setTimeout(function() {
|
|||
|
|
|||
|
self.extendPageScroll = false;
|
|||
|
|
|||
|
}, 0);
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _generateToc
|
|||
|
// ------------
|
|||
|
// Generates the HTML for the dynamic table of contents
|
|||
|
_generateToc: function() {
|
|||
|
|
|||
|
// _Local variables_
|
|||
|
|
|||
|
// Stores the plugin context in the self variable
|
|||
|
var self = this,
|
|||
|
|
|||
|
// All of the HTML tags found within the context provided (i.e. body) that match the top level jQuery selector above
|
|||
|
firstElem,
|
|||
|
|
|||
|
// Instantiated variable that will store the top level newly created unordered list DOM element
|
|||
|
ul,
|
|||
|
ignoreSelector = self.options.ignoreSelector;
|
|||
|
|
|||
|
|
|||
|
// Determine the element to start the toc with
|
|||
|
// get all the top level selectors
|
|||
|
firstElem = [];
|
|||
|
var selectors = this.options.selectors.replace(/ /g, "").split(",");
|
|||
|
// find the first set that have at least one non-ignored element
|
|||
|
for(var i = 0; i < selectors.length; i++) {
|
|||
|
var foundSelectors = $(this.options.context).find(selectors[i]);
|
|||
|
for (var s = 0; s < foundSelectors.length; s++) {
|
|||
|
if (!$(foundSelectors[s]).is(ignoreSelector)) {
|
|||
|
firstElem = foundSelectors;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
if (firstElem.length> 0)
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
if (!firstElem.length) {
|
|||
|
|
|||
|
self.element.addClass(hideTocClassName);
|
|||
|
|
|||
|
return;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
self.element.addClass(tocClassName);
|
|||
|
|
|||
|
// Loops through each top level selector
|
|||
|
firstElem.each(function(index) {
|
|||
|
|
|||
|
//If the element matches the ignoreSelector then we skip it
|
|||
|
if ($(this).is(ignoreSelector)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
// Creates an unordered list HTML element and adds a dynamic ID and standard class name
|
|||
|
ul = $("<ul/>", {
|
|||
|
"id": headerClassName + index,
|
|||
|
"class": headerClassName
|
|||
|
}).
|
|||
|
|
|||
|
// Appends a top level list item HTML element to the previously created HTML header
|
|||
|
append(self._nestElements($(this), index));
|
|||
|
|
|||
|
// Add the created unordered list element to the HTML element calling the plugin
|
|||
|
self.element.append(ul);
|
|||
|
|
|||
|
// Finds all of the HTML tags between the header and subheader elements
|
|||
|
$(this).nextUntil(this.nodeName.toLowerCase()).each(function() {
|
|||
|
|
|||
|
// If there are no nested subheader elemements
|
|||
|
if ($(this).find(self.options.selectors).length === 0) {
|
|||
|
|
|||
|
// Loops through all of the subheader elements
|
|||
|
$(this).filter(self.options.selectors).each(function() {
|
|||
|
|
|||
|
//If the element matches the ignoreSelector then we skip it
|
|||
|
if ($(this).is(ignoreSelector)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
self._appendSubheaders.call(this, self, ul);
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If there are nested subheader elements
|
|||
|
else {
|
|||
|
|
|||
|
// Loops through all of the subheader elements
|
|||
|
$(this).find(self.options.selectors).each(function() {
|
|||
|
|
|||
|
//If the element matches the ignoreSelector then we skip it
|
|||
|
if ($(this).is(ignoreSelector)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
self._appendSubheaders.call(this, self, ul);
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
_setActiveElement: function(pageload) {
|
|||
|
|
|||
|
var self = this,
|
|||
|
|
|||
|
hash = window.location.hash.substring(1),
|
|||
|
|
|||
|
elem = self.element.find('li[data-unique="' + hash + '"]');
|
|||
|
|
|||
|
if (hash.length) {
|
|||
|
|
|||
|
// Removes highlighting from all of the list item's
|
|||
|
self.element.find("." + self.focusClass).removeClass(self.focusClass);
|
|||
|
|
|||
|
// Highlights the current list item that was clicked
|
|||
|
elem.addClass(self.focusClass);
|
|||
|
|
|||
|
// Triggers the click event on the currently focused TOC item
|
|||
|
elem.click();
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
// Removes highlighting from all of the list item's
|
|||
|
self.element.find("." + self.focusClass).removeClass(self.focusClass);
|
|||
|
|
|||
|
if (!hash.length && pageload && self.options.highlightDefault) {
|
|||
|
|
|||
|
// Highlights the first TOC item if no other items are highlighted
|
|||
|
self.element.find(itemClass).first().addClass(self.focusClass);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return self;
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _nestElements
|
|||
|
// -------------
|
|||
|
// Helps create the table of contents list by appending nested list items
|
|||
|
_nestElements: function(self, index) {
|
|||
|
|
|||
|
var arr, item, hashValue;
|
|||
|
|
|||
|
arr = $.grep(this.items, function(item) {
|
|||
|
|
|||
|
return item === self.text();
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
// If there is already a duplicate TOC item
|
|||
|
if (arr.length) {
|
|||
|
|
|||
|
// Adds the current TOC item text and index (for slight randomization) to the internal array
|
|||
|
this.items.push(self.text() + index);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If there not a duplicate TOC item
|
|||
|
else {
|
|||
|
|
|||
|
// Adds the current TOC item text to the internal array
|
|||
|
this.items.push(self.text());
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
hashValue = this._generateHashValue(arr, self, index);
|
|||
|
|
|||
|
// Appends a list item HTML element to the last unordered list HTML element found within the HTML element calling the plugin
|
|||
|
item = $("<li/>", {
|
|||
|
|
|||
|
// Sets a common class name to the list item
|
|||
|
"class": itemClassName,
|
|||
|
|
|||
|
"data-unique": hashValue
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
if (this.options.theme !== "bootstrap3") {
|
|||
|
|
|||
|
item.append($("<a/>", {
|
|||
|
|
|||
|
"html": self.html()
|
|||
|
|
|||
|
}));
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
item.html(self.html());
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Adds an HTML anchor tag before the currently traversed HTML element
|
|||
|
self.before($("<div/>", {
|
|||
|
|
|||
|
// Sets a name attribute on the anchor tag to the text of the currently traversed HTML element (also making sure that all whitespace is replaced with an underscore)
|
|||
|
"name": hashValue,
|
|||
|
|
|||
|
"data-unique": hashValue
|
|||
|
|
|||
|
}));
|
|||
|
|
|||
|
return item;
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _generateHashValue
|
|||
|
// ------------------
|
|||
|
// Generates the hash value that will be used to refer to each item.
|
|||
|
_generateHashValue: function(arr, self, index) {
|
|||
|
|
|||
|
var hashValue = "",
|
|||
|
hashGeneratorOption = this.options.hashGenerator;
|
|||
|
|
|||
|
if (hashGeneratorOption === "pretty") {
|
|||
|
|
|||
|
// prettify the text
|
|||
|
hashValue = self.text().toLowerCase().replace(/\s/g, "-");
|
|||
|
|
|||
|
// fix double hyphens
|
|||
|
while (hashValue.indexOf("--") > -1) {
|
|||
|
hashValue = hashValue.replace(/--/g, "-");
|
|||
|
}
|
|||
|
|
|||
|
// fix colon-space instances
|
|||
|
while (hashValue.indexOf(":-") > -1) {
|
|||
|
hashValue = hashValue.replace(/:-/g, "-");
|
|||
|
}
|
|||
|
|
|||
|
} else if (typeof hashGeneratorOption === "function") {
|
|||
|
|
|||
|
// call the function
|
|||
|
hashValue = hashGeneratorOption(self.text(), self);
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
// compact - the default
|
|||
|
hashValue = self.text().replace(/\s/g, "");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// add the index if we need to
|
|||
|
if (arr.length) {
|
|||
|
hashValue += "" + index;
|
|||
|
}
|
|||
|
|
|||
|
// return the value
|
|||
|
return hashValue;
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _appendElements
|
|||
|
// ---------------
|
|||
|
// Helps create the table of contents list by appending subheader elements
|
|||
|
|
|||
|
_appendSubheaders: function(self, ul) {
|
|||
|
|
|||
|
// The current element index
|
|||
|
var index = $(this).index(self.options.selectors),
|
|||
|
|
|||
|
// Finds the previous header DOM element
|
|||
|
previousHeader = $(self.options.selectors).eq(index - 1),
|
|||
|
|
|||
|
currentTagName = +$(this).prop("tagName").charAt(1),
|
|||
|
|
|||
|
previousTagName = +previousHeader.prop("tagName").charAt(1),
|
|||
|
|
|||
|
lastSubheader;
|
|||
|
|
|||
|
// If the current header DOM element is smaller than the previous header DOM element or the first subheader
|
|||
|
if (currentTagName < previousTagName) {
|
|||
|
|
|||
|
// Selects the last unordered list HTML found within the HTML element calling the plugin
|
|||
|
self.element.find(subheaderClass + "[data-tag=" + currentTagName + "]").last().append(self._nestElements($(this), index));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the current header DOM element is the same type of header(eg. h4) as the previous header DOM element
|
|||
|
else if (currentTagName === previousTagName) {
|
|||
|
|
|||
|
ul.find(itemClass).last().after(self._nestElements($(this), index));
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
// Selects the last unordered list HTML found within the HTML element calling the plugin
|
|||
|
ul.find(itemClass).last().
|
|||
|
|
|||
|
// Appends an unorderedList HTML element to the dynamic `unorderedList` variable and sets a common class name
|
|||
|
after($("<ul/>", {
|
|||
|
|
|||
|
"class": subheaderClassName,
|
|||
|
|
|||
|
"data-tag": currentTagName
|
|||
|
|
|||
|
})).next(subheaderClass).
|
|||
|
|
|||
|
// Appends a list item HTML element to the last unordered list HTML element found within the HTML element calling the plugin
|
|||
|
append(self._nestElements($(this), index));
|
|||
|
}
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _setEventHandlers
|
|||
|
// ----------------
|
|||
|
// Adds jQuery event handlers to the newly generated table of contents
|
|||
|
_setEventHandlers: function() {
|
|||
|
|
|||
|
// _Local variables_
|
|||
|
|
|||
|
// Stores the plugin context in the self variable
|
|||
|
var self = this,
|
|||
|
|
|||
|
// Instantiates a new variable that will be used to hold a specific element's context
|
|||
|
$self,
|
|||
|
|
|||
|
// Instantiates a new variable that will be used to determine the smoothScroll animation time duration
|
|||
|
duration;
|
|||
|
|
|||
|
// Event delegation that looks for any clicks on list item elements inside of the HTML element calling the plugin
|
|||
|
this.element.on("click.tocify", "li", function(event) {
|
|||
|
|
|||
|
if (self.options.history) {
|
|||
|
|
|||
|
window.location.hash = $(this).attr("data-unique");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Removes highlighting from all of the list item's
|
|||
|
self.element.find("." + self.focusClass).removeClass(self.focusClass);
|
|||
|
|
|||
|
// Highlights the current list item that was clicked
|
|||
|
$(this).addClass(self.focusClass);
|
|||
|
|
|||
|
// If the showAndHide option is true
|
|||
|
if (self.options.showAndHide) {
|
|||
|
|
|||
|
var elem = $('li[data-unique="' + $(this).attr("data-unique") + '"]');
|
|||
|
|
|||
|
self._triggerShow(elem);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
self._scrollTo($(this));
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
// Mouseenter and Mouseleave event handlers for the list item's within the HTML element calling the plugin
|
|||
|
this.element.find("li").on({
|
|||
|
|
|||
|
// Mouseenter event handler
|
|||
|
"mouseenter.tocify": function() {
|
|||
|
|
|||
|
// Adds a hover CSS class to the current list item
|
|||
|
$(this).addClass(self.hoverClass);
|
|||
|
|
|||
|
// Makes sure the cursor is set to the pointer icon
|
|||
|
$(this).css("cursor", "pointer");
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// Mouseleave event handler
|
|||
|
"mouseleave.tocify": function() {
|
|||
|
|
|||
|
if (self.options.theme !== "bootstrap") {
|
|||
|
|
|||
|
// Removes the hover CSS class from the current list item
|
|||
|
$(this).removeClass(self.hoverClass);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// only attach handler if needed (expensive in IE)
|
|||
|
if (self.options.extendPage || self.options.highlightOnScroll || self.options.scrollHistory || self.options.showAndHideOnScroll) {
|
|||
|
// Window scroll event handler
|
|||
|
$(window).on("scroll.tocify", function() {
|
|||
|
|
|||
|
// Once all animations on the page are complete, this callback function will be called
|
|||
|
$("html, body").promise().done(function() {
|
|||
|
|
|||
|
// Local variables
|
|||
|
|
|||
|
// Stores how far the user has scrolled
|
|||
|
var winScrollTop = $(window).scrollTop(),
|
|||
|
|
|||
|
// Stores the height of the window
|
|||
|
winHeight = $(window).height(),
|
|||
|
|
|||
|
// Stores the height of the document
|
|||
|
docHeight = $(document).height(),
|
|||
|
|
|||
|
scrollHeight = $("body")[0].scrollHeight,
|
|||
|
|
|||
|
// Instantiates a variable that will be used to hold a selected HTML element
|
|||
|
elem,
|
|||
|
|
|||
|
lastElem,
|
|||
|
|
|||
|
lastElemOffset,
|
|||
|
|
|||
|
currentElem;
|
|||
|
|
|||
|
if (self.options.extendPage) {
|
|||
|
|
|||
|
// If the user has scrolled to the bottom of the page and the last toc item is not focused
|
|||
|
if ((self.webkit && winScrollTop >= scrollHeight - winHeight - self.options.extendPageOffset) || (!self.webkit && winHeight + winScrollTop > docHeight - self.options.extendPageOffset)) {
|
|||
|
|
|||
|
if (!$(extendPageClass).length) {
|
|||
|
|
|||
|
lastElem = $('div[data-unique="' + $(itemClass).last().attr("data-unique") + '"]');
|
|||
|
|
|||
|
if (!lastElem.length) return;
|
|||
|
|
|||
|
// Gets the top offset of the page header that is linked to the last toc item
|
|||
|
lastElemOffset = lastElem.offset().top;
|
|||
|
|
|||
|
// Appends a div to the bottom of the page and sets the height to the difference of the window scrollTop and the last element's position top offset
|
|||
|
$(self.options.context).append($("<div/>", {
|
|||
|
|
|||
|
"class": extendPageClassName,
|
|||
|
|
|||
|
"height": Math.abs(lastElemOffset - winScrollTop) + "px",
|
|||
|
|
|||
|
"data-unique": extendPageClassName
|
|||
|
|
|||
|
}));
|
|||
|
|
|||
|
if (self.extendPageScroll) {
|
|||
|
|
|||
|
currentElem = self.element.find('li.' + self.focusClass);
|
|||
|
|
|||
|
self._scrollTo($('div[data-unique="' + currentElem.attr("data-unique") + '"]'));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// The zero timeout ensures the following code is run after the scroll events
|
|||
|
setTimeout(function() {
|
|||
|
|
|||
|
// _Local variables_
|
|||
|
|
|||
|
// Stores the distance to the closest anchor
|
|||
|
var closestAnchorDistance = null,
|
|||
|
|
|||
|
// Stores the index of the closest anchor
|
|||
|
closestAnchorIdx = null,
|
|||
|
|
|||
|
// Keeps a reference to all anchors
|
|||
|
anchors = $(self.options.context).find("div[data-unique]"),
|
|||
|
|
|||
|
anchorText;
|
|||
|
|
|||
|
// Determines the index of the closest anchor
|
|||
|
anchors.each(function(idx) {
|
|||
|
var distance = Math.abs(($(this).next().length ? $(this).next() : $(this)).offset().top - winScrollTop - self.options.highlightOffset);
|
|||
|
if (closestAnchorDistance == null || distance < closestAnchorDistance) {
|
|||
|
closestAnchorDistance = distance;
|
|||
|
closestAnchorIdx = idx;
|
|||
|
} else {
|
|||
|
return false;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
anchorText = $(anchors[closestAnchorIdx]).attr("data-unique");
|
|||
|
|
|||
|
// Stores the list item HTML element that corresponds to the currently traversed anchor tag
|
|||
|
elem = $('li[data-unique="' + anchorText + '"]');
|
|||
|
|
|||
|
// If the `highlightOnScroll` option is true and a next element is found
|
|||
|
if (self.options.highlightOnScroll && elem.length) {
|
|||
|
|
|||
|
// Removes highlighting from all of the list item's
|
|||
|
self.element.find("." + self.focusClass).removeClass(self.focusClass);
|
|||
|
|
|||
|
// Highlights the corresponding list item
|
|||
|
elem.addClass(self.focusClass);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
if (self.options.scrollHistory) {
|
|||
|
|
|||
|
if (window.location.hash !== "#" + anchorText) {
|
|||
|
|
|||
|
window.location.replace("#" + anchorText);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// If the `showAndHideOnScroll` option is true
|
|||
|
if (self.options.showAndHideOnScroll && self.options.showAndHide) {
|
|||
|
|
|||
|
self._triggerShow(elem, true);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}, 0);
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// Show
|
|||
|
// ----
|
|||
|
// Opens the current sub-header
|
|||
|
show: function(elem, scroll) {
|
|||
|
|
|||
|
// Stores the plugin context in the `self` variable
|
|||
|
var self = this,
|
|||
|
element = elem;
|
|||
|
|
|||
|
// If the sub-header is not already visible
|
|||
|
if (!elem.is(":visible")) {
|
|||
|
|
|||
|
// If the current element does not have any nested subheaders, is not a header, and its parent is not visible
|
|||
|
if (!elem.find(subheaderClass).length && !elem.parent().is(headerClass) && !elem.parent().is(":visible")) {
|
|||
|
|
|||
|
// Sets the current element to all of the subheaders within the current header
|
|||
|
elem = elem.parents(subheaderClass).add(elem);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the current element does not have any nested subheaders and is not a header
|
|||
|
else if (!elem.children(subheaderClass).length && !elem.parent().is(headerClass)) {
|
|||
|
|
|||
|
// Sets the current element to the closest subheader
|
|||
|
elem = elem.closest(subheaderClass);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//Determines what jQuery effect to use
|
|||
|
switch (self.options.showEffect) {
|
|||
|
|
|||
|
//Uses `no effect`
|
|||
|
case "none":
|
|||
|
|
|||
|
elem.show();
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
//Uses the jQuery `show` special effect
|
|||
|
case "show":
|
|||
|
|
|||
|
elem.show(self.options.showEffectSpeed);
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
//Uses the jQuery `slideDown` special effect
|
|||
|
case "slideDown":
|
|||
|
|
|||
|
elem.slideDown(self.options.showEffectSpeed);
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
//Uses the jQuery `fadeIn` special effect
|
|||
|
case "fadeIn":
|
|||
|
|
|||
|
elem.fadeIn(self.options.showEffectSpeed);
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
//If none of the above options were passed, then a `jQueryUI show effect` is expected
|
|||
|
default:
|
|||
|
|
|||
|
elem.show();
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the current subheader parent element is a header
|
|||
|
if (elem.parent().is(headerClass)) {
|
|||
|
|
|||
|
// Hides all non-active sub-headers
|
|||
|
self.hide($(subheaderClass).not(elem));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the current subheader parent element is not a header
|
|||
|
else {
|
|||
|
|
|||
|
// Hides all non-active sub-headers
|
|||
|
self.hide($(subheaderClass).not(elem.closest(headerClass).find(subheaderClass).not(elem.siblings())));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Maintains chainablity
|
|||
|
return self;
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// Hide
|
|||
|
// ----
|
|||
|
// Closes the current sub-header
|
|||
|
hide: function(elem) {
|
|||
|
|
|||
|
// Stores the plugin context in the `self` variable
|
|||
|
var self = this;
|
|||
|
|
|||
|
//Determines what jQuery effect to use
|
|||
|
switch (self.options.hideEffect) {
|
|||
|
|
|||
|
// Uses `no effect`
|
|||
|
case "none":
|
|||
|
|
|||
|
elem.hide();
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
// Uses the jQuery `hide` special effect
|
|||
|
case "hide":
|
|||
|
|
|||
|
elem.hide(self.options.hideEffectSpeed);
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
// Uses the jQuery `slideUp` special effect
|
|||
|
case "slideUp":
|
|||
|
|
|||
|
elem.slideUp(self.options.hideEffectSpeed);
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
// Uses the jQuery `fadeOut` special effect
|
|||
|
case "fadeOut":
|
|||
|
|
|||
|
elem.fadeOut(self.options.hideEffectSpeed);
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
// If none of the above options were passed, then a `jqueryUI hide effect` is expected
|
|||
|
default:
|
|||
|
|
|||
|
elem.hide();
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Maintains chainablity
|
|||
|
return self;
|
|||
|
},
|
|||
|
|
|||
|
// _triggerShow
|
|||
|
// ------------
|
|||
|
// Determines what elements get shown on scroll and click
|
|||
|
_triggerShow: function(elem, scroll) {
|
|||
|
|
|||
|
var self = this;
|
|||
|
|
|||
|
// If the current element's parent is a header element or the next element is a nested subheader element
|
|||
|
if (elem.parent().is(headerClass) || elem.next().is(subheaderClass)) {
|
|||
|
|
|||
|
// Shows the next sub-header element
|
|||
|
self.show(elem.next(subheaderClass), scroll);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the current element's parent is a subheader element
|
|||
|
else if (elem.parent().is(subheaderClass)) {
|
|||
|
|
|||
|
// Shows the parent sub-header element
|
|||
|
self.show(elem.parent(), scroll);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Maintains chainability
|
|||
|
return self;
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _addCSSClasses
|
|||
|
// --------------
|
|||
|
// Adds CSS classes to the newly generated table of contents HTML
|
|||
|
_addCSSClasses: function() {
|
|||
|
|
|||
|
// If the user wants a jqueryUI theme
|
|||
|
if (this.options.theme === "jqueryui") {
|
|||
|
|
|||
|
this.focusClass = "ui-state-default";
|
|||
|
|
|||
|
this.hoverClass = "ui-state-hover";
|
|||
|
|
|||
|
//Adds the default styling to the dropdown list
|
|||
|
this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the user wants a twitterBootstrap theme
|
|||
|
else if (this.options.theme === "bootstrap") {
|
|||
|
|
|||
|
this.element.find(headerClass + "," + subheaderClass).addClass("nav nav-list");
|
|||
|
|
|||
|
this.focusClass = "active";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If the user wants a twitterBootstrap theme
|
|||
|
else if (this.options.theme === "bootstrap3") {
|
|||
|
|
|||
|
this.element.find(headerClass + "," + subheaderClass).addClass("list-group");
|
|||
|
|
|||
|
this.element.find(itemClass).addClass("list-group-item");
|
|||
|
|
|||
|
this.focusClass = "active";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// If a user does not want a prebuilt theme
|
|||
|
else {
|
|||
|
|
|||
|
// Adds more neutral classes (instead of jqueryui)
|
|||
|
|
|||
|
this.focusClass = tocFocusClassName;
|
|||
|
|
|||
|
this.hoverClass = tocHoverClassName;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//Maintains chainability
|
|||
|
return this;
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// setOption
|
|||
|
// ---------
|
|||
|
// Sets a single Tocify option after the plugin is invoked
|
|||
|
setOption: function() {
|
|||
|
|
|||
|
// Calls the jQueryUI Widget Factory setOption method
|
|||
|
$.Widget.prototype._setOption.apply(this, arguments);
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// setOptions
|
|||
|
// ----------
|
|||
|
// Sets a single or multiple Tocify options after the plugin is invoked
|
|||
|
setOptions: function() {
|
|||
|
|
|||
|
// Calls the jQueryUI Widget Factory setOptions method
|
|||
|
$.Widget.prototype._setOptions.apply(this, arguments);
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
// _scrollTo
|
|||
|
// ---------
|
|||
|
// Scrolls to a specific element
|
|||
|
_scrollTo: function(elem) {
|
|||
|
|
|||
|
var self = this,
|
|||
|
duration = self.options.smoothScroll || 0,
|
|||
|
scrollTo = self.options.scrollTo,
|
|||
|
currentDiv = $('div[data-unique="' + elem.attr("data-unique") + '"]');
|
|||
|
|
|||
|
if (!currentDiv.length) {
|
|||
|
|
|||
|
return self;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Once all animations on the page are complete, this callback function will be called
|
|||
|
$("html, body").promise().done(function() {
|
|||
|
|
|||
|
// Animates the html and body element scrolltops
|
|||
|
$("html, body").animate({
|
|||
|
|
|||
|
// Sets the jQuery `scrollTop` to the top offset of the HTML div tag that matches the current list item's `data-unique` tag
|
|||
|
"scrollTop": currentDiv.offset().top - ($.isFunction(scrollTo) ? scrollTo.call() : scrollTo) + "px"
|
|||
|
|
|||
|
}, {
|
|||
|
|
|||
|
// Sets the smoothScroll animation time duration to the smoothScrollSpeed option
|
|||
|
"duration": duration
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
// Maintains chainability
|
|||
|
return self;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
});
|
|||
|
|
|||
|
})); //end of plugin
|
|||
|
</script>
|
|||
|
<script>
|
|||
|
|
|||
|
/**
|
|||
|
* jQuery Plugin: Sticky Tabs
|
|||
|
*
|
|||
|
* @author Aidan Lister <aidan@php.net>
|
|||
|
* adapted by Ruben Arslan to activate parent tabs too
|
|||
|
* http://www.aidanlister.com/2014/03/persisting-the-tab-state-in-bootstrap/
|
|||
|
*/
|
|||
|
(function($) {
|
|||
|
"use strict";
|
|||
|
$.fn.rmarkdownStickyTabs = function() {
|
|||
|
var context = this;
|
|||
|
// Show the tab corresponding with the hash in the URL, or the first tab
|
|||
|
var showStuffFromHash = function() {
|
|||
|
var hash = window.location.hash;
|
|||
|
var selector = hash ? 'a[href="' + hash + '"]' : 'li.active > a';
|
|||
|
var $selector = $(selector, context);
|
|||
|
if($selector.data('toggle') === "tab") {
|
|||
|
$selector.tab('show');
|
|||
|
// walk up the ancestors of this element, show any hidden tabs
|
|||
|
$selector.parents('.section.tabset').each(function(i, elm) {
|
|||
|
var link = $('a[href="#' + $(elm).attr('id') + '"]');
|
|||
|
if(link.data('toggle') === "tab") {
|
|||
|
link.tab("show");
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
// Set the correct tab when the page loads
|
|||
|
showStuffFromHash(context);
|
|||
|
|
|||
|
// Set the correct tab when a user uses their back/forward button
|
|||
|
$(window).on('hashchange', function() {
|
|||
|
showStuffFromHash(context);
|
|||
|
});
|
|||
|
|
|||
|
// Change the URL when tabs are clicked
|
|||
|
$('a', context).on('click', function(e) {
|
|||
|
history.pushState(null, null, this.href);
|
|||
|
showStuffFromHash(context);
|
|||
|
});
|
|||
|
|
|||
|
return this;
|
|||
|
};
|
|||
|
}(jQuery));
|
|||
|
|
|||
|
window.buildTabsets = function(tocID) {
|
|||
|
|
|||
|
// build a tabset from a section div with the .tabset class
|
|||
|
function buildTabset(tabset) {
|
|||
|
|
|||
|
// check for fade and pills options
|
|||
|
var fade = tabset.hasClass("tabset-fade");
|
|||
|
var pills = tabset.hasClass("tabset-pills");
|
|||
|
var navClass = pills ? "nav-pills" : "nav-tabs";
|
|||
|
|
|||
|
// determine the heading level of the tabset and tabs
|
|||
|
var match = tabset.attr('class').match(/level(\d) /);
|
|||
|
if (match === null)
|
|||
|
return;
|
|||
|
var tabsetLevel = Number(match[1]);
|
|||
|
var tabLevel = tabsetLevel + 1;
|
|||
|
|
|||
|
// find all subheadings immediately below
|
|||
|
var tabs = tabset.find("div.section.level" + tabLevel);
|
|||
|
if (!tabs.length)
|
|||
|
return;
|
|||
|
|
|||
|
// create tablist and tab-content elements
|
|||
|
var tabList = $('<ul class="nav ' + navClass + '" role="tablist"></ul>');
|
|||
|
$(tabs[0]).before(tabList);
|
|||
|
var tabContent = $('<div class="tab-content"></div>');
|
|||
|
$(tabs[0]).before(tabContent);
|
|||
|
|
|||
|
// build the tabset
|
|||
|
var activeTab = 0;
|
|||
|
tabs.each(function(i) {
|
|||
|
|
|||
|
// get the tab div
|
|||
|
var tab = $(tabs[i]);
|
|||
|
|
|||
|
// get the id then sanitize it for use with bootstrap tabs
|
|||
|
var id = tab.attr('id');
|
|||
|
|
|||
|
// see if this is marked as the active tab
|
|||
|
if (tab.hasClass('active'))
|
|||
|
activeTab = i;
|
|||
|
|
|||
|
// remove any table of contents entries associated with
|
|||
|
// this ID (since we'll be removing the heading element)
|
|||
|
$("div#" + tocID + " li a[href='#" + id + "']").parent().remove();
|
|||
|
|
|||
|
// sanitize the id for use with bootstrap tabs
|
|||
|
id = id.replace(/[.\/?&!#<>]/g, '').replace(/\s/g, '_');
|
|||
|
tab.attr('id', id);
|
|||
|
|
|||
|
// get the heading element within it, grab it's text, then remove it
|
|||
|
var heading = tab.find('h' + tabLevel + ':first');
|
|||
|
var headingText = heading.html();
|
|||
|
heading.remove();
|
|||
|
|
|||
|
// build and append the tab list item
|
|||
|
var a = $('<a role="tab" data-toggle="tab">' + headingText + '</a>');
|
|||
|
a.attr('href', '#' + id);
|
|||
|
a.attr('aria-controls', id);
|
|||
|
var li = $('<li role="presentation"></li>');
|
|||
|
li.append(a);
|
|||
|
tabList.append(li);
|
|||
|
|
|||
|
// set it's attributes
|
|||
|
tab.attr('role', 'tabpanel');
|
|||
|
tab.addClass('tab-pane');
|
|||
|
tab.addClass('tabbed-pane');
|
|||
|
if (fade)
|
|||
|
tab.addClass('fade');
|
|||
|
|
|||
|
// move it into the tab content div
|
|||
|
tab.detach().appendTo(tabContent);
|
|||
|
});
|
|||
|
|
|||
|
// set active tab
|
|||
|
$(tabList.children('li')[activeTab]).addClass('active');
|
|||
|
var active = $(tabContent.children('div.section')[activeTab]);
|
|||
|
active.addClass('active');
|
|||
|
if (fade)
|
|||
|
active.addClass('in');
|
|||
|
|
|||
|
if (tabset.hasClass("tabset-sticky"))
|
|||
|
tabset.rmarkdownStickyTabs();
|
|||
|
}
|
|||
|
|
|||
|
// convert section divs with the .tabset class to tabsets
|
|||
|
var tabsets = $("div.section.tabset");
|
|||
|
tabsets.each(function(i) {
|
|||
|
buildTabset($(tabsets[i]));
|
|||
|
});
|
|||
|
};
|
|||
|
|
|||
|
</script>
|
|||
|
<style type="text/css">.hljs-literal {
|
|||
|
color: #990073;
|
|||
|
}
|
|||
|
.hljs-number {
|
|||
|
color: #099;
|
|||
|
}
|
|||
|
.hljs-comment {
|
|||
|
color: #998;
|
|||
|
font-style: italic;
|
|||
|
}
|
|||
|
.hljs-keyword {
|
|||
|
color: #900;
|
|||
|
font-weight: bold;
|
|||
|
}
|
|||
|
.hljs-string {
|
|||
|
color: #d14;
|
|||
|
}
|
|||
|
</style>
|
|||
|
<script src="data:application/javascript;base64,LyohIGhpZ2hsaWdodC5qcyB2OS4xMi4wIHwgQlNEMyBMaWNlbnNlIHwgZ2l0LmlvL2hsanNsaWNlbnNlICovCiFmdW5jdGlvbihlKXt2YXIgbj0ib2JqZWN0Ij09dHlwZW9mIHdpbmRvdyYmd2luZG93fHwib2JqZWN0Ij09dHlwZW9mIHNlbGYmJnNlbGY7InVuZGVmaW5lZCIhPXR5cGVvZiBleHBvcnRzP2UoZXhwb3J0cyk6biYmKG4uaGxqcz1lKHt9KSwiZnVuY3Rpb24iPT10eXBlb2YgZGVmaW5lJiZkZWZpbmUuYW1kJiZkZWZpbmUoW10sZnVuY3Rpb24oKXtyZXR1cm4gbi5obGpzfSkpfShmdW5jdGlvbihlKXtmdW5jdGlvbiBuKGUpe3JldHVybiBlLnJlcGxhY2UoLyYvZywiJmFtcDsiKS5yZXBsYWNlKC88L2csIiZsdDsiKS5yZXBsYWNlKC8+L2csIiZndDsiKX1mdW5jdGlvbiB0KGUpe3JldHVybiBlLm5vZGVOYW1lLnRvTG93ZXJDYXNlKCl9ZnVuY3Rpb24gcihlLG4pe3ZhciB0PWUmJmUuZXhlYyhuKTtyZXR1cm4gdCYmMD09PXQuaW5kZXh9ZnVuY3Rpb24gYShlKXtyZXR1cm4gay50ZXN0KGUpfWZ1bmN0aW9uIGkoZSl7dmFyIG4sdCxyLGksbz1lLmNsYXNzTmFtZSsiICI7aWYobys9ZS5wYXJlbnROb2RlP2UucGFyZW50Tm9kZS5jbGFzc05hbWU6IiIsdD1CLmV4ZWMobykpcmV0dXJuIHcodFsxXSk/dFsxXToibm8taGlnaGxpZ2h0Ijtmb3Iobz1vLnNwbGl0KC9ccysvKSxuPTAscj1vLmxlbmd0aDtyPm47bisrKWlmKGk9b1tuXSxhKGkpfHx3KGkpKXJldHVybiBpfWZ1bmN0aW9uIG8oZSl7dmFyIG4sdD17fSxyPUFycmF5LnByb3RvdHlwZS5zbGljZS5jYWxsKGFyZ3VtZW50cywxKTtmb3IobiBpbiBlKXRbbl09ZVtuXTtyZXR1cm4gci5mb3JFYWNoKGZ1bmN0aW9uKGUpe2ZvcihuIGluIGUpdFtuXT1lW25dfSksdH1mdW5jdGlvbiB1KGUpe3ZhciBuPVtdO3JldHVybiBmdW5jdGlvbiByKGUsYSl7Zm9yKHZhciBpPWUuZmlyc3RDaGlsZDtpO2k9aS5uZXh0U2libGluZykzPT09aS5ub2RlVHlwZT9hKz1pLm5vZGVWYWx1ZS5sZW5ndGg6MT09PWkubm9kZVR5cGUmJihuLnB1c2goe2V2ZW50OiJzdGFydCIsb2Zmc2V0OmEsbm9kZTppfSksYT1yKGksYSksdChpKS5tYXRjaCgvYnJ8aHJ8aW1nfGlucHV0Lyl8fG4ucHVzaCh7ZXZlbnQ6InN0b3AiLG9mZnNldDphLG5vZGU6aX0pKTtyZXR1cm4gYX0oZSwwKSxufWZ1bmN0aW9uIGMoZSxyLGEpe2Z1bmN0aW9uIGkoKXtyZXR1cm4gZS5sZW5ndGgmJnIubGVuZ3RoP2VbMF0ub2Zmc2V0IT09clswXS5vZmZzZXQ/ZVswXS5vZmZzZXQ8clswXS5vZmZzZXQ/ZTpyOiJzdGFydCI9PT1yWzBdLmV2ZW50P2U6cjplLmxlbmd0aD9lOnJ9ZnVuY3Rpb24gbyhlKXtmdW5jdGlvbiByKGUpe3JldHVybiIgIitlLm5vZGVOYW1lKyc9IicrbihlLnZhbHVlKS5yZXBsYWNlKCciJywiJnF1b3Q7IikrJyInfXMrPSI8Iit0KGUpK0UubWFwLmNhbGwoZS5hdHRyaWJ1dGVzLHIpLmpvaW4oIiIpKyI+In1mdW5jdGlvbiB1KGUpe3MrPSI8LyIrdChlKSsiPiJ9ZnVuY3Rpb24gYyhlKXsoInN0YXJ0Ij09PWUuZXZlbnQ/bzp1KShlLm5vZGUpfWZvcih2YXIgbD0wLHM9IiIsZj1bXTtlLmxlbmd0aHx8ci5sZW5ndGg7KXt2YXIgZz1pKCk7aWYocys9bihhLnN1YnN0cmluZyhsLGdbMF0ub2Zmc2V0KSksbD1nWzBdLm9mZnNldCxnPT09ZSl7Zi5yZXZlcnNlKCkuZm9yRWFjaCh1KTtkbyBjKGcuc3BsaWNlKDAsMSlbMF0pLGc9aSgpO3doaWxlKGc9PT1lJiZnLmxlbmd0aCYmZ1swXS5vZmZzZXQ9PT1sKTtmLnJldmVyc2UoKS5mb3JFYWNoKG8pfWVsc2Uic3RhcnQiPT09Z1swXS5ldmVudD9mLnB1c2goZ1swXS5ub2RlKTpmLnBvcCgpLGMoZy5zcGxpY2UoMCwxKVswXSl9cmV0dXJuIHMrbihhLnN1YnN0cihsKSl9ZnVuY3Rpb24gbChlKXtyZXR1cm4gZS52JiYhZS5jYWNoZWRfdmFyaWFudHMmJihlLmNhY2hlZF92YXJpYW50cz1lLnYubWFwKGZ1bmN0aW9uKG4pe3JldHVybiBvKGUse3Y6bnVsbH0sbil9KSksZS5jYWNoZWRfdmFyaWFudHN8fGUuZVcmJltvKGUpXXx8W2VdfWZ1bmN0aW9uIHMoZSl7ZnVuY3Rpb24gbihlKXtyZXR1cm4gZSYmZS5zb3VyY2V8fGV9ZnVuY3Rpb24gdCh0LHIpe3JldHVybiBuZXcgUmVnRXhwKG4odCksIm0iKyhlLmNJPyJpIjoiIikrKHI/ImciOiIiKSl9ZnVuY3Rpb24gcihhLGkpe2lmKCFhLmNvbXBpbGVkKXtpZihhLmNvbXBpbGVkPSEwLGEuaz1hLmt8fGEuYkssYS5rKXt2YXIgbz17fSx1PWZ1bmN0aW9uKG4sdCl7ZS5jSSYmKHQ9dC50b0xvd2VyQ2FzZSgpKSx0LnNwbGl0KCIgIikuZm9yRWFjaChmdW5jdGlvbihlKXt2YXIgdD1lLnNwbGl0KCJ8Iik7b1t0WzBdXT1bbix0WzFdP051bWJlcih0WzFdKToxXX0pfTsic3RyaW5nIj09dHlwZW9mIGEuaz91KCJrZXl3b3JkIixhLmspOngoYS5rKS5mb3JFYWNoKGZ1bmN0aW9uKGUpe3UoZSxhLmtbZV0pfSksYS5rPW99YS5sUj10KGEubHx8L1x3Ky8sITApLGkmJihhLmJLJiYoYS5iPSJcXGIoIithLmJLLnNwbGl0KCIgIikuam9pbigifCIpKyIpXFxiIiksYS5ifHwoYS5iPS9cQnxcYi8pLGEuYlI9dChhLmIpLGEuZXx8YS5lV3x8KGEuZT0vXEJ8XGIvKSxhLmUmJihhLmVSPXQoYS5lKSksYS50RT1uKGEuZSl8fCIiLGEuZVcmJmkudEUmJihhLnRFKz0oYS5lPyJ8IjoiIikraS50RSkpLGEuaSYmKGEuaVI9dChhLmkpKSxudWxsPT1hLnImJihhLnI9MSksYS5jfHwoYS5jPVtdKSxhLmM9QXJyYXkucHJvdG90eXBlLmNvbmNhdC5hcHBseShbXSxhLmMubWFwKGZ1bmN0aW9uKGUpe3JldHVybiBsKCJzZWxmIj09PWU/YTplKX0pKSxhLmMuZm9yRWFjaChmdW5jdGlvbihlKXtyKGUsYSl9KSxhLnN0YXJ0cyYmcihhLnN0YXJ0cyxpKTt2YXIgYz1hLmMubWFwKGZ1bmN0aW9uKGUpe3JldHVybiBlLmJLPyJcXC4/KCIrZS5iKyIpXFwuPyI6ZS5ifSkuY29uY2F0KFthLnRFLGEuaV0pLm1hcChuKS5maWx0ZXIoQm9vbGVhbik7YS50PWMubGVuZ3RoP3QoYy5qb2luKCJ8IiksITApOntleGVjOmZ1bmN0aW9uKCl7cmV0dXJuIG51bGx9fX19cihlKX1mdW5jdGlvbiBmKGUsdCxhLGkpe2Z1bmN0aW9uIG8oZSxuKXt2YXIgdCxhO2Zvcih0PTAsYT1uLmMubGVuZ3RoO2E+dDt0Kys
|
|||
|
<style type="text/css">
|
|||
|
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;}
|
|||
|
a.anchor-section::before {content: '#';}
|
|||
|
.hasAnchor:hover a.anchor-section {visibility: visible;}
|
|||
|
</style>
|
|||
|
<script>// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020.
|
|||
|
document.addEventListener('DOMContentLoaded', function() {
|
|||
|
// Do nothing if AnchorJS is used
|
|||
|
if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
|||
|
|
|||
|
// Do nothing if sections are already anchored
|
|||
|
if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
// Use section id when pandoc runs with --section-divs
|
|||
|
const section_id = function(x) {
|
|||
|
return ((x.classList.contains('section') || (x.tagName === 'SECTION'))
|
|||
|
? x.id : '');
|
|||
|
};
|
|||
|
|
|||
|
// Add anchors
|
|||
|
h.forEach(function(x) {
|
|||
|
const id = x.id || section_id(x.parentElement);
|
|||
|
if (id === '') {
|
|||
|
return null;
|
|||
|
}
|
|||
|
let anchor = document.createElement('a');
|
|||
|
anchor.href = '#' + id;
|
|||
|
anchor.classList = ['anchor-section'];
|
|||
|
x.classList.add('hasAnchor');
|
|||
|
x.appendChild(anchor);
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
code{white-space: pre-wrap;}
|
|||
|
span.smallcaps{font-variant: small-caps;}
|
|||
|
span.underline{text-decoration: underline;}
|
|||
|
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
|||
|
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
|||
|
ul.task-list{list-style: none;}
|
|||
|
</style>
|
|||
|
|
|||
|
<style type="text/css">code{white-space: pre;}</style>
|
|||
|
<style type="text/css">
|
|||
|
pre:not([class]) {
|
|||
|
background-color: white;
|
|||
|
}
|
|||
|
</style>
|
|||
|
<script type="text/javascript">
|
|||
|
if (window.hljs) {
|
|||
|
hljs.configure({languages: []});
|
|||
|
hljs.initHighlightingOnLoad();
|
|||
|
if (document.readyState && document.readyState === "complete") {
|
|||
|
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
h1 {
|
|||
|
font-size: 34px;
|
|||
|
}
|
|||
|
h1.title {
|
|||
|
font-size: 38px;
|
|||
|
}
|
|||
|
h2 {
|
|||
|
font-size: 30px;
|
|||
|
}
|
|||
|
h3 {
|
|||
|
font-size: 24px;
|
|||
|
}
|
|||
|
h4 {
|
|||
|
font-size: 18px;
|
|||
|
}
|
|||
|
h5 {
|
|||
|
font-size: 16px;
|
|||
|
}
|
|||
|
h6 {
|
|||
|
font-size: 12px;
|
|||
|
}
|
|||
|
.table th:not([align]) {
|
|||
|
text-align: left;
|
|||
|
}
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
.main-container {
|
|||
|
max-width: 940px;
|
|||
|
margin-left: auto;
|
|||
|
margin-right: auto;
|
|||
|
}
|
|||
|
code {
|
|||
|
color: inherit;
|
|||
|
background-color: rgba(0, 0, 0, 0.04);
|
|||
|
}
|
|||
|
img {
|
|||
|
max-width:100%;
|
|||
|
}
|
|||
|
.tabbed-pane {
|
|||
|
padding-top: 12px;
|
|||
|
}
|
|||
|
.html-widget {
|
|||
|
margin-bottom: 20px;
|
|||
|
}
|
|||
|
button.code-folding-btn:focus {
|
|||
|
outline: none;
|
|||
|
}
|
|||
|
summary {
|
|||
|
display: list-item;
|
|||
|
}
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<!-- tabsets -->
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
.tabset-dropdown > .nav-tabs {
|
|||
|
display: inline-table;
|
|||
|
max-height: 500px;
|
|||
|
min-height: 44px;
|
|||
|
overflow-y: auto;
|
|||
|
background: white;
|
|||
|
border: 1px solid #ddd;
|
|||
|
border-radius: 4px;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs > li.active:before {
|
|||
|
content: "";
|
|||
|
font-family: 'Glyphicons Halflings';
|
|||
|
display: inline-block;
|
|||
|
padding: 10px;
|
|||
|
border-right: 1px solid #ddd;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
|
|||
|
content: "";
|
|||
|
border: none;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
|
|||
|
content: "";
|
|||
|
font-family: 'Glyphicons Halflings';
|
|||
|
display: inline-block;
|
|||
|
padding: 10px;
|
|||
|
border-right: 1px solid #ddd;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs > li.active {
|
|||
|
display: block;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs > li > a,
|
|||
|
.tabset-dropdown > .nav-tabs > li > a:focus,
|
|||
|
.tabset-dropdown > .nav-tabs > li > a:hover {
|
|||
|
border: none;
|
|||
|
display: inline-block;
|
|||
|
border-radius: 4px;
|
|||
|
background-color: transparent;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
|
|||
|
display: block;
|
|||
|
float: none;
|
|||
|
}
|
|||
|
|
|||
|
.tabset-dropdown > .nav-tabs > li {
|
|||
|
display: none;
|
|||
|
}
|
|||
|
</style>
|
|||
|
|
|||
|
<!-- code folding -->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<style type="text/css">
|
|||
|
|
|||
|
#TOC {
|
|||
|
margin: 25px 0px 20px 0px;
|
|||
|
}
|
|||
|
@media (max-width: 768px) {
|
|||
|
#TOC {
|
|||
|
position: relative;
|
|||
|
width: 100%;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@media print {
|
|||
|
.toc-content {
|
|||
|
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
|
|||
|
float: right;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
.toc-content {
|
|||
|
padding-left: 30px;
|
|||
|
padding-right: 40px;
|
|||
|
}
|
|||
|
|
|||
|
div.main-container {
|
|||
|
max-width: 1200px;
|
|||
|
}
|
|||
|
|
|||
|
div.tocify {
|
|||
|
width: 20%;
|
|||
|
max-width: 260px;
|
|||
|
max-height: 85%;
|
|||
|
}
|
|||
|
|
|||
|
@media (min-width: 768px) and (max-width: 991px) {
|
|||
|
div.tocify {
|
|||
|
width: 25%;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
@media (max-width: 767px) {
|
|||
|
div.tocify {
|
|||
|
width: 100%;
|
|||
|
max-width: none;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
.tocify ul, .tocify li {
|
|||
|
line-height: 20px;
|
|||
|
}
|
|||
|
|
|||
|
.tocify-subheader .tocify-item {
|
|||
|
font-size: 0.90em;
|
|||
|
}
|
|||
|
|
|||
|
.tocify .list-group-item {
|
|||
|
border-radius: 0px;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
|
|||
|
<body>
|
|||
|
|
|||
|
|
|||
|
<div class="container-fluid main-container">
|
|||
|
|
|||
|
|
|||
|
<!-- setup 3col/9col grid for toc_float and main content -->
|
|||
|
<div class="row-fluid">
|
|||
|
<div class="col-xs-12 col-sm-4 col-md-3">
|
|||
|
<div id="TOC" class="tocify">
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<div class="fluid-row" id="header">
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h1 class="title toc-ignore">Parsing command-line arguments by Getopt::Long</h1>
|
|||
|
<h4 class="author">Zuguang Gu (<a href="mailto:z.gu@dkfz.de" class="email">z.gu@dkfz.de</a>)</h4>
|
|||
|
<h4 class="date">2020-12-15</h4>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
<hr />
|
|||
|
<p>There are already several R packages which parse command-line arguments such as <a href="https://CRAN.R-project.org/package=getopt"><strong>getopt</strong></a>, <a href="https://CRAN.R-project.org/package=optparse"><strong>optparse</strong></a>, <a href="https://CRAN.R-project.org/package=argparse"><strong>argparse</strong></a>, <a href="https://CRAN.R-project.org/package=docopt"><strong>docopt</strong></a>. Here <strong>GetoptLong</strong> is another command-line argument parser (actually it was developed very early, <a href="https://cran.r-project.org/src/contrib/Archive/GetoptLong/">the first CRAN version</a> was in 2013) which wraps the powerful Perl module <a href="https://perldoc.pl/Getopt::Long"><code>Getopt::Long</code></a>. <strong>GetoptLong</strong> package also provides some adaptations for easier use in R.</p>
|
|||
|
<p>Using <strong>GetoptLong</strong> is simple especially for users having Perl experience (Oops, age exposed :)) because the specification is almost the same as in Perl. The original website of <a href="https://perldoc.pl/Getopt::Long"><code>Getopt::Long</code></a> is always your best reference.</p>
|
|||
|
<p><strong>Note: to use this package, Perl should be installed.</strong></p>
|
|||
|
<div id="workflow-of-the-wrapping" class="section level2">
|
|||
|
<h2>Workflow of the wrapping</h2>
|
|||
|
<p>The <strong>GetoptLong</strong> R package automatically generates a Perl script according to the specifications in the R script. Later the Perl script is executed with the command-line arguments that user specified. The options are parsed and saved into a json file. Finally R reads back the json file and formats them as R variables.</p>
|
|||
|
<p>Following figure shows how the R package works for parsing the command-line arguments.</p>
|
|||
|
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+EAAALsEAIAAABTov2YAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAPhAAAC7AAIbQc9AACAAElEQVR42uzdf3AU933/cZTxKGFSBHJBpwSEEEoyxVhgiGYiWVaNwAPYZShG5o5oTHDG/HJAmuJaSvmRDjPhRyK5dirhmF+ZxsbVoMPCxGVsYGzAoxDJHWrAMjB1K35YqJWQi0B8WxL9UX3/eJXJJ/lkNyvd6fbu9Hz8gc97e7vvz2dXd7vv/ex7U/r7+/v7+0cAACLQ29vb29u7efPmzZs3b926devWrWlpaWlpae5zOi1t1qxZs2bNWrx48eLFi53mOXTo0KFDh06dOnXq1CmneWpra2tra53ePXv27NmzZ//hH/7hH/7hH5zmoS20hbZEqy1SUVFRUVER/2357ne/+93vfnfGjBkzZsygLbSFtiRHW7x8o9KWoWhL5L90tIW20JZ4a0tsjnIjb4vEwxE7bYl9WzAk+gEAEevs7Ozs7NT3anV1dXV19aVLly5dumTPqenu38z6YXZfo+aJ5Bt+3759+/btc1+CUytoC22hLQNtiyRKWzQPbaEttCWZ2uLlG5W2DEVbIv+loy20hbbEW1tic5QbeVuEtgy3tmi6ltDY2NjY2Pib3/zmN7/5TT8idp+XTQsA8K6qqqqqqkqv/+zP/uzP/uzPzHdv3bp169Yt9yX893//93//939HPo+7mzdv3rx5030e92hpC22hLQONNlHa4mUe2kJbaEtitcXLdxRtGYq2RP5LR1toC22Jt7bE5ig38rZ4QVuSry3/9E//9E//9E9mXkLD/gKBQCAQGOrIk1uKsul+hwEAia2rq6urqyszMzMzM1NTNCa9srKysrLS7+gAAAAAAEDyq6mpqampIY0+FL7gdwAAAAAAAAAAAMQv0ugAAAAAAAAAADgijQ4AAAAAAAAAgCNqowNAFOi79MaNGzdu3Lhy5cqVK1eysrKysrLGjx8/fvx4v6MDAAAAAADJr6Ojo6Ojo729vb29PScnJycnJyMjIyMjIyUlJSUlxe/oEhtpdAAAAAAAAAAAHFHUBQAAAAAAAAAAR6TRAQAAAAAAAABwRBodAAAAAAAAAABHpNEBIAr0nImurq6urq6WlpaWlhY91sPvuAAAAAAAwHChXITyEspR8FzMaCGNDgBRcOPGjRs3bmRmZmZmZhYWFhYWFtbX19fX1/sdFwAAAAAAGC6Ui1BeQjkK5Sv8jisZkEYHAAAAAAAAAMARaXQAAAAAAAAAAByRRgcAAAAAAAAAwBFpdAAAAAAAAAAAHN3ndwAAkAxGjhw5cuTI8vLy8vJyPQs7O3vSpOxsv+MCAAAAAADDhXIRwWAwGAwGAoFAIKB8hd9xJYOU/v7+/v5+v8MAAAAAAAAAACAeUdQFAAAAAAAAAABHpNEBAAAAAAAAAHBEGh0AAAAAAAAAAEek0QEAAAAAAAAAcEQaHQCioLe3t7e3t6KioqKiIhQKhUKhcPjgwXDY77gAAAAAAMBwoVyE8hLKUShf4XdcyeA+vwMAgGRw9+7du3fv1tXV1dXVaUp+fn5+fr7fcQEAAAAAgOHi2rWrV69dC4fD4XsD+zZt2rRp06a0tLS0tDS/o0tsjEYHAAAAAAAAAMARaXQAAAAAAAAAABxR1AUAhh3VStOtXn7HAgDJIzt70qTs7GBwyZJg0O9YgN/idx8AgOjiqG94Io0OAMNOY+ObbzY2mrXSAACRC/4fTqgQX/jdBwAgujjqG55IowNAFAQCgUAg0N/f39/f73csAAAAAABgOKo0+B1LsiGNDgAY0dzc3Nzc7HcUAJB4CgsLCwsL/Y4CGBh+9wEAGCiO+kAaHQAwoqCgoKCgwO8oAABALPC7DwAAMFBf8DsAAAAAAAAAAADiF2l0AAAAAAAAAAAcUdQFAKKgr6+vr6/vyJEjR44caWtra2trKy4uLi4u5qZpAAAAAAAQGy0tLS0tLU1NTU1NTbm5ubm5uQsWLFiwYEFqampqaqrf0SU20ugAEAU9PT09PT2lpaWlpaWaUl1dXV1dTRodAAAAAADEhhLoVVVVVVVVmtLZ2dnZ2RkIBAKBgN/RJTaKugAAAAAAAAAA4Ig0OgAAAAAAAAAAjkijAwAAAAAAAADgiDQ6AAAAAAAAAACOeMQoAERBRkZGRkaGHtxx5cqVK1euZGVlZWVl+R0XAAAAAAAYLsrKysrKyoqLi4uLi3NycnJycpSv8DuuZEAaHQCiICUlJSUlJWDwOyIAAAAAADC8jDf4HUuyoagLAAAAAAAAAACOSKMDAAAAAAAAAOCINDoAAAAAAAAAAI5IowNAFPT39/f393d1dXV1dbW0tLS0tHR0dHR0dPgdFwAAAAAAGC6Ui1BeQjkK5Sv8jisZkEYHgCi4cePGjRs3MjMzMzMzCwsLCwsL6+vr6+vr/Y4LAAAAAAAMF8pFKC+hHIXyFX7HlQxIowMAAAAAfHDnzp07d+5wJx+ASFy6dOnSpUv6JvE7FgDJjDQ6AAAAAMAHFy5cuHDhAnfyDY55274uSESyNDMRGfnS4J22Y01NTU1NDReTBmfLli1btmzRN4nfsWAwuBCCREEaHQCAKNDJT0pKSkpKCoeAiUtbMBQKhUIhp3m0rTVPRkZGRkaGPqV3Nd2ckojYnwEg/pm37euCRCRLMxORkS8N3rW3t7e3t1dVVVVVVem13xEBscaFECQK0ugAADgyU6IkE6Hksk50NWqmpKSkpKQkGAwGg0G/o/MaP/szgPhRUFBQUFCgR59VVlZWVlb6HRGAxNPQ0NDQ0MBDFAEMtfv8DgAAksHIkSNHjhxZXl5eXl6uZ2FnZ0+alJ3td1yInbKysrKysuLi4uLi4qlTp06dOtXviDAYzc3Nzc3No0ePHj16tP3umTNnzpw5o9enT58+ffr0qFGjRo0aZc6j0TTr169fv369360ZPPZnALGhEhYaVa3vHCXWnd7V9/P+/fv379/f1tbW1tZ2//3333///cuXL1++fLk+q4Iku3bt2rVrl/m9XVr61FOlpcHgkiV/6MKnLi42NTU1NTXpO/Cdd95555133nvvvffee0/z5Ofn5+fnr1mzZs2aNfb3v720t99+++2331acmv7YY4899thjS5cuXbp0qdMSdMlTr7Uusy2KQceZZuu0LsWvKXZ/OgmHDx4Mh3V52PvS1M8HDhw4cOCA2Uu5ubm5ubkLFy5cuHChl7W7R3Xt2tWr1645XWIx9xD1ib19nbaFlzid2qi97sknn3zyySfnzp07d+5c9/id9iglf730RiSt8MLsSXO/0vKXLVu2bNmyKVOmTJkyxf6s9lj1/+OPz5//+OP2X5/2/JUrV65cudL87PHjx48fP37+/Pnz58+rl8aPHz9+/HinOLWuMWPGjBkzxlya+95iv7t37969e/c6bQun7xAvvW1/k5w+/atfnT598uSJEydP3rx58+bNm/ordm+v2at5eQ8+mJdnfu9pnmefffbZZ5/VHui0rzr1vNMea8ZpLsHpW8v+ltZ0c1917ze11Pz+Mb8Dxcu+AdO978NgMBgMBAKBQED5Cr/jSgr9AIBhxh4563dEf1yzxX3+3t7e3t5ezXn9+vXr169r+sWLFy9evOhlOZpz9uzZs2fPVi/t2bNnz5495mfNJeu1pmvtXmITrcu9RU7LH2jPRNLn7nGafWvH7KVn3Jdp97kXdgzuvWS31FyCuT80e+Aem70nDG7/8dIzatGGDRs2bNgw1PtzJH+hQ7c/Dx3zu1Tfrn5HBPy+eP7d11+6oqqurq6urnZ612zFuHHjxo0bZ34ny7Fjx44dO2ZOt9tur0U0XfOYS8jLy8vLy9MazbU7fes2NITDv5sYHegSzM+an1JblFhXtFqyGXPQoEi8bAUtzVyX+9IUudlLTlvEeww2c9t52X/sb2B7W2geO057yfrdtLea/Vn9trrHb/ettp3dCvu3T7/Xg2uFF057rLl3mX9fTnus2S6nvz57G2mZ7n+b
|
|||
|
</div>
|
|||
|
<div id="a-quick-example" class="section level2">
|
|||
|
<h2>A quick example</h2>
|
|||
|
<div id="specify-as-a-vector" class="section level3">
|
|||
|
<h3>Specify as a vector</h3>
|
|||
|
<p>The following example gives you some feels of using <strong>GetoptLong</strong> package. The following code is saved in to an R script named <code>foo.R</code>.</p>
|
|||
|
<pre class="r"><code>library(GetoptLong)
|
|||
|
|
|||
|
cutoff = 0.05
|
|||
|
GetoptLong(
|
|||
|
"number=i", "Number of items.",
|
|||
|
"cutoff=f", "Cutoff for filtering results.",
|
|||
|
"verbose", "Print message."
|
|||
|
)</code></pre>
|
|||
|
<p>The R script can be executed as:</p>
|
|||
|
<pre><code>~\> Rscript foo.R --number 4 --cutoff 0.01 --verbose
|
|||
|
~\> Rscript foo.R --number=4 --cutoff=0.01 --verbose
|
|||
|
~\> Rscript foo.R -n 4 -c 0.01 -v
|
|||
|
~\> Rscript foo.R -n 4 --verbose</code></pre>
|
|||
|
<p>In this example, <code>number</code> is a mandatory option and it should only be in integer mode. <code>cutoff</code> is optional and it already has a default value 0.05. <code>verbose</code> is a logical option. If parsing is successful, two variables <code>number</code> and <code>verbose</code> will be imported into the working environment with the specified values. Value for <code>cutoff</code> will be updated if it is specified in command-line.</p>
|
|||
|
<p>Data types are automatically checked. <em>E.g.</em>, if <code>cutoff</code> is specified with a character, an error will be thrown.</p>
|
|||
|
<p>The option usage triggered by <code>--help</code> is automatically generated. There are two styles:</p>
|
|||
|
<p>The one-column style:</p>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--number, -n integer
|
|||
|
Number of items.
|
|||
|
|
|||
|
--cutoff, -c numeric
|
|||
|
Cutoff for filtering results.
|
|||
|
[default: 0.05]
|
|||
|
|
|||
|
--verbose
|
|||
|
Print message.
|
|||
|
|
|||
|
--help, -h
|
|||
|
Print help message and exit.
|
|||
|
|
|||
|
--version
|
|||
|
Print version information and exit.
|
|||
|
</code></pre>
|
|||
|
<p>Or the two-column style:</p>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--number, -n Number of items.
|
|||
|
[type: int]
|
|||
|
--cutoff, -c Cutoff for filtering results.
|
|||
|
[type: num] [default: 0.05]
|
|||
|
--verbose Print message.
|
|||
|
--help, -h Print help message and exit.
|
|||
|
--version Print version information and exit. </code></pre>
|
|||
|
<p>You can find the short option names (in single letters) are automatically added. The information of default values is added as well.</p>
|
|||
|
</div>
|
|||
|
<div id="specify-as-a-template" class="section level3">
|
|||
|
<h3>Specify as a template</h3>
|
|||
|
<p>The specification can also be set as a template where the specifications are marked by <code><></code>.</p>
|
|||
|
<pre class="r"><code>spec = "
|
|||
|
This is an example of using template to specify options.
|
|||
|
|
|||
|
Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
<number=i> Number of items.
|
|||
|
<cutoff=f> Cutoff for filtering results.
|
|||
|
<verbose> Print messages.
|
|||
|
|
|||
|
Contact: name@address
|
|||
|
"
|
|||
|
|
|||
|
GetoptLong(spec, template_control = list(opt_width = 21))</code></pre>
|
|||
|
<p>The parameter <code>opt_width</code> controls the maximal width of the option description (<em>i.e.</em>, <code>--number, -n integer</code>, <code>--cutoff, -c numeric</code> and <code>--verbose</code>).</p>
|
|||
|
<p>Calling <code>Rscript foo.R --help</code> generates the following message:</p>
|
|||
|
<pre><code>This is an example of using template to specify options.
|
|||
|
|
|||
|
Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--number, -n integer Number of items.
|
|||
|
--cutoff, -c numeric Cutoff for filtering results.
|
|||
|
--verbose Print messages.
|
|||
|
|
|||
|
Contact: name@address </code></pre>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="advantages" class="section level2">
|
|||
|
<h2>Advantages</h2>
|
|||
|
<p>There are several advantages compared to other command-line argument parser packages. The major advantage comes from the <code>Getopt::Long</code> Perl module which actually parses the options. The <code>Getopt::Long</code> module provides a flexible, smart and compact way for specifying command-line arguments. The major features are:</p>
|
|||
|
<ol style="list-style-type: decimal">
|
|||
|
<li>Various formats of specifying options with values, such as</li>
|
|||
|
</ol>
|
|||
|
<pre><code>-s 24 -s24</code></pre>
|
|||
|
<p>or</p>
|
|||
|
<pre><code>--size 24 --size=24 -size 24 -size=24</code></pre>
|
|||
|
<ol start="2" style="list-style-type: decimal">
|
|||
|
<li>Single-letter options can be bundled:</li>
|
|||
|
</ol>
|
|||
|
<pre><code>-a -b -c -abs</code></pre>
|
|||
|
<ol start="3" style="list-style-type: decimal">
|
|||
|
<li>Options with multiple names. With the following specification, <code>--length</code>, <code>--height</code> are the same.</li>
|
|||
|
</ol>
|
|||
|
<pre><code>length|height=f</code></pre>
|
|||
|
<ol start="4" style="list-style-type: decimal">
|
|||
|
<li>Automatically support single-letter options. If the first letter of an option is unique to all other options, the first letter can be used as an optional option name. For example, if <code>l</code> and <code>h</code> are unique, <code>--length</code>, <code>--height</code>, <code>-l</code> and <code>-h</code> set the same option.</li>
|
|||
|
</ol>
|
|||
|
<pre><code>length|height=f --length --height -l -h</code></pre>
|
|||
|
<ol start="5" style="list-style-type: decimal">
|
|||
|
<li>Rich option data types, including scalar, vector (array in Perl), list (hash in Perl). For example:</li>
|
|||
|
</ol>
|
|||
|
<pre><code>length=i a single integer scalar
|
|||
|
name=s a single character scalar</code></pre>
|
|||
|
<p>can be specified as:</p>
|
|||
|
<pre><code>--length 1 --name a</code></pre>
|
|||
|
<p>or</p>
|
|||
|
<pre><code>length=i@ a integer vector
|
|||
|
name=s@ a character vector
|
|||
|
length=i{2,} a integer vector, at least two elements
|
|||
|
name=s{2,} a character vector, at least two elements</code></pre>
|
|||
|
<p>can be specified as:</p>
|
|||
|
<pre><code>--length 1 2 3 --name a b c</code></pre>
|
|||
|
<p>or</p>
|
|||
|
<pre><code>length=i% name-value pair, values should be integers
|
|||
|
name=s% name-value pair, values should be characters</code></pre>
|
|||
|
<p>to be specified as:</p>
|
|||
|
<pre><code>--length foo=1 bar=3 --name foo=a bar=b</code></pre>
|
|||
|
<p>The features from R part are:</p>
|
|||
|
<ol style="list-style-type: decimal">
|
|||
|
<li><p>It automaticlly generates option usage in two styles. The data type and default value of options are automatically detected and included.</p></li>
|
|||
|
<li><p>It supports specifying the usage in a template which allows more complex text of option usage.</p></li>
|
|||
|
<li><p>It allows grouping options.</p></li>
|
|||
|
<li><p>It provides a natural and convenient way to specify defaults.</p></li>
|
|||
|
</ol>
|
|||
|
</div>
|
|||
|
<div id="customize-the-specifications" class="section level2">
|
|||
|
<h2>Customize the specifications</h2>
|
|||
|
<p>Each specifier in options consists of two parts: the name specification and the argument specification:</p>
|
|||
|
<pre><code>length|size|l=i@</code></pre>
|
|||
|
<p>Here <code>length|size|l</code> is a list of alternative names separated by <code>|</code>. The remaining part is argument specification which defines the mode and amount of arguments.</p>
|
|||
|
<p>Specify any of alternative option name from command-line is ok and it doesn’t matter whether using one or two slash in front of the option name. Sometimes you even don’t need to specify complete option names, you only need to make sure the partial name match is unique. If the partial match is not uniqe, it will throw an error. For above example, we can specify the argument like:</p>
|
|||
|
<pre><code>~\> Rscript foo.R --length 1
|
|||
|
~\> Rscript foo.R --length=1 # adding "=" is also ok
|
|||
|
~\> Rscript foo.R -len 1
|
|||
|
~\> Rscript foo.R -lengt 1 # this is also ok, but not suggested
|
|||
|
~\> Rscript foo.R --size 1
|
|||
|
~\> Rscript foo.R -l 1</code></pre>
|
|||
|
<p>Options for argument specification are:</p>
|
|||
|
<ul>
|
|||
|
<li>no argument specification: taking no argument. Options are logical.</li>
|
|||
|
<li><code>!</code>: taking no argument. Options are logical. You can set its oposite value by adding it with <code>no</code> or <code>no-</code>. <em>E.g.</em>, <code>foo!</code> allows <code>--foo</code> as well as <code>--nofoo</code> and <code>--no-foo</code>.</li>
|
|||
|
<li><code>=type[desttype][repeat]</code>: options should have arguments (or options should have values specified). <em>E.g.</em> <code>tag=i@</code> where <code>i</code> corresponds to <code>type</code>, and <code>@</code> corresponds to <code>desttype</code>, or <code>tag=i{2,}</code> where <code>{2,}</code> corresponds to <code>repeat</code>.</li>
|
|||
|
</ul>
|
|||
|
<p>Please note <code>:[type][desttype]</code> is not supported here. We use another way to define mandatory options and optional options. If you don’t know what it is, just ignore this paragraph.</p>
|
|||
|
<p>Available <code>type</code> options are:</p>
|
|||
|
<ul>
|
|||
|
<li><code>s</code>: strings</li>
|
|||
|
<li><code>i</code>: integers</li>
|
|||
|
<li><code>F</code>: real numbers</li>
|
|||
|
<li><code>o</code>: extended integer, an octal string (<code>0</code> followed by <code>0</code>, <code>1</code> .. <code>7</code>), or a hexadecimal string (<code>0x</code> followed by <code>0</code> .. <code>9</code>, <code>A</code> .. <code>F</code>, case insensitive), or a binary string (<code>0b</code> followed by a series of <code>0</code> and <code>1</code>).</li>
|
|||
|
</ul>
|
|||
|
<p>Available <code>desttype</code> settings are:</p>
|
|||
|
<ul>
|
|||
|
<li><code>@</code>: array, allow more than one arguments for an option.</li>
|
|||
|
<li><code>%</code>: hash, allow arguments like <code>name=value</code>.</li>
|
|||
|
<li>nothing: scalar, single argument for single option.</li>
|
|||
|
</ul>
|
|||
|
<p>Available <code>repeat</code> settings are formatted as <code>{\d,\d}</code>. Note there is no space character inside:</p>
|
|||
|
<ul>
|
|||
|
<li><code>{2}</code>: exactly 2 arguments for an option.</li>
|
|||
|
<li><code>{2,}</code>: at least 2 arguments for an option.</li>
|
|||
|
<li><code>{,4}</code>: at most 4 arguments for an option.</li>
|
|||
|
<li><code>{2,5}</code>: minimal 2 and maximal 5 arguments for an option.</li>
|
|||
|
</ul>
|
|||
|
<p>Note <code>desttype</code> and <code>repeat</code> cannot be used at the same time.</p>
|
|||
|
<p>In the Perl module, <code>tag=i@</code> only allows, <em>e.g.</em>, specification of <code>--tag 1 --tag 2</code> while <code>--tag 1 2</code> is not allowed which is only possible by <code>tag=i{1,}</code>. In the R package, we made some adjustment and allow <code>tag=i@</code> to also accept <code>-tag 1 2</code>. Similarly, <code>tag=i%</code> only allows <code>--tag name1=value1 --tag name2=value2</code> in the Perl module. In the R package, it also allows <code>--tag name1=value1 name2=value2</code>.</p>
|
|||
|
<p>Following table contains examples for each type of option specification:</p>
|
|||
|
<style>
|
|||
|
#tb th {
|
|||
|
text-align: left;
|
|||
|
background-color: #C0FFC0;
|
|||
|
}
|
|||
|
#tb th, #tb td {
|
|||
|
padding: 2px 4px;
|
|||
|
}
|
|||
|
#tb tr._odd td {
|
|||
|
background-color: #E0FFE0;
|
|||
|
}
|
|||
|
#tb tr._even td {
|
|||
|
background-color: #FFFFE0;
|
|||
|
}
|
|||
|
#tb td._first {
|
|||
|
vertical-align: text-top;
|
|||
|
}
|
|||
|
</style>
|
|||
|
<table id="tb">
|
|||
|
<tr>
|
|||
|
<th>
|
|||
|
Options
|
|||
|
</th>
|
|||
|
<th>
|
|||
|
Command-line arguments
|
|||
|
</th>
|
|||
|
<th>
|
|||
|
Value of <code>tag</code>
|
|||
|
</th>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td rowspan="8" class="_first">
|
|||
|
<code>tag=i</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag=1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>-t 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 –tag 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>2</code>. Here only take the last one
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 0.1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Value “0.1” invalid for option tag (number expected)
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag a</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Value “a” invalid for option tag (number expected)
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Option tag requires an argument
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
no argument
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
tag is mandatory, please specify it
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td rowspan="3" class="_first">
|
|||
|
<code>tag=s</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>“1”</code>. Here double quote is used because it is specified as a string.
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag 0.1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>“0.1”</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag a</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>“a”</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td rowspan="3" class="_first">
|
|||
|
<code>tag=f</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 0.1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>0.1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag a</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Value “a” invalid for option tag (real number expected)
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td rowspan="6" class="_first">
|
|||
|
<code>tag=o</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag 0b001001</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>9</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag 0721</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>465</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag 0xaf2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>2802</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>-tag 0.1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Value “0.1” invalid for option tag (extended number expected)
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag a</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Value “a” invalid for option tag (extended number expected)
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td rowspan="6" class="_first">
|
|||
|
<code>tag</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>TRUE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 0</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>TRUE</code>, it doesn’t care the value for the option.
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 0.1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>TRUE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag a</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>TRUE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>TRUE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
no argument
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>FALSE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td rowspan="2" class="_first">
|
|||
|
<code>tag!</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>TRUE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–no-tag</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>FALSE</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td rowspan="4" class="_first">
|
|||
|
<code>tag=i@</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 –tag 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag=1 –tag=2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td rowspan="3" class="_first">
|
|||
|
<code>tag=i%</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Option tag, key “1”, requires a value
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag foo=1 –tag bar=2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>list(foo = 1, bar = 2)</code>, <code>tag</code> is a list.
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag foo=1 bar=2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>list(foo = 1, bar = 2)</code>, <code>tag</code> is a list.
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td rowspan="3" class="_first">
|
|||
|
<code>tag=i{2}</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Insufficient arguments for option tag
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 –tag 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Value “–tag” invalid for option tag
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td rowspan="3" class="_first">
|
|||
|
<code>tag=i{2,}</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
Error: Insufficient arguments for option tag
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag 1 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_even">
|
|||
|
<td>
|
|||
|
<code>–tag 1 2 3</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2, 3)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td rowspan="3" class="_first">
|
|||
|
<code>tag=i{,2}</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>–tag 1</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>1</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 2</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
<tr class="_odd">
|
|||
|
<td>
|
|||
|
<code>–tag 1 2 3</code>
|
|||
|
</td>
|
|||
|
<td>
|
|||
|
<code>c(1, 2)</code>
|
|||
|
</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
</div>
|
|||
|
<div id="where-do-the-option-values-go" class="section level2">
|
|||
|
<h2>Where do the option values go</h2>
|
|||
|
<p>Options will be imported into user’s environment as R variables by default. The first option name in all alternative names will be taken as the name of the variable, (<em>e.g.</em> for specification of <code>length|size=s</code>, <code>length</code> will be used as the variable name.), which means, it must be a valid R variable name. Any definition of these variables in front of <code>GetoptLong()</code> will be treated as default values for the corresponding options. <strong>If options already have default values, they are optional in command-line</strong>. If the variable is defined as a function before <code>GetoptLong()</code> is called, it is treated as undefined. Please note your option names should not start with the dot. Although it is valid for R variables but it is not allowed for <strong>Getopt::Long</strong> module.</p>
|
|||
|
<p>For the following example:</p>
|
|||
|
<pre class="r"><code>library(GetoptLong)
|
|||
|
|
|||
|
cutoff = 0.05
|
|||
|
GetoptLong(
|
|||
|
"number=i{1,}", "Number of items.",
|
|||
|
"cutoff=f", "Cutoff for filtering results.",
|
|||
|
"param=s%", "Parameters specified by name=value pairs.",
|
|||
|
"verbose", "Print message."
|
|||
|
)
|
|||
|
|
|||
|
print(number)
|
|||
|
print(cutoff)
|
|||
|
print(param)
|
|||
|
print(verbose)</code></pre>
|
|||
|
<p>a calling from command-line:</p>
|
|||
|
<pre><code>Rscript foo.R --number 1 2 --param var1=a var2=b --verbose</code></pre>
|
|||
|
<p>will print</p>
|
|||
|
<pre><code>[1] 1 2
|
|||
|
[1] 0.05
|
|||
|
$var1
|
|||
|
[1] "a"
|
|||
|
|
|||
|
$var2
|
|||
|
[1] "b"
|
|||
|
|
|||
|
[1] TRUE</code></pre>
|
|||
|
<p>There are two ways to specify logical options, <em>e.g.</em>, <code>verbose</code> and <code>verbose!</code>. <code>verbose</code> always takes <code>FALSE</code> as default and you cannot set default value for it, while you can set default for <code>verbose!</code>. <em>E.g.</em>:</p>
|
|||
|
<pre class="r"><code>verbose = TRUE
|
|||
|
GetoptLong(
|
|||
|
"verbose!", "Print message."
|
|||
|
)</code></pre>
|
|||
|
<p>If <code>--verbose</code>/<code>--no-verbose</code> is not specified, the variable <code>verbose</code> is <code>TRUE</code>. If <code>--verbose</code> is specified, <code>verbose</code> is <code>TRUE</code> and if <code>--no-verbose</code> is specified, <code>verbose</code> is <code>FALSE</code>.</p>
|
|||
|
<p>If you don’t want to directly export options as variables, you can assign <code>envir</code> argument with an environment variable so that all the option values go there.</p>
|
|||
|
<pre class="r"><code>opt = new.env()
|
|||
|
|
|||
|
opt$cutoff = 0.05
|
|||
|
GetoptLong(
|
|||
|
"number=i@", "Number of items.",
|
|||
|
"cutoff=f", "Cutoff for filtering results.",
|
|||
|
"param=s%", "Parameters specified by name=value pairs.",
|
|||
|
"verbose", "Print message.",
|
|||
|
|
|||
|
envir = opt
|
|||
|
)
|
|||
|
print(as.list(opt))</code></pre>
|
|||
|
<p>a calling from command-line:</p>
|
|||
|
<pre><code>Rscript foo.R --number 1 2 --param var1=a var2=b --verbose</code></pre>
|
|||
|
<p>will print</p>
|
|||
|
<pre><code>$cutoff
|
|||
|
[1] 0.05
|
|||
|
|
|||
|
$number
|
|||
|
[1] 1 2
|
|||
|
|
|||
|
$param
|
|||
|
$param$var1
|
|||
|
[1] "a"
|
|||
|
|
|||
|
$param$var2
|
|||
|
[1] "b"
|
|||
|
|
|||
|
|
|||
|
$verbose
|
|||
|
[1] TRUE</code></pre>
|
|||
|
</div>
|
|||
|
<div id="help-option" class="section level2">
|
|||
|
<h2>Help option</h2>
|
|||
|
<p><code>help</code> is a reserved option, which means, you can not use it as yours.</p>
|
|||
|
<p>Option usage is automatically generated and can be retrieved by setting <code>--help</code> in the command. In following example, I create an option specification that contains all types of options (with long descriptions):</p>
|
|||
|
<pre class="r"><code>GetoptLong(
|
|||
|
"count=i", paste("This is a count. This is a count. This is a count.",
|
|||
|
"This is a count. This is a count. This is a count."),
|
|||
|
"number=f", paste("This is a number. This is a number. This is a number.",
|
|||
|
"This is a number. This is a number. This is a number."),
|
|||
|
"array=f@", paste("This is an array. This is an array. This is an array.",
|
|||
|
"This is an array. This is an array. This is an array."),
|
|||
|
"hash=s%", paste("This is a hash. This is a hash. This is a hash.",
|
|||
|
"This is a hash. This is a hash. This is a hash."),
|
|||
|
"verbose!", "Whether show messages",
|
|||
|
"flag", "a non-sense option"
|
|||
|
)</code></pre>
|
|||
|
<p>The option usage is as follows. Here, for example, the single-letter option <code>-c</code> for <code>--count</code> is automatically extracted while not for <code>--help</code> because <code>h</code> matches two options.</p>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--count, -c integer
|
|||
|
This is a count. This is a count. This is a count. This is a count. This is
|
|||
|
a count. This is a count.
|
|||
|
|
|||
|
--number, -n numeric
|
|||
|
This is a number. This is a number. This is a number. This is a number. This
|
|||
|
is a number. This is a number.
|
|||
|
|
|||
|
--array, -a [numeric, ...]
|
|||
|
This is an array. This is an array. This is an array. This is an array. This
|
|||
|
is an array. This is an array.
|
|||
|
|
|||
|
--hash {name=character, ...}
|
|||
|
This is a hash. This is a hash. This is a hash. This is a hash. This is a
|
|||
|
hash. This is a hash.
|
|||
|
|
|||
|
--verbose, -no-verbose
|
|||
|
Whether show messages
|
|||
|
[default: off]
|
|||
|
|
|||
|
--flag, -f
|
|||
|
a non-sense option
|
|||
|
|
|||
|
--help
|
|||
|
Print help message and exit.
|
|||
|
|
|||
|
--version
|
|||
|
Print version information and exit.
|
|||
|
</code></pre>
|
|||
|
<p>If default values for options are provided, they are properly inserted to the usage message.</p>
|
|||
|
<pre class="r"><code>count = 1
|
|||
|
number = 0.1
|
|||
|
array = c(1, 2)
|
|||
|
hash = list("foo" = "a", "bar" = "b")
|
|||
|
verbose = TRUE
|
|||
|
GetoptLong(
|
|||
|
...
|
|||
|
)</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--count, -c integer
|
|||
|
This is a count. This is a count. This is a count. This is a count. This is
|
|||
|
a count. This is a count.
|
|||
|
[default: 1]
|
|||
|
|
|||
|
--number, -n numeric
|
|||
|
This is a number. This is a number. This is a number. This is a number. This
|
|||
|
is a number. This is a number.
|
|||
|
[default: 0.1]
|
|||
|
|
|||
|
--array, -a [numeric, ...]
|
|||
|
This is an array. This is an array. This is an array. This is an array. This
|
|||
|
is an array. This is an array.
|
|||
|
[default: 1, 2]
|
|||
|
|
|||
|
--hash {name=character, ...}
|
|||
|
This is a hash. This is a hash. This is a hash. This is a hash. This is a
|
|||
|
hash. This is a hash.
|
|||
|
[default: foo=a, bar=b]
|
|||
|
|
|||
|
--verbose, -no-verbose
|
|||
|
Whether show messages
|
|||
|
[default: on]
|
|||
|
|
|||
|
--flag, -f
|
|||
|
a non-sense option
|
|||
|
|
|||
|
--help
|
|||
|
Print help message and exit.
|
|||
|
|
|||
|
--version
|
|||
|
Print version information and exit.
|
|||
|
</code></pre>
|
|||
|
<p>The global parameters <code>help_style</code> can be set to <code>two-column</code> to change to another style:</p>
|
|||
|
<pre class="r"><code>GetoptLong.options(help_style = "two-column")
|
|||
|
# specifying the defaults
|
|||
|
GetoptLong{
|
|||
|
...
|
|||
|
}</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--count, -c This is a count. This is a count. This is a count.
|
|||
|
[type: int] This is a count. This is a count. This is a count.
|
|||
|
[default: 1]
|
|||
|
--number, -n This is a number. This is a number. This is a
|
|||
|
[type: num] number. This is a number. This is a number. This is
|
|||
|
a number.
|
|||
|
[default: 0.1]
|
|||
|
--array, -a This is an array. This is an array. This is an
|
|||
|
[type: [num, ...]] array. This is an array. This is an array. This is
|
|||
|
an array.
|
|||
|
[default: 1, 2]
|
|||
|
--hash This is a hash. This is a hash. This is a hash. This
|
|||
|
[type: {name=chr, ...}] is a hash. This is a hash. This is a hash.
|
|||
|
[default: foo=a, bar=b]
|
|||
|
--verbose, -no-verbose Whether show messages
|
|||
|
[default: on]
|
|||
|
--flag, -f a non-sense option
|
|||
|
--help Print help message and exit.
|
|||
|
--version Print version information and exit. </code></pre>
|
|||
|
<p>When options are specified as name-value pairs, these sub options can be documented as follows. Note the specifications of <em>e.g.</em> <code>foo$name1</code> are only for the usage message.</p>
|
|||
|
<pre class="r"><code>foo = list(a = 1, b = 2)
|
|||
|
GetoptLong(
|
|||
|
"foo=i%", paste("This is foo. This is foo. This is foo. This is foo.",
|
|||
|
"This is foo. This is foo. This is foo. This is foo."),
|
|||
|
"foo$name1", paste("name1 in foo. name1 in foo. name1 in foo. name1 in foo.",
|
|||
|
"name1 in foo. name1 in foo. name1 in foo. name1 in foo."),
|
|||
|
"foo$name2", paste("name2 in foo. name2 in foo. name2 in foo. name2 in foo.",
|
|||
|
"name2 in foo. name2 in foo. name2 in foo. name2 in foo."),
|
|||
|
"bar=s%", paste("This is bar. This is bar. This is bar. This is bar.",
|
|||
|
"This is bar. This is bar. This is bar. This is bar."),
|
|||
|
"bar$name3", paste("name3 in bar. name3 in bar. name3 in bar. name3 in bar.",
|
|||
|
"name3 in bar. name3 in bar. name3 in bar. name3 in bar."),
|
|||
|
"bar$name4", paste("name4 in bar. name4 in bar. name4 in bar. name4 in bar.",
|
|||
|
"name4 in bar. name4 in bar. name4 in bar. name4 in bar.")
|
|||
|
)</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--foo, -f {name=integer, ...}
|
|||
|
This is foo. This is foo. This is foo. This is foo. This is foo. This is
|
|||
|
foo. This is foo. This is foo.
|
|||
|
[default: a=1, b=2]
|
|||
|
|
|||
|
Sub named options:
|
|||
|
name1=integer name1 in foo. name1 in foo. name1 in foo. name1 in foo. name1
|
|||
|
in foo. name1 in foo. name1 in foo. name1 in foo.
|
|||
|
name2=integer name2 in foo. name2 in foo. name2 in foo. name2 in foo. name2
|
|||
|
in foo. name2 in foo. name2 in foo. name2 in foo.
|
|||
|
|
|||
|
--bar, -b {name=character, ...}
|
|||
|
This is bar. This is bar. This is bar. This is bar. This is bar. This is
|
|||
|
bar. This is bar. This is bar.
|
|||
|
|
|||
|
Sub named options:
|
|||
|
name3=character name3 in bar. name3 in bar. name3 in bar. name3 in bar. name3
|
|||
|
in bar. name3 in bar. name3 in bar. name3 in bar.
|
|||
|
name4=character name4 in bar. name4 in bar. name4 in bar. name4 in bar. name4
|
|||
|
in bar. name4 in bar. name4 in bar. name4 in bar.
|
|||
|
|
|||
|
--help, -h
|
|||
|
Print help message and exit.
|
|||
|
|
|||
|
--version, -v
|
|||
|
Print version information and exit.
|
|||
|
</code></pre>
|
|||
|
<p>And the two-column style for the sub options.</p>
|
|||
|
<pre class="r"><code>GetoptLong.options(help_style = "two-column")
|
|||
|
GetoptLong{
|
|||
|
...
|
|||
|
}</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--foo, -f This is foo. This is foo. This is foo. This is foo.
|
|||
|
[type: {name=int, ...}] This is foo. This is foo. This is foo. This is foo.
|
|||
|
[default: a=1, b=2]
|
|||
|
|
|||
|
Sub named options:
|
|||
|
name1=int name1 in foo. name1 in foo. name1 in foo.
|
|||
|
name1 in foo. name1 in foo. name1 in foo.
|
|||
|
name1 in foo. name1 in foo.
|
|||
|
name2=int name2 in foo. name2 in foo. name2 in foo.
|
|||
|
name2 in foo. name2 in foo. name2 in foo.
|
|||
|
name2 in foo. name2 in foo.
|
|||
|
|
|||
|
--bar, -b This is bar. This is bar. This is bar. This is bar.
|
|||
|
[type: {name=chr, ...}] This is bar. This is bar. This is bar. This is bar.
|
|||
|
|
|||
|
Sub named options:
|
|||
|
name3=chr name3 in bar. name3 in bar. name3 in bar.
|
|||
|
name3 in bar. name3 in bar. name3 in bar.
|
|||
|
name3 in bar. name3 in bar.
|
|||
|
name4=chr name4 in bar. name4 in bar. name4 in bar.
|
|||
|
name4 in bar. name4 in bar. name4 in bar.
|
|||
|
name4 in bar. name4 in bar.
|
|||
|
|
|||
|
--help, -h Print help message and exit.
|
|||
|
--version, -v Print version information and exit. </code></pre>
|
|||
|
<p>Extra text such head and foot of the usage message can be set with <code>help_head</code> and <code>help_foot</code> arguments:</p>
|
|||
|
<pre class="r"><code>GetoptLong(
|
|||
|
help_head = "This is a demonstration of adding usage head and foot.",
|
|||
|
|
|||
|
"number=i", "Number of items.",
|
|||
|
"cutoff=f", "Cutoff for filtering results.",
|
|||
|
"verbose", "Print message.",
|
|||
|
|
|||
|
help_foot = "Please contact name@address."
|
|||
|
)</code></pre>
|
|||
|
<pre><code>This is a demonstration of adding usage head and foot.
|
|||
|
|
|||
|
Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Options:
|
|||
|
--number, -n integer
|
|||
|
Number of items.
|
|||
|
|
|||
|
--cutoff, -c numeric
|
|||
|
Cutoff for filtering results.
|
|||
|
|
|||
|
--verbose
|
|||
|
Print message.
|
|||
|
|
|||
|
--help, -h
|
|||
|
Print help message and exit.
|
|||
|
|
|||
|
--version
|
|||
|
Print version information and exit.
|
|||
|
|
|||
|
Please contact name@address.</code></pre>
|
|||
|
<p>The options in the usage text can be grouped by setting separator lines. The separator line should contain two elements: the separator and the description. The separator can be any character in <code>-+=#%</code> with any length.</p>
|
|||
|
<pre class="r"><code>count = 1
|
|||
|
array = c(0.1, 0.2)
|
|||
|
GetoptLong(
|
|||
|
"--------", "Binary options:",
|
|||
|
"verbose!", "Whether show messages",
|
|||
|
"flag", "a non-sense option",
|
|||
|
|
|||
|
"-------", "Single-value options:",
|
|||
|
"count=i", paste("This is a count. This is a count. This is a count.",
|
|||
|
"This is a count. This is a count. This is a count."),
|
|||
|
"number=f", paste("This is a number. This is a number. This is a number.",
|
|||
|
"This is a number. This is a number. This is a number."),
|
|||
|
|
|||
|
"--------", paste("Multiple-vlaue options: long text long text long text",
|
|||
|
" long text long text long text long text long text"),
|
|||
|
"array=f@", paste("This is an array. This is an array. This is an array.",
|
|||
|
"This is an array. This is an array. This is an array."),
|
|||
|
"hash=s%", paste("This is a hash. This is a hash. This is a hash.",
|
|||
|
"This is a hash. This is a hash. This is a hash."),
|
|||
|
|
|||
|
"-------", "Other options:"
|
|||
|
)</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Binary options:
|
|||
|
--verbose, -no-verbose
|
|||
|
Whether show messages
|
|||
|
[default: off]
|
|||
|
|
|||
|
--flag, -f
|
|||
|
a non-sense option
|
|||
|
|
|||
|
Single-value options:
|
|||
|
--count, -c integer
|
|||
|
This is a count. This is a count. This is a count. This is a count. This is
|
|||
|
a count. This is a count.
|
|||
|
[default: 1]
|
|||
|
|
|||
|
--number, -n numeric
|
|||
|
This is a number. This is a number. This is a number. This is a number. This
|
|||
|
is a number. This is a number.
|
|||
|
|
|||
|
Multiple-vlaue options: long text long text long text long text long text long
|
|||
|
text long text long text
|
|||
|
--array, -a [numeric, ...]
|
|||
|
This is an array. This is an array. This is an array. This is an array. This
|
|||
|
is an array. This is an array.
|
|||
|
[default: 0.1, 0.2]
|
|||
|
|
|||
|
--hash {name=character, ...}
|
|||
|
This is a hash. This is a hash. This is a hash. This is a hash. This is a
|
|||
|
hash. This is a hash.
|
|||
|
|
|||
|
Other options:
|
|||
|
--help
|
|||
|
Print help message and exit.
|
|||
|
|
|||
|
--version
|
|||
|
Print version information and exit.
|
|||
|
</code></pre>
|
|||
|
<p>And the two-column style for the grouped options.</p>
|
|||
|
<pre class="r"><code>GetoptLong.options(help_style = "two-column")
|
|||
|
GetoptLong{
|
|||
|
...
|
|||
|
}</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Binary options:
|
|||
|
--verbose, -no-verbose Whether show messages
|
|||
|
[default: off]
|
|||
|
--flag, -f a non-sense option
|
|||
|
|
|||
|
Single-value options:
|
|||
|
--count, -c This is a count. This is a count. This is a count. This is a
|
|||
|
[type: int] count. This is a count. This is a count.
|
|||
|
[default: 1]
|
|||
|
--number, -n This is a number. This is a number. This is a number. This is
|
|||
|
[type: num] a number. This is a number. This is a number.
|
|||
|
|
|||
|
Multiple-vlaue options: long text long text long text long text long text long
|
|||
|
text long text long text
|
|||
|
--array, -a This is an array. This is an array. This is an
|
|||
|
[type: [num, ...]] array. This is an array. This is an array. This is
|
|||
|
an array.
|
|||
|
[default: 0.1, 0.2]
|
|||
|
--hash This is a hash. This is a hash. This is a hash. This
|
|||
|
[type: {name=chr, ...}] is a hash. This is a hash. This is a hash.
|
|||
|
|
|||
|
Other options:
|
|||
|
--help Print help message and exit.
|
|||
|
--version Print version information and exit. </code></pre>
|
|||
|
<p>The global option <code>GetoptLong.options$help_width</code> controls the maximal width of the usage message.</p>
|
|||
|
<p>The specification can also be set as a template which provides more flexibilities for the usage message. Here option specifications are maked by <code><></code> where the specifications will be extracted and the text will be replaced by the option description. The mark can be set by <code>GetoptLong.options$template_tag</code> global option.</p>
|
|||
|
<p>The option descriptions have different widths. To properly align the text, you need to manually adjust the width (spaces are filled if the width is larger than the option description) by setting <code>opt_width</code> parameter via <code>template_control</code> argument. See the following example.</p>
|
|||
|
<pre class="r"><code>GetoptLong("
|
|||
|
This is a demonstration of using template as the option specification.
|
|||
|
|
|||
|
Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Binary options:
|
|||
|
<verbose!> Whether show messages
|
|||
|
<flag> A non-sense option
|
|||
|
|
|||
|
Single-value options:
|
|||
|
<count=i> This is a count. This is a count.
|
|||
|
<number=f> This is a number. This is a number.
|
|||
|
|
|||
|
Multiple-vlaue options:
|
|||
|
<array=f@> This is an array. This is an array.
|
|||
|
<hash=s%> This is a hash. This is a hash.
|
|||
|
|
|||
|
Questions, please contact your.name@email
|
|||
|
", template_control = list(opt_width = c(verbose = 23, flag = 23,
|
|||
|
count = 22, number = 22,
|
|||
|
array = 30, hash = 30)
|
|||
|
))</code></pre>
|
|||
|
<pre><code>This is a demonstration of using template as the option specification.
|
|||
|
|
|||
|
Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
Binary options:
|
|||
|
--verbose, -no-verbose Whether show messages
|
|||
|
--flag, -f A non-sense option
|
|||
|
|
|||
|
Single-value options:
|
|||
|
--count, -c integer This is a count. This is a count.
|
|||
|
--number, -n numeric This is a number. This is a number.
|
|||
|
|
|||
|
Multiple-vlaue options:
|
|||
|
--array, -a [numeric, ...] This is an array. This is an array.
|
|||
|
--hash {name=character, ...} This is a hash. This is a hash.
|
|||
|
|
|||
|
Questions, please contact your.name@email </code></pre>
|
|||
|
<p>If the option explanation lies in more than one lines, in front from the second line, you should add a tag in form of <code><#tag></code> where <code>tag</code> is the option name of the current option block, so that proper spaces in front of the text can be calculated and the text will be properly aligned. See the following example:</p>
|
|||
|
<pre class="r"><code>GetoptLong("
|
|||
|
Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
<count=i{2,}> This is a count. This is a count. This is a count.
|
|||
|
<#count> This is a count. This is a count.
|
|||
|
<number=f> This is a number. This is a number. This is a number.
|
|||
|
<#number> This is a number. This is a number.
|
|||
|
", template_control = list(opt_width = c(count = 28, number = 28))
|
|||
|
)</code></pre>
|
|||
|
<pre><code>Usage: Rscript foo.R [options]
|
|||
|
|
|||
|
--count, -c [integer, ...] This is a count. This is a count. This is a count.
|
|||
|
This is a count. This is a count.
|
|||
|
--number, -n numeric This is a number. This is a number. This is a number.
|
|||
|
This is a number. This is a number. </code></pre>
|
|||
|
</div>
|
|||
|
<div id="version-option" class="section level2">
|
|||
|
<h2>Version option</h2>
|
|||
|
<p><code>version</code> is also a reserved option.</p>
|
|||
|
<p>Version should be stored in a variable <code>VERSION</code> before the call of <code>GetoptLong()</code>, then <code>--version</code> prints the corresponding version value.</p>
|
|||
|
<pre class="r"><code>VERSION = "0.0.1"
|
|||
|
GetoptLong(
|
|||
|
"tag=i", "...",
|
|||
|
)</code></pre>
|
|||
|
<pre><code>~\> Rscript foo.R --version
|
|||
|
0.0.1</code></pre>
|
|||
|
</div>
|
|||
|
<div id="configuring-getoptlong" class="section level2">
|
|||
|
<h2>Configuring Getopt::Long</h2>
|
|||
|
<p>Configuration of <code>Getopt::Long</code> can be set by <code>GetoptLong.options("config")</code>:</p>
|
|||
|
<pre class="r"><code>GetoptLong.options("config" = "bundling")
|
|||
|
GetoptLong.options("config" = c("no_ignore_case", "bundling"))</code></pre>
|
|||
|
<p>With different configurations, it can support more types of option specifications:</p>
|
|||
|
<pre><code>-a -b -c -abc
|
|||
|
-s 24 -s24 -s=24</code></pre>
|
|||
|
<p>Please refer to website of <a href="https://perldoc.pl/Getopt::Long"><code>Getopt::Long</code></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div id="specify-path-of-perl-in-command-line" class="section level2">
|
|||
|
<h2>Specify path of Perl in command line</h2>
|
|||
|
<p>In some conditions that path of binary <strong>Perl</strong> is not in the <code>PATH</code> environment variable and you do not have permission to modify <code>PATH</code>. You can specify your <strong>Perl</strong> path from command line like:</p>
|
|||
|
<pre><code>~\> Rscript foo.R -a -b -c -- /your/perl/bin/perl</code></pre>
|
|||
|
<p>Since arguments following after <code>--</code> will be ignored by <code>Getopt::Long</code>, we take the first argument next to <code>--</code> as the path of user-specified <strong>Perl</strong> path.</p>
|
|||
|
</div>
|
|||
|
<div id="specify-command-line-options-within-r-session" class="section level2">
|
|||
|
<h2>Specify command-line options within R session</h2>
|
|||
|
<p>When in an interactive R session, arguments can be set when calling <code>source_script()</code>, so it would be convinient to load external R scripts with different comand-line arguments. <em>E.g.</em>:</p>
|
|||
|
<pre class="r"><code>source_script("foo.R", argv_str = "--cutoff 0.01 --input file=foo.txt --verbose")</code></pre>
|
|||
|
</div>
|
|||
|
<div id="session-info" class="section level2">
|
|||
|
<h2>Session info</h2>
|
|||
|
<pre class="r"><code>sessionInfo()</code></pre>
|
|||
|
<pre><code>R version 4.0.2 (2020-06-22)
|
|||
|
Platform: x86_64-apple-darwin17.0 (64-bit)
|
|||
|
Running under: macOS Catalina 10.15.5
|
|||
|
|
|||
|
Matrix products: default
|
|||
|
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
|
|||
|
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
|
|||
|
|
|||
|
locale:
|
|||
|
[1] C/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
|
|||
|
|
|||
|
attached base packages:
|
|||
|
[1] stats graphics grDevices utils datasets methods base
|
|||
|
|
|||
|
other attached packages:
|
|||
|
[1] GetoptLong_1.0.5 knitr_1.30
|
|||
|
|
|||
|
loaded via a namespace (and not attached):
|
|||
|
[1] compiler_4.0.2 rjson_0.2.20 magrittr_2.0.1
|
|||
|
[4] htmltools_0.5.0 tools_4.0.2 GlobalOptions_0.1.2
|
|||
|
[7] yaml_2.2.1 crayon_1.3.4 stringi_1.5.3
|
|||
|
[10] rmarkdown_2.5 stringr_1.4.0 digest_0.6.27
|
|||
|
[13] xfun_0.19 rlang_0.4.8 evaluate_0.14 </code></pre>
|
|||
|
<script>
|
|||
|
var elements = document.getElementsByTagName("pre");
|
|||
|
for(var i = 0; i < elements.length; i ++ ) {
|
|||
|
if(!elements[i].hasAttribute("class")) {
|
|||
|
code = elements[i].children[0];
|
|||
|
code.style.color = "white";
|
|||
|
elements[i].style.background = "hsl(70, 0%, 15%)";
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
|
|||
|
// add bootstrap table styles to pandoc tables
|
|||
|
function bootstrapStylePandocTables() {
|
|||
|
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
|
|||
|
}
|
|||
|
$(document).ready(function () {
|
|||
|
bootstrapStylePandocTables();
|
|||
|
});
|
|||
|
|
|||
|
|
|||
|
</script>
|
|||
|
|
|||
|
<!-- tabsets -->
|
|||
|
|
|||
|
<script>
|
|||
|
$(document).ready(function () {
|
|||
|
window.buildTabsets("TOC");
|
|||
|
});
|
|||
|
|
|||
|
$(document).ready(function () {
|
|||
|
$('.tabset-dropdown > .nav-tabs > li').click(function () {
|
|||
|
$(this).parent().toggleClass('nav-tabs-open')
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<!-- code folding -->
|
|||
|
|
|||
|
<script>
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
// move toc-ignore selectors from section div to header
|
|||
|
$('div.section.toc-ignore')
|
|||
|
.removeClass('toc-ignore')
|
|||
|
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
|
|||
|
|
|||
|
// establish options
|
|||
|
var options = {
|
|||
|
selectors: "h1,h2,h3",
|
|||
|
theme: "bootstrap3",
|
|||
|
context: '.toc-content',
|
|||
|
hashGenerator: function (text) {
|
|||
|
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
|
|||
|
},
|
|||
|
ignoreSelector: ".toc-ignore",
|
|||
|
scrollTo: 0
|
|||
|
};
|
|||
|
options.showAndHide = true;
|
|||
|
options.smoothScroll = true;
|
|||
|
|
|||
|
// tocify
|
|||
|
var toc = $("#TOC").tocify(options).data("toc-tocify");
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<!-- dynamically load mathjax for compatibility with self-contained -->
|
|||
|
<script>
|
|||
|
(function () {
|
|||
|
var script = document.createElement("script");
|
|||
|
script.type = "text/javascript";
|
|||
|
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
|
|||
|
document.getElementsByTagName("head")[0].appendChild(script);
|
|||
|
})();
|
|||
|
</script>
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|