Last active
August 29, 2015 13:57
-
-
Save r-sal/9838615 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#resultswrapper { | |
} | |
.stats-wrap { | |
float: right; | |
margin-top: 5px; | |
} | |
.btn { | |
display: inline-block; | |
padding: 6px 12px; | |
margin-bottom: 0; | |
font-size: 14px; | |
font-weight: normal; | |
line-height: 1.42857143; | |
text-align: center; | |
white-space: nowrap; | |
vertical-align: middle; | |
cursor: pointer; | |
-webkit-user-select: none; | |
-moz-user-select: none; | |
-ms-user-select: none; | |
user-select: none; | |
background-image: none; | |
border: 1px solid transparent; | |
border-radius: 4px; | |
color: #fff; | |
background-color: #428bca; | |
border-color: #357ebd; | |
} | |
.well { | |
min-height: 20px; | |
padding: 19px; | |
margin-bottom: 20px; | |
background-color: #f5f5f5; | |
border: 1px solid #e3e3e3; | |
border-radius: 4px; | |
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.05); | |
box-shadow: inset 0 1px 1px rgba(0,0,0,.05); | |
padding: 9px; | |
border-radius: 3px; | |
} | |
.label { | |
display: inline; | |
padding: .2em .6em .3em; | |
font-size: 75%; | |
font-weight: 700; | |
line-height: 1; | |
color: #fff; | |
text-align: center; | |
white-space: nowrap; | |
vertical-align: baseline; | |
border-radius: .25em; | |
margin-left: 5px; | |
} | |
.label-notfixed { | |
background-color: #d9534f; | |
} | |
.label-verified { | |
background-color: #5cb85c; | |
} | |
.label-toverify { | |
background-color: #f0ad4e; | |
} | |
.label.label-toopen { | |
background-color: #0085FF; | |
} | |
.label-total h3 { | |
padding: 0 10px; | |
font-size: 27px; | |
line-height: 22px; | |
border-right: 3px solid #e3e3e3; | |
} | |
tr.notfixed td:first-of-type, | |
tr.notfixed td:last-of-type, | |
tr.notfixed td:nth-last-child(2) | |
{ | |
background: #ff9a9a; | |
} | |
tr.verified td:first-of-type, | |
tr.verified td:last-of-type, | |
tr.verified td:nth-last-child(2) | |
{ | |
background: #b4ffda; | |
} | |
tr.toopen td:first-of-type, | |
tr.toopen td:last-of-type, | |
tr.toopen td:nth-last-child(2) | |
{ | |
background: #fdee00; | |
} | |
tr.toverify td:first-of-type | |
/*tr.toverify td:last-of-type, | |
tr.toverify td:nth-last-child(2) */ | |
{ | |
background: #fdee00; | |
} | |
tr.moreinfo td:first-of-type | |
/*,tr.moreinfo td:last-of-type, | |
tr.moreinfo td:nth-last-child(2) */ | |
{ | |
background: #42a1ff; | |
} | |
tr.followup td:first-of-type, | |
tr.followup td:last-of-type, | |
tr.followup td:nth-last-child(2) | |
{ | |
background: #ffff8e; | |
} | |
/* | |
notvalid #f1f1f1 | |
empty #42a1ff | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.stats-wrap{float:right;margin-top:5px}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px;color:#fff;background-color:#428bca;border-color:#357ebd}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05);padding:9px;border-radius:3px}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-left:5px}.label-notfixed{background-color:#d9534f}.label-verified{background-color:#5cb85c}.label-toverify{background-color:#f0ad4e}.label.label-toopen{background-color:#0085ff}.label-total h3{padding:0 10px;font-size:27px;line-height:22px;border-right:3px solid #e3e3e3}tr.notfixed td:first-of-type,tr.notfixed td:last-of-type,tr.notfixed td:nth-last-child(2){background:#ff9a9a}tr.verified td:first-of-type,tr.verified td:last-of-type,tr.verified td:nth-last-child(2){background:#b4ffda}tr.toopen td:first-of-type,tr.toopen td:last-of-type,tr.toopen td:nth-last-child(2){background:#fdee00}tr.toverify td:first-of-type{background:#fdee00}tr.moreinfo td:first-of-type{background:#42a1ff}tr.followup td:first-of-type,tr.followup td:last-of-type,tr.followup td:nth-last-child(2){background:#ffff8e} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Underscore.js 1.6.0 */ (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:0>t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r<arguments.length;)e.push(arguments[r++]);return n.apply(this,e)}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:j.now(),a=null,i=n.apply(e,u),e=u=null};return function(){var l=j.now();o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this); | |
function tmpl(){}function hereDoc(e){return e.toString().split(/\n/).slice(1,-1).join("\n")}function loadAssets(){window.style="";style+=" h3{ padding: 15px 0 0 0; margin:0; font-size: 15px;} ";style+=" h2 a { font-size: 20px; color: #000; margin: 0; text-decoration: none; float: left; }";style+=" header { height: 30px; }";style+=" header small{ float: right; clear: left; color: #717171;}";style+=" header span{ float: right; }";style+=" table{ border-spacing:0; border-collapse:collapse }";style+=" table tr td{ border:1px solid }";style+=" table tr td{ border-collapse:collapse; padding-left: 7px; font-size: 13px; }";style+=" table tr td:nth-of-type(1){ width:370px; }";style+=" table tr td:nth-of-type(2){ width:50px; }";style+=" table tr td:nth-of-type(3){ min-width:260px }";style+=" tr.no-pkg-price{ background-color: #fffbe6; }";style+=" td.no-opt-features { border: none; }";style+=" table tr.price-tbd td:nth-of-type(2){ background: #ffe0e0; }";style+=" tr.standard-feat td:first-of-type { background: #ffe0e0; }";window.t="";t+="{{#each sections}}";t+=" <h3>{{title}}</h3>";t+=" <table>";t+=" {{#each features}}";t+=' <tr class="{{classes}}">';t+=" <td>{{{title}}}</td><td>{{price}}</td>";t+=" <td>{{#each package}} {{this}}<br> {{/each}}</td>";t+=" </tr>";t+=" {{else}}";t+=' <tr><td class="no-opt-features">No optional features</td></tr>';t+=" {{/each}}";t+=" </table>";t+="{{/each}}"}function init(){window.mpPrices={};window.mpPrices.features=null;window.mpPrices.packages=null;window.mpPrices.accessories=null;var e=getModelUrls();$.when($.getJSON(e["features"]).done(features_callback),$.getJSON(e["packages"]).done(package_callback)).then(start);var t="<header>";t+='<h2><a href="'+window.location.href+'" target="_blank">'+getModelName()+"</a></h2>";t+="<span>"+getMSRP()+"</span>";t+="<br><small>"+getDateTime()+"</small>";t+="</header>";t+='<p class="loading" style="padding: 100px 0;text-align: center;">Loading..</p>';createPopup(t,"width=690,height=900",getModelName()+" "+getDateString(),window.style)}function features_callback(e){var t=e.model_section_features,n=[];for(var r in t){var i=t[r]["touts"],s=t[r]["title"],o=processFeatures(i);n.push({title:s,features:o})}window.mpPrices.features=n}function package_callback(e){var t=e.model_section_packages,n=[];for(var r in t){var i=t[r],s=i["title"],o=i["status"]?"STD":"OPT",u=[];if(o=="OPT"&&i["price"]==0){u.push("no-pkg-price")}if(o=="STD"&&i["price"]!=0){u.push("no-pkg-price")}n.push({title:s,price:formatPrice(i["price"]),"package":[i["status"]?"Standard":""],status:o,classes:u.join(" ")})}window.mpPrices.packages=[{title:"Packages",features:n}];window.mpPrices.accessories=[{title:"Accessories",features:processFeatures(e.accessories["touts"])}]}function start(){var e=window.mpPrices,t=[].concat(e.features,e.accessories,e.packages);feats=Handlebars.compile(hereDoc(tmpl));phtml=feats({sections:t});$(window.mywindow.document).find("p.loading").remove();$(window.mywindow.document).find("body").append(phtml)}function getPackages(e){var t=[];for(var n in e){t.push(e[n]["title"])}return t}function formatPrice(e){if(e=="99999"){return"TBD"}if(e=="0"){return false}return"$"+e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function processFeatures(e){var t=[];for(var n in e){var r=e[n],i=r["standAlonePrice"],s=formatPrice(i),o=r["standAlone"],u=r["packageContentGroups"],a=getPackages(u),f=r["status"],l=[];if(!s&&a.length==0){l.push("no-pkg-price")}if(f=="OPT"||i>0||o==true){if(f=="STD"){l.push("standard-feat")}if(s=="TBD"){l.push("price-tbd")}t.push({title:r["title"],price:s?s:"","package":a,status:f,classes:l.join(" ")})}}return t}function createPopup(e,t,n,r){if(typeof mywindow!=="undefined"){mywindow.close()}mywindow=window.open("","MyPopup",t);$(mywindow.document.body).html(e);$(mywindow.document).find("head").append("<title>"+n+"</title>");var i="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css";$(mywindow.document).find("head").append("<style>"+r+"</style>");return mywindow}function getModelUrls(){var e=window.location.origin,t=$(".content").data("props").model,n=$(".content").data("props").class,r=$(".content").data("props").contextPath,i=e+r+"/json/vehicles/model/class-"+n+"/model-"+t,s={};s["features"]=i+"/section-features";s["specs"]=i+"/section-specs";s["packages"]=i+"/section-packages";return s}function getModelName(){return $("#exterior-slide").find("h1").find("span").eq(0).text()}function getDateTime(){var e=new Date;return e.toLocaleDateString()+", "+e.toLocaleTimeString()}function getDateString(){var e=new Date,t=e.getMonth()+1,n=e.getDate(),r=e.getUTCFullYear();return r+"-"+(t<10?"0"+t:t)+"-"+(n<10?"0"+n:n)}function getMSRP(){return $("#exterior-slide").find("p.price").text()}loadAssets();init() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* NEWER - White | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(255, 255, 255,.4); } | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(255, 255, 255,.1); } | |
*/ | |
img[src$="jpg"] + | |
img.hero-cladding-image[src$="png"] | |
{ background-color: rgba(0, 255, 20, 0.28); } | |
img[src$="png"] + | |
img.hero-cladding-image[src$="png"] | |
{ background-color: rgba(255, 255, 255,.20); } | |
/* FIRST | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(255,0,0,.8); } | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(0,255,0,.2); } | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(0,0,255,.1); } | |
*/ | |
/* NEW | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(0, 255, 255,.5); } | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(0, 255, 255,.2); } | |
.hero-angle-image-wrapper | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image + | |
img.hero-cladding-image | |
{ background-color: rgba(0, 255, 255,.2); } | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* URI.js - Mutating URLs | |
* | |
* Version: 1.13.2 | |
* | |
* Author: Rodney Rehm | |
* Web: http://medialize.github.io/URI.js/ | |
* | |
* Licensed under | |
* MIT License http://www.opensource.org/licenses/mit-license | |
* GPL v3 http://opensource.org/licenses/GPL-3.0 | |
* | |
*/ | |
(function (root, factory) { | |
'use strict'; | |
// https://github.com/umdjs/umd/blob/master/returnExports.js | |
if (typeof exports === 'object') { | |
// Node | |
module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains')); | |
} else if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['./punycode', './IPv6', './SecondLevelDomains'], factory); | |
} else { | |
// Browser globals (root is window) | |
root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains, root); | |
} | |
}(this, function (punycode, IPv6, SLD, root) { | |
'use strict'; | |
/*global location, escape, unescape */ | |
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase | |
/*jshint camelcase: false */ | |
// save current URI variable, if any | |
var _URI = root && root.URI; | |
function URI(url, base) { | |
// Allow instantiation without the 'new' keyword | |
if (!(this instanceof URI)) { | |
return new URI(url, base); | |
} | |
if (url === undefined) { | |
if (typeof location !== 'undefined') { | |
url = location.href + ''; | |
} else { | |
url = ''; | |
} | |
} | |
this.href(url); | |
// resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor | |
if (base !== undefined) { | |
return this.absoluteTo(base); | |
} | |
return this; | |
} | |
URI.version = '1.13.2'; | |
var p = URI.prototype; | |
var hasOwn = Object.prototype.hasOwnProperty; | |
function escapeRegEx(string) { | |
// https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963 | |
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); | |
} | |
function getType(value) { | |
// IE8 doesn't return [Object Undefined] but [Object Object] for undefined value | |
if (value === undefined) { | |
return 'Undefined'; | |
} | |
return String(Object.prototype.toString.call(value)).slice(8, -1); | |
} | |
function isArray(obj) { | |
return getType(obj) === 'Array'; | |
} | |
function filterArrayValues(data, value) { | |
var lookup = {}; | |
var i, length; | |
if (isArray(value)) { | |
for (i = 0, length = value.length; i < length; i++) { | |
lookup[value[i]] = true; | |
} | |
} else { | |
lookup[value] = true; | |
} | |
for (i = 0, length = data.length; i < length; i++) { | |
if (lookup[data[i]] !== undefined) { | |
data.splice(i, 1); | |
length--; | |
i--; | |
} | |
} | |
return data; | |
} | |
function arrayContains(list, value) { | |
var i, length; | |
// value may be string, number, array, regexp | |
if (isArray(value)) { | |
// Note: this can be optimized to O(n) (instead of current O(m * n)) | |
for (i = 0, length = value.length; i < length; i++) { | |
if (!arrayContains(list, value[i])) { | |
return false; | |
} | |
} | |
return true; | |
} | |
var _type = getType(value); | |
for (i = 0, length = list.length; i < length; i++) { | |
if (_type === 'RegExp') { | |
if (typeof list[i] === 'string' && list[i].match(value)) { | |
return true; | |
} | |
} else if (list[i] === value) { | |
return true; | |
} | |
} | |
return false; | |
} | |
function arraysEqual(one, two) { | |
if (!isArray(one) || !isArray(two)) { | |
return false; | |
} | |
// arrays can't be equal if they have different amount of content | |
if (one.length !== two.length) { | |
return false; | |
} | |
one.sort(); | |
two.sort(); | |
for (var i = 0, l = one.length; i < l; i++) { | |
if (one[i] !== two[i]) { | |
return false; | |
} | |
} | |
return true; | |
} | |
URI._parts = function() { | |
return { | |
protocol: null, | |
username: null, | |
password: null, | |
hostname: null, | |
urn: null, | |
port: null, | |
path: null, | |
query: null, | |
fragment: null, | |
// state | |
duplicateQueryParameters: URI.duplicateQueryParameters, | |
escapeQuerySpace: URI.escapeQuerySpace | |
}; | |
}; | |
// state: allow duplicate query parameters (a=1&a=1) | |
URI.duplicateQueryParameters = false; | |
// state: replaces + with %20 (space in query strings) | |
URI.escapeQuerySpace = true; | |
// static properties | |
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i; | |
URI.idn_expression = /[^a-z0-9\.-]/i; | |
URI.punycode_expression = /(xn--)/i; | |
// well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care? | |
URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; | |
// credits to Rich Brown | |
// source: http://forums.intermapper.com/viewtopic.php?p=1096#1096 | |
// specification: http://www.ietf.org/rfc/rfc4291.txt | |
URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; | |
// expression used is "gruber revised" (@gruber v2) determined to be the | |
// best solution in a regex-golf we did a couple of ages ago at | |
// * http://mathiasbynens.be/demo/url-regex | |
// * http://rodneyrehm.de/t/url-regex.html | |
URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig; | |
URI.findUri = { | |
// valid "scheme://" or "www." | |
start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi, | |
// everything up to the next whitespace | |
end: /[\s\r\n]|$/, | |
// trim trailing punctuation captured by end RegExp | |
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/ | |
}; | |
// http://www.iana.org/assignments/uri-schemes.html | |
// http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports | |
URI.defaultPorts = { | |
http: '80', | |
https: '443', | |
ftp: '21', | |
gopher: '70', | |
ws: '80', | |
wss: '443' | |
}; | |
// allowed hostname characters according to RFC 3986 | |
// ALPHA DIGIT "-" "." "_" "~" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" %encoded | |
// I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . - | |
URI.invalid_hostname_characters = /[^a-zA-Z0-9\.-]/; | |
// map DOM Elements to their URI attribute | |
URI.domAttributes = { | |
'a': 'href', | |
'blockquote': 'cite', | |
'link': 'href', | |
'base': 'href', | |
'script': 'src', | |
'form': 'action', | |
'img': 'src', | |
'area': 'href', | |
'iframe': 'src', | |
'embed': 'src', | |
'source': 'src', | |
'track': 'src', | |
'input': 'src' // but only if type="image" | |
}; | |
URI.getDomAttribute = function(node) { | |
if (!node || !node.nodeName) { | |
return undefined; | |
} | |
var nodeName = node.nodeName.toLowerCase(); | |
// <input> should only expose src for type="image" | |
if (nodeName === 'input' && node.type !== 'image') { | |
return undefined; | |
} | |
return URI.domAttributes[nodeName]; | |
}; | |
function escapeForDumbFirefox36(value) { | |
// https://github.com/medialize/URI.js/issues/91 | |
return escape(value); | |
} | |
// encoding / decoding according to RFC3986 | |
function strictEncodeURIComponent(string) { | |
// see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent | |
return encodeURIComponent(string) | |
.replace(/[!'()*]/g, escapeForDumbFirefox36) | |
.replace(/\*/g, '%2A'); | |
} | |
URI.encode = strictEncodeURIComponent; | |
URI.decode = decodeURIComponent; | |
URI.iso8859 = function() { | |
URI.encode = escape; | |
URI.decode = unescape; | |
}; | |
URI.unicode = function() { | |
URI.encode = strictEncodeURIComponent; | |
URI.decode = decodeURIComponent; | |
}; | |
URI.characters = { | |
pathname: { | |
encode: { | |
// RFC3986 2.1: For consistency, URI producers and normalizers should | |
// use uppercase hexadecimal digits for all percent-encodings. | |
expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig, | |
map: { | |
// -._~!'()* | |
'%24': '$', | |
'%26': '&', | |
'%2B': '+', | |
'%2C': ',', | |
'%3B': ';', | |
'%3D': '=', | |
'%3A': ':', | |
'%40': '@' | |
} | |
}, | |
decode: { | |
expression: /[\/\?#]/g, | |
map: { | |
'/': '%2F', | |
'?': '%3F', | |
'#': '%23' | |
} | |
} | |
}, | |
reserved: { | |
encode: { | |
// RFC3986 2.1: For consistency, URI producers and normalizers should | |
// use uppercase hexadecimal digits for all percent-encodings. | |
expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig, | |
map: { | |
// gen-delims | |
'%3A': ':', | |
'%2F': '/', | |
'%3F': '?', | |
'%23': '#', | |
'%5B': '[', | |
'%5D': ']', | |
'%40': '@', | |
// sub-delims | |
'%21': '!', | |
'%24': '$', | |
'%26': '&', | |
'%27': '\'', | |
'%28': '(', | |
'%29': ')', | |
'%2A': '*', | |
'%2B': '+', | |
'%2C': ',', | |
'%3B': ';', | |
'%3D': '=' | |
} | |
} | |
} | |
}; | |
URI.encodeQuery = function(string, escapeQuerySpace) { | |
var escaped = URI.encode(string + ''); | |
if (escapeQuerySpace === undefined) { | |
escapeQuerySpace = URI.escapeQuerySpace; | |
} | |
return escapeQuerySpace ? escaped.replace(/%20/g, '+') : escaped; | |
}; | |
URI.decodeQuery = function(string, escapeQuerySpace) { | |
string += ''; | |
if (escapeQuerySpace === undefined) { | |
escapeQuerySpace = URI.escapeQuerySpace; | |
} | |
try { | |
return URI.decode(escapeQuerySpace ? string.replace(/\+/g, '%20') : string); | |
} catch(e) { | |
// we're not going to mess with weird encodings, | |
// give up and return the undecoded original string | |
// see https://github.com/medialize/URI.js/issues/87 | |
// see https://github.com/medialize/URI.js/issues/92 | |
return string; | |
} | |
}; | |
URI.recodePath = function(string) { | |
var segments = (string + '').split('/'); | |
for (var i = 0, length = segments.length; i < length; i++) { | |
segments[i] = URI.encodePathSegment(URI.decode(segments[i])); | |
} | |
return segments.join('/'); | |
}; | |
URI.decodePath = function(string) { | |
var segments = (string + '').split('/'); | |
for (var i = 0, length = segments.length; i < length; i++) { | |
segments[i] = URI.decodePathSegment(segments[i]); | |
} | |
return segments.join('/'); | |
}; | |
// generate encode/decode path functions | |
var _parts = {'encode':'encode', 'decode':'decode'}; | |
var _part; | |
var generateAccessor = function(_group, _part) { | |
return function(string) { | |
return URI[_part](string + '').replace(URI.characters[_group][_part].expression, function(c) { | |
return URI.characters[_group][_part].map[c]; | |
}); | |
}; | |
}; | |
for (_part in _parts) { | |
URI[_part + 'PathSegment'] = generateAccessor('pathname', _parts[_part]); | |
} | |
URI.encodeReserved = generateAccessor('reserved', 'encode'); | |
URI.parse = function(string, parts) { | |
var pos; | |
if (!parts) { | |
parts = {}; | |
} | |
// [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment] | |
// extract fragment | |
pos = string.indexOf('#'); | |
if (pos > -1) { | |
// escaping? | |
parts.fragment = string.substring(pos + 1) || null; | |
string = string.substring(0, pos); | |
} | |
// extract query | |
pos = string.indexOf('?'); | |
if (pos > -1) { | |
// escaping? | |
parts.query = string.substring(pos + 1) || null; | |
string = string.substring(0, pos); | |
} | |
// extract protocol | |
if (string.substring(0, 2) === '//') { | |
// relative-scheme | |
parts.protocol = null; | |
string = string.substring(2); | |
// extract "user:pass@host:port" | |
string = URI.parseAuthority(string, parts); | |
} else { | |
pos = string.indexOf(':'); | |
if (pos > -1) { | |
parts.protocol = string.substring(0, pos) || null; | |
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) { | |
// : may be within the path | |
parts.protocol = undefined; | |
} else if (parts.protocol === 'file') { | |
// the file scheme: does not contain an authority | |
string = string.substring(pos + 3); | |
} else if (string.substring(pos + 1, pos + 3) === '//') { | |
string = string.substring(pos + 3); | |
// extract "user:pass@host:port" | |
string = URI.parseAuthority(string, parts); | |
} else { | |
string = string.substring(pos + 1); | |
parts.urn = true; | |
} | |
} | |
} | |
// what's left must be the path | |
parts.path = string; | |
// and we're done | |
return parts; | |
}; | |
URI.parseHost = function(string, parts) { | |
// extract host:port | |
var pos = string.indexOf('/'); | |
var bracketPos; | |
var t; | |
if (pos === -1) { | |
pos = string.length; | |
} | |
if (string.charAt(0) === '[') { | |
// IPv6 host - http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04#section-6 | |
// I claim most client software breaks on IPv6 anyways. To simplify things, URI only accepts | |
// IPv6+port in the format [2001:db8::1]:80 (for the time being) | |
bracketPos = string.indexOf(']'); | |
parts.hostname = string.substring(1, bracketPos) || null; | |
parts.port = string.substring(bracketPos + 2, pos) || null; | |
if (parts.port === '/') { | |
parts.port = null; | |
} | |
} else if (string.indexOf(':') !== string.lastIndexOf(':')) { | |
// IPv6 host contains multiple colons - but no port | |
// this notation is actually not allowed by RFC 3986, but we're a liberal parser | |
parts.hostname = string.substring(0, pos) || null; | |
parts.port = null; | |
} else { | |
t = string.substring(0, pos).split(':'); | |
parts.hostname = t[0] || null; | |
parts.port = t[1] || null; | |
} | |
if (parts.hostname && string.substring(pos).charAt(0) !== '/') { | |
pos++; | |
string = '/' + string; | |
} | |
return string.substring(pos) || '/'; | |
}; | |
URI.parseAuthority = function(string, parts) { | |
string = URI.parseUserinfo(string, parts); | |
return URI.parseHost(string, parts); | |
}; | |
URI.parseUserinfo = function(string, parts) { | |
// extract username:password | |
var firstSlash = string.indexOf('/'); | |
/*jshint laxbreak: true */ | |
var pos = firstSlash > -1 | |
? string.lastIndexOf('@', firstSlash) | |
: string.indexOf('@'); | |
/*jshint laxbreak: false */ | |
var t; | |
// authority@ must come before /path | |
if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) { | |
t = string.substring(0, pos).split(':'); | |
parts.username = t[0] ? URI.decode(t[0]) : null; | |
t.shift(); | |
parts.password = t[0] ? URI.decode(t.join(':')) : null; | |
string = string.substring(pos + 1); | |
} else { | |
parts.username = null; | |
parts.password = null; | |
} | |
return string; | |
}; | |
URI.parseQuery = function(string, escapeQuerySpace) { | |
if (!string) { | |
return {}; | |
} | |
// throw out the funky business - "?"[name"="value"&"]+ | |
string = string.replace(/&+/g, '&').replace(/^\?*&*|&+$/g, ''); | |
if (!string) { | |
return {}; | |
} | |
var items = {}; | |
var splits = string.split('&'); | |
var length = splits.length; | |
var v, name, value; | |
for (var i = 0; i < length; i++) { | |
v = splits[i].split('='); | |
name = URI.decodeQuery(v.shift(), escapeQuerySpace); | |
// no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters | |
value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null; | |
if (items[name]) { | |
if (typeof items[name] === 'string') { | |
items[name] = [items[name]]; | |
} | |
items[name].push(value); | |
} else { | |
items[name] = value; | |
} | |
} | |
return items; | |
}; | |
URI.build = function(parts) { | |
var t = ''; | |
if (parts.protocol) { | |
t += parts.protocol + ':'; | |
} | |
if (!parts.urn && (t || parts.hostname)) { | |
t += '//'; | |
} | |
t += (URI.buildAuthority(parts) || ''); | |
if (typeof parts.path === 'string') { | |
if (parts.path.charAt(0) !== '/' && typeof parts.hostname === 'string') { | |
t += '/'; | |
} | |
t += parts.path; | |
} | |
if (typeof parts.query === 'string' && parts.query) { | |
t += '?' + parts.query; | |
} | |
if (typeof parts.fragment === 'string' && parts.fragment) { | |
t += '#' + parts.fragment; | |
} | |
return t; | |
}; | |
URI.buildHost = function(parts) { | |
var t = ''; | |
if (!parts.hostname) { | |
return ''; | |
} else if (URI.ip6_expression.test(parts.hostname)) { | |
t += '[' + parts.hostname + ']'; | |
} else { | |
t += parts.hostname; | |
} | |
if (parts.port) { | |
t += ':' + parts.port; | |
} | |
return t; | |
}; | |
URI.buildAuthority = function(parts) { | |
return URI.buildUserinfo(parts) + URI.buildHost(parts); | |
}; | |
URI.buildUserinfo = function(parts) { | |
var t = ''; | |
if (parts.username) { | |
t += URI.encode(parts.username); | |
if (parts.password) { | |
t += ':' + URI.encode(parts.password); | |
} | |
t += '@'; | |
} | |
return t; | |
}; | |
URI.buildQuery = function(data, duplicateQueryParameters, escapeQuerySpace) { | |
// according to http://tools.ietf.org/html/rfc3986 or http://labs.apache.org/webarch/uri/rfc/rfc3986.html | |
// being »-._~!$&'()*+,;=:@/?« %HEX and alnum are allowed | |
// the RFC explicitly states ?/foo being a valid use case, no mention of parameter syntax! | |
// URI.js treats the query string as being application/x-www-form-urlencoded | |
// see http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type | |
var t = ''; | |
var unique, key, i, length; | |
for (key in data) { | |
if (hasOwn.call(data, key) && key) { | |
if (isArray(data[key])) { | |
unique = {}; | |
for (i = 0, length = data[key].length; i < length; i++) { | |
if (data[key][i] !== undefined && unique[data[key][i] + ''] === undefined) { | |
t += '&' + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace); | |
if (duplicateQueryParameters !== true) { | |
unique[data[key][i] + ''] = true; | |
} | |
} | |
} | |
} else if (data[key] !== undefined) { | |
t += '&' + URI.buildQueryParameter(key, data[key], escapeQuerySpace); | |
} | |
} | |
} | |
return t.substring(1); | |
}; | |
URI.buildQueryParameter = function(name, value, escapeQuerySpace) { | |
// http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type -- application/x-www-form-urlencoded | |
// don't append "=" for null values, according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization | |
return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? '=' + URI.encodeQuery(value, escapeQuerySpace) : ''); | |
}; | |
URI.addQuery = function(data, name, value) { | |
if (typeof name === 'object') { | |
for (var key in name) { | |
if (hasOwn.call(name, key)) { | |
URI.addQuery(data, key, name[key]); | |
} | |
} | |
} else if (typeof name === 'string') { | |
if (data[name] === undefined) { | |
data[name] = value; | |
return; | |
} else if (typeof data[name] === 'string') { | |
data[name] = [data[name]]; | |
} | |
if (!isArray(value)) { | |
value = [value]; | |
} | |
data[name] = data[name].concat(value); | |
} else { | |
throw new TypeError('URI.addQuery() accepts an object, string as the name parameter'); | |
} | |
}; | |
URI.removeQuery = function(data, name, value) { | |
var i, length, key; | |
if (isArray(name)) { | |
for (i = 0, length = name.length; i < length; i++) { | |
data[name[i]] = undefined; | |
} | |
} else if (typeof name === 'object') { | |
for (key in name) { | |
if (hasOwn.call(name, key)) { | |
URI.removeQuery(data, key, name[key]); | |
} | |
} | |
} else if (typeof name === 'string') { | |
if (value !== undefined) { | |
if (data[name] === value) { | |
data[name] = undefined; | |
} else if (isArray(data[name])) { | |
data[name] = filterArrayValues(data[name], value); | |
} | |
} else { | |
data[name] = undefined; | |
} | |
} else { | |
throw new TypeError('URI.addQuery() accepts an object, string as the first parameter'); | |
} | |
}; | |
URI.hasQuery = function(data, name, value, withinArray) { | |
if (typeof name === 'object') { | |
for (var key in name) { | |
if (hasOwn.call(name, key)) { | |
if (!URI.hasQuery(data, key, name[key])) { | |
return false; | |
} | |
} | |
} | |
return true; | |
} else if (typeof name !== 'string') { | |
throw new TypeError('URI.hasQuery() accepts an object, string as the name parameter'); | |
} | |
switch (getType(value)) { | |
case 'Undefined': | |
// true if exists (but may be empty) | |
return name in data; // data[name] !== undefined; | |
case 'Boolean': | |
// true if exists and non-empty | |
var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]); | |
return value === _booly; | |
case 'Function': | |
// allow complex comparison | |
return !!value(data[name], name, data); | |
case 'Array': | |
if (!isArray(data[name])) { | |
return false; | |
} | |
var op = withinArray ? arrayContains : arraysEqual; | |
return op(data[name], value); | |
case 'RegExp': | |
if (!isArray(data[name])) { | |
return Boolean(data[name] && data[name].match(value)); | |
} | |
if (!withinArray) { | |
return false; | |
} | |
return arrayContains(data[name], value); | |
case 'Number': | |
value = String(value); | |
/* falls through */ | |
case 'String': | |
if (!isArray(data[name])) { | |
return data[name] === value; | |
} | |
if (!withinArray) { | |
return false; | |
} | |
return arrayContains(data[name], value); | |
default: | |
throw new TypeError('URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter'); | |
} | |
}; | |
URI.commonPath = function(one, two) { | |
var length = Math.min(one.length, two.length); | |
var pos; | |
// find first non-matching character | |
for (pos = 0; pos < length; pos++) { | |
if (one.charAt(pos) !== two.charAt(pos)) { | |
pos--; | |
break; | |
} | |
} | |
if (pos < 1) { | |
return one.charAt(0) === two.charAt(0) && one.charAt(0) === '/' ? '/' : ''; | |
} | |
// revert to last / | |
if (one.charAt(pos) !== '/' || two.charAt(pos) !== '/') { | |
pos = one.substring(0, pos).lastIndexOf('/'); | |
} | |
return one.substring(0, pos + 1); | |
}; | |
URI.withinString = function(string, callback, options) { | |
options || (options = {}); | |
var _start = options.start || URI.findUri.start; | |
var _end = options.end || URI.findUri.end; | |
var _trim = options.trim || URI.findUri.trim; | |
var _attributeOpen = /[a-z0-9-]=["']?$/i; | |
_start.lastIndex = 0; | |
while (true) { | |
var match = _start.exec(string); | |
if (!match) { | |
break; | |
} | |
var start = match.index; | |
if (options.ignoreHtml) { | |
// attribut(e=["']?$) | |
var attributeOpen = string.slice(Math.max(start - 3, 0), start); | |
if (attributeOpen && _attributeOpen.test(attributeOpen)) { | |
continue; | |
} | |
} | |
var end = start + string.slice(start).search(_end); | |
var slice = string.slice(start, end).replace(_trim, ''); | |
if (options.ignore && options.ignore.test(slice)) { | |
continue; | |
} | |
end = start + slice.length; | |
var result = callback(slice, start, end, string); | |
string = string.slice(0, start) + result + string.slice(end); | |
_start.lastIndex = start + result.length; | |
} | |
_start.lastIndex = 0; | |
return string; | |
}; | |
URI.ensureValidHostname = function(v) { | |
// Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986) | |
// they are not part of DNS and therefore ignored by URI.js | |
if (v.match(URI.invalid_hostname_characters)) { | |
// test punycode | |
if (!punycode) { | |
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-] and Punycode.js is not available'); | |
} | |
if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) { | |
throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]'); | |
} | |
} | |
}; | |
// noConflict | |
URI.noConflict = function(removeAll) { | |
if (removeAll) { | |
var unconflicted = { | |
URI: this.noConflict() | |
}; | |
if (root.URITemplate && typeof root.URITemplate.noConflict === 'function') { | |
unconflicted.URITemplate = root.URITemplate.noConflict(); | |
} | |
if (root.IPv6 && typeof root.IPv6.noConflict === 'function') { | |
unconflicted.IPv6 = root.IPv6.noConflict(); | |
} | |
if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === 'function') { | |
unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict(); | |
} | |
return unconflicted; | |
} else if (root.URI === this) { | |
root.URI = _URI; | |
} | |
return this; | |
}; | |
p.build = function(deferBuild) { | |
if (deferBuild === true) { | |
this._deferred_build = true; | |
} else if (deferBuild === undefined || this._deferred_build) { | |
this._string = URI.build(this._parts); | |
this._deferred_build = false; | |
} | |
return this; | |
}; | |
p.clone = function() { | |
return new URI(this); | |
}; | |
p.valueOf = p.toString = function() { | |
return this.build(false)._string; | |
}; | |
// generate simple accessors | |
_parts = {protocol: 'protocol', username: 'username', password: 'password', hostname: 'hostname', port: 'port'}; | |
generateAccessor = function(_part){ | |
return function(v, build) { | |
if (v === undefined) { | |
return this._parts[_part] || ''; | |
} else { | |
this._parts[_part] = v || null; | |
this.build(!build); | |
return this; | |
} | |
}; | |
}; | |
for (_part in _parts) { | |
p[_part] = generateAccessor(_parts[_part]); | |
} | |
// generate accessors with optionally prefixed input | |
_parts = {query: '?', fragment: '#'}; | |
generateAccessor = function(_part, _key){ | |
return function(v, build) { | |
if (v === undefined) { | |
return this._parts[_part] || ''; | |
} else { | |
if (v !== null) { | |
v = v + ''; | |
if (v.charAt(0) === _key) { | |
v = v.substring(1); | |
} | |
} | |
this._parts[_part] = v; | |
this.build(!build); | |
return this; | |
} | |
}; | |
}; | |
for (_part in _parts) { | |
p[_part] = generateAccessor(_part, _parts[_part]); | |
} | |
// generate accessors with prefixed output | |
_parts = {search: ['?', 'query'], hash: ['#', 'fragment']}; | |
generateAccessor = function(_part, _key){ | |
return function(v, build) { | |
var t = this[_part](v, build); | |
return typeof t === 'string' && t.length ? (_key + t) : t; | |
}; | |
}; | |
for (_part in _parts) { | |
p[_part] = generateAccessor(_parts[_part][1], _parts[_part][0]); | |
} | |
p.pathname = function(v, build) { | |
if (v === undefined || v === true) { | |
var res = this._parts.path || (this._parts.hostname ? '/' : ''); | |
return v ? URI.decodePath(res) : res; | |
} else { | |
this._parts.path = v ? URI.recodePath(v) : '/'; | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.path = p.pathname; | |
p.href = function(href, build) { | |
var key; | |
if (href === undefined) { | |
return this.toString(); | |
} | |
this._string = ''; | |
this._parts = URI._parts(); | |
var _URI = href instanceof URI; | |
var _object = typeof href === 'object' && (href.hostname || href.path || href.pathname); | |
if (href.nodeName) { | |
var attribute = URI.getDomAttribute(href); | |
href = href[attribute] || ''; | |
_object = false; | |
} | |
// window.location is reported to be an object, but it's not the sort | |
// of object we're looking for: | |
// * location.protocol ends with a colon | |
// * location.query != object.search | |
// * location.hash != object.fragment | |
// simply serializing the unknown object should do the trick | |
// (for location, not for everything...) | |
if (!_URI && _object && href.pathname !== undefined) { | |
href = href.toString(); | |
} | |
if (typeof href === 'string') { | |
this._parts = URI.parse(href, this._parts); | |
} else if (_URI || _object) { | |
var src = _URI ? href._parts : href; | |
for (key in src) { | |
if (hasOwn.call(this._parts, key)) { | |
this._parts[key] = src[key]; | |
} | |
} | |
} else { | |
throw new TypeError('invalid input'); | |
} | |
this.build(!build); | |
return this; | |
}; | |
// identification accessors | |
p.is = function(what) { | |
var ip = false; | |
var ip4 = false; | |
var ip6 = false; | |
var name = false; | |
var sld = false; | |
var idn = false; | |
var punycode = false; | |
var relative = !this._parts.urn; | |
if (this._parts.hostname) { | |
relative = false; | |
ip4 = URI.ip4_expression.test(this._parts.hostname); | |
ip6 = URI.ip6_expression.test(this._parts.hostname); | |
ip = ip4 || ip6; | |
name = !ip; | |
sld = name && SLD && SLD.has(this._parts.hostname); | |
idn = name && URI.idn_expression.test(this._parts.hostname); | |
punycode = name && URI.punycode_expression.test(this._parts.hostname); | |
} | |
switch (what.toLowerCase()) { | |
case 'relative': | |
return relative; | |
case 'absolute': | |
return !relative; | |
// hostname identification | |
case 'domain': | |
case 'name': | |
return name; | |
case 'sld': | |
return sld; | |
case 'ip': | |
return ip; | |
case 'ip4': | |
case 'ipv4': | |
case 'inet4': | |
return ip4; | |
case 'ip6': | |
case 'ipv6': | |
case 'inet6': | |
return ip6; | |
case 'idn': | |
return idn; | |
case 'url': | |
return !this._parts.urn; | |
case 'urn': | |
return !!this._parts.urn; | |
case 'punycode': | |
return punycode; | |
} | |
return null; | |
}; | |
// component specific input validation | |
var _protocol = p.protocol; | |
var _port = p.port; | |
var _hostname = p.hostname; | |
p.protocol = function(v, build) { | |
if (v !== undefined) { | |
if (v) { | |
// accept trailing :// | |
v = v.replace(/:(\/\/)?$/, ''); | |
if (!v.match(URI.protocol_expression)) { | |
throw new TypeError('Protocol "' + v + '" contains characters other than [A-Z0-9.+-] or doesn\'t start with [A-Z]'); | |
} | |
} | |
} | |
return _protocol.call(this, v, build); | |
}; | |
p.scheme = p.protocol; | |
p.port = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v !== undefined) { | |
if (v === 0) { | |
v = null; | |
} | |
if (v) { | |
v += ''; | |
if (v.charAt(0) === ':') { | |
v = v.substring(1); | |
} | |
if (v.match(/[^0-9]/)) { | |
throw new TypeError('Port "' + v + '" contains characters other than [0-9]'); | |
} | |
} | |
} | |
return _port.call(this, v, build); | |
}; | |
p.hostname = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v !== undefined) { | |
var x = {}; | |
URI.parseHost(v, x); | |
v = x.hostname; | |
} | |
return _hostname.call(this, v, build); | |
}; | |
// compound accessors | |
p.host = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v === undefined) { | |
return this._parts.hostname ? URI.buildHost(this._parts) : ''; | |
} else { | |
URI.parseHost(v, this._parts); | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.authority = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v === undefined) { | |
return this._parts.hostname ? URI.buildAuthority(this._parts) : ''; | |
} else { | |
URI.parseAuthority(v, this._parts); | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.userinfo = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v === undefined) { | |
if (!this._parts.username) { | |
return ''; | |
} | |
var t = URI.buildUserinfo(this._parts); | |
return t.substring(0, t.length -1); | |
} else { | |
if (v[v.length-1] !== '@') { | |
v += '@'; | |
} | |
URI.parseUserinfo(v, this._parts); | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.resource = function(v, build) { | |
var parts; | |
if (v === undefined) { | |
return this.path() + this.search() + this.hash(); | |
} | |
parts = URI.parse(v); | |
this._parts.path = parts.path; | |
this._parts.query = parts.query; | |
this._parts.fragment = parts.fragment; | |
this.build(!build); | |
return this; | |
}; | |
// fraction accessors | |
p.subdomain = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
// convenience, return "www" from "www.example.org" | |
if (v === undefined) { | |
if (!this._parts.hostname || this.is('IP')) { | |
return ''; | |
} | |
// grab domain and add another segment | |
var end = this._parts.hostname.length - this.domain().length - 1; | |
return this._parts.hostname.substring(0, end) || ''; | |
} else { | |
var e = this._parts.hostname.length - this.domain().length; | |
var sub = this._parts.hostname.substring(0, e); | |
var replace = new RegExp('^' + escapeRegEx(sub)); | |
if (v && v.charAt(v.length - 1) !== '.') { | |
v += '.'; | |
} | |
if (v) { | |
URI.ensureValidHostname(v); | |
} | |
this._parts.hostname = this._parts.hostname.replace(replace, v); | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.domain = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (typeof v === 'boolean') { | |
build = v; | |
v = undefined; | |
} | |
// convenience, return "example.org" from "www.example.org" | |
if (v === undefined) { | |
if (!this._parts.hostname || this.is('IP')) { | |
return ''; | |
} | |
// if hostname consists of 1 or 2 segments, it must be the domain | |
var t = this._parts.hostname.match(/\./g); | |
if (t && t.length < 2) { | |
return this._parts.hostname; | |
} | |
// grab tld and add another segment | |
var end = this._parts.hostname.length - this.tld(build).length - 1; | |
end = this._parts.hostname.lastIndexOf('.', end -1) + 1; | |
return this._parts.hostname.substring(end) || ''; | |
} else { | |
if (!v) { | |
throw new TypeError('cannot set domain empty'); | |
} | |
URI.ensureValidHostname(v); | |
if (!this._parts.hostname || this.is('IP')) { | |
this._parts.hostname = v; | |
} else { | |
var replace = new RegExp(escapeRegEx(this.domain()) + '$'); | |
this._parts.hostname = this._parts.hostname.replace(replace, v); | |
} | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.tld = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (typeof v === 'boolean') { | |
build = v; | |
v = undefined; | |
} | |
// return "org" from "www.example.org" | |
if (v === undefined) { | |
if (!this._parts.hostname || this.is('IP')) { | |
return ''; | |
} | |
var pos = this._parts.hostname.lastIndexOf('.'); | |
var tld = this._parts.hostname.substring(pos + 1); | |
if (build !== true && SLD && SLD.list[tld.toLowerCase()]) { | |
return SLD.get(this._parts.hostname) || tld; | |
} | |
return tld; | |
} else { | |
var replace; | |
if (!v) { | |
throw new TypeError('cannot set TLD empty'); | |
} else if (v.match(/[^a-zA-Z0-9-]/)) { | |
if (SLD && SLD.is(v)) { | |
replace = new RegExp(escapeRegEx(this.tld()) + '$'); | |
this._parts.hostname = this._parts.hostname.replace(replace, v); | |
} else { | |
throw new TypeError('TLD "' + v + '" contains characters other than [A-Z0-9]'); | |
} | |
} else if (!this._parts.hostname || this.is('IP')) { | |
throw new ReferenceError('cannot set TLD on non-domain host'); | |
} else { | |
replace = new RegExp(escapeRegEx(this.tld()) + '$'); | |
this._parts.hostname = this._parts.hostname.replace(replace, v); | |
} | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.directory = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v === undefined || v === true) { | |
if (!this._parts.path && !this._parts.hostname) { | |
return ''; | |
} | |
if (this._parts.path === '/') { | |
return '/'; | |
} | |
var end = this._parts.path.length - this.filename().length - 1; | |
var res = this._parts.path.substring(0, end) || (this._parts.hostname ? '/' : ''); | |
return v ? URI.decodePath(res) : res; | |
} else { | |
var e = this._parts.path.length - this.filename().length; | |
var directory = this._parts.path.substring(0, e); | |
var replace = new RegExp('^' + escapeRegEx(directory)); | |
// fully qualifier directories begin with a slash | |
if (!this.is('relative')) { | |
if (!v) { | |
v = '/'; | |
} | |
if (v.charAt(0) !== '/') { | |
v = '/' + v; | |
} | |
} | |
// directories always end with a slash | |
if (v && v.charAt(v.length - 1) !== '/') { | |
v += '/'; | |
} | |
v = URI.recodePath(v); | |
this._parts.path = this._parts.path.replace(replace, v); | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.filename = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v === undefined || v === true) { | |
if (!this._parts.path || this._parts.path === '/') { | |
return ''; | |
} | |
var pos = this._parts.path.lastIndexOf('/'); | |
var res = this._parts.path.substring(pos+1); | |
return v ? URI.decodePathSegment(res) : res; | |
} else { | |
var mutatedDirectory = false; | |
if (v.charAt(0) === '/') { | |
v = v.substring(1); | |
} | |
if (v.match(/\.?\//)) { | |
mutatedDirectory = true; | |
} | |
var replace = new RegExp(escapeRegEx(this.filename()) + '$'); | |
v = URI.recodePath(v); | |
this._parts.path = this._parts.path.replace(replace, v); | |
if (mutatedDirectory) { | |
this.normalizePath(build); | |
} else { | |
this.build(!build); | |
} | |
return this; | |
} | |
}; | |
p.suffix = function(v, build) { | |
if (this._parts.urn) { | |
return v === undefined ? '' : this; | |
} | |
if (v === undefined || v === true) { | |
if (!this._parts.path || this._parts.path === '/') { | |
return ''; | |
} | |
var filename = this.filename(); | |
var pos = filename.lastIndexOf('.'); | |
var s, res; | |
if (pos === -1) { | |
return ''; | |
} | |
// suffix may only contain alnum characters (yup, I made this up.) | |
s = filename.substring(pos+1); | |
res = (/^[a-z0-9%]+$/i).test(s) ? s : ''; | |
return v ? URI.decodePathSegment(res) : res; | |
} else { | |
if (v.charAt(0) === '.') { | |
v = v.substring(1); | |
} | |
var suffix = this.suffix(); | |
var replace; | |
if (!suffix) { | |
if (!v) { | |
return this; | |
} | |
this._parts.path += '.' + URI.recodePath(v); | |
} else if (!v) { | |
replace = new RegExp(escapeRegEx('.' + suffix) + '$'); | |
} else { | |
replace = new RegExp(escapeRegEx(suffix) + '$'); | |
} | |
if (replace) { | |
v = URI.recodePath(v); | |
this._parts.path = this._parts.path.replace(replace, v); | |
} | |
this.build(!build); | |
return this; | |
} | |
}; | |
p.segment = function(segment, v, build) { | |
var separator = this._parts.urn ? ':' : '/'; | |
var path = this.path(); | |
var absolute = path.substring(0, 1) === '/'; | |
var segments = path.split(separator); | |
if (segment !== undefined && typeof segment !== 'number') { | |
build = v; | |
v = segment; | |
segment = undefined; | |
} | |
if (segment !== undefined && typeof segment !== 'number') { | |
throw new Error('Bad segment "' + segment + '", must be 0-based integer'); | |
} | |
if (absolute) { | |
segments.shift(); | |
} | |
if (segment < 0) { | |
// allow negative indexes to address from the end | |
segment = Math.max(segments.length + segment, 0); | |
} | |
if (v === undefined) { | |
/*jshint laxbreak: true */ | |
return segment === undefined | |
? segments | |
: segments[segment]; | |
/*jshint laxbreak: false */ | |
} else if (segment === null || segments[segment] === undefined) { | |
if (isArray(v)) { | |
segments = []; | |
// collapse empty elements within array | |
for (var i=0, l=v.length; i < l; i++) { | |
if (!v[i].length && (!segments.length || !segments[segments.length -1].length)) { | |
continue; | |
} | |
if (segments.length && !segments[segments.length -1].length) { | |
segments.pop(); | |
} | |
segments.push(v[i]); | |
} | |
} else if (v || (typeof v === 'string')) { | |
if (segments[segments.length -1] === '') { | |
// empty trailing elements have to be overwritten | |
// to prevent results such as /foo//bar | |
segments[segments.length -1] = v; | |
} else { | |
segments.push(v); | |
} | |
} | |
} else { | |
if (v || (typeof v === 'string' && v.length)) { | |
segments[segment] = v; | |
} else { | |
segments.splice(segment, 1); | |
} | |
} | |
if (absolute) { | |
segments.unshift(''); | |
} | |
return this.path(segments.join(separator), build); | |
}; | |
p.segmentCoded = function(segment, v, build) { | |
var segments, i, l; | |
if (typeof segment !== 'number') { | |
build = v; | |
v = segment; | |
segment = undefined; | |
} | |
if (v === undefined) { | |
segments = this.segment(segment, v, build); | |
if (!isArray(segments)) { | |
segments = segments !== undefined ? URI.decode(segments) : undefined; | |
} else { | |
for (i = 0, l = segments.length; i < l; i++) { | |
segments[i] = URI.decode(segments[i]); | |
} | |
} | |
return segments; | |
} | |
if (!isArray(v)) { | |
v = typeof v === 'string' ? URI.encode(v) : v; | |
} else { | |
for (i = 0, l = v.length; i < l; i++) { | |
v[i] = URI.decode(v[i]); | |
} | |
} | |
return this.segment(segment, v, build); | |
}; | |
// mutating query string | |
var q = p.query; | |
p.query = function(v, build) { | |
if (v === true) { | |
return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); | |
} else if (typeof v === 'function') { | |
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); | |
var result = v.call(this, data); | |
this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); | |
this.build(!build); | |
return this; | |
} else if (v !== undefined && typeof v !== 'string') { | |
this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); | |
this.build(!build); | |
return this; | |
} else { | |
return q.call(this, v, build); | |
} | |
}; | |
p.setQuery = function(name, value, build) { | |
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); | |
if (typeof name === 'object') { | |
for (var key in name) { | |
if (hasOwn.call(name, key)) { | |
data[key] = name[key]; | |
} | |
} | |
} else if (typeof name === 'string') { | |
data[name] = value !== undefined ? value : null; | |
} else { | |
throw new TypeError('URI.addQuery() accepts an object, string as the name parameter'); | |
} | |
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); | |
if (typeof name !== 'string') { | |
build = value; | |
} | |
this.build(!build); | |
return this; | |
}; | |
p.addQuery = function(name, value, build) { | |
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); | |
URI.addQuery(data, name, value === undefined ? null : value); | |
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); | |
if (typeof name !== 'string') { | |
build = value; | |
} | |
this.build(!build); | |
return this; | |
}; | |
p.removeQuery = function(name, value, build) { | |
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); | |
URI.removeQuery(data, name, value); | |
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace); | |
if (typeof name !== 'string') { | |
build = value; | |
} | |
this.build(!build); | |
return this; | |
}; | |
p.hasQuery = function(name, value, withinArray) { | |
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace); | |
return URI.hasQuery(data, name, value, withinArray); | |
}; | |
p.setSearch = p.setQuery; | |
p.addSearch = p.addQuery; | |
p.removeSearch = p.removeQuery; | |
p.hasSearch = p.hasQuery; | |
// sanitizing URLs | |
p.normalize = function() { | |
if (this._parts.urn) { | |
return this | |
.normalizeProtocol(false) | |
.normalizeQuery(false) | |
.normalizeFragment(false) | |
.build(); | |
} | |
return this | |
.normalizeProtocol(false) | |
.normalizeHostname(false) | |
.normalizePort(false) | |
.normalizePath(false) | |
.normalizeQuery(false) | |
.normalizeFragment(false) | |
.build(); | |
}; | |
p.normalizeProtocol = function(build) { | |
if (typeof this._parts.protocol === 'string') { | |
this._parts.protocol = this._parts.protocol.toLowerCase(); | |
this.build(!build); | |
} | |
return this; | |
}; | |
p.normalizeHostname = function(build) { | |
if (this._parts.hostname) { | |
if (this.is('IDN') && punycode) { | |
this._parts.hostname = punycode.toASCII(this._parts.hostname); | |
} else if (this.is('IPv6') && IPv6) { | |
this._parts.hostname = IPv6.best(this._parts.hostname); | |
} | |
this._parts.hostname = this._parts.hostname.toLowerCase(); | |
this.build(!build); | |
} | |
return this; | |
}; | |
p.normalizePort = function(build) { | |
// remove port of it's the protocol's default | |
if (typeof this._parts.protocol === 'string' && this._parts.port === URI.defaultPorts[this._parts.protocol]) { | |
this._parts.port = null; | |
this.build(!build); | |
} | |
return this; | |
}; | |
p.normalizePath = function(build) { | |
if (this._parts.urn) { | |
return this; | |
} | |
if (!this._parts.path || this._parts.path === '/') { | |
return this; | |
} | |
var _was_relative; | |
var _path = this._parts.path; | |
var _leadingParents = ''; | |
var _parent, _pos; | |
// handle relative paths | |
if (_path.charAt(0) !== '/') { | |
_was_relative = true; | |
_path = '/' + _path; | |
} | |
// resolve simples | |
_path = _path | |
.replace(/(\/(\.\/)+)|(\/\.$)/g, '/') | |
.replace(/\/{2,}/g, '/'); | |
// remember leading parents | |
if (_was_relative) { | |
_leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || ''; | |
if (_leadingParents) { | |
_leadingParents = _leadingParents[0]; | |
} | |
} | |
// resolve parents | |
while (true) { | |
_parent = _path.indexOf('/..'); | |
if (_parent === -1) { | |
// no more ../ to resolve | |
break; | |
} else if (_parent === 0) { | |
// top level cannot be relative, skip it | |
_path = _path.substring(3); | |
continue; | |
} | |
_pos = _path.substring(0, _parent).lastIndexOf('/'); | |
if (_pos === -1) { | |
_pos = _parent; | |
} | |
_path = _path.substring(0, _pos) + _path.substring(_parent + 3); | |
} | |
// revert to relative | |
if (_was_relative && this.is('relative')) { | |
_path = _leadingParents + _path.substring(1); | |
} | |
_path = URI.recodePath(_path); | |
this._parts.path = _path; | |
this.build(!build); | |
return this; | |
}; | |
p.normalizePathname = p.normalizePath; | |
p.normalizeQuery = function(build) { | |
if (typeof this._parts.query === 'string') { | |
if (!this._parts.query.length) { | |
this._parts.query = null; | |
} else { | |
this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace)); | |
} | |
this.build(!build); | |
} | |
return this; | |
}; | |
p.normalizeFragment = function(build) { | |
if (!this._parts.fragment) { | |
this._parts.fragment = null; | |
this.build(!build); | |
} | |
return this; | |
}; | |
p.normalizeSearch = p.normalizeQuery; | |
p.normalizeHash = p.normalizeFragment; | |
p.iso8859 = function() { | |
// expect unicode input, iso8859 output | |
var e = URI.encode; | |
var d = URI.decode; | |
URI.encode = escape; | |
URI.decode = decodeURIComponent; | |
this.normalize(); | |
URI.encode = e; | |
URI.decode = d; | |
return this; | |
}; | |
p.unicode = function() { | |
// expect iso8859 input, unicode output | |
var e = URI.encode; | |
var d = URI.decode; | |
URI.encode = strictEncodeURIComponent; | |
URI.decode = unescape; | |
this.normalize(); | |
URI.encode = e; | |
URI.decode = d; | |
return this; | |
}; | |
p.readable = function() { | |
var uri = this.clone(); | |
// removing username, password, because they shouldn't be displayed according to RFC 3986 | |
uri.username('').password('').normalize(); | |
var t = ''; | |
if (uri._parts.protocol) { | |
t += uri._parts.protocol + '://'; | |
} | |
if (uri._parts.hostname) { | |
if (uri.is('punycode') && punycode) { | |
t += punycode.toUnicode(uri._parts.hostname); | |
if (uri._parts.port) { | |
t += ':' + uri._parts.port; | |
} | |
} else { | |
t += uri.host(); | |
} | |
} | |
if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== '/') { | |
t += '/'; | |
} | |
t += uri.path(true); | |
if (uri._parts.query) { | |
var q = ''; | |
for (var i = 0, qp = uri._parts.query.split('&'), l = qp.length; i < l; i++) { | |
var kv = (qp[i] || '').split('='); | |
q += '&' + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace) | |
.replace(/&/g, '%26'); | |
if (kv[1] !== undefined) { | |
q += '=' + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace) | |
.replace(/&/g, '%26'); | |
} | |
} | |
t += '?' + q.substring(1); | |
} | |
t += URI.decodeQuery(uri.hash(), true); | |
return t; | |
}; | |
// resolving relative and absolute URLs | |
p.absoluteTo = function(base) { | |
var resolved = this.clone(); | |
var properties = ['protocol', 'username', 'password', 'hostname', 'port']; | |
var basedir, i, p; | |
if (this._parts.urn) { | |
throw new Error('URNs do not have any generally defined hierarchical components'); | |
} | |
if (!(base instanceof URI)) { | |
base = new URI(base); | |
} | |
if (!resolved._parts.protocol) { | |
resolved._parts.protocol = base._parts.protocol; | |
} | |
if (this._parts.hostname) { | |
return resolved; | |
} | |
for (i = 0; (p = properties[i]); i++) { | |
resolved._parts[p] = base._parts[p]; | |
} | |
if (!resolved._parts.path) { | |
resolved._parts.path = base._parts.path; | |
if (!resolved._parts.query) { | |
resolved._parts.query = base._parts.query; | |
} | |
} else if (resolved._parts.path.substring(-2) === '..') { | |
resolved._parts.path += '/'; | |
} | |
if (resolved.path().charAt(0) !== '/') { | |
basedir = base.directory(); | |
resolved._parts.path = (basedir ? (basedir + '/') : '') + resolved._parts.path; | |
resolved.normalizePath(); | |
} | |
resolved.build(); | |
return resolved; | |
}; | |
p.relativeTo = function(base) { | |
var relative = this.clone().normalize(); | |
var relativeParts, baseParts, common, relativePath, basePath; | |
if (relative._parts.urn) { | |
throw new Error('URNs do not have any generally defined hierarchical components'); | |
} | |
base = new URI(base).normalize(); | |
relativeParts = relative._parts; | |
baseParts = base._parts; | |
relativePath = relative.path(); | |
basePath = base.path(); | |
if (relativePath.charAt(0) !== '/') { | |
throw new Error('URI is already relative'); | |
} | |
if (basePath.charAt(0) !== '/') { | |
throw new Error('Cannot calculate a URI relative to another relative URI'); | |
} | |
if (relativeParts.protocol === baseParts.protocol) { | |
relativeParts.protocol = null; | |
} | |
if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) { | |
return relative.build(); | |
} | |
if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) { | |
return relative.build(); | |
} | |
if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) { | |
relativeParts.hostname = null; | |
relativeParts.port = null; | |
} else { | |
return relative.build(); | |
} | |
if (relativePath === basePath) { | |
relativeParts.path = ''; | |
return relative.build(); | |
} | |
// determine common sub path | |
common = URI.commonPath(relative.path(), base.path()); | |
// If the paths have nothing in common, return a relative URL with the absolute path. | |
if (!common) { | |
return relative.build(); | |
} | |
var parents = baseParts.path | |
.substring(common.length) | |
.replace(/[^\/]*$/, '') | |
.replace(/.*?\//g, '../'); | |
relativeParts.path = parents + relativeParts.path.substring(common.length); | |
return relative.build(); | |
}; | |
// comparing URIs | |
p.equals = function(uri) { | |
var one = this.clone(); | |
var two = new URI(uri); | |
var one_map = {}; | |
var two_map = {}; | |
var checked = {}; | |
var one_query, two_query, key; | |
one.normalize(); | |
two.normalize(); | |
// exact match | |
if (one.toString() === two.toString()) { | |
return true; | |
} | |
// extract query string | |
one_query = one.query(); | |
two_query = two.query(); | |
one.query(''); | |
two.query(''); | |
// definitely not equal if not even non-query parts match | |
if (one.toString() !== two.toString()) { | |
return false; | |
} | |
// query parameters have the same length, even if they're permuted | |
if (one_query.length !== two_query.length) { | |
return false; | |
} | |
one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace); | |
two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace); | |
for (key in one_map) { | |
if (hasOwn.call(one_map, key)) { | |
if (!isArray(one_map[key])) { | |
if (one_map[key] !== two_map[key]) { | |
return false; | |
} | |
} else if (!arraysEqual(one_map[key], two_map[key])) { | |
return false; | |
} | |
checked[key] = true; | |
} | |
} | |
for (key in two_map) { | |
if (hasOwn.call(two_map, key)) { | |
if (!checked[key]) { | |
// two contains a parameter not present in one | |
return false; | |
} | |
} | |
} | |
return true; | |
}; | |
// state | |
p.duplicateQueryParameters = function(v) { | |
this._parts.duplicateQueryParameters = !!v; | |
return this; | |
}; | |
p.escapeQuerySpace = function(v) { | |
this._parts.escapeQuerySpace = !!v; | |
return this; | |
}; | |
return URI; | |
})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! URI.js v1.13.2 http://medialize.github.io/URI.js/ */ | |
/* build contains: IPv6.js, punycode.js, SecondLevelDomains.js, URI.js, URITemplate.js */ | |
(function(f,n){"object"===typeof exports?module.exports=n():"function"===typeof define&&define.amd?define(n):f.IPv6=n(f)})(this,function(f){var n=f&&f.IPv6;return{best:function(g){g=g.toLowerCase().split(":");var h=g.length,d=8;""===g[0]&&""===g[1]&&""===g[2]?(g.shift(),g.shift()):""===g[0]&&""===g[1]?g.shift():""===g[h-1]&&""===g[h-2]&&g.pop();h=g.length;-1!==g[h-1].indexOf(".")&&(d=7);var m;for(m=0;m<h&&""!==g[m];m++);if(m<d)for(g.splice(m,1,"0000");g.length<d;)g.splice(m,0,"0000");for(m=0;m<d;m++){for(var h= | |
g[m].split(""),f=0;3>f;f++)if("0"===h[0]&&1<h.length)h.splice(0,1);else break;g[m]=h.join("")}var h=-1,n=f=0,k=-1,u=!1;for(m=0;m<d;m++)u?"0"===g[m]?n+=1:(u=!1,n>f&&(h=k,f=n)):"0"===g[m]&&(u=!0,k=m,n=1);n>f&&(h=k,f=n);1<f&&g.splice(h,f,"");h=g.length;d="";""===g[0]&&(d=":");for(m=0;m<h;m++){d+=g[m];if(m===h-1)break;d+=":"}""===g[h-1]&&(d+=":");return d},noConflict:function(){f.IPv6===this&&(f.IPv6=n);return this}}}); | |
(function(f){function n(a){throw RangeError(B[a]);}function g(a,b){for(var c=a.length;c--;)a[c]=b(a[c]);return a}function h(a,b){return g(a.split(l),b).join(".")}function d(a){for(var b=[],c=0,d=a.length,l,e;c<d;)l=a.charCodeAt(c++),55296<=l&&56319>=l&&c<d?(e=a.charCodeAt(c++),56320==(e&64512)?b.push(((l&1023)<<10)+(e&1023)+65536):(b.push(l),c--)):b.push(l);return b}function m(a){return g(a,function(a){var b="";65535<a&&(a-=65536,b+=D(a>>>10&1023|55296),a=56320|a&1023);return b+=D(a)}).join("")}function w(a, | |
b){return a+22+75*(26>a)-((0!=b)<<5)}function r(a,b,c){var d=0;a=c?z(a/H):a>>1;for(a+=z(a/b);a>v*t>>1;d+=p)a=z(a/v);return z(d+(v+1)*a/(a+x))}function k(b){var c=[],d=b.length,l,e=0,B=E,k=F,g,v,f,h,u;g=b.lastIndexOf(a);0>g&&(g=0);for(v=0;v<g;++v)128<=b.charCodeAt(v)&&n("not-basic"),c.push(b.charCodeAt(v));for(g=0<g?g+1:0;g<d;){v=e;l=1;for(f=p;;f+=p){g>=d&&n("invalid-input");h=b.charCodeAt(g++);h=10>h-48?h-22:26>h-65?h-65:26>h-97?h-97:p;(h>=p||h>z((q-e)/l))&&n("overflow");e+=h*l;u=f<=k?s:f>=k+t?t: | |
f-k;if(h<u)break;h=p-u;l>z(q/h)&&n("overflow");l*=h}l=c.length+1;k=r(e-v,l,0==v);z(e/l)>q-B&&n("overflow");B+=z(e/l);e%=l;c.splice(e++,0,B)}return m(c)}function u(b){var c,l,e,B,g,k,v,h,f,u=[],m,y,A;b=d(b);m=b.length;c=E;l=0;g=F;for(k=0;k<m;++k)f=b[k],128>f&&u.push(D(f));for((e=B=u.length)&&u.push(a);e<m;){v=q;for(k=0;k<m;++k)f=b[k],f>=c&&f<v&&(v=f);y=e+1;v-c>z((q-l)/y)&&n("overflow");l+=(v-c)*y;c=v;for(k=0;k<m;++k)if(f=b[k],f<c&&++l>q&&n("overflow"),f==c){h=l;for(v=p;;v+=p){f=v<=g?s:v>=g+t?t:v-g; | |
if(h<f)break;A=h-f;h=p-f;u.push(D(w(f+A%h,0)));h=z(A/h)}u.push(D(w(h,0)));g=r(l,y,e==B);l=0;++e}++l;++c}return u.join("")}var y="object"==typeof exports&&exports,A="object"==typeof module&&module&&module.exports==y&&module,C="object"==typeof global&&global;if(C.global===C||C.window===C)f=C;var e,q=2147483647,p=36,s=1,t=26,x=38,H=700,F=72,E=128,a="-",b=/^xn--/,c=/[^ -~]/,l=/\x2E|\u3002|\uFF0E|\uFF61/g,B={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)", | |
"invalid-input":"Invalid input"},v=p-s,z=Math.floor,D=String.fromCharCode,G;e={version:"1.2.3",ucs2:{decode:d,encode:m},decode:k,encode:u,toASCII:function(a){return h(a,function(a){return c.test(a)?"xn--"+u(a):a})},toUnicode:function(a){return h(a,function(a){return b.test(a)?k(a.slice(4).toLowerCase()):a})}};if("function"==typeof define&&"object"==typeof define.amd&&define.amd)define(function(){return e});else if(y&&!y.nodeType)if(A)A.exports=e;else for(G in e)e.hasOwnProperty(G)&&(y[G]=e[G]);else f.punycode= | |
e})(this); | |
(function(f,n){"object"===typeof exports?module.exports=n():"function"===typeof define&&define.amd?define(n):f.SecondLevelDomains=n(f)})(this,function(f){var n=f&&f.SecondLevelDomains,g={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ", | |
bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ", | |
cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ", | |
et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ", | |
ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ", | |
kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ", | |
mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ", | |
pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ", | |
sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ", | |
na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ", | |
rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ", | |
tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ", | |
us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(h){var d=h.lastIndexOf(".");if(0>=d||d>=h.length-1)return!1; | |
var f=h.lastIndexOf(".",d-1);if(0>=f||f>=d-1)return!1;var n=g.list[h.slice(d+1)];return n?0<=n.indexOf(" "+h.slice(f+1,d)+" "):!1},is:function(f){var d=f.lastIndexOf(".");if(0>=d||d>=f.length-1||0<=f.lastIndexOf(".",d-1))return!1;var m=g.list[f.slice(d+1)];return m?0<=m.indexOf(" "+f.slice(0,d)+" "):!1},get:function(f){var d=f.lastIndexOf(".");if(0>=d||d>=f.length-1)return null;var m=f.lastIndexOf(".",d-1);if(0>=m||m>=d-1)return null;var n=g.list[f.slice(d+1)];return!n||0>n.indexOf(" "+f.slice(m+ | |
1,d)+" ")?null:f.slice(m+1)},noConflict:function(){f.SecondLevelDomains===this&&(f.SecondLevelDomains=n);return this}};return g}); | |
(function(f,n){"object"===typeof exports?module.exports=n(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],n):f.URI=n(f.punycode,f.IPv6,f.SecondLevelDomains,f)})(this,function(f,n,g,h){function d(a,b){if(!(this instanceof d))return new d(a,b);void 0===a&&(a="undefined"!==typeof location?location.href+"":"");this.href(a);return void 0!==b?this.absoluteTo(b):this}function m(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g, | |
"\\$1")}function w(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function r(a){return"Array"===w(a)}function k(a,b){var c,d;if(r(b)){c=0;for(d=b.length;c<d;c++)if(!k(a,b[c]))return!1;return!0}var e=w(b);c=0;for(d=a.length;c<d;c++)if("RegExp"===e){if("string"===typeof a[c]&&a[c].match(b))return!0}else if(a[c]===b)return!0;return!1}function u(a,b){if(!r(a)||!r(b)||a.length!==b.length)return!1;a.sort();b.sort();for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1; | |
return!0}function y(a){return escape(a)}function A(a){return encodeURIComponent(a).replace(/[!'()*]/g,y).replace(/\*/g,"%2A")}var C=h&&h.URI;d.version="1.13.0";var e=d.prototype,q=Object.prototype.hasOwnProperty;d._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:d.duplicateQueryParameters,escapeQuerySpace:d.escapeQuerySpace}};d.duplicateQueryParameters=!1;d.escapeQuerySpace=!0;d.protocol_expression= | |
/^[a-z][a-z0-9.+-]*$/i;d.idn_expression=/[^a-z0-9\.-]/i;d.punycode_expression=/(xn--)/i;d.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;d.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; | |
d.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/};d.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};d.invalid_hostname_characters= | |
/[^a-zA-Z0-9\.-]/;d.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src"};d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();return"input"===b&&"image"!==a.type?void 0:d.domAttributes[b]}};d.encode=A;d.decode=decodeURIComponent;d.iso8859=function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=A;d.decode=decodeURIComponent};d.characters= | |
{pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}}};d.encodeQuery= | |
function(a,b){var c=d.encode(a+"");void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery=function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};d.recodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;b<c;b++)a[b]=d.encodePathSegment(d.decode(a[b]));return a.join("/")};d.decodePath=function(a){a=(a+"").split("/");for(var b=0,c=a.length;b<c;b++)a[b]=d.decodePathSegment(a[b]);return a.join("/")}; | |
var p={encode:"encode",decode:"decode"},s,t=function(a,b){return function(c){return d[b](c+"").replace(d.characters[a][b].expression,function(c){return d.characters[a][b].map[c]})}};for(s in p)d[s+"PathSegment"]=t("pathname",p[s]);d.encodeReserved=t("reserved","encode");d.parse=function(a,b){var c;b||(b={});c=a.indexOf("#");-1<c&&(b.fragment=a.substring(c+1)||null,a=a.substring(0,c));c=a.indexOf("?");-1<c&&(b.query=a.substring(c+1)||null,a=a.substring(0,c));"//"===a.substring(0,2)?(b.protocol=null, | |
a=a.substring(2),a=d.parseAuthority(a,b)):(c=a.indexOf(":"),-1<c&&(b.protocol=a.substring(0,c)||null,b.protocol&&!b.protocol.match(d.protocol_expression)?b.protocol=void 0:"file"===b.protocol?a=a.substring(c+3):"//"===a.substring(c+1,c+3)?(a=a.substring(c+3),a=d.parseAuthority(a,b)):(a=a.substring(c+1),b.urn=!0)));b.path=a;return b};d.parseHost=function(a,b){var c=a.indexOf("/"),d;-1===c&&(c=a.length);"["===a.charAt(0)?(d=a.indexOf("]"),b.hostname=a.substring(1,d)||null,b.port=a.substring(d+2,c)|| | |
null,"/"===b.port&&(b.port=null)):a.indexOf(":")!==a.lastIndexOf(":")?(b.hostname=a.substring(0,c)||null,b.port=null):(d=a.substring(0,c).split(":"),b.hostname=d[0]||null,b.port=d[1]||null);b.hostname&&"/"!==a.substring(c).charAt(0)&&(c++,a="/"+a);return a.substring(c)||"/"};d.parseAuthority=function(a,b){a=d.parseUserinfo(a,b);return d.parseHost(a,b)};d.parseUserinfo=function(a,b){var c=a.indexOf("/"),l=-1<c?a.lastIndexOf("@",c):a.indexOf("@");-1<l&&(-1===c||l<c)?(c=a.substring(0,l).split(":"),b.username= | |
c[0]?d.decode(c[0]):null,c.shift(),b.password=c[0]?d.decode(c.join(":")):null,a=a.substring(l+1)):(b.username=null,b.password=null);return a};d.parseQuery=function(a,b){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var c={},l=a.split("&"),e=l.length,f,k,g=0;g<e;g++)f=l[g].split("="),k=d.decodeQuery(f.shift(),b),f=f.length?d.decodeQuery(f.join("="),b):null,c[k]?("string"===typeof c[k]&&(c[k]=[c[k]]),c[k].push(f)):c[k]=f;return c};d.build=function(a){var b="";a.protocol&& | |
(b+=a.protocol+":");a.urn||!b&&!a.hostname||(b+="//");b+=d.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(b+="/"),b+=a.path);"string"===typeof a.query&&a.query&&(b+="?"+a.query);"string"===typeof a.fragment&&a.fragment&&(b+="#"+a.fragment);return b};d.buildHost=function(a){var b="";if(a.hostname)b=d.ip6_expression.test(a.hostname)?b+("["+a.hostname+"]"):b+a.hostname;else return"";a.port&&(b+=":"+a.port);return b};d.buildAuthority=function(a){return d.buildUserinfo(a)+ | |
d.buildHost(a)};d.buildUserinfo=function(a){var b="";a.username&&(b+=d.encode(a.username),a.password&&(b+=":"+d.encode(a.password)),b+="@");return b};d.buildQuery=function(a,b,c){var l="",e,f,k,g;for(f in a)if(q.call(a,f)&&f)if(r(a[f]))for(e={},k=0,g=a[f].length;k<g;k++)void 0!==a[f][k]&&void 0===e[a[f][k]+""]&&(l+="&"+d.buildQueryParameter(f,a[f][k],c),!0!==b&&(e[a[f][k]+""]=!0));else void 0!==a[f]&&(l+="&"+d.buildQueryParameter(f,a[f],c));return l.substring(1)};d.buildQueryParameter=function(a, | |
b,c){return d.encodeQuery(a,c)+(null!==b?"="+d.encodeQuery(b,c):"")};d.addQuery=function(a,b,c){if("object"===typeof b)for(var l in b)q.call(b,l)&&d.addQuery(a,l,b[l]);else if("string"===typeof b)void 0===a[b]?a[b]=c:("string"===typeof a[b]&&(a[b]=[a[b]]),r(c)||(c=[c]),a[b]=a[b].concat(c));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};d.removeQuery=function(a,b,c){var l;if(r(b))for(c=0,l=b.length;c<l;c++)a[b[c]]=void 0;else if("object"===typeof b)for(l in b)q.call(b, | |
l)&&d.removeQuery(a,l,b[l]);else if("string"===typeof b)if(void 0!==c)if(a[b]===c)a[b]=void 0;else{if(r(a[b])){l=a[b];var e={},f,k;if(r(c))for(f=0,k=c.length;f<k;f++)e[c[f]]=!0;else e[c]=!0;f=0;for(k=l.length;f<k;f++)void 0!==e[l[f]]&&(l.splice(f,1),k--,f--);a[b]=l}}else a[b]=void 0;else throw new TypeError("URI.addQuery() accepts an object, string as the first parameter");};d.hasQuery=function(a,b,c,l){if("object"===typeof b){for(var e in b)if(q.call(b,e)&&!d.hasQuery(a,e,b[e]))return!1;return!0}if("string"!== | |
typeof b)throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter");switch(w(c)){case "Undefined":return b in a;case "Boolean":return a=Boolean(r(a[b])?a[b].length:a[b]),c===a;case "Function":return!!c(a[b],b,a);case "Array":return r(a[b])?(l?k:u)(a[b],c):!1;case "RegExp":return r(a[b])?l?k(a[b],c):!1:Boolean(a[b]&&a[b].match(c));case "Number":c=String(c);case "String":return r(a[b])?l?k(a[b],c):!1:a[b]===c;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter"); | |
}};d.commonPath=function(a,b){var c=Math.min(a.length,b.length),d;for(d=0;d<c;d++)if(a.charAt(d)!==b.charAt(d)){d--;break}if(1>d)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b,c){c||(c={});var l=c.start||d.findUri.start,e=c.end||d.findUri.end,f=c.trim||d.findUri.trim,k=/[a-z0-9-]=["']?$/i;for(l.lastIndex=0;;){var g=l.exec(a);if(!g)break;g=g.index;if(c.ignoreHtml){var h= | |
a.slice(Math.max(g-3,0),g);if(h&&k.test(h))continue}var h=g+a.slice(g).search(e),u=a.slice(g,h).replace(f,"");c.ignore&&c.ignore.test(u)||(h=g+u.length,u=b(u,g,h,a),a=a.slice(0,g)+u+a.slice(h),l.lastIndex=g+u.length)}l.lastIndex=0;return a};d.ensureValidHostname=function(a){if(a.match(d.invalid_hostname_characters)){if(!f)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available');if(f.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+ | |
a+'" contains characters other than [A-Z0-9.-]');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},h.URITemplate&&"function"===typeof h.URITemplate.noConflict&&(a.URITemplate=h.URITemplate.noConflict()),h.IPv6&&"function"===typeof h.IPv6.noConflict&&(a.IPv6=h.IPv6.noConflict()),h.SecondLevelDomains&&"function"===typeof h.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=h.SecondLevelDomains.noConflict()),a;h.URI===this&&(h.URI=C);return this};e.build=function(a){if(!0===a)this._deferred_build= | |
!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};e.clone=function(){return new d(this)};e.valueOf=e.toString=function(){return this.build(!1)._string};p={protocol:"protocol",username:"username",password:"password",hostname:"hostname",port:"port"};t=function(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}};for(s in p)e[s]=t(p[s]);p={query:"?",fragment:"#"};t=function(a, | |
b){return function(c,d){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!d);return this}};for(s in p)e[s]=t(s,p[s]);p={search:["?","query"],hash:["#","fragment"]};t=function(a,b){return function(c,d){var e=this[a](c,d);return"string"===typeof e&&e.length?b+e:e}};for(s in p)e[s]=t(p[s][1],p[s][0]);e.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}this._parts.path= | |
a?d.recodePath(a):"/";this.build(!b);return this};e.path=e.pathname;e.href=function(a,b){var c;if(void 0===a)return this.toString();this._string="";this._parts=d._parts();var l=a instanceof d,e="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(e=d.getDomAttribute(a),a=a[e]||"",e=!1);!l&&e&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a)this._parts=d.parse(a,this._parts);else if(l||e)for(c in l=l?a._parts:a,l)q.call(this._parts,c)&&(this._parts[c]=l[c]);else throw new TypeError("invalid input"); | |
this.build(!b);return this};e.is=function(a){var b=!1,c=!1,e=!1,f=!1,k=!1,h=!1,u=!1,p=!this._parts.urn;this._parts.hostname&&(p=!1,c=d.ip4_expression.test(this._parts.hostname),e=d.ip6_expression.test(this._parts.hostname),b=c||e,k=(f=!b)&&g&&g.has(this._parts.hostname),h=f&&d.idn_expression.test(this._parts.hostname),u=f&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return p;case "absolute":return!p;case "domain":case "name":return f;case "sld":return k; | |
case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;case "ip6":case "ipv6":case "inet6":return e;case "idn":return h;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return u}return null};var x=e.protocol,H=e.port,F=e.hostname;e.protocol=function(a,b){if(void 0!==a&&a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return x.call(this, | |
a,b)};e.scheme=e.protocol;e.port=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),a.match(/[^0-9]/))))throw new TypeError('Port "'+a+'" contains characters other than [0-9]');return H.call(this,a,b)};e.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={};d.parseHost(a,c);a=c.hostname}return F.call(this,a,b)};e.host=function(a,b){if(this._parts.urn)return void 0===a?"":this; | |
if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";d.parseHost(a,this._parts);this.build(!b);return this};e.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";d.parseAuthority(a,this._parts);this.build(!b);return this};e.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.username)return"";var c=d.buildUserinfo(this._parts);return c.substring(0, | |
c.length-1)}"@"!==a[a.length-1]&&(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};e.resource=function(a,b){var c;if(void 0===a)return this.path()+this.search()+this.hash();c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};e.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length- | |
1;return this._parts.hostname.substring(0,c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=RegExp("^"+m(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");a&&d.ensureValidHostname(a);this._parts.hostname=this._parts.hostname.replace(c,a);this.build(!b);return this};e.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.match(/\./g); | |
if(c&&2>c.length)return this._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");d.ensureValidHostname(a);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=RegExp(m(this.domain())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};e.tld=function(a,b){if(this._parts.urn)return void 0===a?"": | |
this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf("."),c=this._parts.hostname.substring(c+1);return!0!==b&&g&&g.list[c.toLowerCase()]?g.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(g&&g.is(a))c=RegExp(m(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(c,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname|| | |
this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=RegExp(m(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};e.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1,c=this._parts.path.substring(0, | |
c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=RegExp("^"+m(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);return this};e.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return""; | |
var c=this._parts.path.lastIndexOf("/"),c=this._parts.path.substring(c+1);return a?d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var e=RegExp(m(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);c?this.normalizePath(b):this.build(!b);return this};e.suffix=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),e=c.lastIndexOf("."); | |
if(-1===e)return"";c=c.substring(e+1);c=/^[a-z0-9%]+$/i.test(c)?c:"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())e=a?RegExp(m(c)+"$"):RegExp(m("."+c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}e&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(e,a));this.build(!b);return this};e.segment=function(a,b,c){var d=this._parts.urn?":":"/",e=this.path(),f="/"===e.substring(0,1),e=e.split(d);void 0!==a&&"number"!==typeof a&& | |
(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');f&&e.shift();0>a&&(a=Math.max(e.length+a,0));if(void 0===b)return void 0===a?e:e[a];if(null===a||void 0===e[a])if(r(b)){e=[];a=0;for(var k=b.length;a<k;a++)if(b[a].length||e.length&&e[e.length-1].length)e.length&&!e[e.length-1].length&&e.pop(),e.push(b[a])}else{if(b||"string"===typeof b)""===e[e.length-1]?e[e.length-1]=b:e.push(b)}else b||"string"===typeof b&&b.length?e[a]=b:e.splice(a, | |
1);f&&e.unshift("");return this.path(e.join(d),c)};e.segmentCoded=function(a,b,c){var e,f;"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0===b){a=this.segment(a,b,c);if(r(a))for(e=0,f=a.length;e<f;e++)a[e]=d.decode(a[e]);else a=void 0!==a?d.decode(a):void 0;return a}if(r(b))for(e=0,f=b.length;e<f;e++)b[e]=d.decode(b[e]);else b="string"===typeof b?d.encode(b):b;return this.segment(a,b,c)};var E=e.query;e.query=function(a,b){if(!0===a)return d.parseQuery(this._parts.query,this._parts.escapeQuerySpace); | |
if("function"===typeof a){var c=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,c);this._parts.query=d.buildQuery(e||c,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!b);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=d.buildQuery(a,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace),this.build(!b),this):E.call(this,a,b)};e.setQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace); | |
if("object"===typeof a)for(var f in a)q.call(a,f)&&(e[f]=a[f]);else if("string"===typeof a)e[a]=void 0!==b?b:null;else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};e.addQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.addQuery(e,a,void 0===b?null:b);this._parts.query= | |
d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};e.removeQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.removeQuery(e,a,b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};e.hasQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace); | |
return d.hasQuery(e,a,b,c)};e.setSearch=e.setQuery;e.addSearch=e.addQuery;e.removeSearch=e.removeQuery;e.hasSearch=e.hasQuery;e.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};e.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(), | |
this.build(!a));return this};e.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&f?this._parts.hostname=f.toASCII(this._parts.hostname):this.is("IPv6")&&n&&(this._parts.hostname=n.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};e.normalizePort=function(a){"string"===typeof this._parts.protocol&&this._parts.port===d.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};e.normalizePath= | |
function(a){if(this._parts.urn||!this._parts.path||"/"===this._parts.path)return this;var b,c=this._parts.path,e="",f,k;"/"!==c.charAt(0)&&(b=!0,c="/"+c);c=c.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");b&&(e=c.substring(1).match(/^(\.\.\/)+/)||"")&&(e=e[0]);for(;;){f=c.indexOf("/..");if(-1===f)break;else if(0===f){c=c.substring(3);continue}k=c.substring(0,f).lastIndexOf("/");-1===k&&(k=f);c=c.substring(0,k)+c.substring(f+3)}b&&this.is("relative")&&(c=e+c.substring(1));c=d.recodePath(c); | |
this._parts.path=c;this.build(!a);return this};e.normalizePathname=e.normalizePath;e.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(d.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=null,this.build(!a));return this};e.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};e.normalizeSearch=e.normalizeQuery;e.normalizeHash=e.normalizeFragment;e.iso8859=function(){var a= | |
d.encode,b=d.decode;d.encode=escape;d.decode=decodeURIComponent;this.normalize();d.encode=a;d.decode=b;return this};e.unicode=function(){var a=d.encode,b=d.decode;d.encode=A;d.decode=unescape;this.normalize();d.encode=a;d.decode=b;return this};e.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&f?(b+=f.toUnicode(a._parts.hostname),a._parts.port&&(b+=":"+a._parts.port)):b+=a.host()); | |
a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(b+="/");b+=a.path(!0);if(a._parts.query){for(var c="",e=0,k=a._parts.query.split("&"),g=k.length;e<g;e++){var h=(k[e]||"").split("="),c=c+("&"+d.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,"%26"));void 0!==h[1]&&(c+="="+d.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}b+="?"+c.substring(1)}return b+=d.decodeQuery(a.hash(),!0)};e.absoluteTo=function(a){var b=this.clone(),c=["protocol","username", | |
"password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a instanceof d||(a=new d(a));b._parts.protocol||(b._parts.protocol=a._parts.protocol);if(this._parts.hostname)return b;for(e=0;f=c[e];e++)b._parts[f]=a._parts[f];b._parts.path?".."===b._parts.path.substring(-2)&&(b._parts.path+="/"):(b._parts.path=a._parts.path,b._parts.query||(b._parts.query=a._parts.query));"/"!==b.path().charAt(0)&&(a=a.directory(),b._parts.path=(a? | |
a+"/":"")+b._parts.path,b.normalizePath());b.build();return b};e.relativeTo=function(a){var b=this.clone().normalize(),c,e,f,k;if(b._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new d(a)).normalize();c=b._parts;e=a._parts;f=b.path();k=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==k.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");c.protocol===e.protocol&&(c.protocol=null);if(c.username=== | |
e.username&&c.password===e.password&&null===c.protocol&&null===c.username&&null===c.password&&c.hostname===e.hostname&&c.port===e.port)c.hostname=null,c.port=null;else return b.build();if(f===k)return c.path="",b.build();a=d.commonPath(b.path(),a.path());if(!a)return b.build();e=e.path.substring(a.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");c.path=e+c.path.substring(a.length);return b.build()};e.equals=function(a){var b=this.clone();a=new d(a);var c={},e={},f={},k;b.normalize();a.normalize(); | |
if(b.toString()===a.toString())return!0;c=b.query();e=a.query();b.query("");a.query("");if(b.toString()!==a.toString()||c.length!==e.length)return!1;c=d.parseQuery(c,this._parts.escapeQuerySpace);e=d.parseQuery(e,this._parts.escapeQuerySpace);for(k in c)if(q.call(c,k)){if(!r(c[k])){if(c[k]!==e[k])return!1}else if(!u(c[k],e[k]))return!1;f[k]=!0}for(k in e)if(q.call(e,k)&&!f[k])return!1;return!0};e.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};e.escapeQuerySpace= | |
function(a){this._parts.escapeQuerySpace=!!a;return this};return d}); | |
(function(f,n){"object"===typeof exports?module.exports=n(require("./URI")):"function"===typeof define&&define.amd?define(["./URI"],n):f.URITemplate=n(f.URI,f)})(this,function(f,n){function g(d){if(g._cache[d])return g._cache[d];if(!(this instanceof g))return new g(d);this.expression=d;g._cache[d]=this;return this}function h(d){this.data=d;this.cache={}}var d=n&&n.URITemplate,m=Object.prototype.hasOwnProperty,w=g.prototype,r={"":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encode"}, | |
"+":{prefix:"",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},"#":{prefix:"#",separator:",",named:!1,empty_name_separator:!1,encode:"encodeReserved"},".":{prefix:".",separator:".",named:!1,empty_name_separator:!1,encode:"encode"},"/":{prefix:"/",separator:"/",named:!1,empty_name_separator:!1,encode:"encode"},";":{prefix:";",separator:";",named:!0,empty_name_separator:!1,encode:"encode"},"?":{prefix:"?",separator:"&",named:!0,empty_name_separator:!0,encode:"encode"},"&":{prefix:"&", | |
separator:"&",named:!0,empty_name_separator:!0,encode:"encode"}};g._cache={};g.EXPRESSION_PATTERN=/\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g;g.VARIABLE_PATTERN=/^([^*:]+)((\*)|:(\d+))?$/;g.VARIABLE_NAME_PATTERN=/[^a-zA-Z0-9%_]/;g.expand=function(d,f){var h=r[d.operator],m=h.named?"Named":"Unnamed",n=d.variables,e=[],q,p,s;for(s=0;p=n[s];s++)q=f.get(p.name),q.val.length?e.push(g["expand"+m](q,h,p.explode,p.explode&&h.separator||",",p.maxlength,p.name)):q.type&&e.push("");return e.length?h.prefix+e.join(h.separator): | |
""};g.expandNamed=function(d,g,h,m,n,e){var q="",p=g.encode;g=g.empty_name_separator;var s=!d[p].length,t=2===d.type?"":f[p](e),x,r,w;r=0;for(w=d.val.length;r<w;r++)n?(x=f[p](d.val[r][1].substring(0,n)),2===d.type&&(t=f[p](d.val[r][0].substring(0,n)))):s?(x=f[p](d.val[r][1]),2===d.type?(t=f[p](d.val[r][0]),d[p].push([t,x])):d[p].push([void 0,x])):(x=d[p][r][1],2===d.type&&(t=d[p][r][0])),q&&(q+=m),h?q+=t+(g||x?"=":"")+x:(r||(q+=f[p](e)+(g||x?"=":"")),2===d.type&&(q+=t+","),q+=x);return q};g.expandUnnamed= | |
function(d,g,h,n,m){var e="",q=g.encode;g=g.empty_name_separator;var p=!d[q].length,s,t,r,w;r=0;for(w=d.val.length;r<w;r++)m?t=f[q](d.val[r][1].substring(0,m)):p?(t=f[q](d.val[r][1]),d[q].push([2===d.type?f[q](d.val[r][0]):void 0,t])):t=d[q][r][1],e&&(e+=n),2===d.type&&(s=m?f[q](d.val[r][0].substring(0,m)):d[q][r][0],e+=s,e=h?e+(g||t?"=":""):e+","),e+=t;return e};g.noConflict=function(){n.URITemplate===g&&(n.URITemplate=d);return g};w.expand=function(d){var f="";this.parts&&this.parts.length||this.parse(); | |
d instanceof h||(d=new h(d));for(var m=0,n=this.parts.length;m<n;m++)f+="string"===typeof this.parts[m]?this.parts[m]:g.expand(this.parts[m],d);return f};w.parse=function(){var d=this.expression,f=g.EXPRESSION_PATTERN,h=g.VARIABLE_PATTERN,m=g.VARIABLE_NAME_PATTERN,n=[],e=0,q,p,s;for(f.lastIndex=0;;){p=f.exec(d);if(null===p){n.push(d.substring(e));break}else n.push(d.substring(e,p.index)),e=p.index+p[0].length;if(!r[p[1]])throw Error('Unknown Operator "'+p[1]+'" in "'+p[0]+'"');if(!p[3])throw Error('Unclosed Expression "'+ | |
p[0]+'"');q=p[2].split(",");for(var t=0,w=q.length;t<w;t++){s=q[t].match(h);if(null===s)throw Error('Invalid Variable "'+q[t]+'" in "'+p[0]+'"');if(s[1].match(m))throw Error('Invalid Variable Name "'+s[1]+'" in "'+p[0]+'"');q[t]={name:s[1],explode:!!s[3],maxlength:s[4]&&parseInt(s[4],10)}}if(!q.length)throw Error('Expression Missing Variable(s) "'+p[0]+'"');n.push({expression:p[0],operator:p[1],variables:q})}n.length||n.push(d);this.parts=n;return this};h.prototype.get=function(d){var f=this.data, | |
g={type:0,val:[],encode:[],encodeReserved:[]},h;if(void 0!==this.cache[d])return this.cache[d];this.cache[d]=g;f="[object Function]"===String(Object.prototype.toString.call(f))?f(d):"[object Function]"===String(Object.prototype.toString.call(f[d]))?f[d](d):f[d];if(void 0!==f&&null!==f)if("[object Array]"===String(Object.prototype.toString.call(f))){h=0;for(d=f.length;h<d;h++)void 0!==f[h]&&null!==f[h]&&g.val.push([void 0,String(f[h])]);g.val.length&&(g.type=3)}else if("[object Object]"===String(Object.prototype.toString.call(f))){for(h in f)m.call(f, | |
h)&&void 0!==f[h]&&null!==f[h]&&g.val.push([h,String(f[h])]);g.val.length&&(g.type=2)}else g.type=1,g.val.push([void 0,String(f)]);return g};f.expand=function(d,h){var m=(new g(d)).expand(h);return new f(m)};return g}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* URI.js - Mutating URLs | |
* URI Template Support - http://tools.ietf.org/html/rfc6570 | |
* | |
* Version: 1.13.2 | |
* | |
* Author: Rodney Rehm | |
* Web: http://medialize.github.io/URI.js/ | |
* | |
* Licensed under | |
* MIT License http://www.opensource.org/licenses/mit-license | |
* GPL v3 http://opensource.org/licenses/GPL-3.0 | |
* | |
*/ | |
(function (root, factory) { | |
'use strict'; | |
// https://github.com/umdjs/umd/blob/master/returnExports.js | |
if (typeof exports === 'object') { | |
// Node | |
module.exports = factory(require('./URI')); | |
} else if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['./URI'], factory); | |
} else { | |
// Browser globals (root is window) | |
root.URITemplate = factory(root.URI, root); | |
} | |
}(this, function (URI, root) { | |
'use strict'; | |
// FIXME: v2.0.0 renamce non-camelCase properties to uppercase | |
/*jshint camelcase: false */ | |
// save current URITemplate variable, if any | |
var _URITemplate = root && root.URITemplate; | |
var hasOwn = Object.prototype.hasOwnProperty; | |
function URITemplate(expression) { | |
// serve from cache where possible | |
if (URITemplate._cache[expression]) { | |
return URITemplate._cache[expression]; | |
} | |
// Allow instantiation without the 'new' keyword | |
if (!(this instanceof URITemplate)) { | |
return new URITemplate(expression); | |
} | |
this.expression = expression; | |
URITemplate._cache[expression] = this; | |
return this; | |
} | |
function Data(data) { | |
this.data = data; | |
this.cache = {}; | |
} | |
var p = URITemplate.prototype; | |
// list of operators and their defined options | |
var operators = { | |
// Simple string expansion | |
'' : { | |
prefix: '', | |
separator: ',', | |
named: false, | |
empty_name_separator: false, | |
encode : 'encode' | |
}, | |
// Reserved character strings | |
'+' : { | |
prefix: '', | |
separator: ',', | |
named: false, | |
empty_name_separator: false, | |
encode : 'encodeReserved' | |
}, | |
// Fragment identifiers prefixed by '#' | |
'#' : { | |
prefix: '#', | |
separator: ',', | |
named: false, | |
empty_name_separator: false, | |
encode : 'encodeReserved' | |
}, | |
// Name labels or extensions prefixed by '.' | |
'.' : { | |
prefix: '.', | |
separator: '.', | |
named: false, | |
empty_name_separator: false, | |
encode : 'encode' | |
}, | |
// Path segments prefixed by '/' | |
'/' : { | |
prefix: '/', | |
separator: '/', | |
named: false, | |
empty_name_separator: false, | |
encode : 'encode' | |
}, | |
// Path parameter name or name=value pairs prefixed by ';' | |
';' : { | |
prefix: ';', | |
separator: ';', | |
named: true, | |
empty_name_separator: false, | |
encode : 'encode' | |
}, | |
// Query component beginning with '?' and consisting | |
// of name=value pairs separated by '&'; an | |
'?' : { | |
prefix: '?', | |
separator: '&', | |
named: true, | |
empty_name_separator: true, | |
encode : 'encode' | |
}, | |
// Continuation of query-style &name=value pairs | |
// within a literal query component. | |
'&' : { | |
prefix: '&', | |
separator: '&', | |
named: true, | |
empty_name_separator: true, | |
encode : 'encode' | |
} | |
// The operator characters equals ("="), comma (","), exclamation ("!"), | |
// at sign ("@"), and pipe ("|") are reserved for future extensions. | |
}; | |
// storage for already parsed templates | |
URITemplate._cache = {}; | |
// pattern to identify expressions [operator, variable-list] in template | |
URITemplate.EXPRESSION_PATTERN = /\{([^a-zA-Z0-9%_]?)([^\}]+)(\}|$)/g; | |
// pattern to identify variables [name, explode, maxlength] in variable-list | |
URITemplate.VARIABLE_PATTERN = /^([^*:]+)((\*)|:(\d+))?$/; | |
// pattern to verify variable name integrity | |
URITemplate.VARIABLE_NAME_PATTERN = /[^a-zA-Z0-9%_]/; | |
// expand parsed expression (expression, not template!) | |
URITemplate.expand = function(expression, data) { | |
// container for defined options for the given operator | |
var options = operators[expression.operator]; | |
// expansion type (include keys or not) | |
var type = options.named ? 'Named' : 'Unnamed'; | |
// list of variables within the expression | |
var variables = expression.variables; | |
// result buffer for evaluating the expression | |
var buffer = []; | |
var d, variable, i; | |
for (i = 0; (variable = variables[i]); i++) { | |
// fetch simplified data source | |
d = data.get(variable.name); | |
if (!d.val.length) { | |
if (d.type) { | |
// empty variables (empty string) | |
// still lead to a separator being appended! | |
buffer.push(''); | |
} | |
// no data, no action | |
continue; | |
} | |
// expand the given variable | |
buffer.push(URITemplate['expand' + type]( | |
d, | |
options, | |
variable.explode, | |
variable.explode && options.separator || ',', | |
variable.maxlength, | |
variable.name | |
)); | |
} | |
if (buffer.length) { | |
return options.prefix + buffer.join(options.separator); | |
} else { | |
// prefix is not prepended for empty expressions | |
return ''; | |
} | |
}; | |
// expand a named variable | |
URITemplate.expandNamed = function(d, options, explode, separator, length, name) { | |
// variable result buffer | |
var result = ''; | |
// peformance crap | |
var encode = options.encode; | |
var empty_name_separator = options.empty_name_separator; | |
// flag noting if values are already encoded | |
var _encode = !d[encode].length; | |
// key for named expansion | |
var _name = d.type === 2 ? '': URI[encode](name); | |
var _value, i, l; | |
// for each found value | |
for (i = 0, l = d.val.length; i < l; i++) { | |
if (length) { | |
// maxlength must be determined before encoding can happen | |
_value = URI[encode](d.val[i][1].substring(0, length)); | |
if (d.type === 2) { | |
// apply maxlength to keys of objects as well | |
_name = URI[encode](d.val[i][0].substring(0, length)); | |
} | |
} else if (_encode) { | |
// encode value | |
_value = URI[encode](d.val[i][1]); | |
if (d.type === 2) { | |
// encode name and cache encoded value | |
_name = URI[encode](d.val[i][0]); | |
d[encode].push([_name, _value]); | |
} else { | |
// cache encoded value | |
d[encode].push([undefined, _value]); | |
} | |
} else { | |
// values are already encoded and can be pulled from cache | |
_value = d[encode][i][1]; | |
if (d.type === 2) { | |
_name = d[encode][i][0]; | |
} | |
} | |
if (result) { | |
// unless we're the first value, prepend the separator | |
result += separator; | |
} | |
if (!explode) { | |
if (!i) { | |
// first element, so prepend variable name | |
result += URI[encode](name) + (empty_name_separator || _value ? '=' : ''); | |
} | |
if (d.type === 2) { | |
// without explode-modifier, keys of objects are returned comma-separated | |
result += _name + ','; | |
} | |
result += _value; | |
} else { | |
// only add the = if it is either default (?&) or there actually is a value (;) | |
result += _name + (empty_name_separator || _value ? '=' : '') + _value; | |
} | |
} | |
return result; | |
}; | |
// expand an unnamed variable | |
URITemplate.expandUnnamed = function(d, options, explode, separator, length) { | |
// variable result buffer | |
var result = ''; | |
// performance crap | |
var encode = options.encode; | |
var empty_name_separator = options.empty_name_separator; | |
// flag noting if values are already encoded | |
var _encode = !d[encode].length; | |
var _name, _value, i, l; | |
// for each found value | |
for (i = 0, l = d.val.length; i < l; i++) { | |
if (length) { | |
// maxlength must be determined before encoding can happen | |
_value = URI[encode](d.val[i][1].substring(0, length)); | |
} else if (_encode) { | |
// encode and cache value | |
_value = URI[encode](d.val[i][1]); | |
d[encode].push([ | |
d.type === 2 ? URI[encode](d.val[i][0]) : undefined, | |
_value | |
]); | |
} else { | |
// value already encoded, pull from cache | |
_value = d[encode][i][1]; | |
} | |
if (result) { | |
// unless we're the first value, prepend the separator | |
result += separator; | |
} | |
if (d.type === 2) { | |
if (length) { | |
// maxlength also applies to keys of objects | |
_name = URI[encode](d.val[i][0].substring(0, length)); | |
} else { | |
// at this point the name must already be encoded | |
_name = d[encode][i][0]; | |
} | |
result += _name; | |
if (explode) { | |
// explode-modifier separates name and value by "=" | |
result += (empty_name_separator || _value ? '=' : ''); | |
} else { | |
// no explode-modifier separates name and value by "," | |
result += ','; | |
} | |
} | |
result += _value; | |
} | |
return result; | |
}; | |
URITemplate.noConflict = function() { | |
if (root.URITemplate === URITemplate) { | |
root.URITemplate = _URITemplate; | |
} | |
return URITemplate; | |
}; | |
// expand template through given data map | |
p.expand = function(data) { | |
var result = ''; | |
if (!this.parts || !this.parts.length) { | |
// lazilyy parse the template | |
this.parse(); | |
} | |
if (!(data instanceof Data)) { | |
// make given data available through the | |
// optimized data handling thingie | |
data = new Data(data); | |
} | |
for (var i = 0, l = this.parts.length; i < l; i++) { | |
/*jshint laxbreak: true */ | |
result += typeof this.parts[i] === 'string' | |
// literal string | |
? this.parts[i] | |
// expression | |
: URITemplate.expand(this.parts[i], data); | |
/*jshint laxbreak: false */ | |
} | |
return result; | |
}; | |
// parse template into action tokens | |
p.parse = function() { | |
// performance crap | |
var expression = this.expression; | |
var ePattern = URITemplate.EXPRESSION_PATTERN; | |
var vPattern = URITemplate.VARIABLE_PATTERN; | |
var nPattern = URITemplate.VARIABLE_NAME_PATTERN; | |
// token result buffer | |
var parts = []; | |
// position within source template | |
var pos = 0; | |
var variables, eMatch, vMatch; | |
// RegExp is shared accross all templates, | |
// which requires a manual reset | |
ePattern.lastIndex = 0; | |
// I don't like while(foo = bar()) loops, | |
// to make things simpler I go while(true) and break when required | |
while (true) { | |
eMatch = ePattern.exec(expression); | |
if (eMatch === null) { | |
// push trailing literal | |
parts.push(expression.substring(pos)); | |
break; | |
} else { | |
// push leading literal | |
parts.push(expression.substring(pos, eMatch.index)); | |
pos = eMatch.index + eMatch[0].length; | |
} | |
if (!operators[eMatch[1]]) { | |
throw new Error('Unknown Operator "' + eMatch[1] + '" in "' + eMatch[0] + '"'); | |
} else if (!eMatch[3]) { | |
throw new Error('Unclosed Expression "' + eMatch[0] + '"'); | |
} | |
// parse variable-list | |
variables = eMatch[2].split(','); | |
for (var i = 0, l = variables.length; i < l; i++) { | |
vMatch = variables[i].match(vPattern); | |
if (vMatch === null) { | |
throw new Error('Invalid Variable "' + variables[i] + '" in "' + eMatch[0] + '"'); | |
} else if (vMatch[1].match(nPattern)) { | |
throw new Error('Invalid Variable Name "' + vMatch[1] + '" in "' + eMatch[0] + '"'); | |
} | |
variables[i] = { | |
name: vMatch[1], | |
explode: !!vMatch[3], | |
maxlength: vMatch[4] && parseInt(vMatch[4], 10) | |
}; | |
} | |
if (!variables.length) { | |
throw new Error('Expression Missing Variable(s) "' + eMatch[0] + '"'); | |
} | |
parts.push({ | |
expression: eMatch[0], | |
operator: eMatch[1], | |
variables: variables | |
}); | |
} | |
if (!parts.length) { | |
// template doesn't contain any expressions | |
// so it is a simple literal string | |
// this probably should fire a warning or something? | |
parts.push(expression); | |
} | |
this.parts = parts; | |
return this; | |
}; | |
// simplify data structures | |
Data.prototype.get = function(key) { | |
// performance crap | |
var data = this.data; | |
// cache for processed data-point | |
var d = { | |
// type of data 0: undefined/null, 1: string, 2: object, 3: array | |
type: 0, | |
// original values (except undefined/null) | |
val: [], | |
// cache for encoded values (only for non-maxlength expansion) | |
encode: [], | |
encodeReserved: [] | |
}; | |
var i, l, value; | |
if (this.cache[key] !== undefined) { | |
// we've already processed this key | |
return this.cache[key]; | |
} | |
this.cache[key] = d; | |
if (String(Object.prototype.toString.call(data)) === '[object Function]') { | |
// data itself is a callback (global callback) | |
value = data(key); | |
} else if (String(Object.prototype.toString.call(data[key])) === '[object Function]') { | |
// data is a map of callbacks (local callback) | |
value = data[key](key); | |
} else { | |
// data is a map of data | |
value = data[key]; | |
} | |
// generalize input into [ [name1, value1], [name2, value2], … ] | |
// so expansion has to deal with a single data structure only | |
if (value === undefined || value === null) { | |
// undefined and null values are to be ignored completely | |
return d; | |
} else if (String(Object.prototype.toString.call(value)) === '[object Array]') { | |
for (i = 0, l = value.length; i < l; i++) { | |
if (value[i] !== undefined && value[i] !== null) { | |
// arrays don't have names | |
d.val.push([undefined, String(value[i])]); | |
} | |
} | |
if (d.val.length) { | |
// only treat non-empty arrays as arrays | |
d.type = 3; // array | |
} | |
} else if (String(Object.prototype.toString.call(value)) === '[object Object]') { | |
for (i in value) { | |
if (hasOwn.call(value, i) && value[i] !== undefined && value[i] !== null) { | |
// objects have keys, remember them for named expansion | |
d.val.push([i, String(value[i])]); | |
} | |
} | |
if (d.val.length) { | |
// only treat non-empty objects as objects | |
d.type = 2; // object | |
} | |
} else { | |
d.type = 1; // primitive string (could've been string, number, boolean and objects with a toString()) | |
// arrays don't have names | |
d.val.push([undefined, String(value)]); | |
} | |
return d; | |
}; | |
// hook into URI for fluid access | |
URI.expand = function(expression, data) { | |
var template = new URITemplate(expression); | |
var expansion = template.expand(data); | |
return new URI(expansion); | |
}; | |
return URITemplate; | |
})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:function getScript(e,t){var n=document.getElementsByTagName("head")[0],r=false;var i=document.createElement("script");i.src=e;i.onload=i.onreadystatechange=function(){if(!r&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){r=true;t()}};n.appendChild(i)}function urlToFilename(e){return!e?"":e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("?")==-1?e.length:e.lastIndexOf("?"))}function init(){var e=getModelName(),t=getModelUrls();window.mywindow=createPopup(window.popHtml,"width=1001,height=600",e,window.styles);Handlebars.registerPartial("tout",window.pFeature);Handlebars.registerPartial("specSection",window.pSpecSec);createPopupHeader();$.when($.getJSON(t["features"]).done(features_callback).fail(fail_callback),$.getJSON(t["packages"]).done(package_callback).fail(fail_callback),$.getJSON(t["specs"]).done(specs_callback).fail(fail_callback)).then(initEvents)}function package_callback(e){console.log("package success",e);var t=Handlebars.compile(tmplPkg);var n=Handlebars.compile(tmplAcc);var r=t(e);var i=n(e);$(window.mywindow.document).find("#pkgContainer").html(r);$(window.mywindow.document).find("#accessoryContainer").html(i)}function specs_callback(e){console.log("specs success",e);var t=Handlebars.compile(tmplSpec);var n=t(e);$(window.mywindow.document).find("#specsContainer").html(n)}function features_callback(e){console.log("features success",e);var t=Handlebars.compile(tmplFeat);var n=t(e);$(window.mywindow.document).find("#featuresContainer").html(n)}function fail_callback(){console.error("Failed to load data! Try again.")}function initEvents(){}function createPopupHeader(){var e="";e+='<div class="container">';e+="";e+=' <div class="row">';e+=' <div class="col-md-8">';e+=" <h1>"+getModelName()+" <small>"+getMSRP()+"</small></h1>";e+=" </div>";e+=' <div class="col-md-4">';e+=" </div>";e+=" </div>";e+="";e+="</div>";var t={exterior:{desktop:{regular:getHeroExterior()}},interior:{desktop:{regular:getHeroInterior()}}};$(mywindow.document.body).find("header").html(e);var n=Handlebars.compile(tmplHero);var e=n(t);$(window.mywindow.document).find("#heroContainer").html(e)}function getHeroInterior(){return $("#interior-slide").find("img").attr("src")}function getHeroExterior(){return $("#exterior-image-container").find("img").eq(0).attr("src")}function createPopup(e,t,n,r){if(typeof mywindow!=="undefined"){mywindow.close()}mywindow=window.open("","MyPopup",t);$(mywindow.document.body).html(e);$(mywindow.document).find("head").append("<title>"+n+"</title>");var i="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css";$.get(i,function(e){$(mywindow.document).find("head").append("<style>"+r+"</style>");$(mywindow.document).find("head").append("<style>"+e+"</style>")});return mywindow}function getModelUrls(){var e=window.location.origin,t=$(".content").data("props").model,n=$(".content").data("props").class,r=$(".content").data("props").contextPath,i=e+r+"/json/vehicles/model/class-"+n+"/model-"+t,s={};s["features"]=i+"/section-features";s["specs"]=i+"/section-specs";s["packages"]=i+"/section-packages";return s}function getModelName(){return $("#exterior-slide").find("h1").find("span").eq(0).text()}function getModelYear(){return $("#exterior-slide").find("h1").find("span.year").text()}function getMSRP(){return $("#exterior-slide").find("p.price").text()}window.styles=window.popHtml="";window.tmplFeat=window.tmplSpec=window.tmplPkg=window.tmplAcc=window.tmplHero="";window.pFeature=window.pSpecSec="";popHtml+="<head></head>";popHtml+="<body>";popHtml+="<header></header>";popHtml+='<div id="heroContainer">Loading hero..</div>';popHtml+='<div id="featuresContainer">Loading features..</div>';popHtml+='<div id="pkgContainer">Loading packages..</div>';popHtml+='<div id="accessoryContainer">Loading accessories..</div>';popHtml+='<div id="specsContainer">Loading specs..</div>';popHtml+="</body>";popHtml+="";styles+=".status-OPT{}";styles+=".status-OPT .panel-heading .label{ }";styles+=".status-STD .panel-heading .label{ display: none; }";styles+=".status-STD{}";styles+=".feat-thumb { margin: 0 auto; max-width: 100%; }";styles+="";styles+=".table-dimensions img{ max-height: 140px; margin: 0 auto; display: block;}";styles+="table.specs-table td:first-of-type { width: 250px; }";styles+="";styles+=".features-container .panel + .feat-section-title { margin-top: 71px; }";styles+=".item-copy.textless { display: none; }";styles+=".feature-tout .inline-title { display: none; }";pFeature+='<div class="row">';pFeature+=" {{#if image.breakpoint6Col.regular.sourceUrl}}";pFeature+=' <div class="col-sm-12 col-md-7">';pFeature+=" {{getImage image.breakpoint6Col.regular.sourceUrl}}";pFeature+=" </div>";pFeature+=' <div class="col-sm-12 col-md-5">';pFeature+=" {{else}}";pFeature+=' <div class="col-sm-12 col-md-12">';pFeature+=" {{/if}}";pFeature+=' <b class="inline-title">{{{title}}}</b><br>';pFeature+=' <p class="item-copy {{isTextless body}}">{{{body}}}</p>';pFeature+=' {{#if disclaimer}}<p class="text-primary">{{{disclaimer}}}</p>{{/if}}';pFeature+=' {{#if defaultDisclaimer}}<p class="text-primary">{{{defaultDisclaimer}}}</p>{{/if}}';pFeature+=" </div>";pFeature+="</div>";pSpecSec+=" <h3>{{title}}</h3>";pSpecSec+=' <table class="table table-condensed table-bordered specs-table">';pSpecSec+=" {{#children}}";pSpecSec+=" {{#if children}}";pSpecSec+=' <tr class="active"><td colspan="2"><b>{{title}}</b></td></tr>';pSpecSec+=" {{#children}}";pSpecSec+=" <tr><td>{{title}}</td><td>{{{body}}}</td></tr>";pSpecSec+=" {{/children}}";pSpecSec+=" {{else}}";pSpecSec+=" <tr><td>{{title}}</td><td>{{{body}}}</td></tr>";pSpecSec+=" {{/if}}";pSpecSec+=" {{/children}}";pSpecSec+=" </table>";tmplHero+="";tmplHero+='<div class="container">';tmplHero+="<h2>Hero</h2>";tmplHero+='<div class="row">';tmplHero+=' <div class="col-sm-12 col-md-6">';tmplHero+=" {{getImage exterior.desktop.regular}}";tmplHero+=" </div>";tmplHero+=' <div class="col-sm-12 col-md-6">';tmplHero+=" {{getImage interior.desktop.regular}}";tmplHero+=" </div>";tmplHero+="</div>";tmplHero+="";tmplHero+="";tmplHero+="</div>";tmplFeat+="";tmplFeat+='<div class="container features-container">';tmplFeat+="<h2>Features</h2>";tmplFeat+="{{#model_section_features}}";tmplFeat+=' <h3 class="feat-section-title">{{title}}</h3>';tmplFeat+=" {{#touts}}";tmplFeat+=" ";tmplFeat+=' <div class="panel panel-default status-{{status}} standAlone-{{standAlone}}">';tmplFeat+=' <div class="panel-heading">';tmplFeat+=" <b>{{title}}</b>";tmplFeat+=' <div class="pull-right">';tmplFeat+=' <h4 class="panel-title">';tmplFeat+=' <span class="label label-success">${{standAlonePrice}}</span> ';tmplFeat+=" {{getFeatureStatus status}}";tmplFeat+=" </h4>";tmplFeat+=" </div>";tmplFeat+=" </div>";tmplFeat+=' <div class="panel-body feature-tout"> {{> tout}} </div>';tmplFeat+=" </div>";tmplFeat+=" {{/touts}}";tmplFeat+="";tmplFeat+="{{/model_section_features}}";tmplFeat+="";tmplFeat+="</div>";tmplSpec+='<div class="container">';tmplSpec+="<h2>Specifications</h2>";tmplSpec+="<h3>Dimensions</h3>";tmplSpec+='<table class="table table-condensed table-bordered table-dimensions">';tmplSpec+='<tr class="active"><th class="text-center">Desktop Regular</th><th class="text-center">Desktop Retina</th></tr>';tmplSpec+="<tr>";tmplSpec+=' <td><img src="{{dimensions.breakpoint9Col.regular.sourceUrl}}"/></td>';tmplSpec+=' <td><img src="{{dimensions.breakpoint9Col.retina.sourceUrl}}"/></td>';tmplSpec+="</tr>";tmplSpec+='<tr class="active"><th class="text-center">Tablet Regular</th><th class="text-center">Tablet Retina</th></tr>';tmplSpec+="<tr>";tmplSpec+=' <td><img src="{{dimensions.breakpoint6Col.regular.sourceUrl}}"/></td>';tmplSpec+=' <td><img src="{{dimensions.breakpoint6Col.retina.sourceUrl}}"/></td>';tmplSpec+="</tr>";tmplSpec+="</table>";tmplSpec+="";tmplSpec+="{{#key_features}} {{> specSection}} {{/key_features}}";tmplSpec+="{{#exterior_dimensions}} {{> specSection}} {{/exterior_dimensions}}";tmplSpec+="{{#interior_dimensions}} {{> specSection}} {{/interior_dimensions}}";tmplSpec+="{{#specs}} {{> specSection}} {{/specs}}";tmplSpec+="</div>";tmplSpec+="";tmplPkg+='<div class="container">';tmplPkg+="<h2>Packages</h2>";tmplPkg+="{{#model_section_packages}}";tmplPkg+=" ";tmplPkg+=' <div class="panel panel-default">';tmplPkg+=' <div class="panel-heading">';tmplPkg+=" <b>{{{title}}}</b>";tmplPkg+=' <span class="pull-right">';tmplPkg+=' <p class="label label-success">${{price}}</p>';tmplPkg+=" </span>";tmplPkg+=" </div>";tmplPkg+="";tmplPkg+=' <div class="panel-body">';tmplPkg+=' <div class="row">';tmplPkg+=' {{#if disclaimer}}<p class="text-primary"> {{{disclaimer}}}</p>{{/if}}';tmplPkg+=" </div>";tmplPkg+=" </div>";tmplPkg+="";tmplPkg+=' <ul class="list-group">';tmplPkg+=" {{#touts}}";tmplPkg+=' <li class="list-group-item">';tmplPkg+=" {{> tout}}";tmplPkg+=" </li>";tmplPkg+=" {{/touts}}";tmplPkg+=" </ul>";tmplPkg+=" </div>";tmplPkg+="";tmplPkg+="{{/model_section_packages}}";tmplPkg+="</div>";tmplAcc+='<div class="container">';tmplAcc+="<h2>Accessories</h2>";tmplAcc+="{{#accessories}}";tmplAcc+=" {{#if touts}}";tmplAcc+=" {{#touts}}";tmplAcc+=" ";tmplAcc+=' <div class="panel panel-default status-{{status}} standAlone-{{standAlone}}">';tmplAcc+=' <div class="panel-heading">';tmplAcc+=" <b>{{title}}</b>";tmplAcc+=' <span class="pull-right">';tmplAcc+=' <p class="label label-success">${{standAlonePrice}}</p> {{getFeatureStatus status}}';tmplAcc+=" </span>";tmplAcc+=" </div>";tmplAcc+=' <div class="panel-body">';tmplAcc+="";tmplAcc+=' <div class="row">';tmplAcc+=" {{#if image}}";tmplAcc+=' <div class="col-sm-12 col-md-7">';tmplAcc+=" {{getImage image.breakpoint6Col.regular.sourceUrl}}";tmplAcc+=" </div>";tmplAcc+=' <div class="col-sm-12 col-md-5">';tmplAcc+=" {{else}}";tmplAcc+=' <div class="col-sm-12 col-md-12">';tmplAcc+=" {{/if}}";tmplAcc+=" <p>{{{body}}}</p>";tmplAcc+=' <p class="text-primary">{{{defaultDisclaimer}}}</p>';tmplAcc+=" </div>";tmplAcc+="";tmplAcc+=" </div>";tmplAcc+=" </div>";tmplAcc+="";tmplAcc+=" </div>";tmplAcc+="";tmplAcc+="";tmplAcc+=" {{/touts}}";tmplAcc+=" {{else}}";tmplAcc+=' <div class="alert alert-danger">No accessories</div>';tmplAcc+=" {{/if}}";tmplAcc+="{{/accessories}}";tmplAcc+="</div>";Handlebars.registerHelper("getFeatureStatus",function(e){return new Handlebars.SafeString(e=="OPT"?"Optional":"Standard")});Handlebars.registerHelper("getImage",function(e){var t=urlToFilename(e);return new Handlebars.SafeString('<img src="'+e+'" alt="'+t+'" title="'+t+'" class="feat-thumb" />')});Handlebars.registerHelper("getFilename",function(e){return new Handlebars.SafeString(!e?"":e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("?")==-1?e.length:e.lastIndexOf("?")))});Handlebars.registerHelper("isTextless",function(e){return new Handlebars.SafeString(e.replace(/[ +]/g,"").trim()?"":"textless")});init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment