// moment.js // // version : 1.7.2 // // author : Tim Wood // // license : MIT // // momentjs.com (function(a){function E(a,b,c,d){var e=c.lang();return e[a].call?e[a](c,d):e[a][b]}function F(a,b){return function(c){return K(a.call(this,c),b)}}function G(a){return function(b){var c=a.call(this,b);return c+this.lang().ordinal(c)}}function H(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,this._lang=c||!1}function I(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=J(j/1e3),b.seconds=i%60,h+=J(i/60),b.minutes=h%60,g+=J(h/60),b.hours=g%24,f+=J(g/24),f+=e*7,b.days=f%30,d+=J(f/30),b.months=d%12,c+=J(d/12),b.years=c,this._lang=!1}function J(a){return a<0?Math.ceil(a):Math.floor(a)}function K(a,b){var c=a+"";while(c.length70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(x),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}b==null&&(c[8]=!1)}function W(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(k),f,g;for(f=0;f0,j[4]=c,Z.apply({},j)}function _(a,c){b.fn[a]=function(a){var b=this._isUTC?"UTC":"";return a!=null?(this._d["set"+b+c](a),this):this._d["get"+b+c]()}}function ab(a){b.duration.fn[a]=function(){return this._data[a]}}function bb(a,c){b.duration.fn["as"+a]=function(){return+this/c}}var b,c="1.7.2",d=Math.round,e,f={},g="en",h=typeof module!="undefined"&&module.exports,i="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),j=/^\/?Date\((\-?\d+)/i,k=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g,l=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g,m=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,n=/\d\d?/,o=/\d{1,3}/,p=/\d{3}/,q=/\d{1,4}/,r=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,s=/Z|[\+\-]\d\d:?\d\d/i,t=/T/i,u=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,v="YYYY-MM-DDTHH:mm:ssZ",w=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],x=/([\+\-]|\d\d)/gi,y="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),z={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},A={},B="DDD w M D d".split(" "),C="M D H h m s w".split(" "),D={M:function(){return this.month()+1},MMM:function(a){return E("monthsShort",this.month(),this,a)},MMMM:function(a){return E("months",this.month(),this,a)},D:function(){return this.date()},DDD:function(){var a=new Date(this.year(),this.month(),this.date()),b=new Date(this.year(),0,1);return~~((a-b)/864e5+1.5)},d:function(){return this.day()},dd:function(a){return E("weekdaysMin",this.day(),this,a)},ddd:function(a){return E("weekdaysShort",this.day(),this,a)},dddd:function(a){return E("weekdays",this.day(),this,a)},w:function(){var a=new Date(this.year(),this.month(),this.date()-this.day()+5),b=new Date(a.getFullYear(),0,4);return~~((a-b)/864e5/7+1.5)},YY:function(){return K(this.year()%100,2)},YYYY:function(){return K(this.year(),4)},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return~~(this.milliseconds()/100)},SS:function(){return K(~~(this.milliseconds()/10),2)},SSS:function(){return K(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+K(~~(a/60),2)+":"+K(~~a%60,2)},ZZ:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+K(~~(10*a/6),4)}};while(B.length)e=B.pop(),D[e+"o"]=G(D[e]);while(C.length)e=C.pop(),D[e+e]=F(D[e],2);D.DDDD=F(D.DDD,3),b=function(c,d){if(c===null||c==="")return null;var e,f;return b.isMoment(c)?new H(new Date(+c._d),c._isUTC,c._lang):(d?M(d)?e=X(c,d):e=W(c,d):(f=j.exec(c),e=c===a?new Date:f?new Date(+f[1]):c instanceof Date?c:M(c)?O(c):typeof c=="string"?Y(c):new Date(c)),new H(e))},b.utc=function(a,c){return M(a)?new H(O(a,!0),!0):(typeof a=="string"&&!s.exec(a)&&(a+=" +0000",c&&(c+=" Z")),b(a,c).utc())},b.unix=function(a){return b(a*1e3)},b.duration=function(a,c){var d=b.isDuration(a),e=typeof a=="number",f=d?a._data:e?{}:a,g;return e&&(c?f[c]=a:f.milliseconds=a),g=new I(f),d&&(g._lang=a._lang),g},b.humanizeDuration=function(a,c,d){return b.duration(a,c===!0?null:c).humanize(c===!0?!0:d)},b.version=c,b.defaultFormat=v,b.lang=function(a,c){var d;if(!a)return g;(c||!f[a])&&P(a,c);if(f[a]){for(d=0;d11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),b.fn=H.prototype={clone:function(){return b(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?this._a[8]!=null?!!this._a[8]:!N(this._a,(this._a[7]?b.utc(this._a):b(this._a)).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return T(this,a?a:b.defaultFormat)},add:function(a,c){var d=c?b.duration(+c,a):b.duration(a);return L(this,d,1),this},subtract:function(a,c){var d=c?b.duration(+c,a):b.duration(a);return L(this,d,-1),this},diff:function(a,c,e){var f=this._isUTC?b(a).utc():b(a).local(),g=(this.zone()-f.zone())*6e4,h=this._d-f._d-g,i=this.year()-f.year(),j=this.month()-f.month(),k=this.date()-f.date(),l;return c==="months"?l=i*12+j+k/30:c==="years"?l=i+(j+k/30)/12:l=c==="seconds"?h/1e3:c==="minutes"?h/6e4:c==="hours"?h/36e5:c==="days"?h/864e5:c==="weeks"?h/6048e5:h,e?l:d(l)},from:function(a,c){return b.duration(this.diff(a)).lang(this._lang).humanize(!c)},fromNow:function(a){return this.from(b(),a)},calendar:function(){var a=this.diff(b().sod(),"days",!0),c=this.lang().calendar,d=c.sameElse,e=a<-6?d:a<-1?c.lastWeek:a<0?c.lastDay:a<1?c.sameDay:a<2?c.nextDay:a<7?c.nextWeek:d;return this.format(typeof e=="function"?e.apply(this):e)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()=7)t-=7;return n?e.i18n.weekdaysShort[t]:e.i18n.weekdays[t]},w=function(e,t,n,r,i){if(i)return'';var s=[];return r&&s.push("is-disabled"),n&&s.push("is-today"),t&&s.push("is-selected"),'"+""},E=function(e,t){return""+(t?e.reverse():e).join("")+""},S=function(e){return""+e.join("")+""},x=function(e){var t,n=[];for(t=0;t<7;t++)n.push(''+b(e,t,!0)+"");return""+(e.isRTL?n.reverse():n).join("")+""},T=function(e){var t,n,r,i=e._o,s=e._m,o=e._y,u=o===i.minYear,a=o===i.maxYear,f='
',l=!0,c=!0;for(r=[],t=0;t<12;t++)r.push('");f+='
'+i.i18n.months[s]+'
",h(i.yearRange)?(t=i.yearRange[0],n=i.yearRange[1]+1):(t=o-i.yearRange,n=1+o+i.yearRange);for(r=[];t=i.minYear&&r.push('");return f+='
'+o+'
",u&&(s===0||i.minMonth>=s)&&(l=!1),a&&(s===11||i.maxMonth<=s)&&(c=!1),f+='',f+='',f+="
"},N=function(e,t){return''+x(e)+S(t)+"
"};e.Pikaday=function(n){var u=this,a=u.config(n);u._onMouseDown=function(t){if(!u._v)return;t=t||e.event;var n=t.target||t.srcElement;if(!n)return;if(!f(n,"is-disabled")){if(f(n,"pika-button")&&!f(n,"is-empty")){u.setDate(new Date(u._y,u._m,parseInt(n.innerHTML,10))),a.bound&&s(function(){u.hide()},100);return}f(n,"pika-prev")?u.prevMonth():f(n,"pika-next")&&u.nextMonth()}if(!f(n,"pika-select")){if(!t.preventDefault)return t.returnValue=!1;t.preventDefault()}else u._c=!0},u._onChange=function(t){t=t||e.event;var n=t.target||t.srcElement;if(!n)return;f(n,"pika-select-month")?u.gotoMonth(n.value):f(n,"pika-select-year")&&u.gotoYear(n.value)},u._onInputChange=function(t){if(r)u.setDate(e.moment(a.field.value,a.format).toDate());else{var n=new Date(Date.parse(a.field.value));u.setDate(p(n)?n:null)}u._v||u.show()},u._onInputFocus=function(e){u.show()},u._onInputClick=function(e){u.show()},u._onInputBlur=function(e){u._c||(u._b=s(function(){u.hide()},50)),u._c=!1},u._onClick=function(t){t=t||e.event;var n=t.target||t.srcElement,r=n;if(!n)return;!i&&f(n,"pika-select")&&(n.onchange||(n.setAttribute("onchange","return;"),o(n,"change",u._onChange)));do if(f(r,"pika-single"))return;while(r=r.parentNode);u._v&&n!==a.field&&u.hide()},u.el=t.createElement("div"),u.el.className="pika-single"+(a.isRTL?" is-rtl":""),o(u.el,"mousedown",u._onMouseDown,!0),o(u.el,"change",u._onChange),a.field&&(a.bound?t.body.appendChild(u.el):a.field.parentNode.insertBefore(u.el,a.field.nextSibling),o(a.field,"change",u._onInputChange),a.defaultDate||(r&&a.field.value?a.defaultDate=e.moment(a.field.value,a.format).toDate():a.defaultDate=new Date(Date.parse(a.field.value)),a.setDefaultDate=!0));var l=a.defaultDate;p(l)?a.setDefaultDate?u.setDate(l):u.gotoDate(l):u.gotoDate(new Date),a.bound?(this.hide(),u.el.className+=" is-bound",o(a.field,"click",u._onInputClick),o(a.field,"focus",u._onInputFocus),o(a.field,"blur",u._onInputBlur)):this.show()},e.Pikaday.prototype={config:function(e){this._o||(this._o=g({},y,!0));var t=g(this._o,e,!0);t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.bound=!!(t.bound!==n?t.field&&t.bound:t.field);var r=parseInt(t.numberOfMonths,10)||1;t.numberOfMonths=r>4?4:r,p(t.minDate)||(t.minDate=!1),p(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate100&&(t.yearRange=100);return t},toString:function(t){return p(this._d)?r?e.moment(this._d).format(t||this._o.format):this._d.toDateString():""},getMoment:function(){return r?e.moment(this._d):null},getDate:function(){return p(this._d)?new Date(this._d.getTime()):null},setDate:function(e){if(!e)return this._d=null,this.draw();typeof e=="string"&&(e=new Date(Date.parse(e)));if(!p(e))return;var t=this._o.minDate,n=this._o.maxDate;p(t)&&en&&(e=n),this._d=new Date(e.getTime()),this._d.setHours(0,0,0,0),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString()),typeof this._o.onSelect=="function"&&this._o.onSelect.call(this,this.getDate())},gotoDate:function(e){if(!p(e))return;this._y=e.getFullYear(),this._m=e.getMonth(),this.draw()},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(e){isNaN(e=parseInt(e,10))||(this._m=e<0?0:e>11?11:e,this.draw())},nextMonth:function(){++this._m>11&&(this._m=0,this._y++),this.draw()},prevMonth:function(){--this._m<0&&(this._m=11,this._y--),this.draw()},gotoYear:function(e){isNaN(e)||(this._y=parseInt(e,10),this.draw())},draw:function(e){if(!this._v&&!e)return;var t=this._o,n=t.minYear,r=t.maxYear,i=t.minMonth,o=t.maxMonth;this._y<=n&&(this._y=n,!isNaN(i)&&this._m=r&&(this._y=r,!isNaN(o)&&this._m>o&&(this._m=o)),this.el.innerHTML=T(this)+this.render(this._y,this._m);if(t.bound){var u=t.field,a=u.offsetLeft,f=u.offsetTop+u.offsetHeight;while(u=u.offsetParent)a+=u.offsetLeft,f+=u.offsetTop;this.el.style.cssText="position:absolute;left:"+a+"px;top:"+f+"px;",s(function(){t.field.focus()},1)}},render:function(e,t){var n=this._o,r=new Date,i=v(e,t),s=(new Date(e,t,1)).getDay(),o=[],u=[];r.setHours(0,0,0,0),n.firstDay>0&&(s-=n.firstDay,s<0&&(s+=7));var a=i+s,f=a;while(f>7)f-=7;a+=7-f;for(var l=0,c=0;ln.maxDate,g=p(this._d)?m(h,this._d):!1,y=m(h,r),b=l=i+s;u.push(w(1+(l-s),g,y,d,b)),++c===7&&(o.push(E(u,n.isRTL)),u=[],c=0)}return N(n,o)},isVisible:function(){return this._v},show:function(){this._v||(this._o.bound&&o(t,"click",this._onClick),c(this.el,"is-hidden"),this._v=!0,this.draw(),typeof this._o.onOpen=="function"&&this._o.onOpen.call(this))},hide:function(){var e=this._v;e!==!1&&(this._o.bound&&u(t,"click",this._onClick),this.el.style.cssText="",l(this.el,"is-hidden"),this._v=!1,e!==n&&typeof this._o.onClose=="function"&&this._o.onClose.call(this))},destroy:function(){this.hide(),u(this.el,"mousedown",this._onMouseDown,!0),u(this.el,"change",this._onChange),this._o.field&&(u(this._o.field,"change",this._onInputChange),this._o.bound&&(u(this._o.field,"click",this._onInputClick),u(this._o.field,"focus",this._onInputFocus),u(this._o.field,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}})(window,window.document); /* tears.js */ var tears = {} function pick(src) { if(tears.input) { var name = tears.input.getAttribute("data-name"); var input = document.getElementsByName(name)[0]; tears.input.src = src; input.value = src; tears.input = null; } } function insert(text) { var t = document.getElementsByName('tekst')[0]; if(!t) return; if(t.selectionStart || t.selectionStart == '0') { var pos = t.selectionStart; var end = t.selectionEnd; t.value = t.value.substring(0, pos) + text + t.value.substring(end, t.value.length); } var cpos = t.selectionStart; t.setSelectionRange(cpos, cpos); t.focus(); } function wrap(prefix, postfix) { var t = document.getElementsByName('tekst')[0]; if(!t) return; if(t.selectionStart || t.selectionStart == '0') { var pos = t.selectionStart; var end = t.selectionEnd; var n = t.value.indexOf("\n", pos); if(n > 0 && n < end) end = n; t.value = t.value.substring(0, pos) + prefix + t.value.substring(pos, end) + postfix + t.value.substring(end, t.value.length); } var cpos = end + prefix.length + postfix.length; t.setSelectionRange(cpos, cpos); t.focus(); } function prepend(text) { var t = document.getElementsByName('tekst')[0]; if(!t) return; if(t.selectionStart || t.selectionStart == '0') { var pos = t.selectionStart; var end = t.selectionEnd; for(;pos < end; pos++) { if(t.value.charAt(pos) != "\n") break; } for(;end > pos; end--) { if(t.value.charAt(end - 1) != "\n") break; } var quote = ""; var cpos = end; if(t.value.charAt(pos - 1) != "\n") { quote += "\n"; cpos += 1; } if(pos == end) { quote += text; cpos += text.length; } else { var lines = t.value.substring(pos, end).split("\n"); for(var i=0; i < lines.length; i++) { quote += text + lines[i] + "\n"; cpos += text.length; } quote = quote.slice(0, -1); } t.value = t.value.substring(0, pos) + quote + t.value.substring(end, t.value.length); } t.setSelectionRange(cpos, cpos); t.focus(); } function marxup_bold(e) { wrap("*", "*"); } function marxup_header(e) { prepend("= "); } function marxup_italics(e) { wrap("_", "_"); } function marxup_small(e) { wrap("~", "~"); } function marxup_link(e) { wrap("[", "]"); } function marxup_quote(e) { prepend("> "); } function marxup_list(e) { prepend("* "); } function button(node, html, fun) { var a = document.createElement("a"); a.innerHTML = html; a.href = "#"; a.onclick = fun; node.parentNode.insertBefore(a, node.nextSibling); } function orz(src) { insert("\n{" + src.replace(".t.jpg", "") + "}\n"); } document.addEventListener("DOMContentLoaded", function(e) { var field = document.getElementsByName('publisert')[0]; if(field) { new Pikaday({ field: field, format: 'YYYY-MM-DD' }); } /* var els = document.getElementsByClassName('orz'); for(var i=0; i < els.length; i++) { els[i].onclick = function(e) { tears.input = e.target; window.open(e.target.getAttribute('data-uri')); return false; } } */ var title = document.getElementsByTagName('h1')[0]; var headers = document.getElementsByTagName("h2"); if(headers.length > 0) { var menu = document.createElement("div"); menu.className = 'magisk meny'; for(var i = 0; i < headers.length; i++) { var a = document.createElement("a"); var id = "h-" + i; headers[i].id = id; a.href = "#" + id; a.textContent = headers[i].textContent; menu.appendChild(a); menu.appendChild(document.createElement("br")); } title.parentNode.insertBefore(menu, title.nextSibling); } // var orz = document.getElementById('orz'); var orz = document.getElementsByClassName('orz')[0]; if(orz) { orz.onclick = function(e) { window.open("/orz"); return false; } button(orz, "> sitat", marxup_quote); button(orz, "* liste", marxup_list); button(orz, "[lenke]", marxup_link); button(orz, "_kursiv_", marxup_italics); button(orz, "*fet*", marxup_bold); button(orz, "liten", marxup_small); button(orz, "= overskrift", marxup_header); } });