www.berekenen.nl
Open in
urlscan Pro
185.58.56.175
Public Scan
Submitted URL: http://www.berekenen.nl/skin/default/cache/47c4b52bc5e62b52c471513fe703411f1bhtugm.js
Effective URL: https://www.berekenen.nl/skin/default/cache/47c4b52bc5e62b52c471513fe703411f1bhtugm.js
Submission: On April 11 via manual from NL — Scanned from NL
Effective URL: https://www.berekenen.nl/skin/default/cache/47c4b52bc5e62b52c471513fe703411f1bhtugm.js
Submission: On April 11 via manual from NL — Scanned from NL
Form analysis
0 forms found in the DOMText Content
if(typeof(json)=='undefined'){ function json(data, onsucces, onerror){ var value = null; try { eval('value = ' + data + ';'); }catch(e){ onerror(e); return; } onsucces(value); } } if(typeof(json.get)=='undefined'){ json.get = function(url, onsucces, onerror){ $.get(url, function(response){ json(response, onsucces, function(ex){ onerror(ex, response); }); }, 'text'); }; } if(typeof(json.post)=='undefined'){ json.post = function(url, data, onsucces, onerror){ $.post(url, data, function(response){ json(response, onsucces, function(ex){ onerror(ex, response); }); }, 'text'); }; } function print_r(i,t){ d = ''; if(t==null) t=''; if(i==null) return '(null)'; switch(i.constructor){ case Number: case Boolean: case Date: { d+=i; } break; case Function: { d+=i.toString().replace('\n','').replace('\r',''); } break; case String: { d+='"'+i+'"'; } break; case Array: { d+='Array\n'+t+'(\n'+t; for(x in i){ d+=' ['+x+'] = '+print_r(i[x],t+' ')+'\n'+t; } d+=')'; } break; case Object: { d+='Object\n'+t+'(\n'+t; for(x in i){ d+=' ['+x+'] = '+print_r(i[x],t+' ')+'\n'+t; } d+=')'; } break; default:{ d+='Unknown: ' + i; //alert('Error variable unknown:\n'+i.constructor); } } return d; } (function($) { $.fn.serializeForm = function(){ var data = {}; this.each(function() { var form = $(this); var items = form.find('select,input,textarea'); for(var i=0; i<items.length; i++){ var item = $(items[i]); var name = item.attr('name'); if(name){ if('checkbox|radio'.indexOf(item.attr('type'))>=0){ if(item.prop('checked')){ if(item.attr('value')){ data[name] = item.val(); }else{ data[name] = 'on'; } } }else { data[name] = item.val(); } } } }); return data; }; })(jQuery); (function($) { $.fn.traverse = function(data, callback, namespace){ var form = this; var __make = function(base, sub){ if(!base) return sub; return base + '[' + sub + ']'; }; var __traverse = function(data, base, callback){ for(key in data){ var item = data[key]; if(typeof(item)=='object'){ __traverse(item, __make(base, key), callback); }else{ var element = form.find('[name="' + __make(base, key) + '"]'); callback(element, item); } } }; __traverse(data, typeof(namespace)=='undefined' ? false : namespace, callback); }; })(jQuery); /** * json_encode */ if(typeof(json_encode)=='undefined'){ function json_string(text){ text = text.replace(/\\/g,'\\\\').replace(/\'/g,'\\\'').replace(/\"/g,'\\"').replace(/\0/g,'\\0').replace(/\r\n/g,'\\n').replace(/\n/g,'\\n').replace(/\r/g,'\\r'); var string = ''; for(var i=0; i<text.length; i++){ var c = text.charCodeAt(i); if(c >= 128){ var value = c.toString(16); while(value.length < 4) value = '0' + value; string+= '\\u' + value; }else{ string+= text.charAt(i); } } return '"' + (string) + '"'; } function json_encode(value){ if(value==null) return 'null'; switch(value.constructor){ case Boolean: return value ? 'true' : 'false'; case Number: return value.toString(); case Date: return json_encode(value.toString()); case Function: return json_encode(value.toString()); case String: return json_string(value); case Array: var json = []; for(var i=0; i<value.length; i++){ json.push(json_encode(value[i])); } return '[' + json.join(',') + ']'; default: case Object: var json = []; for(key in value){ json.push(json_encode(key.toString()) + ':' + json_encode(value[key])); } return '{' + json.join(',') + '}'; } } } function select_set_values(selector, data, params){ if(typeof(params.empty)=='undefined') params.empty = false; var select = $(selector); select.find('option').remove(); if(params.empty) select.append($('<option>', { value : '' }).text('')); for(var x in data){ var item = data[x]; select.append($('<option>', { value : item[params.value] }).text(item[params.text])); } if(typeof(params.defaultValue)=='undefined'){ select.val(params.defaultValue); } select.change(); } function serialize(form){ form = $(form); var data = {}; var items = form.find('select,input,textarea'); for(var i=0; i<items.length; i++){ var item = $(items[i]); var name = item.attr('name'); if(name){ if('checkbox|radio'.indexOf(item.attr('type'))>=0){ if(item.checked('type')){ if(item.attr('value')){ data[name] = item.val(); }else{ data[name] = 'on'; } } }else { data[name] = item.val(); } } } return data; } function traverse(data, callback, namespace){ var __make = function(base, sub){ if(!base) return sub; return base + '[' + sub + ']'; }; var __traverse = function(data, base, callback){ for(key in data){ var item = data[key]; if(typeof(item)=='object'){ __traverse(item, __make(base, key), callback); }else{ callback(__make(base, key), item); } } }; __traverse(data, typeof(namespace)=='undefined' ? false : namespace, callback); } (function($){ $.fn.selectFancy = function(settings){ var config = { emptySelect: true, className: null, multipleText: '%d geselecteerd' }; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); var select = me.find('> select'); if(select.length <= 0) return; if(me.data('installed')){ return; } me.data('installed', true); if(me.css('position')=='static') me.css('position', 'relative'); select.css('z-index', 0).css('vissible', 'hidden'); var container = $(document.createElement('span')); select.after(container); container.addClass('select-fancy-container'); container.html('<span class="select-fancy-button"></span><span class="select-fancy-text"><span><span></span></span></span>'); var list = $(document.createElement('div')); $(document.body).append(list); list.addClass('select-fancy-list'); if(config.className) list.addClass(config.className); $(document.body).click(function(){ if(list.hasClass('open')){ list.removeClass('open'); container.removeClass('open'); select.change(); } }); var __onChange = function(){ var active = select.find(':selected'); if(active.length > 1){ container.find('.select-fancy-text span span').text(config.multipleText.replace('%d', active.length)); }else if(active.length == 1){ container.find('.select-fancy-text span span').text(active.text()); }else if(select.find('option').length > 0){ container.find('.select-fancy-text span span').text(select.find(':first-child').text()); }else{ container.find('.select-fancy-text span span').text(''); } }; __onChange(); var __onClick = function(evt){ evt.preventDefault(); evt.stopPropagation(); if(list.hasClass('open')){ list.removeClass('open'); container.removeClass('open'); }else{ $('body > div.select-fancy-list.open,.select-fancy-container.open').removeClass('open'); list.find('.select-fancy-list-item').remove(); select.find('option').each(function(){ var option = $(this); if(config.emptySelect==false && option.val()=='') return; var item = $(document.createElement('div')) .addClass('select-fancy-list-item') .text(option.text()); if(option.prop('selected')) item.addClass('selected'); item.click(function(evt){ evt.stopPropagation(); if(select.attr('multiple') && (evt.ctrlKey || evt.metaKey)){ option.prop('selected', !option.prop('selected')); item[option.prop('selected') ? 'addClass' : 'removeClass']('selected'); }else{ select.val(option.val()); list.removeClass('open'); container.removeClass('open'); select.change(); } }); list.append(item); }); container.addClass('open'); list.addClass('open'); var offset = me.offset(); list.css('left', offset.left); list.css('top', offset.top + me.height()); list.css('min-width', me.width()); } }; select.change(__onChange); container.find('.select-fancy-text').click(__onClick); container.find('.select-fancy-button').click(__onClick); }); }; })(jQuery); /*! * selectivizr v1.0.2 - (c) Keith Clark, freely distributable under the terms of the MIT license. * selectivizr.com */ (function(j){function A(a){return a.replace(B,h).replace(C,function(a,d,b){for(var a=b.split(","),b=0,e=a.length;b<e;b++){var s=D(a[b].replace(E,h).replace(F,h))+o,l=[];a[b]=s.replace(G,function(a,b,c,d,e){if(b){if(l.length>0){var a=l,f,e=s.substring(0,e).replace(H,i);if(e==i||e.charAt(e.length-1)==o)e+="*";try{f=t(e)}catch(k){}if(f){e=0;for(c=f.length;e<c;e++){for(var d=f[e],h=d.className,j=0,m=a.length;j<m;j++){var g=a[j];if(!RegExp("(^|\\s)"+g.className+"(\\s|$)").test(d.className)&&g.b&&(g.b===!0||g.b(d)===!0))h=u(h,g.className,!0)}d.className=h}}l=[]}return b}else{if(b=c?I(c):!v||v.test(d)?{className:w(d),b:!0}:null)return l.push(b),"."+b.className;return a}})}return d+a.join(",")})}function I(a){var c=!0,d=w(a.slice(1)),b=a.substring(0,5)==":not(",e,f;b&&(a=a.slice(5,-1));var l=a.indexOf("(");l>-1&&(a=a.substring(0,l));if(a.charAt(0)==":")switch(a.slice(1)){case "root":c=function(a){return b?a!=p:a==p};break;case "target":if(m==8){c=function(a){function c(){var d=location.hash,e=d.slice(1);return b?d==i||a.id!=e:d!=i&&a.id==e}k(j,"hashchange",function(){g(a,d,c())});return c()};break}return!1;case "checked":c=function(a){J.test(a.type)&&k(a,"propertychange",function(){event.propertyName=="checked"&&g(a,d,a.checked!==b)});return a.checked!==b};break;case "disabled":b=!b;case "enabled":c=function(c){if(K.test(c.tagName))return k(c,"propertychange",function(){event.propertyName=="$disabled"&&g(c,d,c.a===b)}),q.push(c),c.a=c.disabled,c.disabled===b;return a==":enabled"?b:!b};break;case "focus":e="focus",f="blur";case "hover":e||(e="mouseenter",f="mouseleave");c=function(a){k(a,b?f:e,function(){g(a,d,!0)});k(a,b?e:f,function(){g(a,d,!1)});return b};break;default:if(!L.test(a))return!1}return{className:d,b:c}}function w(a){return M+"-"+(m==6&&N?O++:a.replace(P,function(a){return a.charCodeAt(0)}))}function D(a){return a.replace(x,h).replace(Q,o)}function g(a,c,d){var b=a.className,c=u(b,c,d);if(c!=b)a.className=c,a.parentNode.className+=i}function u(a,c,d){var b=RegExp("(^|\\s)"+c+"(\\s|$)"),e=b.test(a);return d?e?a:a+o+c:e?a.replace(b,h).replace(x,h):a}function k(a,c,d){a.attachEvent("on"+c,d)}function r(a,c){if(/^https?:\/\//i.test(a))return c.substring(0,c.indexOf("/",8))==a.substring(0,a.indexOf("/",8))?a:null;if(a.charAt(0)=="/")return c.substring(0,c.indexOf("/",8))+a;var d=c.split(/[?#]/)[0];a.charAt(0)!="?"&&d.charAt(d.length-1)!="/"&&(d=d.substring(0,d.lastIndexOf("/")+1));return d+a}function y(a){if(a)return n.open("GET",a,!1),n.send(),(n.status==200?n.responseText:i).replace(R,i).replace(S,function(c,d,b,e,f){return y(r(b||f,a))}).replace(T,function(c,d,b){d=d||i;return" url("+d+r(b,a)+d+") "});return i}function U(){var a,c;a=f.getElementsByTagName("BASE");for(var d=a.length>0?a[0].href:f.location.href,b=0;b<f.styleSheets.length;b++)if(c=f.styleSheets[b],c.href!=i&&(a=r(c.href,d)))c.cssText=A(y(a));q.length>0&&setInterval(function(){for(var a=0,c=q.length;a<c;a++){var b=q[a];if(b.disabled!==b.a)b.disabled?(b.disabled=!1,b.a=!0,b.disabled=!0):b.a=b.disabled}},250)}if(!/*@cc_on!@*/true){var f=document,p=f.documentElement,n=function(){if(j.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){return null}}(),m=/MSIE (\d+)/.exec(navigator.userAgent)[1];if(!(f.compatMode!="CSS1Compat"||m<6||m>8||!n)){var z={NW:"*.Dom.select",MooTools:"$$",DOMAssistant:"*.$",Prototype:"$$",YAHOO:"*.util.Selector.query",Sizzle:"*",jQuery:"*",dojo:"*.query"},t,q=[],O=0,N=!0,M="slvzr",R=/(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*/g,S=/@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))[^;]*;/g,T=/\burl\(\s*(["']?)(?!data:)([^"')]+)\1\s*\)/g,L=/^:(empty|(first|last|only|nth(-last)?)-(child|of-type))$/,B=/:(:first-(?:line|letter))/g,C=/(^|})\s*([^\{]*?[\[:][^{]+)/g,G=/([ +~>])|(:[a-z-]+(?:\(.*?\)+)?)|(\[.*?\])/g,H=/(:not\()?:(hover|enabled|disabled|focus|checked|target|active|visited|first-line|first-letter)\)?/g,P=/[^\w-]/g,K=/^(INPUT|SELECT|TEXTAREA|BUTTON)$/,J=/^(checkbox|radio)$/,v=m>6?/[\$\^*]=(['"])\1/:null,E=/([(\[+~])\s+/g,F=/\s+([)\]+~])/g,Q=/\s+/g,x=/^\s*((?:[\S\s]*\S)?)\s*$/,i="",o=" ",h="$1";(function(a,c){function d(){try{p.doScroll("left")}catch(a){setTimeout(d,50);return}b("poll")}function b(d){if(!(d.type=="readystatechange"&&f.readyState!="complete")&&((d.type=="load"?a:f).detachEvent("on"+d.type,b,!1),!e&&(e=!0)))c.call(a,d.type||d)}var e=!1,g=!0;if(f.readyState=="complete")c.call(a,i);else{if(f.createEventObject&&p.doScroll){try{g=!a.frameElement}catch(h){}g&&d()}k(f,"readystatechange",b);k(a,"load",b)}})(j,function(){for(var a in z){var c,d,b=j;if(j[a]){for(c=z[a].replace("*",a).split(".");(d=c.shift())&&(b=b[d]););if(typeof b=="function"){t=b;U();break}}}})}}})(this); (function($){ $.fn.smartSearch = function(settings){ var config = { }; if(settings) $.extend(config, settings); var __getValue = function(obj, key, def){ if(typeof(obj[key])!='undefined'){ if(typeof(obj[key])=='function'){ var value = obj[key](); if(typeof(value)=='undefined') return def; return value; } return obj[key]; } return def; }; this.each(function(){ var source = $(this); var popup = $('<div class="smart-search"><ul></ul></div>'); var instance = { index: -1, items: [], confirm:function(){ if(instance.index < 0) return false; var item = instance.items[instance.index]; if(typeof(item.url)!='undefined'){ window.location = item.url; }else if(typeof(item.value)!='undefined'){ source.val(item.value); if(typeof(config.onconfirm)!='undefined') return config.onconfirm(); }else{ source.val(item.text); if(typeof(config.onconfirm)!='undefined') return config.onconfirm(); } return true; }, search:function(){ instance.index = -1; if(source.val().length > 0){ config.search(source.val(), instance); }else{ instance.setItems([]); } }, setItems:function(items){ var bounds = source.offset(); bounds.top+= __getValue(config, 'top'); bounds.left+= __getValue(config, 'left'); bounds.width = __getValue(config, 'width', source.width()); popup.css(bounds); instance.items = items; if(instance.items.length > 0){ popup.css('display', 'block'); }else{ popup.css('display', 'none'); } popup.find('> ul > li').remove(); for(var i=0; i<Math.min(items.length, 10); i++){ var item = items[i]; var li = $(document.createElement('li')); li.text(item.text); li.hover(function(){ instance.setActive(popup.find('> ul > li').index(this)); }); li.click(function(){ instance.setActive(popup.find('> ul > li').index(this)); instance.confirm(); if(typeof(config.onclick)!='undefined') config.onclick(source); }); popup.find('> ul').append(li); } if(items.length==1) instance.setActive(0); }, setActive:function(index){ instance.index = Math.max(-1, Math.min(index, instance.items.length - 1)); popup.find('> ul > li.active').removeClass('active'); if(instance.index>=0){ $(popup.find('> ul > li')[instance.index]).addClass('active'); } } }; source.attr('autocomplete', 'off'); source.keydown(function(evt){ if(evt.keyCode==38){ evt.preventDefault(); instance.setActive(instance.index - 1); }else if(evt.keyCode==40){ evt.preventDefault(); instance.setActive(instance.index + 1); }else if(evt.keyCode==13){ if(instance.confirm()){ evt.preventDefault(); } }else if(evt.keyCode!=37 && evt.keyCode!=39){ setTimeout(function(){ instance.search(); }, 10); } }); $(document.body).append(popup); }); }; })(jQuery); (function($){ $.fn.dialog = function(settings){ var config = { trigger:function(source, dialog){ source.click(function(evt){ evt.preventDefault(); dialog.open(); }); } }; if(settings) $.extend(config, settings); this.each(function(){ var source = $(this); var dialog = { open:function(){ var me = this; $('body > .dialog').remove(); $('body').append('<div class="dialog"><div><div><div class="window"><a href="javascript:void(0)">X</a><div></div></div></div></div></div>'); $('body > .dialog .window > a').click(function(){ me.close(); }); config.content(source, dialog); }, setContent:function(html){ $('body > .dialog > div > div > .window > div')[0].innerHTML = html; return $('body > .dialog > div > div > .window > div'); }, setCloseText:function(text){ $('body > .dialog > div > div > .window > a').text(text); }, addClass:function(className){ $('body > .dialog').addClass(className); }, setWidth:function(width){ width = parseInt(width); var body = $('.dialog .window > div'); if(body.css('padding-left').match(/(\d+(\.\d+)?)px/i)) width+= parseInt(body.css('padding-left').match(/(\d+(\.\d+)?)px/i)[1]); if(body.css('padding-right').match(/(\d+(\.\d+)?)px/i)) width+= parseInt(body.css('padding-right').match(/(\d+(\.\d+)?)px/i)[1]); $('.dialog .window').width(width); }, show:function(html){ $('body').addClass('dialog'); }, hide:function(){ $('body').removeClass('dialog'); }, close:function(html){ this.hide(); $('body > .dialog').remove(); }, find:function(selector){ return $('.dialog .window > div').find(selector); } }; config.trigger(source, dialog); }); return this; }; })(jQuery); jQuery.dialog = function(settings){ settings.trigger = function(source, dialog){ dialog.open(); }; $(window).dialog(settings); }; (function($) { $.fn.caret = function(pos) { var target = this[0]; var isContentEditable = target.contentEditable === 'true'; //get if (arguments.length == 0) { //HTML5 if (window.getSelection) { //contenteditable if (isContentEditable) { target.focus(); var range1 = window.getSelection().getRangeAt(0), range2 = range1.cloneRange(); range2.selectNodeContents(target); range2.setEnd(range1.endContainer, range1.endOffset); return range2.toString().length; } //textarea return target.selectionStart; } //IE<9 if (document.selection) { target.focus(); //contenteditable if (isContentEditable) { var range1 = document.selection.createRange(), range2 = document.body.createTextRange(); range2.moveToElementText(target); range2.setEndPoint('EndToEnd', range1); return range2.text.length; } //textarea var pos = 0, range = target.createTextRange(), range2 = document.selection.createRange().duplicate(), bookmark = range2.getBookmark(); range.moveToBookmark(bookmark); while (range.moveStart('character', -1) !== 0) pos++; return pos; } //not supported return 0; } //set if (pos == -1) pos = this[isContentEditable? 'text' : 'val']().length; //HTML5 if (window.getSelection) { //contenteditable if (isContentEditable) { target.focus(); window.getSelection().collapse(target.firstChild, pos); } //textarea else target.setSelectionRange(pos, pos); } //IE<9 else if (document.body.createTextRange) { var range = document.body.createTextRange(); range.moveToElementText(target); range.moveStart('character', pos); range.collapse(true); range.select(); } if (!isContentEditable) target.focus(); return pos; }; })(jQuery); /*! js-cookie v2.1.4 | MIT */ !function(a){var b=!1;if("function"==typeof define&&define.amd&&(define(a),b=!0),"object"==typeof exports&&(module.exports=a(),b=!0),!b){var c=window.Cookies,d=window.Cookies=a();d.noConflict=function(){return window.Cookies=c,d}}}(function(){function a(){for(var a=0,b={};a<arguments.length;a++){var c=arguments[a];for(var d in c)b[d]=c[d]}return b}function b(c){function d(b,e,f){var g;if("undefined"!=typeof document){if(arguments.length>1){if(f=a({path:"/"},d.defaults,f),"number"==typeof f.expires){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*f.expires),f.expires=h}f.expires=f.expires?f.expires.toUTCString():"";try{g=JSON.stringify(e),/^[\{\[]/.test(g)&&(e=g)}catch(p){}e=c.write?c.write(e,b):encodeURIComponent(e+"").replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),b=encodeURIComponent(b+""),b=b.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),b=b.replace(/[\(\)]/g,escape);var i="";for(var j in f)f[j]&&(i+="; "+j,!0!==f[j]&&(i+="="+f[j]));return document.cookie=b+"="+e+i}b||(g={});for(var k=document.cookie?document.cookie.split("; "):[],l=0;l<k.length;l++){var m=k[l].split("="),n=m.slice(1).join("=");'"'===n.charAt(0)&&(n=n.slice(1,-1));try{var o=m[0].replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent);if(n=c.read?c.read(n,o):c(n,o)||n.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent),this.json)try{n=JSON.parse(n)}catch(p){}if(b===o){g=n;break}b||(g[o]=n)}catch(p){}}return g}}return d.set=d,d.get=function(a){return d.call(d,a)},d.getJSON=function(){return d.apply({json:!0},[].slice.call(arguments))},d.defaults={},d.remove=function(b,c){d(b,"",a(c,{expires:-1}))},d.withConverter=b,d}return b(function(){})}); /** * Registers the handles on the side */ (function($){ $.fn.calculationForm = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var form = $(this); form.find('label.input-prefix.from,label.input-suffix.from').each(function(){ var me = $(this); $('select#calculation_' + me.attr('data-from')).change(function(){ me.text($(this).find('> :selected').text()); }); }); form.find('fieldset.calculation > div.visible-switch').each(function(){ var me = $(this); var sources = $('[name="calculation[' + $(this).attr('data-variable') + ']"]'); var value = $(this).attr('data-value'); sources.each(function(){ var source = $(this); if(source.attr('type')=='radio'){ source.change(function(){ sources.each(function(){ if($(this).val()==value){ me[$(this).prop('checked') ? 'removeClass' : 'addClass']('hidden').trigger('visible-switch'); } }); }); }else if(source.attr('type')=='checkbox'){ if(source.val()==value){ source.change(function(){ me[source.prop('checked') ? 'removeClass' : 'addClass']('hidden').trigger('visible-switch'); }); } }else{ source.change(function(){ me[source.val()==value ? 'removeClass' : 'addClass']('hidden').trigger('visible-switch'); }); } }); sources.closest('div[data-variable]').on('visible-switch', function(){ if($(this).hasClass('hidden')){ me.addClass('hidden').trigger('visible-switch'); }else{ sources.change(); } }); }); form.find('fieldset.calculation > div.visible-switch.hidden').trigger('visible-switch'); form.find('fieldset.calculation > div[data-formula]').each(function(){ var me = $(this); var fields = me.attr('data-formula').split(','); for(var i=0; i<fields.length; i++){ (function(input){ var value = input.val(); var busy = false; var queue = false; var __get = function(){ queue = false; var values = $('#calculation form').serializeForm(); values.field = me.attr('data-name'); values.fields = me.attr('data-formula'); json.post('/ajax/calculations/field', values, function(data){ busy = false; if(queue){ __get(); }else{ if(data.success=='OK'){ me.find('input').val(data.value); } } }, function(ex, response){ busy = false; }); }; var _evt = function(evt){ if(value==input.val()) return; value = input.val(); if(busy){ queue = true; }else{ __get(); } }; input.change(_evt).keyup(_evt); })(form.find('fieldset.calculation [name="calculation[' + fields[i] + ']"]')); } }); form.find('fieldset.calculation > div > div.field[data-type="number"] > span.input > input[type="text"]').keyup(function(){ var value = $(this).val(); if(value.match(/\d+/g)){ var caret = $(this).caret(); var _cs = value.substr(0, caret); if(_cs.match(/\d|,/g)){ caret = _cs.match(/\d|,/g).join('').length; }else{ caret = 0; } value = value.match(/\d|,/g).join(''); var parts = value.match(/(\d+)(,(\d+,?)*)?/); var number = ''; for(var i=0; i<parts[1].length; i++){ var index = parts[1].length - i - 1; if(i > 2 && (i%3)==0){ number = parts[1].charAt(index) + '.' + number; }else{ number = parts[1].charAt(index) + number; } } if(parts[2]){ number+= ','; if(parts[3]) number+= parts[3].match(/\d/g).join(''); } if(caret <= parts[1].length){ if((parts[1].length%3)!=0){ caret += Math.floor(((3-(parts[1].length%3)) + caret) / 3); }else{ caret += Math.floor(caret / 3); } }else{ caret += Math.floor(parts[1].length / 3); } if($(this).val()!=number){ $(this).val(number); $(this).caret(caret); } } $(this).parent().find('input[type="number"]').val(value.replace('.', '').replace(',', '.')); }).keyup(); form.find('fieldset.calculation > div > div.field[data-type="number"] > span.input > input[type="number"]').keyup(function(){ $(this).parent().find('input[type="text"]').val($(this).val().replace('.', ',')); }).change(function(){ $(this).parent().find('input[type="text"]').val($(this).val().replace('.', ',')); }).blur(function(){ $(this).parent().find('input[type="text"]').val($(this).val().replace('.', ',')); }); form.find('fieldset.calculation > div > div.field[data-type="date"] > span.input > input[type="text"]').each(function(){ var me = $(this); me.after('<input type="text">'); var max = new Date(); var years = 140; if(me.attr('data-max')){ max = new Date(me.attr('data-max')); }else{ max.setFullYear(max.getFullYear() + 30); } if(me.attr('data-min')){ var min = new Date(me.attr('data-min')); years = max.getFullYear() - min.getFullYear(); } var update = true; var calender = me.parent().find('>input+input'); calender.pickadate({ monthsFull: [ 'januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december' ], monthsShort: [ 'jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec' ], weekdaysFull: [ 'zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag' ], weekdaysShort: [ 'zo', 'ma', 'di', 'wo', 'do', 'vr', 'za' ], today: 'vandaag', clear: 'verwijderen', close: 'sluiten', firstDay: 1, format: 'dd-mm-yyyy', formatSubmit: 'dd-mm-yyyy', selectYears: years, selectMonths: true, max: max, onSet: function(context) { if(update) me.val(calender.val()); } }); var picker = calender.pickadate('picker') me.keyup(function(){ var matches = me.val().match(/^\s*(\d{1,2})(?:(\D*)(?:(\d{1,2})(?:(\D*)(\d{1,4})?)?)?)?/); if(matches){ if(typeof(matches[3])!='undefined') matches[2] = '-'; if(typeof(matches[5])!='undefined') matches[4] = '-'; var output = matches.slice(1).join(''); console.log(matches, output); if(me.val()!=output){ me.val(output); } } if(me.val().match(/^\d{1,2}-\d{1,2}-\d{4}$/)){ update = false; picker.set('select', me.val(), { format: 'dd-mm-yyyy' }); update = true; } }); }); var __submit = function(){ var values = form.serializeForm(); values.embed = $('#calculation').attr('data-embed')=='true' ? 'true' : 'false'; var title = $('h1').text(); json.post('/ajax/calculations/calculation', values, function(data){ $('#calculation form .error').removeClass('error'); if(data.success=='OK'){ if($('#calculation').attr('data-embed')!='true'){ window.location = data.url; }else{ if(typeof(_gaq)!='undefined') _gaq.push(['_trackEvent', 'berekening', title]); $('#calculation').html(data.view); window.location.hash = data.code; $('.social-share').share(); $('.stars.input').rating(); $('html,body').animate({scrollTop: $('#calculation').offset().top}, 'slow'); askQuestion(); } }else if(data.error=='Invalid'){ $('#calculation form').traverse(data.errors, function(item, value){ item.parent().find('[type="number"]').addClass('error').attr('title', value); item.addClass('error').attr('title', value); }, 'calculation'); } }, function(ex, response){ alert(response); }); }; $('fieldset.calculation > div > div.field > input[type="submit"]').click(function(evt){ evt.preventDefault(); __submit(); }); $('fieldset.calculation > div > div.field > input[type="submit"]').attr('disabled', false); form.submit(function(evt){ evt.preventDefault(); __submit(); }); form.find('fieldset.calculation div.help > span').click(function(){ if($(this).parent().hasClass('open')){ $(this).parent().removeClass('open'); $(this).parent().find('> div').height(0); }else{ var parent = $(this).parent(); parent.addClass('open'); var height = parent.find('> div > div').height(); height+= parseInt(parent.find('> div > div').css('margin-top').match(/(\d+)px/)[1]); height+= parseInt(parent.find('> div > div').css('margin-bottom').match(/(\d+)px/)[1]); height+= parseInt(parent.find('> div > div').css('padding-top').match(/(\d+)px/)[1]); height+= parseInt(parent.find('> div > div').css('padding-bottom').match(/(\d+)px/)[1]); parent.find('> div').height(height); } }); if(typeof(SelectFancy)!='undefined'){ SelectFancy(); }else{ $('select.select-fancy').each(function(){ $(this).removeClass('select-fancy'); $(this).parent().selectFancy(); }); } // END }); }; })(jQuery); $(window).scroll(function () { var top = $(window).scrollTop(); if($('aside .banner-desktop.static').hasClass('floating')){ if(top < 655) $('aside .banner-desktop.static').removeClass('floating'); }else{ if(top > 655) $('aside .banner-desktop.static').addClass('floating'); } }); function askQuestion(){ $('.ask-question').dialog({ content: function(source, dialog){ dialog.addClass('clean'); dialog.setCloseText('Sluit dit venster'); json.get('/ajax/calculations/question', function(data){ dialog.setContent(data.view); dialog.find('input[type="submit"]').click(function(){ var params = dialog.find('.question-form').serializeForm(); params.calculation_id = source.attr('data-id'); json.post('/ajax/calculations/question', params, function(data){ if(data.success=='OK'){ dialog.setContent(data.view); }else{ dialog.find('.question-form .error').each(function(){ $(this).removeClass('error').attr('title', ''); }); dialog.find('.question-form').traverse(data.errors, function(element, item){ element.addClass('error').attr('title', item); }); } }, function(ex, response){ dialog.setContent('Er is een fout opgetreden'); dialog.show(); }); }); dialog.show(); }, function(ex, response){ dialog.setContent('Er is een fout opgetreden'); dialog.show(); }); } }); } (function($){ $.fn.flipCounter = function(settings){ var config = { }; if(settings) $.extend(config, settings); var objects = []; this.each(function(){ var item = $(document.createElement('span')); var html = ''; html+= '<span class="current"><span>' + $(this).text() + '</span></span>'; html+= '<span ><span>' + $(this).text() + '</span></span>'; html+= '<span class="next"><span></span></span>'; html+= '<span ><span></span></span>'; item.html(html); $(this).replaceWith(item); objects.push({ flipUp: function(fast){ item[fast ? 'addClass': 'removeClass']('fast'); var value = parseInt(item.find('> .current > span').text()); var next = (value + 1) % 10; item.find('> .next > span').text(next); item.find('> .next + span > span').text(next); item.addClass('flip'); setTimeout(function(){ item.find('> .current > span').text(next); item.find('> .current + span > span').text(next); item.removeClass('flip'); }, fast ? 20 : 550); return next==0; }, flipTo: function(value, fast){ item[fast ? 'addClass': 'removeClass']('fast'); item.find('> .next > span').text(value); item.find('> .next + span > span').text(value); item.addClass('flip'); setTimeout(function(){ item.find('> .current > span').text(value); item.find('> .current + span > span').text(value); item.removeClass('flip'); }, fast ? 180 : 550); } }); }); return objects; }; })(jQuery); /** * Registers the handles on the side */ (function($){ $.fn.share = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); var info = {}; info.url = window.location; info.title = $($('h1')[0]).text(); info.description = ''; me.find('.facebook').click(function(evt){ evt.preventDefault(); var address = 'http://www.facebook.com/share.php?u=' + escape(info.url); window.open(address,'facebook-popup', 'width=700,height=500,scrollbars=no,toolbar=no,location=no'); }); me.find('.twitter').click(function(evt){ evt.preventDefault(); var address = 'http://twitter.com/share?url=' + escape(info.url) + '&text=' + escape(info.title); window.open(address,'twitter-popup', 'width=650,height=400,scrollbars=yes,toolbar=no,location=no'); }); me.find('.linkedin').click(function(evt){ evt.preventDefault(); var address = 'http://www.linkedin.com/shareArticle?mini=true&url=' + escape(info.url) + '&title=' + escape(info.title) + '&summary=' + escape(info.description); window.open(address,'linkedin-popup', 'width=520,height=570,scrollbars=yes,toolbar=no,location=no'); }); me.find('.googleplus').click(function(evt){ evt.preventDefault(); var address = 'mailto:?SUBJECT=' + escape(info.title) + '&BODY=' + escape(info.url); window.location.href = address; }); }); }; })(jQuery); /** * Registers the handles on the side */ (function($){ $.fn.rating = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); if(!me.data('installed')){ me.data('installed', true); me.find('> span > span').click(function(evt){ var index = me.find('> span > span').index(this); var base = (5 - Math.floor(index / 2)) * 2; var value = base - ($(this).index() ? 0 : 1); me.find('> span.on,> span.on.half').removeClass('on').removeClass('half'); $(this).parent().addClass($(this).index() ? 'on' : 'on half'); $.post('/ajax/calculations/rating', {action: 'vote', id: me.attr('data-id'), value:value}, function(response){ json(response, function(data){ me.parent().find('[itemprop="ratingValue"]').html(data.value); me.parent().find('[itemprop="reviewCount"]').html(data.total); if(typeof(data.html)!='undefined'){ $.dialog({ content: function(source, dialog){ dialog.setContent(data.html); dialog.setWidth(500); dialog.find('[type="submit"]').click(function(){ $.post('/ajax/calculations/rating', {action: 'message', id: me.attr('data-id'), value:value, email: dialog.find('[name="email"]').val(), reden:dialog.find('[name="reden"]').val()}, function(response){ json(response, function(data){ if(data.success=='OK'){ me.parent().find('[itemprop="ratingValue"]').html(data.value); me.parent().find('[itemprop="reviewCount"]').html(data.total); dialog.close(); }else{ dialog.find('.error').removeClass('error').attr('title', ''); dialog.find('fieldset').traverse(data.errors, function(item, value){ item.addClass('error').attr('title', value); }); } }, function(ex){ }); }, 'text'); }) dialog.show(); } }); }else if(typeof(data.tip)!='undefined'){ showtip(evt.pageX, evt.pageY, data.tip); }else{ showtip(evt.pageX, evt.pageY, 'Bedankt voor je beoordeling'); } }, function(ex){ }); }, 'text'); }); } }); }; })(jQuery); (function($){ $.fn.ratingafstand = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); if(!me.data('installed')){ me.data('installed', true); me.find('> span > span').click(function(evt){ var index = me.find('> span > span').index(this); var base = (5 - Math.floor(index / 2)) * 2; var value = base - ($(this).index() ? 0 : 1); me.find('> span.on,> span.on.half').removeClass('on').removeClass('half'); $(this).parent().addClass($(this).index() ? 'on' : 'on half'); $.post('/ajax/afstand/rating', {action: 'vote', id: me.attr('data-id'), value:value}, function(response){ json(response, function(data){ me.parent().find('[itemprop="ratingValue"]').html(data.value); me.parent().find('[itemprop="reviewCount"]').html(data.total); if(typeof(data.html)!='undefined'){ $.dialog({ content: function(source, dialog){ dialog.setContent(data.html); dialog.setWidth(500); dialog.find('[type="submit"]').click(function(){ $.post('/ajax/afstand/rating', {action: 'message', id: me.attr('data-id'), value:value, email: dialog.find('[name="email"]').val(), reden:dialog.find('[name="reden"]').val()}, function(response){ json(response, function(data){ if(data.success=='OK'){ me.parent().find('[itemprop="ratingValue"]').html(data.value); me.parent().find('[itemprop="reviewCount"]').html(data.total); dialog.close(); }else{ dialog.find('.error').removeClass('error').attr('title', ''); dialog.find('fieldset').traverse(data.errors, function(item, value){ item.addClass('error').attr('title', value); }); } }, function(ex){ }); }, 'text'); }) dialog.show(); } }); }else if(typeof(data.tip)!='undefined'){ showtip(evt.pageX, evt.pageY, data.tip); }else{ showtip(evt.pageX, evt.pageY, 'Bedankt voor je beoordeling'); } }, function(ex){ }); }, 'text'); }); } }); }; })(jQuery); /** * Registers the handles on the side */ (function($){ $.fn.addToHome = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); me.addClass('add-to-home'); me.html('<div><div>Om deze webapp op je telefoon te installeren, klik op <span></span> en dan <strong>Toevoegen aan startscherm</strong>.</div><a href="javascript:void(0)">X</a></div>'); me.find('> div > a').click(function(evt){ evt.preventDefault(); me.remove(); $.post('/', {action: 'add-to-home'}); }); }); }; $.addToHome = function(){ var item = $(document.createElement('div')); $(document.body).append(item); item.addToHome(); }; })(jQuery); function showtip(left, top, contents){ var tip = $(document.createElement('div')); tip.addClass('tip'); tip.html('<div></di>'); tip.find('>div').html(contents); tip.css({left:left, top:top}); $(document.body).append(tip); tip.fadeIn(200).delay(1000).fadeOut(500, function(){ $(this).remove(); }); } (function($){ $.fn.enlargeImage = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); if(me.hasClass('enlarge')) return; me.addClass('enlarge'); me.click(function(){ var image = new Image(); image.onload = function(){ if((me.width() / image.width) < 0.7 || (me.height() / image.height) < 0.7){ var viewer = $('<div class="image-viewer"><div><div><div><img src=""></div></div></div><span></span></div>'); viewer.find('img').attr('src', me.attr('src')); viewer.find('span').click(function(){ viewer.remove(); $('body').css('overflow', 'auto'); }); $('body').append(viewer); $('body').css('overflow', 'hidden'); } } image.src = me.attr('src'); }); }); }; })(jQuery); (function($){ $.fn.lazy = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var me = $(this); if(me.hasClass('lazy')) return; me.addClass('lazy'); var __load = function(){ var view = { top: $(window).scrollTop(), bottom: $(window).scrollTop() + $(window).height() }; if((me.offset().top + me.height()) > view.top && me.offset().top < view.bottom){ me.addClass('loading'); me.on(function(){ me.removeClass('loading').removeClass('error').addClass('loaded'); }).on(function(){ me.addClass('error'); setTimeout(function(){ me.removeClass('loading'); }, 1000); }); if(me.attr('data-src')){ me.attr('src', me.attr('data-src')); }else if(me.attr('data-background-image')){ me.css('background-image', 'url(\'' + me.attr('data-background-image') + '\')'); } } }; $(window).scroll(function(){ __load(); }); __load(); }); }; })(jQuery); $(document).ready(function() { $('img[data-src],div[data-background-image]').lazy(); $('img').enlargeImage(); var stickyTopStart, stickyParentHeight; var elem = $('nav.most-searched'); if (elem.length > 0) { stickyTopStart = elem.offset().top; $(window).scroll(function() { var elem = $('nav.most-searched'); var stickyTop = elem.offset().top; var windowTop = $(window).scrollTop(); if (stickyTop < windowTop + 30 || stickyTop > stickyTopStart) { elem.stop().animate( {'top': Math.min(Math.max(0, windowTop + 30 - stickyTopStart), stickyParentHeight)} ); } }); } var elem = $('nav.most-searched'); if (elem.length > 0) { var marginTop = elem.css('top'); elem.css('top', 0); stickyParentHeight = elem.parent().height() - stickyTopStart + elem.parent().offset().top - elem.height(); elem.css('top', marginTop); } $('table').after('<div class="swipe"></div>'); }); $(document).ready(function(){ var lastUrl = null; window.onhashchange = function(){ var currentUrl = window.location.toString(); if(lastUrl==null){ lastUrl = currentUrl; }else{ if(currentUrl.indexOf('#')<0 && lastUrl.indexOf('#')>=0){ window.location.reload(); } } }; $('.social-share').share(); $('#calculation form').each(function(){ if(window.location.hash.length > 0){ json.get('/ajax/calculations/result?code=' + window.location.hash.substr(1), function(data){ if(data.success=='OK'){ $('#calculation').html(data.view); $('.social-share').share(); $('.stars.input').rating(); askQuestion(); $('img').enlargeImage(); /*var pymt = document.createElement("script"); pymt.type = "text/javascript";pymt.src = "//wwa.pacific-yield.com/yield/yieldtag.php?pi=319&psi=698&cr=1447341782&cb=" + Math.random(); pymt.setAttribute("async", "true"); document.body.appendChild(pymt);*/ } }, function(ex, response){ alert(response); }); } $(this).calculationForm(); }); $('#source_id').change(function(){ var values = $('#calculation form').serializeForm(); json.get('/ajax/calculations/form/' + $(this).val() + '/' + $(this).attr('data-id'), function(data){ if(data.success=='OK'){ $('#calculation div.fields').html(data.html); $('#calculation form').calculationForm(); $('#calculation form').traverse(values, function(element, item){ if(element.attr('name').match(/^calculation\[/)){ element.val(item).change().keyup(); } }); } }, function(ex, response){ alert(response); }); }); if($('fieldset.iframe.open input[type="submit"]').length > 0 && $('fieldset.iframe input[name="newwindow"]').val() > 0){ window.location = $('fieldset.iframe input[name="url"]').val(); }else{ $('fieldset.iframe.open input[type="submit"]').dialog({ content: function(source, dialog){ var title = $('h1').text(); if(typeof(_gaq)!='undefined') _gaq.push(['_trackEvent', 'berekening', title]); var fieldset = source.parent(); var url = $('fieldset.iframe input[name="url"]').val(); var code = $('fieldset.iframe input[name="code"]').val(); var width = $('fieldset.iframe input[name="width"]').val(); var height = $('fieldset.iframe input[name="height"]').val(); var bron = $('fieldset.iframe input[name="bron"]').val(); var mobiel = $('fieldset.iframe input[name="mobiel"]').val(); if(url){ dialog.setContent('<iframe src="#" style="height: 400px; width: 100%; border: 0px;" scrolling="yes"></iframe><div class="source">Bron: <span>BRON</span></div>'); dialog.find('>iframe').attr('src', url); dialog.find('>iframe').height(height ? height : 500); }else{ //dialog.setContent(code + '<div class="source">Bron: <span>BRON</span></div>'); var src = $('fieldset.iframe').attr('data-url'); if(src.indexOf('#')>0) src = src.substr(0, src.indexOf('#')); if(src.indexOf('?')>0) src = src.substr(0, src.indexOf('?')); dialog.setContent('<iframe src="#" style="height: 400px; width: 100%; border: 0px;" scrolling="yes"></iframe><div class="source">Bron: <span>BRON</span></div>'); dialog.find('>iframe').attr('src', src + '/embed'); dialog.find('>iframe').height(height ? height : 500); } if(width) dialog.setWidth(width); dialog.find('>div>span').text(bron); dialog.show(); } }).click(); } $('fieldset.iframe:not(.open) input[type="submit"]').click(function(evt){ if($('fieldset.iframe input[name="newwindow"]').val() > 0){ window.open($(this).attr('data-url')); }else { window.location = $(this).attr('data-url'); } }); if(typeof(SelectFancy)!='undefined'){ SelectFancy(); }else{ $('select.select-fancy').each(function(){ $(this).removeClass('select-fancy'); $(this).parent().selectFancy(); }); } askQuestion(); $('input#searchbar').smartSearch({ search: function(search, instance){ var url = '/ajax/calculations/search?q=' + escape(search); json.get(url, function(data){ instance.setItems(data.items); }, function(ex, response){ alert(ex + ', ' + response); }); }, left: 0, top: function(){ return ($('body.home fieldset').length > 0 ? $('body.home fieldset') : $('form#search')).height(); }, width: function(){ return ($('body.home fieldset').length > 0 ? $('body.home fieldset') : $('form#search')).width(); }, onconfirm: function(){ return false; }, onclick: function(source){ return false; source.parent('form').submit(); } }); $('a[href*=\\#]').on("click",function(e){ if(this.hash.match(/\^#[a-z0-9-_]$/i)){ var t = $(this.hash); var t = t.length && t || $('[name=' + this.hash.slice(1) + ']'); if (t.length) { var tOffset = t.offset().top; $('html,body').animate({scrollTop: tOffset - 20}, 'slow'); e.preventDefault(); } } }); if(window.location.hash){ if(window.location.hash.match(/\^#[a-z0-9-_]$/i)){ var t = $(window.location.hash); var t = t.length && t || $('[name=' + window.location.hash.substr(1) + ']'); if (t.length) { var tOffset = t.offset().top; $('html,body').animate({scrollTop: tOffset - 20}, 'slow'); } } } $('section.page .most-searched ol li a').each(function(){ var size = 100; while($(this).parent().height() > 50) { $(this).css('font-size', (--size) + '%'); } }); $('section.page .most-searched').each(function(){ var me = $(this); me.find('> h2').click(function(){ me[!me.hasClass('open') ? 'addClass' : 'removeClass']('open'); }); }); $('.desktop-button > a').click(function(evt){ evt.preventDefault(); $('html').addClass('desktop'); $.post('/', {action: 'desktop'}); }); $('#reaction-form input[type="submit"]').click(function(){ var params = $('#reaction-form .question-form').serializeForm(); params.parent_id = $('#reaction-form').attr('data-id'); json.post('/ajax/calculations/reaction', params, function(data){ if(data.success=='OK'){ $('#reaction-form').html(data.view); $('#reactions').append(data.update); if(typeof(data.reactionCount)!='undefined'){ if(data.reactionCount>1){ $('#reactions-count .notice').text('Er zijn ' + data.reactionCount + ' antwoorden gegeven'); }else if(data.reactionCount==1){ $('#reactions-count .notice').text('Er is 1 antwoord gegeven'); }else{ $('#reactions-count .notice').text('Er is nog niet gereageerd op deze vraag. Reageer jij?'); } } }else{ $('#reaction-form .question-form .error').each(function(){ $(this).removeClass('error').attr('title', ''); }); $('#reaction-form .question-form').traverse(data.errors, function(element, item){ element.addClass('error').attr('title', item); }); } }, function(ex, response){ }); }); $('.rating.normal .stars.input').rating(); $('#afstand .rating.afstand .stars.input').ratingafstand(); $('nav.questions').each(function(){ var me = $(this); me.find('> ul > li.loadmore').click(function(){ var more = $(this); var params = { calculation_id: me.attr('data-id'), offset: me.find('> ul > li:not(.loadmore)').length }; $.get('/ajax/calculations/questions', params, function(response){ json(response, function(data){ more.before(data.view); more.find('>a>span').text(data.remain); if(data.remain <= 0) more.hide(); }, function(ex){ }); }, 'text'); }); }); if($('body').attr('data-tracking')){ setTimeout(function(){ $.post('/ajax/advert/callback', {data: $('body').attr('data-tracking')}); }, 100); } $('[data-track]').click(function(){ $.post('/ajax/advert/track', {data: $(this).attr('data-track')}); }); $('a[data-href]').click(function(){ window.open($(this).attr('data-href')); }); }); $(document).ready(function(){ return; var initial = $('body.home .intro .counter').text(); var counter = $('.counter > em').flipCounter(); setTimeout(function(){ $('body.home .intro h1 > span').text('Op naar'); var current = initial; var interval = setInterval(function(){ current++; if(counter[2].flipUp(true)){ if(counter[1].flipUp()){ counter[0].flipUp(); } } if(current==500){ clearInterval(interval); setTimeout(function(){ $('body.home .intro h1 > span').text('Zoek in'); counter[2].flipTo(initial.charAt(2)); counter[1].flipTo(initial.charAt(1)); counter[0].flipTo(initial.charAt(0)); }, 2000); } }, 80); }, 5000); }); function updateTool(){ var styles = []; $('.input-prefix.color').each(function(){ var input = $(this).parent().find('input'); if(input.val().length > 0){ styles.push(input.attr('name') + '=' + escape(input.val())); } }); $('#font-family').each(function(){ var input = $(this); if(input.val().length > 0){ styles.push(input.attr('name') + '=' + escape(input.val())); } }); window.location.hash = $('#url').val(); styles.push('url=' + escape($('#url').val())); var url = 'https://www.berekenen.nl/tools/embed?' + styles.join('&'); $('#preview').attr('src', url); } $(document).ready(function(){ $('.input-prefix.color').each(function(){ var me = $(this); me.ColorPicker({ color: me.val(), onShow: function (colpkr) { $(colpkr).fadeIn(500); return false; }, onHide: function (colpkr) { $(colpkr).fadeOut(500); return false; }, onChange: function (hsb, hex, rgb) { me.find('span').css('backgroundColor', '#' + hex); me.find('span').removeClass('nocolor'); me.parent().find('input').val(hex); updateTool(); } }); me.parent().find('input').keyup(function(){ me.ColorPickerSetColor($(this).val()); me.find('span').css('backgroundColor', '#' + $(this).val()); updateTool(); }); }); $('#font-family,#url').change(function(){ updateTool(); }); $('#generate-code,#generate-code2').click(function(){ var styles = []; $('.input-prefix.color').each(function(){ var input = $(this).parent().find('input'); if(input.val().length > 0){ styles.push(input.attr('name') + ':' + input.val()); } }); $('#font-family').each(function(){ var input = $(this); if(input.val().length > 0){ styles.push(input.attr('name') + ':' + input.val()); } }); var html = ''; html+= '<div' + (styles.length ? ' data-style="' + styles.join(';')+ '"' : '') + '>© <a href="https://www.berekenen.nl/' + $('#url').val() + '">berekenen.nl</a></div>\n'; html+= '<script src="https://www.berekenen.nl/tools.js"></script>'; $('#embed-code').val(html).fadeIn(500); $('html,body').animate({scrollTop: $('#embed-code').offset().top}, 'slow'); }); if($('select#url').length && window.location.hash){ var value = null; $('select#url option').each(function(){ if($(this).attr('data-url') == window.location.hash.substr(1)){ value = $(this).attr('value'); } }); $('select#url').val(value).change(); }else if($('select#url').length){ $('select#url').change(); } }); $(document).ready(function(){ $('#valuta-tabs a').click(function(evt){ evt.preventDefault(); $('.valuta-list').css('display', 'none'); $($(this).attr('href')).css('display', 'block'); }); $('aside .banner-desktop:not(.static)').each(function(){ var me = $(this); var top = me.offset().top; $(window).scroll(function(){ if($(window).scrollTop() > (top + 10)){ me.css({top: 10, position: 'fixed'}); }else if($(window).scrollTop() < (top + 10)){ me.css({position: 'static'}); } }); }); $('body').click(function(e) { Cookies.set('cookies_allowed', true); $('.cookie_place_reserve').hide(); $('#cookie_notice_mobile').hide(); $('#cookie_notice_desktop').hide(); }); window.onscroll = function (e) { Cookies.set('cookies_allowed', true); $('.cookie_place_reserve').hide(); $('#cookie_notice_mobile').hide(); $('#cookie_notice_desktop').hide(); } $('body').bind('touchmove', function(e) { Cookies.set('cookies_allowed', true); $('.cookie_place_reserve').hide(); $('#cookie_notice_mobile').hide(); $('#cookie_notice_desktop').hide(); }); }); (function($) { $.fn.mobileMenu = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var source = $(this); var menu = null; source.click(function(){ if(menu==null){ menu = $(this).clone(); menu.addClass('pop-up'); var form = $(document.createElement('form')); form.attr({action: '/zoeken'}); form.html('<label><span><input type="text" name="q"></span><em></em></label>'); menu.find('> ul').before(form); var close = $(document.createElement('span')); close.click(function(){ menu.removeClass('open'); }); menu.append(close); $(document.body).append(menu); form.find('input').keydown(function(evt){ var value = $(this).val(); if(value.length > 1){ var url = '/ajax/calculations/search?q=' + escape(value); json.get(url, function(data){ menu.find('> ul > li').remove(); for(var i=0; i<data.items.length; i++){ var item = data.items[i]; var li = $(document.createElement('li')); li.html('<a></a>'); li.find('> a').text(item.text); if(typeof(item.url)!='undefined'){ li.find('> a').attr('href', item.url); }else if(typeof(item.value)!='undefined'){ li.find('> a').attr('href', '/zoeken?q=' + escape(item.value)); }else{ li.find('> a').attr('href', '/zoeken?q=' + escape(item.text)); } menu.find('> ul').append(li); } }, function(ex, response){ alert(ex + ', ' + response); }); }else{ menu.find('> ul > li').remove(); menu.find('> ul').append(source.find('> ul > li').clone()); } }); } setTimeout(function(){ if(menu.hasClass('open')){ menu.removeClass('open'); }else{ menu.addClass('open'); } }, 10); }); }); return this; }; })(jQuery); (function($) { $.fn.mobileSearch = function(settings){ var config = {}; if(settings) $.extend(config, settings); this.each(function(){ var source = $(this); var menu = null; source.click(function(){ if(menu==null){ menu = $(document.createElement('nav')); menu.addClass('pop-up'); menu.addClass('no-full'); menu.addClass('right'); menu.html('<ul></ul>'); var form = $(document.createElement('form')); form.attr({action: '/zoeken'}); form.html('<label><span><input type="text" name="q" placeholder="Zoek je berekening"></span><em></em></label>'); menu.find('> ul').before(form); $(document.body).append(menu); form.find('input').keydown(function(evt){ var value = $(this).val(); if(value.length > 1){ var url = '/ajax/calculations/search?q=' + escape(value); json.get(url, function(data){ menu.find('> ul > li').remove(); for(var i=0; i<data.items.length; i++){ var item = data.items[i]; var li = $(document.createElement('li')); li.html('<a></a>'); li.find('> a').text(item.text); if(typeof(item.url)!='undefined'){ li.find('> a').attr('href', item.url); }else if(typeof(item.value)!='undefined'){ li.find('> a').attr('href', '/zoeken?q=' + escape(item.value)); }else{ li.find('> a').attr('href', '/zoeken?q=' + escape(item.text)); } menu.find('> ul').append(li); } }, function(ex, response){ alert(ex + ', ' + response); }); }else{ menu.find('> ul > li').remove(); menu.find('> ul').append(source.find('> ul > li').clone()); } }); } setTimeout(function(){ if(menu.hasClass('open')){ menu.removeClass('open'); }else{ menu.addClass('open'); } }, 10); }); }); return this; }; })(jQuery); $(document).ready(function(){ $('header nav').mobileMenu(); $('header > div > span').mobileSearch(); }); function autocomplete() { if(document.getElementById('SearchPlaatsVan')){ var placesAutocomplete = places({ appId: 'plL3WG5LBQDA', apiKey: 'af14e24e27727286e2d95292e6fb3193', container: document.querySelector('#SearchPlaatsVan') }); var $address = document.querySelector('#SearchPlaatsVan') placesAutocomplete.on('change', function(e) { $address.textContent = e.suggestion.value }); placesAutocomplete.on('clear', function() { $address.textContent = 'none'; }); var placesAutocomplete = places({ appId: 'plL3WG5LBQDA', apiKey: 'af14e24e27727286e2d95292e6fb3193', container: document.querySelector('#SearchPlaatsNaar') }); var $address = document.querySelector('#SearchPlaatsNaar') placesAutocomplete.on('change', function(e) { $address.textContent = e.suggestion.value }); placesAutocomplete.on('clear', function() { $address.textContent = 'none'; }); // var input = document.getElementById('SearchPlaatsVan'); // var autocomplete = new google.maps.places.Autocomplete(input); // var input2 = document.getElementById('SearchPlaatsNaar'); // var autocomplete2 = new google.maps.places.Autocomplete(input2); } } function getResult(){ var item = new Array(); hash= window.location.hash.substring(1); //verkrijg de hash zonder # action = 'getresult'; var url = window.location.origin + '/a-z/afstand'; $.post(url, {hash: hash, action: action}, function(response){ //console.log(response); $('#afstand')[0].innerHTML = response; loadMap(); }); } function init(){ getResult(); } $(document).ready(function(){ if(window.location.hash.substring(1) && $('#afstand').length){ init(); }else{ if($('#afstand').length) autocomplete(); } }); $(window).on('hashchange', function (e) { if($('#map-canvas').length) init(); }); if (window.location.hash) { $(window).trigger('hashchange') } var time = 0; var distance = 0; var lineLenght; var start; var end; var mode; function getData(){ var data = $('#map'); mode = data.attr('data-mode'); start = new google.maps.LatLng(data.attr('data-vanlat'),data.attr('data-vanlong')) end = new google.maps.LatLng(data.attr('data-naarlat'),data.attr('data-naarlong')) } function seconds2time (seconds) { var hours = Math.floor(seconds / 3600); var minutes = Math.floor((seconds - (hours * 3600)) / 60); var seconds = seconds - (hours * 3600) - (minutes * 60); var timeIntern = ""; if (hours != 0) { timeIntern = hours+" uur "; } if (minutes != 0 || time !== "") { minutes = (minutes < 10 && timeIntern !== "") ? "0"+minutes : String(minutes); timeIntern += minutes +" minuten"; } if (timeIntern === "") { timeIntern = "Er is geen tijd bekend"; } else { } return timeIntern; } function roundKm(number){ var number = Math.round( number * 10 ) / 10; var number = number.toFixed(1); var number = parseFloat(number) return number; } var directionsDisplay; var directionsService; var bounds; var polyLengthInMeters; function initialize() { directionsDisplay = new google.maps.DirectionsRenderer(); directionsService = new google.maps.DirectionsService(); bounds = new google.maps.LatLngBounds(); bounds.extend(start); bounds.extend(end); mapOptions = { mapTypeId : 'roadmap' }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById('directions-panel')); var LineCoordinates = [start, end]; var Line = new google.maps.Polyline({ path : LineCoordinates, geodesic : true, strokeColor : '#FF0000', strokeOpacity : 1.0, strokeWeight : 2 }); Line.setMap(map); polyLengthInMeters = google.maps.geometry.spherical.computeLength(Line.getPath().getArray()); lineLenght = roundKm((polyLengthInMeters / 1000)); document.getElementById('line').innerHTML += lineLenght + ' km'; } function calcRoute() { var selectedMode = mode; var request = { origin : start, destination : end, travelMode : google.maps.TravelMode[selectedMode] }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { // Display the distance: distance = roundKm((response.routes[0].legs[0].distance.value / 1000)); document.getElementById('distance').innerHTML = distance + ' km'; time = seconds2time(response.routes[0].legs[0].duration.value); // Display the duration: document.getElementById('duration').innerHTML = time; replaceVariables(); directionsDisplay.setDirections(response); } }); } function loadMap(){ if($('#map-canvas').length){ getData(); initialize(); calcRoute(); } } function goPost(url, params){ if(url!=null && typeof(url)=='object') url = url.href; var form = $('<form method="post"></form>').appendTo(document.body); if(url!=null) form.attr('action', url); for(x in params){ form.append('<input type="hidden" name="' + x + '" value="' + params[x] + '"/>'); } form.submit(); return false; } $('.tab-item').on('click', function(){ if( !$(this).parent().hasClass('active') ){ var mode = $(this).data('mode'); var van = $( "div#van" ).text(); var naar = $( "div#naar" ).text(); var url = '/afstand'; var params = {van:van, naar:naar, mode:mode}; goPost(url, params); } }); function replaceVariables(){ $('p').each(function() { var text = $(this).text().replace('{afstandrecht}', lineLenght).replace('{afstandvervoer}', distance).replace('{tijd}', time); $(this).text(text); }); } $(document).ready(function() { setTimeout(loadMap, 150); });