<commit_before>// customize.js

$(document)
    .ready(function () {

        // fix menu when passed
        $('.masthead')
            .visibility({
                once: false,
                onBottomPassed: function () {
                    $('.fixed.menu').transition('fade in');
                },
                onBottomPassedReverse: function () {
                    $('.fixed.menu').transition('fade out');
                }
            });

        // create sidebar and attach to menu open
        $('.ui.sidebar')
            .sidebar('attach events', '.toc.item');

    });

// loading dimmer
$('.loading-trigger')
    .on('click', function () {
        $('#loading-dimmer')
            .dimmer('show');
    });

// feedback
$('.feedback')
    .on('click', function () {
        $('#contacts-dimmer')
            .dimmer('show');
    });

// masthead background
$('.ui.inverted.masthead.segment').addClass('bg' + Math.ceil(Math.random() * 14)).removeClass('zoomed');

// analytics
$.getJSON(urlPrefix + '/json/analytics.json', function (data) {
    $.getJSON(data.api.url, {
        'module': 'API',
        'method': 'VisitsSummary.getVisits',
        'idSite': '1',
        'period': 'day',
        'date': 'yesterday',
        'format': 'JSON',
        'token_auth': data.api.token
    }, function (data) {
        $('#yesterday-visits').text(data.value);
    });
    $.getJSON(data.api.url, {
        'module': 'API',
        'method': 'VisitsSummary.getActions',
        'idSite': '1',
        'period': 'day',
        'date': 'yesterday',
        'format': 'JSON',
        'token_auth': data.api.token
    }, function (data) {
        $('#yesterday-actions').text(data.value);
    });
});
function updateAnalytics() {
    $.getJSON(urlPrefix + '/json/analytics.json', function (data) {
        $.getJSON(data.api.url, {
            'module': 'API',
            'method': 'VisitsSummary.getVisits',
            'idSite': '1',
            'period': 'day',
            'date': 'today',
            'format': 'JSON',
            'token_auth': data.api.token
        }, function (data) {
            $('#today-visits').text(data.value);
        });
        $.getJSON(data.api.url, {
            'module': 'API',
            'method': 'VisitsSummary.getActions',
            'idSite': '1',
            'period': 'day',
            'date': 'today',
            'format': 'JSON',
            'token_auth': data.api.token
        }, function (data) {
            $('#today-actions').text(data.value);
        });
    });
};
updateAnalytics();
setInterval(function () {
    updateAnalytics();
}, 15000);<commit_msg>Update<commit_after>// customize.js

$(document).ready(function () {
    // fix menu when passed
    $('.masthead').visibility({
        once: false,
        onBottomPassed: function () {
            $('.fixed.menu').transition('fade in');
        },
        onBottomPassedReverse: function () {
            $('.fixed.menu').transition('fade out');
        }
    });
    // create sidebar and attach to menu open
    $('.ui.sidebar').sidebar('attach events', '.toc.item');
});

// loading dimmer
$('.loading-trigger').on('click', function () {
    $('#loading-dimmer').dimmer('show');
});

// feedback
$('.feedback').on('click', function () {
    $('#contacts-dimmer').dimmer('show');
});

// masthead background
$('.ui.inverted.masthead.segment').addClass('bg' + Math.ceil(Math.random() * 14)).removeClass('zoomed');

// analytics
$.getJSON(urlPrefix + '/json/analytics.json', function (data) {
    $.getJSON(data.api.url, {
        'module': 'API',
        'method': 'VisitsSummary.getVisits',
        'idSite': '1',
        'period': 'day',
        'date': 'yesterday',
        'format': 'JSON',
        'token_auth': data.api.token
    }, function (data) {
        $('#yesterday-visits').text(data.value);
    });
    $.getJSON(data.api.url, {
        'module': 'API',
        'method': 'VisitsSummary.getActions',
        'idSite': '1',
        'period': 'day',
        'date': 'yesterday',
        'format': 'JSON',
        'token_auth': data.api.token
    }, function (data) {
        $('#yesterday-actions').text(data.value);
    });
});
function updateAnalytics() {
    $.getJSON(urlPrefix + '/json/analytics.json', function (data) {
        $.getJSON(data.api.url, {
            'module': 'API',
            'method': 'VisitsSummary.getVisits',
            'idSite': '1',
            'period': 'day',
            'date': 'today',
            'format': 'JSON',
            'token_auth': data.api.token
        }, function (data) {
            $('#today-visits').text(data.value);
        });
        $.getJSON(data.api.url, {
            'module': 'API',
            'method': 'VisitsSummary.getActions',
            'idSite': '1',
            'period': 'day',
            'date': 'today',
            'format': 'JSON',
            'token_auth': data.api.token
        }, function (data) {
            $('#today-actions').text(data.value);
        });
    });
};
updateAnalytics();
setInterval(function () {
    updateAnalytics();
}, 15000);<|endoftext|>


<commit_before>$(document).ready(function(){
	$.get('./data', function(data){
		if (data){
			var string = "";
			var months = new Array("","JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
			var events = data.objects;
			for (var i=events.length-1;i>=0;i--) {
				var event = events[i];
				date = new Date(event.start);
				string+= "

<time datetime=\"";
				string+= new Date(event.start);
				string+= "\">";
				string+= ""+months[date.getMonth()]+"";
				string+= ""+date.getDate()+"";
				string+= ""+date.getFullYear()+"";
				string+= "</time>
";
				string+= "
"+event.name+"
";
				string+= "
"+event.description+"
";
				string+= "
";
			}
			//debugger
			$("#centfix").html(string);
		}
	})
});<commit_msg>Fixed bug where wrong month was shown for events<commit_after>$(document).ready(function(){
	$.get('./data', function(data){
		if (data){
			var string = "";
			var months = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
			var events = data.objects;
			for (var i=events.length-1;i>=0;i--) {
				var event = events[i];
				date = new Date(event.start);
				string+= "

<time datetime=\"";
				string+= new Date(event.start);
				string+= "\">";
				string+= ""+months[date.getMonth()]+"";
				string+= ""+date.getDate()+"";
				string+= ""+date.getFullYear()+"";
				string+= "</time>
";
				string+= "
"+event.name+"
";
				string+= "
"+event.description+"
";
				string+= "
";
			}
			//debugger
			$("#centfix").html(string);
		}
	})
});
<|endoftext|>


<commit_before>// jQuery(document).ready(function($) {
//
// 	$('a.smoothScroll').click(function(){
// 	    $('html, body').animate({
// 	        scrollTop: $( $.attr(this, 'href') ).offset().top
// 	    }, 500);
// 	    return false;
// 	});
// });
<commit_msg>Delete primecoin.js<commit_after><|endoftext|>


<commit_before>var images = [
  {      title:"abacus",      class:"flaticon-tool"    },
  {      title:"alien",      class:"flaticon2-ufo"    },
  {      title:"angry woman",      class:"flaticon3-angry-woman"    },
  {      title:"apple",      class:"flaticon-fruit"    },
  {      title:"arrow (bow)",      class:"flaticon-weapon"    },
  {      title:"arrow (direction)",      class:"flaticon2-right-arrow"    },
  {      title:"automobile",      class:"flaticon4-automobile"    },
  {      title:"bat",      class:"flaticon-animals-1"    },
  {      title:"batman",      class:"flaticon3-batman"    },
  {      title:"beetle",      class:"flaticon-animal"    },
  {      title:"bicycle",      class:"flaticon4-bicycle"    },
  {      title:"birthday cake",      class:"flaticon4-birthday-cake"    },
  {      title:"book",      class:"flaticon-book"    },
  {      title:"boy happy smile",      class:"flaticon3-boy-happy-smile"    },
  {      title:"boy smiling",      class:"flaticon3-boy-smiling"    },
  {      title:"boy suffering",      class:"flaticon3-boy-suffering"    },
  {      title:"bridge over stream",      class:"flaticon-road"    },
  {      title:"bumblebee",      class:"flaticon-animals"    },
  {      title:"burning home",      class:"flaticon4-burning-home"    },
  {      title:"bus",      class:"flaticon4-bus"    },
  {      title:"calculator",      class:"flaticon3-calculator"    },
  {      title:"cannon",      class:"flaticon4-cannon"    },
  {      title:"car",      class:"flaticon4-car"    },
  {      title:"castle tower",      class:"flaticon-summer"    },
  {      title:"circus elephant",      class:"flaticon4-circus-elephant"    },
  {      title:"circus seal",      class:"flaticon4-circus-seal"    },
  {      title:"clock",      class:"flaticon-clock"    },
  {      title:"cloudy",      class:"flaticon4-cloudy"    },
  {      title:"clown with hat",      class:"flaticon4-clown-with-hat"    },
  {      title:"cold",      class:"flaticon4-cold"    },
  {      title:"compas points",      class:"flaticon-compass"    },
  {      title:"cooking",      class:"flaticon4-cooking"    },
  {      title:"crane",      class:"flaticon4-crane"    },
  {      title:"cup",      class:"flaticon4-cup"    },
  {      title:"dark night",      class:"flaticon4-dark-night"    },
  {      title:"delighted granny",      class:"flaticon3-delighted-granny"    },
  {      title:"dice",      class:"flaticon-game"    },
  {      title:"donatello bo staff",      class:"flaticon3-donatello-bo-staff"    },
  {      title:"dragon",      class:"flaticon-animals-2"    },
  {      title:"dump truck",      class:"flaticon4-dump-truck"    },
  {      title:"elephant",      class:"flaticon3-elephant"    },
  {      title:"eye",      class:"flaticon-view"    },
  {      title:"fat boy smiling",      class:"flaticon3-fat-boy-smiling"    },
  {      title:"fire",      class:"flaticon4-fire"    },
  {      title:"fish",      class:"flaticon-food"    },
  {      title:"flask",      class:"flaticon3-flask"    },
  {      title:"flower",      class:"flaticon-nature-2"    },
  {      title:"footprint",      class:"flaticon-shape"    },
  {      title:"fountain",      class:"flaticon-fountain"    },
  {      title:"ghost",      class:"flaticon-creepy"    },
  {      title:"giraffe",      class:"flaticon3-giraffe"    },
  {      title:"girl crying",      class:"flaticon3-girl-crying"    },
  {      title:"girl showing tongue",      class:"flaticon3-girl-showing-tongue"    },
  {      title:"girl smiling",      class:"flaticon3-girl-smiling"    },
  {      title:"globe",      class:"flaticon-globe"    },
  {      title:"green lanthern power ring",      class:"flaticon3-green-lanthern-power-ring"    },
  {      title:"hamburger",      class:"flaticon4-hamburger"    },
  {      title:"hand",      class:"flaticon-stop"    },
  {      title:"handcuffs",      class:"flaticon4-handcuffs"    },
  {      title:"happy baby",      class:"flaticon3-happy-baby"    },
  {      title:"happy face",      class:"flaticon-people-1"    },
  {      title:"happy woman",      class:"flaticon3-happy-woman"    },
  {      title:"happy/sad faces",      class:"flaticon-happy-and-sad-masks"    },
  {      title:"hawkeye bow and arrow",      class:"flaticon3-hawkeye-bow-and-arrow"    },
  {      title:"hills",      class:"flaticon4-hills"    },
  {      title:"hipster smiling",      class:"flaticon3-hipster-smiling"    },
  {      title:"hose",      class:"flaticon4-hose"    },
  {      title:"hot dog with sauce and bread",      class:"flaticon4-hot-dog-with-sauce-and-bread"    },
  {      title:"hot drink",      class:"flaticon4-hot-drink"    },
  {      title:"house",      class:"flaticon-home"    },
  {      title:"ice cream",      class:"flaticon4-ice-cream"    },
  {      title:"inexpressive girl",      class:"flaticon3-inexpressive-girl"    },
  {      title:"iron man",      class:"flaticon3-iron-man"    },
  {      title:"jail",      class:"flaticon4-jail"    },
  {      title:"key",      class:"flaticon-key-1"    },
  {      title:"keyhole",      class:"flaticon-key"    },
  {      title:"kissing girl",      class:"flaticon3-kissing-girl"    },
  {      title:"leonard katana",      class:"flaticon3-leonard-katana"    },
  {      title:"lightbulb",      class:"flaticon-technology"    },
  {      title:"lightning",      class:"flaticon2-storm"    },
  {      title:"lion",      class:"flaticon3-lion"    },
  {      title:"lollipop",      class:"flaticon4-lollipop"    },
  {      title:"magic wand",      class:"flaticon-witch"    },
  {      title:"magnet",      class:"flaticon-tool-1"    },
  {      title:"magnifying glass",      class:"flaticon-search"    },
  {      title:"meteorite falling",      class:"flaticon4-meteorite-falling"    },
  {      title:"michelangelo nunchakus",      class:"flaticon3-michelangelo-nunchakus"    },
  {      title:"mixer",      class:"flaticon4-mixer"    },
  {      title:"molecule",      class:"flaticon3-molecule"    },
  {      title:"monkey",      class:"flaticon3-monkey"    },
  {      title:"moon",      class:"flaticon-moon"    },
  {      title:"mountains",      class:"flaticon4-mountains"    },
  {      title:"naughty girl",      class:"flaticon3-naughty-girl"    },
  {      title:"office block",      class:"flaticon-city"    },
  {      title:"padlock",      class:"flaticon-lock"    },
  {      title:"parachute",      class:"flaticon-paratrooper"    },
  {      title:"parcel",      class:"flaticon4-parcel"    },
  {      title:"perplexed man",      class:"flaticon3-perplexed-man"    },
  {      title:"philosophizing boy",      class:"flaticon3-philosophizing-boy"    },
  {      title:"phone",      class:"flaticon-phone-call"    },
  {      title:"pizza",      class:"flaticon4-pizza"    },
  {      title:"plane",      class:"flaticon-transport"    },
  {      title:"police badge",      class:"flaticon4-police-badge"    },
  {      title:"postcard",      class:"flaticon-back"    },
  {      title:"prize",      class:"flaticon4-prize"    },
  {      title:"pyramid",      class:"flaticon-monuments"    },
  {      title:"questionmark",      class:"flaticon-question"    },
  {      title:"rain",      class:"flaticon4-rain"    },
  {      title:"raphael sais",      class:"flaticon3-raphael-sais"    },
  {      title:"reed",      class:"flaticon4-reed"    },
  {      title:"river",      class:"flaticon-nature-1"    },
  {      title:"road perspective of curves",      class:"flaticon4-road-perspective-of-curves"    },
  {      title:"rocket",      class:"flaticon4-rocket"    },
  {      title:"sad baby",      class:"flaticon3-sad-baby"    },
  {      title:"sad face",      class:"flaticon-boy-with-sadness-face"    },
  {      title:"sad girl",      class:"flaticon3-sad-girl"    },
  {      title:"sad woman",      class:"flaticon3-sad-woman"    },
  {      title:"sandwich",      class:"flaticon4-sandwich"    },
  {      title:"satellite",      class:"flaticon4-satellite"    },
  {      title:"satisfied woman",      class:"flaticon3-satisfied-woman"    },
  {      title:"saturn",      class:"flaticon3-saturn"    },
  {      title:"saturn",      class:"flaticon4-saturn"    },
  {      title:"scales",      class:"flaticon-scales-of-justice"    },
  {      title:"scientist",      class:"flaticon3-scientist"    },
  {      title:"shapes",      class:"flaticon3-shapes"    },
  {      title:"sheep",      class:"flaticon-animals-3"    },
  {      title:"shocked girl",      class:"flaticon3-shocked-girl"    },
  {      title:"shooting star",      class:"flaticon-hand-drawn-shooting-star"    },
  {      title:"shredder",      class:"flaticon3-shredder"    },
  {      title:"sleepy face",      class:"flaticon-people"    },
  {      title:"smiling baby",      class:"flaticon3-smiling-baby"    },
  {      title:"smiling girl",      class:"flaticon3-smiling-girl"    },
  {      title:"snack",      class:"flaticon4-snack"    },
  {      title:"speechbubble",      class:"flaticon-multimedia"    },
  {      title:"sputnik",      class:"flaticon4-sputnik"    },
  {      title:"squirrel",      class:"flaticon3-squirrel"    },
  {      title:"sun",      class:"flaticon4-sun"    },
  {      title:"superman",      class:"flaticon3-superman"    },
  {      title:"surprised girl",      class:"flaticon3-surprised-girl"    },
  {      title:"teenage mutant ninja turtles",      class:"flaticon3-teenage-mutant-ninja-turtles"    },
  {      title:"telescope",      class:"flaticon4-telescope"    },
  {      title:"tent",      class:"flaticon-tent"    },
  {      title:"thor mjolnir",      class:"flaticon3-thor-mjolnir"    },
  {      title:"thor",      class:"flaticon3-thor"    },
  {      title:"torch",      class:"flaticon-light"    },
  {      title:"treasure",      class:"flaticon4-treasure"    },
  {      title:"tree",      class:"flaticon-nature"    },
  {      title:"truck 1",      class:"flaticon4-truck-1"    },
  {      title:"truck",      class:"flaticon4-truck"    },
  {      title:"turtle",      class:"flaticon-animal-1"    },
  {      title:"unicorn",      class:"flaticon4-unicorn"    },
  {      title:"walking cane",      class:"flaticon2-hiker"    },
  {      title:"water",      class:"flaticon4-water"    },
  {      title:"winking boy    ",      class:"flaticon3-winking-boy"    }
];  <commit_msg>Removed some faces<commit_after>var images = [
  {      title:"abacus",      class:"flaticon-tool"    },
  {      title:"alien",      class:"flaticon2-ufo"    },
  //{      title:"angry woman",      class:"flaticon3-angry-woman"    },
  {      title:"apple",      class:"flaticon-fruit"    },
  {      title:"arrow (bow)",      class:"flaticon-weapon"    },
  {      title:"arrow (direction)",      class:"flaticon2-right-arrow"    },
  {      title:"automobile",      class:"flaticon4-automobile"    },
  {      title:"bat",      class:"flaticon-animals-1"    },
  {      title:"batman",      class:"flaticon3-batman"    },
  {      title:"beetle",      class:"flaticon-animal"    },
  {      title:"bicycle",      class:"flaticon4-bicycle"    },
  {      title:"birthday cake",      class:"flaticon4-birthday-cake"    },
  {      title:"book",      class:"flaticon-book"    },
  //{      title:"boy happy smile",      class:"flaticon3-boy-happy-smile"    },
  {      title:"boy smiling",      class:"flaticon3-boy-smiling"    },
  {      title:"boy suffering",      class:"flaticon3-boy-suffering"    },
  {      title:"bridge over stream",      class:"flaticon-road"    },
  {      title:"bumblebee",      class:"flaticon-animals"    },
  {      title:"burning home",      class:"flaticon4-burning-home"    },
  {      title:"bus",      class:"flaticon4-bus"    },
  {      title:"calculator",      class:"flaticon3-calculator"    },
  {      title:"cannon",      class:"flaticon4-cannon"    },
  {      title:"car",      class:"flaticon4-car"    },
  {      title:"castle tower",      class:"flaticon-summer"    },
  {      title:"circus elephant",      class:"flaticon4-circus-elephant"    },
  {      title:"circus seal",      class:"flaticon4-circus-seal"    },
  {      title:"clock",      class:"flaticon-clock"    },
  {      title:"cloudy",      class:"flaticon4-cloudy"    },
  {      title:"clown with hat",      class:"flaticon4-clown-with-hat"    },
  {      title:"cold",      class:"flaticon4-cold"    },
  {      title:"compas points",      class:"flaticon-compass"    },
  {      title:"cooking",      class:"flaticon4-cooking"    },
  {      title:"crane",      class:"flaticon4-crane"    },
  {      title:"cup",      class:"flaticon4-cup"    },
  {      title:"dark night",      class:"flaticon4-dark-night"    },
  {      title:"delighted granny",      class:"flaticon3-delighted-granny"    },
  {      title:"dice",      class:"flaticon-game"    },
  {      title:"donatello bo staff",      class:"flaticon3-donatello-bo-staff"    },
  {      title:"dragon",      class:"flaticon-animals-2"    },
  {      title:"dump truck",      class:"flaticon4-dump-truck"    },
  {      title:"elephant",      class:"flaticon3-elephant"    },
  {      title:"eye",      class:"flaticon-view"    },
  //{      title:"fat boy smiling",      class:"flaticon3-fat-boy-smiling"    },
  {      title:"fire",      class:"flaticon4-fire"    },
  {      title:"fish",      class:"flaticon-food"    },
  {      title:"flask",      class:"flaticon3-flask"    },
  {      title:"flower",      class:"flaticon-nature-2"    },
  {      title:"footprint",      class:"flaticon-shape"    },
  {      title:"fountain",      class:"flaticon-fountain"    },
  {      title:"ghost",      class:"flaticon-creepy"    },
  {      title:"giraffe",      class:"flaticon3-giraffe"    },
  {      title:"girl crying",      class:"flaticon3-girl-crying"    },
  {      title:"girl showing tongue",      class:"flaticon3-girl-showing-tongue"    },
  //{      title:"girl smiling",      class:"flaticon3-girl-smiling"    },
  {      title:"globe",      class:"flaticon-globe"    },
  {      title:"green lanthern power ring",      class:"flaticon3-green-lanthern-power-ring"    },
  {      title:"hamburger",      class:"flaticon4-hamburger"    },
  {      title:"hand",      class:"flaticon-stop"    },
  {      title:"handcuffs",      class:"flaticon4-handcuffs"    },
  {      title:"happy baby",      class:"flaticon3-happy-baby"    },
  {      title:"happy face",      class:"flaticon-people-1"    },
  {      title:"happy woman",      class:"flaticon3-happy-woman"    },
  {      title:"happy/sad faces",      class:"flaticon-happy-and-sad-masks"    },
  {      title:"hawkeye bow and arrow",      class:"flaticon3-hawkeye-bow-and-arrow"    },
  {      title:"hills",      class:"flaticon4-hills"    },
  {      title:"hipster smiling",      class:"flaticon3-hipster-smiling"    },
  {      title:"hose",      class:"flaticon4-hose"    },
  {      title:"hot dog with sauce and bread",      class:"flaticon4-hot-dog-with-sauce-and-bread"    },
  {      title:"hot drink",      class:"flaticon4-hot-drink"    },
  {      title:"house",      class:"flaticon-home"    },
  {      title:"ice cream",      class:"flaticon4-ice-cream"    },
  //{      title:"inexpressive girl",      class:"flaticon3-inexpressive-girl"    },
  {      title:"iron man",      class:"flaticon3-iron-man"    },
  {      title:"jail",      class:"flaticon4-jail"    },
  {      title:"key",      class:"flaticon-key-1"    },
  {      title:"keyhole",      class:"flaticon-key"    },
  //{      title:"kissing girl",      class:"flaticon3-kissing-girl"    },
  {      title:"leonard katana",      class:"flaticon3-leonard-katana"    },
  {      title:"lightbulb",      class:"flaticon-technology"    },
  {      title:"lightning",      class:"flaticon2-storm"    },
  {      title:"lion",      class:"flaticon3-lion"    },
  {      title:"lollipop",      class:"flaticon4-lollipop"    },
  {      title:"magic wand",      class:"flaticon-witch"    },
  {      title:"magnet",      class:"flaticon-tool-1"    },
  {      title:"magnifying glass",      class:"flaticon-search"    },
  {      title:"meteorite falling",      class:"flaticon4-meteorite-falling"    },
  {      title:"michelangelo nunchakus",      class:"flaticon3-michelangelo-nunchakus"    },
  {      title:"mixer",      class:"flaticon4-mixer"    },
  {      title:"molecule",      class:"flaticon3-molecule"    },
  {      title:"monkey",      class:"flaticon3-monkey"    },
  {      title:"moon",      class:"flaticon-moon"    },
  {      title:"mountains",      class:"flaticon4-mountains"    },
  //{      title:"naughty girl",      class:"flaticon3-naughty-girl"    },
  {      title:"office block",      class:"flaticon-city"    },
  {      title:"padlock",      class:"flaticon-lock"    },
  {      title:"parachute",      class:"flaticon-paratrooper"    },
  {      title:"parcel",      class:"flaticon4-parcel"    },
  {      title:"perplexed man",      class:"flaticon3-perplexed-man"    },
  //{      title:"philosophizing boy",      class:"flaticon3-philosophizing-boy"    },
  {      title:"phone",      class:"flaticon-phone-call"    },
  {      title:"pizza",      class:"flaticon4-pizza"    },
  {      title:"plane",      class:"flaticon-transport"    },
  {      title:"police badge",      class:"flaticon4-police-badge"    },
  {      title:"postcard",      class:"flaticon-back"    },
  {      title:"prize",      class:"flaticon4-prize"    },
  {      title:"pyramid",      class:"flaticon-monuments"    },
  {      title:"questionmark",      class:"flaticon-question"    },
  {      title:"rain",      class:"flaticon4-rain"    },
  {      title:"raphael sais",      class:"flaticon3-raphael-sais"    },
  {      title:"reed",      class:"flaticon4-reed"    },
  {      title:"river",      class:"flaticon-nature-1"    },
  {      title:"road perspective of curves",      class:"flaticon4-road-perspective-of-curves"    },
  {      title:"rocket",      class:"flaticon4-rocket"    },
  {      title:"sad baby",      class:"flaticon3-sad-baby"    },
  {      title:"sad face",      class:"flaticon-boy-with-sadness-face"    },
  {      title:"sad girl",      class:"flaticon3-sad-girl"    },
 // {      title:"sad woman",      class:"flaticon3-sad-woman"    },
  {      title:"sandwich",      class:"flaticon4-sandwich"    },
  {      title:"satellite",      class:"flaticon4-satellite"    },
  //{      title:"satisfied woman",      class:"flaticon3-satisfied-woman"    },
  {      title:"saturn",      class:"flaticon3-saturn"    },
  {      title:"saturn",      class:"flaticon4-saturn"    },
  {      title:"scales",      class:"flaticon-scales-of-justice"    },
  {      title:"scientist",      class:"flaticon3-scientist"    },
  {      title:"shapes",      class:"flaticon3-shapes"    },
  {      title:"sheep",      class:"flaticon-animals-3"    },
  {      title:"shocked girl",      class:"flaticon3-shocked-girl"    },
  {      title:"shooting star",      class:"flaticon-hand-drawn-shooting-star"    },
  {      title:"shredder",      class:"flaticon3-shredder"    },
  {      title:"sleepy face",      class:"flaticon-people"    },
  {      title:"smiling baby",      class:"flaticon3-smiling-baby"    },
  {      title:"smiling girl",      class:"flaticon3-smiling-girl"    },
  {      title:"snack",      class:"flaticon4-snack"    },
  {      title:"speechbubble",      class:"flaticon-multimedia"    },
  {      title:"sputnik",      class:"flaticon4-sputnik"    },
  {      title:"squirrel",      class:"flaticon3-squirrel"    },
  {      title:"sun",      class:"flaticon4-sun"    },
  {      title:"superman",      class:"flaticon3-superman"    },
  {      title:"surprised girl",      class:"flaticon3-surprised-girl"    },
  {      title:"teenage mutant ninja turtles",      class:"flaticon3-teenage-mutant-ninja-turtles"    },
  {      title:"telescope",      class:"flaticon4-telescope"    },
  {      title:"tent",      class:"flaticon-tent"    },
  {      title:"thor mjolnir",      class:"flaticon3-thor-mjolnir"    },
  {      title:"thor",      class:"flaticon3-thor"    },
  {      title:"torch",      class:"flaticon-light"    },
  {      title:"treasure",      class:"flaticon4-treasure"    },
  {      title:"tree",      class:"flaticon-nature"    },
  {      title:"truck 1",      class:"flaticon4-truck-1"    },
  {      title:"truck",      class:"flaticon4-truck"    },
  {      title:"turtle",      class:"flaticon-animal-1"    },
  {      title:"unicorn",      class:"flaticon4-unicorn"    },
  {      title:"walking cane",      class:"flaticon2-hiker"    },
  {      title:"water",      class:"flaticon4-water"    },
  {      title:"winking boy    ",      class:"flaticon3-winking-boy"    }
];  <|endoftext|>


<commit_before>/* ========================================================================
 * DOM-based Routing
 * Based on http://goo.gl/EUTi53 by Paul Irish
 *
 * Only fires on body classes that match. If a body class contains a dash,
 * replace the dash with an underscore when adding it to the object below.
 *
 * .noConflict()
 * The routing is enclosed within an anonymous function so that you can
 * always reference jQuery with $, even when in .noConflict() mode.
 * ======================================================================== */

(function($) {

  // Use this variable to set up the common and page specific functions. If you
  // rename this variable, you will also need to rename the namespace below.
  var Sage = {
    // All pages
    'common': {
      init: function() {
        // JavaScript to be fired on all pages
      },
      finalize: function() {
        // JavaScript to be fired on all pages, after page specific JS is fired
      }
    },
    // Home page
    'home': {
      init: function() {
        // JavaScript to be fired on the home page
        $('.sector-toggle').dropdown();
      },
      finalize: function() {
        // JavaScript to be fired on the home page, after the init JS
      }
    },
    // About us page, note the change from about-us to about_us.
    'about_us': {
      init: function() {
        // JavaScript to be fired on the about us page
      }
    }
  };

  // The routing fires all common scripts, followed by the page specific scripts.
  // Add additional events for more control over timing e.g. a finalize event
  var UTIL = {
    fire: function(func, funcname, args) {
      var fire;
      var namespace = Sage;
      funcname = (funcname === undefined) ? 'init' : funcname;
      fire = func !== '';
      fire = fire && namespace[func];
      fire = fire && typeof namespace[func][funcname] === 'function';

      if (fire) {
        namespace[func][funcname](args);
      }
    },
    loadEvents: function() {
      // Fire common init JS
      UTIL.fire('common');

      // Fire page-specific init JS, and then finalize JS
      $.each(document.body.className.replace(/-/g, '_').split(/\s+/), function(i, classnm) {
        UTIL.fire(classnm);
        UTIL.fire(classnm, 'finalize');
      });

      // Fire common finalize JS
      UTIL.fire('common', 'finalize');
    }
  };

  // Load Events
  $(document).ready(UTIL.loadEvents);

  // TRIGGER ACTIVE STATE
  $('#mobnav-btn').click(

    function() {
      $('.navbar-nav').toggleClass("xactive");
    });

  // TRIGGER DROP DOWN SUBS
  $('.mobnav-subarrow').click(

    function() {
      $(this).parent().toggleClass("xpopdrop");
    });

  // Match height of grid tiles
  if ( $('.grid-match').length ) {
      $('.grid-match').matchHeight();
  }

  // Initialise wow
  wow = new WOW({
    boxClass:     'wow',      // default
    animateClass: 'animated', // default
    offset:       0,          // default
    mobile:       false,       // default
    live:         true        // default
  });
  wow.init();

})(jQuery); // Fully reference jQuery after this point.
<commit_msg>Dropdown toggle for whole site<commit_after>/* ========================================================================
 * DOM-based Routing
 * Based on http://goo.gl/EUTi53 by Paul Irish
 *
 * Only fires on body classes that match. If a body class contains a dash,
 * replace the dash with an underscore when adding it to the object below.
 *
 * .noConflict()
 * The routing is enclosed within an anonymous function so that you can
 * always reference jQuery with $, even when in .noConflict() mode.
 * ======================================================================== */

(function($) {

  // Use this variable to set up the common and page specific functions. If you
  // rename this variable, you will also need to rename the namespace below.
  var Sage = {
    // All pages
    'common': {
      init: function() {
        // JavaScript to be fired on all pages
      },
      finalize: function() {
        // JavaScript to be fired on all pages, after page specific JS is fired
      }
    },
    // Home page
    'home': {
      init: function() {
        // JavaScript to be fired on the home page

      },
      finalize: function() {
        // JavaScript to be fired on the home page, after the init JS
      }
    },
    // About us page, note the change from about-us to about_us.
    'about_us': {
      init: function() {
        // JavaScript to be fired on the about us page
      }
    }
  };

  // The routing fires all common scripts, followed by the page specific scripts.
  // Add additional events for more control over timing e.g. a finalize event
  var UTIL = {
    fire: function(func, funcname, args) {
      var fire;
      var namespace = Sage;
      funcname = (funcname === undefined) ? 'init' : funcname;
      fire = func !== '';
      fire = fire && namespace[func];
      fire = fire && typeof namespace[func][funcname] === 'function';

      if (fire) {
        namespace[func][funcname](args);
      }
    },
    loadEvents: function() {
      // Fire common init JS
      UTIL.fire('common');

      // Fire page-specific init JS, and then finalize JS
      $.each(document.body.className.replace(/-/g, '_').split(/\s+/), function(i, classnm) {
        UTIL.fire(classnm);
        UTIL.fire(classnm, 'finalize');
      });

      // Fire common finalize JS
      UTIL.fire('common', 'finalize');
    }
  };

  // Load Events
  $(document).ready(UTIL.loadEvents);

  // Drop down menu for Industry sector selection
  $('.sector-toggle').dropdown();

  // TRIGGER ACTIVE STATE
  $('#mobnav-btn').click(

    function() {
      $('.navbar-nav').toggleClass("xactive");
    });

  // TRIGGER DROP DOWN SUBS
  $('.mobnav-subarrow').click(

    function() {
      $(this).parent().toggleClass("xpopdrop");
    });

  // Match height of grid tiles
  if ( $('.grid-match').length ) {
      $('.grid-match').matchHeight();
  }

  // Initialise wow
  wow = new WOW({
    boxClass:     'wow',      // default
    animateClass: 'animated', // default
    offset:       0,          // default
    mobile:       false,       // default
    live:         true        // default
  });
  wow.init();

})(jQuery); // Fully reference jQuery after this point.
<|endoftext|>


<commit_before>(function(window) {

	var submitForm = document.getElementById("submitForm");

	createSimpleField('id', '');
	createSimpleField('browserId', getParameter('browserId'));
	createSimpleField('userAgent', navigator.userAgent);
	createSimpleField('jsUnitVersion', '2.2');
	createSimpleField('url', window.location.href);
	createSimpleField('cacheBuster', new Date().getTime());
	createSimpleField('userProperty', '');

	var timeField = createSimpleField('time', 0);
	var testCasesField = document.getElementById("testCaseResults");

	document.body.appendChild(submitForm);

	var runnerFrame = document.getElementById('runner');

	var urls = getParameter('urls').split(';');
	var nextUrlIndex = 0;

	window.initListener = function() {
		// TODO: Not sure if this will work on all browsers.
		var contentWindow = runnerFrame.contentWindow;
		var QUnit = contentWindow.QUnit;

		var testState = {
				moduleName: contentWindow.location + ":",
				messages: ""
		};
		QUnit.log = function(result, message) {
			if (!result && message) {
				testState.messages += message + "-";
			}
		};
		QUnit.testStart = function(name) {
			testState.testStartTime = new Date().getTime();
			testState.testName = name;
			testState.messages = "";
		};
		QUnit.moduleStart = function(name) {
			testState.moduleName = name + ":";
		};
		QUnit.testDone = function(name, failures, total) {
			addTestResult(testState.moduleName, testState.testName, (new Date().getTime() - testState.testStartTime), failures, testState.messages);
		};
		QUnit.done = function(failures, total) {
			loadNextUrl();
		};
	};

	loadNextUrl();

	function loadNextUrl() {
		if (nextUrlIndex < urls.length) {
			runnerFrame.src = '/jsunit/' + urls[nextUrlIndex];
			nextUrlIndex++;
		} else {
			submitResults();
		}
	}

	function getParameter(name) {
		var matches = window.location.href.match(new RegExp('[&?]' + name + '=([^&]+)'));
		if (matches && matches.length > 1) {
			return matches[1];
		}
	}

	function createSimpleField(name, value) {
		var field = document.createElement('input');
		field.name = name;
		field.value = value;
		submitForm.appendChild(field);
		return field;
	}

	function addTestResult(moduleName, testName, time, failures, message) {
		var resultOption = document.createElement('option');
		testCasesField.options[testCasesField.options.length] = resultOption;
		resultOption.value = resultOption.innerHTML = moduleName + testName + '|' + (time/1000) + '|' + (failures == 0 ? 'S' : 'F') + '|' + message + '|';
		resultOption.selected = true;
	};

	var startTime = new Date().getTime();
	function submitResults() {
		timeField.value = new Date().getTime() - startTime;
		document.body.appendChild(submitForm);
		if (window.location.href.toLowerCase().match(/[?&]submitresults=true/)) {
			submitForm.submit();
		} else {
			submitForm.style.display = "";
		}
	}
})(this);

<commit_msg>MAINTENANCE: Improved error message layout.<commit_after>(function(window) {

	var submitForm = document.getElementById("submitForm");

	createSimpleField('id', '');
	createSimpleField('browserId', getParameter('browserId'));
	createSimpleField('userAgent', navigator.userAgent);
	createSimpleField('jsUnitVersion', '2.2');
	createSimpleField('url', window.location.href);
	createSimpleField('cacheBuster', new Date().getTime());
	createSimpleField('userProperty', '');

	var timeField = createSimpleField('time', 0);
	var testCasesField = document.getElementById("testCaseResults");

	document.body.appendChild(submitForm);

	var runnerFrame = document.getElementById('runner');

	var urls = getParameter('urls').split(';');
	var nextUrlIndex = 0;

	window.initListener = function() {
		// TODO: Not sure if this will work on all browsers.
		var contentWindow = runnerFrame.contentWindow;
		var QUnit = contentWindow.QUnit;

		var testState = {
				moduleName: contentWindow.location + ":",
				messages: ""
		};
		QUnit.log = function(result, message) {
			if (!result && message) {
				testState.messages += message + "\n";
			}
		};
		QUnit.testStart = function(name) {
			testState.testStartTime = new Date().getTime();
			testState.testName = name;
			testState.messages = "";
		};
		QUnit.moduleStart = function(name) {
			testState.moduleName = name + ":";
		};
		QUnit.testDone = function(name, failures, total) {
			addTestResult(testState.moduleName, testState.testName, (new Date().getTime() - testState.testStartTime), failures, testState.messages);
		};
		QUnit.done = function(failures, total) {
			loadNextUrl();
		};
	};

	loadNextUrl();

	function loadNextUrl() {
		if (nextUrlIndex < urls.length) {
			runnerFrame.src = '/jsunit/' + urls[nextUrlIndex];
			nextUrlIndex++;
		} else {
			submitResults();
		}
	}

	function getParameter(name) {
		var matches = window.location.href.match(new RegExp('[&?]' + name + '=([^&]+)'));
		if (matches && matches.length > 1) {
			return matches[1];
		}
	}

	function createSimpleField(name, value) {
		var field = document.createElement('input');
		field.name = name;
		field.value = value;
		submitForm.appendChild(field);
		return field;
	}

	function addTestResult(moduleName, testName, time, failures, message) {
		var resultOption = document.createElement('option');
		testCasesField.options[testCasesField.options.length] = resultOption;
		resultOption.value = resultOption.innerHTML = moduleName + testName + '|' + (time/1000) + '|' + (failures == 0 ? 'S' : 'F') + '|' + message + '|';
		resultOption.selected = true;
	};

	var startTime = new Date().getTime();
	function submitResults() {
		timeField.value = new Date().getTime() - startTime;
		document.body.appendChild(submitForm);
		if (window.location.href.toLowerCase().match(/[?&]submitresults=true/)) {
			submitForm.submit();
		} else {
			submitForm.style.display = "";
		}
	}
})(this);

<|endoftext|>


<commit_before>import PropTypes from 'prop-types'
import React from 'react'
import EventRow from '../../EventRow'
import Selection, { getBoundsForNode } from '../../Selection'
import * as dates from '../../utils/dates'
import { eventSegments } from '../../utils/eventLevels'
import { getSlotAtX, pointInBox } from '../../utils/selection'
import { dragAccessors, eventTimes } from './common'
import { DnDContext } from './DnDContext'

class WeekWrapper extends React.Component {
  static propTypes = {
    isAllDay: PropTypes.bool,
    slotMetrics: PropTypes.object.isRequired,
    accessors: PropTypes.object.isRequired,
    getters: PropTypes.object.isRequired,
    components: PropTypes.object.isRequired,
    resourceId: PropTypes.any,
    rtl: PropTypes.bool,
  }

  static contextType = DnDContext

  constructor(...args) {
    super(...args)
    this.state = {}
    this.ref = React.createRef()
  }

  componentDidMount() {
    this._selectable()
  }

  componentWillUnmount() {
    this._teardownSelectable()
  }

  reset() {
    if (this.state.segment) this.setState({ segment: null })
  }

  update(event, start, end) {
    const segment = eventSegments(
      { ...event, end, start, __isPreview: true },
      this.props.slotMetrics.range,
      dragAccessors
    )

    const { segment: lastSegment } = this.state
    if (
      lastSegment &&
      segment.span === lastSegment.span &&
      segment.left === lastSegment.left &&
      segment.right === lastSegment.right
    ) {
      return
    }
    this.setState({ segment })
  }

  handleMove = (point, bounds, draggedEvent) => {
    if (!pointInBox(bounds, point)) return this.reset()
    const event = this.context.draggable.dragAndDropAction.event || draggedEvent
    const { accessors, slotMetrics, rtl } = this.props

    const slot = getSlotAtX(
      bounds,
      point.x - this.eventOffsetLeft,
      rtl,
      slotMetrics.slots
    )

    const date = slotMetrics.getDateForSlot(slot)

    // Adjust the dates, but maintain the times when moving
    let { start, duration } = eventTimes(event, accessors)
    start = dates.merge(date, start)
    const end = dates.add(start, duration, 'milliseconds')
    // LATER: when dragging a multi-row event, only the first row is animating
    this.update(event, start, end)
  }

  handleDropFromOutside = (point, bounds) => {
    if (!this.context.draggable.onDropFromOutside) return
    const { slotMetrics, rtl } = this.props

    const slot = getSlotAtX(bounds, point.x, rtl, slotMetrics.slots)
    const start = slotMetrics.getDateForSlot(slot)

    this.context.draggable.onDropFromOutside({
      start,
      end: dates.add(start, 1, 'day'),
      allDay: false,
    })
  }

  handleDragOverFromOutside = (point, node) => {
    if (!this.context.draggable.dragFromOutsideItem) return
    this.handleMove(point, node, this.context.draggable.dragFromOutsideItem())
  }

  handleResize(point, bounds) {
    const { event, direction } = this.context.draggable.dragAndDropAction
    const { accessors, slotMetrics, rtl } = this.props

    let { start, end } = eventTimes(event, accessors)

    const slot = getSlotAtX(bounds, point.x, rtl, slotMetrics.slots)
    const date = slotMetrics.getDateForSlot(slot)
    const cursorInRow = pointInBox(bounds, point)

    if (direction === 'RIGHT') {
      if (cursorInRow) {
        if (slotMetrics.last < start) return this.reset()
        end = dates.add(date, 1, 'day')
      } else if (
        dates.inRange(start, slotMetrics.first, slotMetrics.last) ||
        (bounds.bottom < point.y && +slotMetrics.first > +start)
      ) {
        end = dates.add(slotMetrics.last, 1, 'milliseconds')
      } else {
        this.setState({ segment: null })
        return
      }
      const originalEnd = accessors.end(event)
      end = dates.merge(end, originalEnd)
      if (dates.lt(end, start)) {
        end = originalEnd
      }
    } else if (direction === 'LEFT') {
      if (cursorInRow) {
        if (slotMetrics.first > end) return this.reset()
        start = date
      } else if (
        dates.inRange(end, slotMetrics.first, slotMetrics.last) ||
        (bounds.top > point.y && dates.lt(slotMetrics.last, end))
      ) {
        start = dates.add(slotMetrics.first, -1, 'milliseconds')
      } else {
        this.reset()
        return
      }
      const originalStart = accessors.start(event)
      start = dates.merge(start, originalStart)
      if (dates.gt(start, end)) {
        start = originalStart
      }
    }

    this.update(event, start, end)
  }

  _selectable = () => {
    let node = this.ref.current.closest('.rbc-month-row, .rbc-allday-cell')
    let container = node.closest('.rbc-month-view, .rbc-time-view')

    let selector = (this._selector = new Selection(() => container))

    selector.on('beforeSelect', point => {
      const { isAllDay } = this.props
      const { action } = this.context.draggable.dragAndDropAction
      const bounds = getBoundsForNode(node)

      // eventOffsetLeft is distance from the left of the event to the initial
      // mouseDown position. We need this later to compute the new top of the
      // event during move operations, since the final location is really a
      // delta from this point. note: if we want to DRY this with
      // EventContainerWrapper, probably better just to capture the mouseDown
      // point here and do the placement computation in handleMove()...
      this.eventOffsetLeft = point.x - bounds.left

      const isInBox = pointInBox(bounds, point)
      return (
        action === 'move' || (action === 'resize' && (!isAllDay || isInBox))
      )
    })

    selector.on('selecting', box => {
      const bounds = getBoundsForNode(node)
      const { dragAndDropAction } = this.context.draggable
      if (dragAndDropAction.action === 'move') this.handleMove(box, bounds)
      if (dragAndDropAction.action === 'resize') this.handleResize(box, bounds)
    })

    selector.on('selectStart', () => this.context.draggable.onStart())

    selector.on('select', point => {
      const bounds = getBoundsForNode(node)
      if (!this.state.segment) return
      if (!pointInBox(bounds, point)) {
        this.reset()
      } else {
        this.handleInteractionEnd()
      }
    })

    selector.on('dropFromOutside', point => {
      if (!this.context.draggable.onDropFromOutside) return
      const bounds = getBoundsForNode(node)
      if (!pointInBox(bounds, point)) return
      this.handleDropFromOutside(point, bounds)
    })

    selector.on('dragOverFromOutside', point => {
      if (!this.context.draggable.dragFromOutsideItem) return
      const bounds = getBoundsForNode(node)

      this.handleDragOverFromOutside(point, bounds)
    })

    selector.on('click', () => this.context.draggable.onEnd(null))

    selector.on('reset', () => {
      this.reset()
      this.context.draggable.onEnd(null)
    })
  }

  handleInteractionEnd = () => {
    const { resourceId, isAllDay } = this.props
    const { event } = this.state.segment

    this.reset()

    this.context.draggable.onEnd({
      start: event.start,
      end: event.end,
      resourceId,
      isAllDay,
    })
  }

  _teardownSelectable = () => {
    if (!this._selector) return
    this._selector.teardown()
    this._selector = null
  }

  render() {
    const { children, accessors } = this.props

    let { segment } = this.state

    return (

        {children}

        {segment && (
          <EventRow
            {...this.props}
            selected={null}
            className="rbc-addons-dnd-drag-row"
            segments={[segment]}
            accessors={{
              ...accessors,
              ...dragAccessors,
            }}
          />
        )}

    )
  }
}

export default WeekWrapper
<commit_msg>fix(Dnd): Offset is not needed (#1892)<commit_after>import PropTypes from 'prop-types'
import React from 'react'
import EventRow from '../../EventRow'
import Selection, { getBoundsForNode } from '../../Selection'
import * as dates from '../../utils/dates'
import { eventSegments } from '../../utils/eventLevels'
import { getSlotAtX, pointInBox } from '../../utils/selection'
import { dragAccessors, eventTimes } from './common'
import { DnDContext } from './DnDContext'

class WeekWrapper extends React.Component {
  static propTypes = {
    isAllDay: PropTypes.bool,
    slotMetrics: PropTypes.object.isRequired,
    accessors: PropTypes.object.isRequired,
    getters: PropTypes.object.isRequired,
    components: PropTypes.object.isRequired,
    resourceId: PropTypes.any,
    rtl: PropTypes.bool,
  }

  static contextType = DnDContext

  constructor(...args) {
    super(...args)
    this.state = {}
    this.ref = React.createRef()
  }

  componentDidMount() {
    this._selectable()
  }

  componentWillUnmount() {
    this._teardownSelectable()
  }

  reset() {
    if (this.state.segment) this.setState({ segment: null })
  }

  update(event, start, end) {
    const segment = eventSegments(
      { ...event, end, start, __isPreview: true },
      this.props.slotMetrics.range,
      dragAccessors
    )

    const { segment: lastSegment } = this.state
    if (
      lastSegment &&
      segment.span === lastSegment.span &&
      segment.left === lastSegment.left &&
      segment.right === lastSegment.right
    ) {
      return
    }
    this.setState({ segment })
  }

  handleMove = (point, bounds, draggedEvent) => {
    if (!pointInBox(bounds, point)) return this.reset()
    const event = this.context.draggable.dragAndDropAction.event || draggedEvent
    const { accessors, slotMetrics, rtl } = this.props

    const slot = getSlotAtX(
      bounds,
      point.x,
      rtl,
      slotMetrics.slots
    )

    const date = slotMetrics.getDateForSlot(slot)

    // Adjust the dates, but maintain the times when moving
    let { start, duration } = eventTimes(event, accessors)
    start = dates.merge(date, start)
    const end = dates.add(start, duration, 'milliseconds')
    // LATER: when dragging a multi-row event, only the first row is animating
    this.update(event, start, end)
  }

  handleDropFromOutside = (point, bounds) => {
    if (!this.context.draggable.onDropFromOutside) return
    const { slotMetrics, rtl } = this.props

    const slot = getSlotAtX(bounds, point.x, rtl, slotMetrics.slots)
    const start = slotMetrics.getDateForSlot(slot)

    this.context.draggable.onDropFromOutside({
      start,
      end: dates.add(start, 1, 'day'),
      allDay: false,
    })
  }

  handleDragOverFromOutside = (point, node) => {
    if (!this.context.draggable.dragFromOutsideItem) return
    this.handleMove(point, node, this.context.draggable.dragFromOutsideItem())
  }

  handleResize(point, bounds) {
    const { event, direction } = this.context.draggable.dragAndDropAction
    const { accessors, slotMetrics, rtl } = this.props

    let { start, end } = eventTimes(event, accessors)

    const slot = getSlotAtX(bounds, point.x, rtl, slotMetrics.slots)
    const date = slotMetrics.getDateForSlot(slot)
    const cursorInRow = pointInBox(bounds, point)

    if (direction === 'RIGHT') {
      if (cursorInRow) {
        if (slotMetrics.last < start) return this.reset()
        end = dates.add(date, 1, 'day')
      } else if (
        dates.inRange(start, slotMetrics.first, slotMetrics.last) ||
        (bounds.bottom < point.y && +slotMetrics.first > +start)
      ) {
        end = dates.add(slotMetrics.last, 1, 'milliseconds')
      } else {
        this.setState({ segment: null })
        return
      }
      const originalEnd = accessors.end(event)
      end = dates.merge(end, originalEnd)
      if (dates.lt(end, start)) {
        end = originalEnd
      }
    } else if (direction === 'LEFT') {
      if (cursorInRow) {
        if (slotMetrics.first > end) return this.reset()
        start = date
      } else if (
        dates.inRange(end, slotMetrics.first, slotMetrics.last) ||
        (bounds.top > point.y && dates.lt(slotMetrics.last, end))
      ) {
        start = dates.add(slotMetrics.first, -1, 'milliseconds')
      } else {
        this.reset()
        return
      }
      const originalStart = accessors.start(event)
      start = dates.merge(start, originalStart)
      if (dates.gt(start, end)) {
        start = originalStart
      }
    }

    this.update(event, start, end)
  }

  _selectable = () => {
    let node = this.ref.current.closest('.rbc-month-row, .rbc-allday-cell')
    let container = node.closest('.rbc-month-view, .rbc-time-view')

    let selector = (this._selector = new Selection(() => container))

    selector.on('beforeSelect', point => {
      const { isAllDay } = this.props
      const { action } = this.context.draggable.dragAndDropAction
      const bounds = getBoundsForNode(node)
      const isInBox = pointInBox(bounds, point)
      return (
        action === 'move' || (action === 'resize' && (!isAllDay || isInBox))
      )
    })

    selector.on('selecting', box => {
      const bounds = getBoundsForNode(node)
      const { dragAndDropAction } = this.context.draggable
      if (dragAndDropAction.action === 'move') this.handleMove(box, bounds)
      if (dragAndDropAction.action === 'resize') this.handleResize(box, bounds)
    })

    selector.on('selectStart', () => this.context.draggable.onStart())

    selector.on('select', point => {
      const bounds = getBoundsForNode(node)
      if (!this.state.segment) return
      if (!pointInBox(bounds, point)) {
        this.reset()
      } else {
        this.handleInteractionEnd()
      }
    })

    selector.on('dropFromOutside', point => {
      if (!this.context.draggable.onDropFromOutside) return
      const bounds = getBoundsForNode(node)
      if (!pointInBox(bounds, point)) return
      this.handleDropFromOutside(point, bounds)
    })

    selector.on('dragOverFromOutside', point => {
      if (!this.context.draggable.dragFromOutsideItem) return
      const bounds = getBoundsForNode(node)

      this.handleDragOverFromOutside(point, bounds)
    })

    selector.on('click', () => this.context.draggable.onEnd(null))

    selector.on('reset', () => {
      this.reset()
      this.context.draggable.onEnd(null)
    })
  }

  handleInteractionEnd = () => {
    const { resourceId, isAllDay } = this.props
    const { event } = this.state.segment

    this.reset()

    this.context.draggable.onEnd({
      start: event.start,
      end: event.end,
      resourceId,
      isAllDay,
    })
  }

  _teardownSelectable = () => {
    if (!this._selector) return
    this._selector.teardown()
    this._selector = null
  }

  render() {
    const { children, accessors } = this.props

    let { segment } = this.state

    return (

        {children}

        {segment && (
          <EventRow
            {...this.props}
            selected={null}
            className="rbc-addons-dnd-drag-row"
            segments={[segment]}
            accessors={{
              ...accessors,
              ...dragAccessors,
            }}
          />
        )}

    )
  }
}

export default WeekWrapper
<|endoftext|>


<commit_before>var errors = require('../../../../errors')
var FieldVal = require('fieldval');
var BasicVal = FieldVal.BasicVal;
var PathPermissionChecker = require('../../models/PathPermissionChecker');
var Path = require('../../../../common_classes/Path');
var Constants = require('../../../../common_classes/Constants');
var validators = require('../../validators');
var logger = require('tracer').console();

function SearchHandler(api, user, parameters, callback){
    var sh = this;

    sh.api = api;
    sh.user = user;
    sh.parameters = parameters;
    sh.callback = callback;

    sh.path_permission_checker = new PathPermissionChecker(sh);

    sh.validator = new FieldVal(parameters);

    sh.mongo_query = {}
    sh.query_and = [];

    sh.paths = sh.validator.get("paths", BasicVal.array(true));
    sh.skip = sh.validator.get("skip", BasicVal.integer(false), BasicVal.minimum(0));
    if(sh.skip===undefined){
        sh.skip = 0;
    }
    sh.limit = sh.validator.get("limit", BasicVal.integer(false), BasicVal.minimum(1));
    sh.include_subfolders = sh.validator.get("include_subfolders", BasicVal.boolean(false));
    if(sh.include_subfolders===undefined){
        sh.include_subfolders = false;
    }
    sh.query = sh.validator.get("query", BasicVal.object(false));
    if(sh.query){
        sh.query_and.push(sh.query);
    }

    sh.sort = sh.validator.get('sort', BasicVal.object(false), function(sort_object) {
        var inner_validator = new FieldVal(sort_object);
        for (var key in sort_object) {
            inner_validator.get(key, BasicVal.number(true), function(value) {
                if (value != 1 && value != -1) {
                    return errors.INVALID_SORT_PARAM;
                }
            });
        }
        return inner_validator.end();
    })

    sh.text_search = sh.validator.get("text_search", BasicVal.string(false));
    if(sh.text_search){
        sh.query_and.push({"$text":{"$search":sh.text_search}});
    }

    var error = sh.validator.end();
    if(error){
        sh.callback(error);
        return;
    } else {
        sh.do_search(function(err,res){
            // logger.log(err);
            // logger.log(res);
            callback(err, res);
        })
    }
}

SearchHandler.prototype.do_search = function(callback){
    var sh = this;

    var db = sh.api.ds;

    var path_validator = new FieldVal(null);
    for(var i = 0; i < sh.paths.length; i++){
        (function(i){
            var sh = this;

            var path;
            var path_error = validators.folder_path(sh.paths[i], function(emit_path){
                path = emit_path
            })
            logger.log(path_error);

            if(path_error){
                path_validator.invalid(i, path_error);
            } else {
                sh.path_permission_checker.check_permissions_for_path(path,function(status){
                    if(status===Constants.WRITE_PERMISSION || status===Constants.READ_PERMISSION){
                        //All good
                    } else {
                        path_validator.invalid(i, errors.NOT_FOUND_OR_NO_PERMISSION_TO_ACCESS);
                    }
                });
            }
        }).call(sh,i);
    }

    sh.path_permission_checker.retrieve_permissions(function(){

        var path_error = path_validator.end();
        if(path_error){
            sh.validator.invalid("paths", path_error);
            sh.callback(sh.validator.end());
            return;
        }

        if(sh.include_subfolders){
            var path_prefixes = [];
            for(var i = 0; i < sh.paths.length; i++){
                var path = sh.paths[i];

                path_prefixes.push({
                    "path":{
                        "$regex": "^"+path
                    }
                })
            }
            sh.mongo_query["$or"] = path_prefixes;
        } else {
            sh.mongo_query.path = {
                "$in": sh.paths
            };
        }

        var error;
        var results;
        var have_results;
        var count;
        var have_count;
        var done = function(){
            if(have_results && have_count){

                if(error){
                    callback(error);
                    return;
                }

                callback(null,{
                    objects: results,
                    total: count,
                    limit: sh.limit,
                    skip: sh.skip
                });
            }
        }

        var options = {
            skip: sh.skip,
            limit: sh.limit
        };

        if(sh.query_and.length>0){
            sh.mongo_query["$and"] = sh.query_and;
        }

        logger.log(JSON.stringify(sh.mongo_query,null,4));
        logger.log(options);

        var mongo_cursor = db.object_collection.find(sh.mongo_query,options);
        if (sh.sort) {
            mongo_cursor.sort(sh.sort);
        }
        mongo_cursor.toArray(function(search_err, search_res){
            logger.log(search_err, search_res);
            if(search_err){
                error = search_err;
            } else {
                results = search_res;
            }
            have_results = true;
            done();
        });

        var mongo_count_cursor = db.object_collection.find(sh.mongo_query);
        mongo_count_cursor.count(function(err, res_count){
            logger.log(err, res_count);
            if(err){
                error = err;
            } else {
                count = res_count;
            }
            have_count = true;
            done();
        })
    });
}

module.exports = SearchHandler;<commit_msg>Updated SearchHandler sort validation with BasicVal.each<commit_after>var errors = require('../../../../errors')
var FieldVal = require('fieldval');
var BasicVal = FieldVal.BasicVal;
var PathPermissionChecker = require('../../models/PathPermissionChecker');
var Path = require('../../../../common_classes/Path');
var Constants = require('../../../../common_classes/Constants');
var validators = require('../../validators');
var logger = require('tracer').console();

function SearchHandler(api, user, parameters, callback){
    var sh = this;

    sh.api = api;
    sh.user = user;
    sh.parameters = parameters;
    sh.callback = callback;

    sh.path_permission_checker = new PathPermissionChecker(sh);

    sh.validator = new FieldVal(parameters);

    sh.mongo_query = {}
    sh.query_and = [];

    sh.paths = sh.validator.get("paths", BasicVal.array(true));
    sh.skip = sh.validator.get("skip", BasicVal.integer(false), BasicVal.minimum(0));
    if(sh.skip===undefined){
        sh.skip = 0;
    }
    sh.limit = sh.validator.get("limit", BasicVal.integer(false), BasicVal.minimum(1));
    sh.include_subfolders = sh.validator.get("include_subfolders", BasicVal.boolean(false));
    if(sh.include_subfolders===undefined){
        sh.include_subfolders = false;
    }
    sh.query = sh.validator.get("query", BasicVal.object(false));
    if(sh.query){
        sh.query_and.push(sh.query);
    }

    sh.sort = sh.validator.get('sort', BasicVal.object(false), BasicVal.each(function(value) {
        if (value != 1 && value != -1) {
            return errors.INVALID_SORT_PARAM;
        }
    }));

    sh.text_search = sh.validator.get("text_search", BasicVal.string(false));
    if(sh.text_search){
        sh.query_and.push({"$text":{"$search":sh.text_search}});
    }

    var error = sh.validator.end();
    if(error){
        sh.callback(error);
        return;
    } else {
        sh.do_search(function(err,res){
            // logger.log(err);
            // logger.log(res);
            callback(err, res);
        })
    }
}

SearchHandler.prototype.do_search = function(callback){
    var sh = this;

    var db = sh.api.ds;

    var path_validator = new FieldVal(null);
    for(var i = 0; i < sh.paths.length; i++){
        (function(i){
            var sh = this;

            var path;
            var path_error = validators.folder_path(sh.paths[i], function(emit_path){
                path = emit_path
            })
            logger.log(path_error);

            if(path_error){
                path_validator.invalid(i, path_error);
            } else {
                sh.path_permission_checker.check_permissions_for_path(path,function(status){
                    if(status===Constants.WRITE_PERMISSION || status===Constants.READ_PERMISSION){
                        //All good
                    } else {
                        path_validator.invalid(i, errors.NOT_FOUND_OR_NO_PERMISSION_TO_ACCESS);
                    }
                });
            }
        }).call(sh,i);
    }

    sh.path_permission_checker.retrieve_permissions(function(){

        var path_error = path_validator.end();
        if(path_error){
            sh.validator.invalid("paths", path_error);
            sh.callback(sh.validator.end());
            return;
        }

        if(sh.include_subfolders){
            var path_prefixes = [];
            for(var i = 0; i < sh.paths.length; i++){
                var path = sh.paths[i];

                path_prefixes.push({
                    "path":{
                        "$regex": "^"+path
                    }
                })
            }
            sh.mongo_query["$or"] = path_prefixes;
        } else {
            sh.mongo_query.path = {
                "$in": sh.paths
            };
        }

        var error;
        var results;
        var have_results;
        var count;
        var have_count;
        var done = function(){
            if(have_results && have_count){

                if(error){
                    callback(error);
                    return;
                }

                callback(null,{
                    objects: results,
                    total: count,
                    limit: sh.limit,
                    skip: sh.skip
                });
            }
        }

        var options = {
            skip: sh.skip,
            limit: sh.limit
        };

        if(sh.query_and.length>0){
            sh.mongo_query["$and"] = sh.query_and;
        }

        logger.log(JSON.stringify(sh.mongo_query,null,4));
        logger.log(options);

        var mongo_cursor = db.object_collection.find(sh.mongo_query,options);
        if (sh.sort) {
            mongo_cursor.sort(sh.sort);
        }
        mongo_cursor.toArray(function(search_err, search_res){
            logger.log(search_err, search_res);
            if(search_err){
                error = search_err;
            } else {
                results = search_res;
            }
            have_results = true;
            done();
        });

        var mongo_count_cursor = db.object_collection.find(sh.mongo_query);
        mongo_count_cursor.count(function(err, res_count){
            logger.log(err, res_count);
            if(err){
                error = err;
            } else {
                count = res_count;
            }
            have_count = true;
            done();
        })
    });
}

module.exports = SearchHandler;<|endoftext|>


<commit_before>var iox = (function () {
  var ret = {};
  function PostJSON(url, data, success) {
    $.ajax({
      url: url,
      type: 'POST',
      data: JSON.stringify(data),
      contentType: 'application/json',
      dataType: "json",
      success: success
    });
  }
  function EachList(url, loaded, f, after) {
    $.getJSON(url, function (data) {
      loaded();
      $.each(data, function (k, m) {
        f(m);
      });
      if (after)
        after();
    });
  }
  function ListAllModules(loaded, f, after) {
    EachList('available-modules', loaded, f, after);
  }
  function UpdateModulesList(relPath) {
    $("#ModulesDropDown .dynamic-menu-item").remove();
    var divider = $("#ModulesDropDown .divider");
    divider.before($('
Loading...
'));
    EachList(
      relPath + 'loaded-modules',
      function () {
        $("#ModulesDropDown .dynamic-menu-item").remove();
      },
      function (m) {
        divider.before($('
' + m.Name + '
'));
      }
    );
  }
  return {
    post_json: PostJSON,
    each_list: EachList,
    available_modules: ListAllModules,
    update_modules_list: UpdateModulesList,
  };
})();
<commit_msg>Used PostJSon instead of getJSon in EachList.<commit_after>var iox = (function () {
  var ret = {};
  function PostJSON(url, data, success) {
    $.ajax({
      url: url,
      type: 'POST',
      data: JSON.stringify(data),
      contentType: 'application/json',
      dataType: "json",
      success: success
    });
  }
  function EachList(url, loaded, f, after) {
    PostJSON(url, null, function (data) {
      loaded();
      $.each(data, function (k, m) {
        f(m);
      });
      if (after)
        after();
    });
  }
  function ListAllModules(loaded, f, after) {
    EachList('available-modules', loaded, f, after);
  }
  function UpdateModulesList(relPath) {
    $("#ModulesDropDown .dynamic-menu-item").remove();
    var divider = $("#ModulesDropDown .divider");
    divider.before($('
Loading...
'));
    EachList(
      relPath + 'loaded-modules',
      function () {
        $("#ModulesDropDown .dynamic-menu-item").remove();
      },
      function (m) {
        divider.before($('
' + m.Name + '
'));
      }
    );
  }
  return {
    post_json: PostJSON,
    each_list: EachList,
    available_modules: ListAllModules,
    update_modules_list: UpdateModulesList,
  };
})();
<|endoftext|>


<commit_before>function delegateService(e) {
    return ["$log", function(t) {
        function n(e) {
            this.handle = e
        }
        var a = this,
            o = this._instances = [];
        this._registerInstance = function(e, t) {
            return e.$$delegateHandle = t, o.push(e),
                function() {
                    var t = o.indexOf(e); - 1 !== t && o.splice(t, 1)
                }
        }, this.$getByHandle = function(e) {
            return e ? new n(e) : a
        }, e.forEach(function(e) {
            n.prototype[e] = function() {
                var n, a, r = this.handle,
                    l = arguments,
                    u = 0;
                return o.forEach(function(t) {
                    t.$$delegateHandle === r && (u++, a = t[e].apply(t, l), 1 === u && (n = a))
                }), u ? n : t.warn('Delegate for handle "' + this.handle + '" could not find a corresponding element with delegate-handle="' + this.handle + '"! ' + e + "() was not called!\nPossible cause: If you are calling " + e + '() immediately, and your element with delegate-handle="' + this.handle + '" is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to ' + e + "() and try again.")
            }, a[e] = function() {
                var t, n, a = arguments;
                return o.forEach(function(o, r) {
                    n = o[e].apply(o, a), 0 === r && (t = n)
                }), t
            }
        })
    }]
}
angular.module("pdf", []).service("pdfDelegate", delegateService(["prev", "next", "zoomIn", "zoomOut", "zoomTo", "rotate", "getPageCount", "getCurrentPage", "goToPage", "load"])), angular.module("pdf").controller("PdfCtrl", ["$scope", "$element", "$attrs", "pdfDelegate", "$log", "$q", function(e, t, n, a, o, r) {
    var l = a._registerInstance(this, n.delegateHandle);
    e.$on("$destroy", l);
    var u, i = this,
        c = e.$eval(n.url),
        d = e.$eval(n.headers);
    e.pageCount = 0;
    var g = 1,
        s = 0,
        f = n.scale ? n.scale : 1,
        p = t.find("canvas")[0],
        h = p.getContext("2d"),
        m = function(e) {
            angular.isNumber(e) || (e = parseInt(e)), u.getPage(e).then(function(e) {
                var t = e.getViewport(f);
                p.height = t.height, p.width = t.width;
                var n = {
                    canvasContext: h,
                    viewport: t
                };
                e.render(n)
            })
        },
        v = function() {
            p.style.webkitTransform = "rotate(" + s + "deg)", p.style.MozTransform = "rotate(" + s + "deg)", p.style.msTransform = "rotate(" + s + "deg)", p.style.OTransform = "rotate(" + s + "deg)", p.style.transform = "rotate(" + s + "deg)"
        };
    i.prev = function() {
        1 >= g || (g = parseInt(g, 10) - 1, m(g))
    }, i.next = function() {
        g >= u.numPages || (g = parseInt(g, 10) + 1, m(g))
    }, i.zoomIn = function(e) {
        return e = e || .2, f = parseFloat(f) + e, m(g), f
    }, i.zoomOut = function(e) {
        return e = e || .2, f = parseFloat(f) - e, f = f > 0 ? f : .1, m(g), f
    }, i.zoomTo = function(e) {
        return e = e ? e : 1, f = parseFloat(e), m(g), f
    }, i.rotate = function() {
        s = 0 === s ? 90 : 90 === s ? 180 : 180 === s ? 270 : 0, v()
    }, i.getPageCount = function() {
        return e.pageCount
    }, i.getCurrentPage = function() {
        return g
    }, i.goToPage = function(e) {
        null !== u && (g = e, m(e))
    }, i.load = function(t) {
        t && (c = t);
        var n = {};
        return "string" == typeof c ? n.url = c : n.data = c, d && (n.httpHeaders = d), PDFJS.getDocument(n).then(function(t) {
            u = t, m(1), e.$apply(function() {
                e.pageCount = t.numPages
            })
        }, function(e) {
            return o.error(e), r.reject(e)
        })
    }, c && i.load()
}]), angular.module("pdf").directive("pdfViewerToolbar", ["pdfDelegate", function(e) {
    return {
        restrict: "E",
        scope: {
            pageCount: "="
        },
        link: function(t, n, a) {
            var o = a.delegateHandle;
            t.currentPage = 1, t.prev = function() {
                e.$getByHandle(o).prev(), r()
            }, t.next = function() {
                e.$getByHandle(o).next(), r()
            }, t.zoomIn = function() {
                e.$getByHandle(o).zoomIn()
            }, t.zoomOut = function() {
                e.$getByHandle(o).zoomOut()
            }, t.rotate = function() {
                e.$getByHandle(o).rotate()
            }, t.goToPage = function() {
                e.$getByHandle(o).goToPage(t.currentPage)
            };
            var r = function() {
                t.currentPage = e.$getByHandle(o).getCurrentPage()
            }
        }
    }
}]), angular.module("pdf").directive("pdfViewer", ["$window", "$log", "pdfDelegate", function() {
    return {
        restrict: "E",
        template: '<pdf-viewer-toolbar ng-if="showToolbar" delegate-handle="{{id}}" page-count="pageCount"></pdf-viewer-toolbar><canvas></canvas>',
        scope: !0,
        controller: "PdfCtrl",
        link: function(e, t, n) {
            e.id = n.delegateHandle, e.showToolbar = e.$eval(n.showToolbar) || !1
        }
    }
}]);
<commit_msg>line spacing<commit_after>function delegateService(e) {
    return ["$log", function(t) {
        function n(e) {
            this.handle = e
        }
        var a = this,
            o = this._instances = [];
        this._registerInstance = function(e, t) {
            return e.$$delegateHandle = t, o.push(e),
                function() {
                    var t = o.indexOf(e); - 1 !== t && o.splice(t, 1)
                }
        }, this.$getByHandle = function(e) {
            return e ? new n(e) : a
        }, e.forEach(function(e) {
            n.prototype[e] = function() {
                var n, a, r = this.handle,
                    l = arguments,
                    u = 0;
                return o.forEach(function(t) {
                    t.$$delegateHandle === r && (u++, a = t[e].apply(t, l), 1 === u && (n = a))
                }), u ? n : t.warn('Delegate for handle "' + this.handle + '" could not find a corresponding element with delegate-handle="' + this.handle + '"! ' + e + "() was not called!\nPossible cause: If you are calling " + e + '() immediately, and your element with delegate-handle="' + this.handle + '" is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to ' + e + "() and try again.")
            }, a[e] = function() {
                var t, n, a = arguments;
                return o.forEach(function(o, r) {
                    n = o[e].apply(o, a), 0 === r && (t = n)
                }), t
            }
        })
    }]
}
angular.module("pdf", []).service("pdfDelegate", delegateService(["prev", "next", "zoomIn", "zoomOut", "zoomTo", "rotate", "getPageCount", "getCurrentPage", "goToPage", "load"])), angular.module("pdf").controller("PdfCtrl", ["$scope", "$element", "$attrs", "pdfDelegate", "$log", "$q", function(e, t, n, a, o, r) {
    var l = a._registerInstance(this, n.delegateHandle);
    e.$on("$destroy", l);
    var u, i = this,
        c = e.$eval(n.url),
        d = e.$eval(n.headers);
    e.pageCount = 0;
    var g = 1,
        s = 0,
        f = n.scale ? n.scale : 1,
        p = t.find("canvas")[0],
        h = p.getContext("2d"),
        m = function(e) {
            angular.isNumber(e) || (e = parseInt(e)), u.getPage(e).then(function(e) {
                var t = e.getViewport(f);
                p.height = t.height, p.width = t.width;
                var n = {
                    canvasContext: h,
                    viewport: t
                };
                e.render(n)
            })
        },
        v = function() {
            p.style.webkitTransform = "rotate(" + s + "deg)", p.style.MozTransform = "rotate(" + s + "deg)", p.style.msTransform = "rotate(" + s + "deg)", p.style.OTransform = "rotate(" + s + "deg)", p.style.transform = "rotate(" + s + "deg)"
        };
    i.prev = function() {
        1 >= g || (g = parseInt(g, 10) - 1, m(g))
    }, i.next = function() {
        g >= u.numPages || (g = parseInt(g, 10) + 1, m(g))
    }, i.zoomIn = function(e) {
        return e = e || .2, f = parseFloat(f) + e, m(g), f
    }, i.zoomOut = function(e) {
        return e = e || .2, f = parseFloat(f) - e, f = f > 0 ? f : .1, m(g), f
    }, i.zoomTo = function(e) {
        return e = e ? e : 1, f = parseFloat(e), m(g), f
    }, i.rotate = function() {
        s = 0 === s ? 90 : 90 === s ? 180 : 180 === s ? 270 : 0, v()
    }, i.getPageCount = function() {
        return e.pageCount
    }, i.getCurrentPage = function() {
        return g
    }, i.goToPage = function(e) {
        null !== u && (g = e, m(e))
    }, i.load = function(t) {
        t && (c = t);
        var n = {};
        return "string" == typeof c ? n.url = c : n.data = c, d && (n.httpHeaders = d), PDFJS.getDocument(n).then(function(t) {
            u = t, m(1), e.$apply(function() {
                e.pageCount = t.numPages
            })
        }, function(e) {
            return o.error(e), r.reject(e)
        })
    }, c && i.load()
}]), angular.module("pdf").directive("pdfViewerToolbar", ["pdfDelegate", function(e) {
    return {
        restrict: "E",
        template: '

Page <input type="text" class="field-dark" min=1 ng-model="currentPage" ng-change="goToPage()" style="width: 10%">  / {{pageCount}}

',
        scope: {
            pageCount: "="
        },
        link: function(t, n, a) {
            var o = a.delegateHandle;
            t.currentPage = 1, t.prev = function() {
                e.$getByHandle(o).prev(), r()
            }, t.next = function() {
                e.$getByHandle(o).next(), r()
            }, t.zoomIn = function() {
                e.$getByHandle(o).zoomIn()
            }, t.zoomOut = function() {
                e.$getByHandle(o).zoomOut()
            }, t.rotate = function() {
                e.$getByHandle(o).rotate()
            }, t.goToPage = function() {
                e.$getByHandle(o).goToPage(t.currentPage)
            };
            var r = function() {
                t.currentPage = e.$getByHandle(o).getCurrentPage()
            }
        }
    }
}]), angular.module("pdf").directive("pdfViewer", ["$window", "$log", "pdfDelegate", function() {
    return {
        restrict: "E",
        template: '<pdf-viewer-toolbar ng-if="showToolbar" delegate-handle="{{id}}" page-count="pageCount"></pdf-viewer-toolbar><canvas></canvas>',
        scope: !0,
        controller: "PdfCtrl",
        link: function(e, t, n) {
            e.id = n.delegateHandle, e.showToolbar = e.$eval(n.showToolbar) || !1
        }
    }
}]);<|endoftext|>


<commit_before>import templateUrl from 'single.html';

export default function routes ($stateProvider, $urlMatcherFactoryProvider) {
  'ngInject';
  $urlMatcherFactoryProvider.strictMode(false);
  $stateProvider
    .state('single', {
      url: '/:name',
      templateUrl: templateUrl,
      controller: 'SingleController',
      controllerAs: '$ctrl',
      bindToController: true
    });
}<commit_msg>Updating single routes<commit_after>import templateUrl from 'single.html';

export default function routes ($stateProvider, $urlMatcherFactoryProvider) {
  'ngInject';
  $urlMatcherFactoryProvider.strictMode(false);
  $stateProvider
    .state('single', {
      url: '/:type/:name',
      templateUrl: templateUrl,
      params: {id: null},
      controller: 'SingleController',
      controllerAs: '$ctrl',
      bindToController: true
    });
}<|endoftext|>


<commit_before>import React, {Component} from 'react';
import { withStyles } from 'material-ui/styles';
import axios from 'axios';
import moment from 'moment';
import { DatePicker } from 'material-ui-pickers';
import Drawer from 'material-ui/Drawer';
import Typography from 'material-ui/Typography';
import TextField from 'material-ui/TextField';
import InfiniteScroll from 'react-infinite-scroller';

import CustomProgress from '../CustomProgress/CustomProgress.js';
import EntryWidget from '../EntryWidget/EntryWidget.js';

axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.xsrfHeaderName = 'X-CSRFToken';

const styles = theme => ({
  root: {
    margin: '25px auto 50px',
    width: '100%',
    maxWidth: 720,
    backgroundColor: theme.palette.background.paper,
  },
  drawerPaper: {
    width: 240,
  },
  datePicker: {
    margin: '10px',
  },
  textField: {
    margin: '10px',
    display: 'flex',
  },
});

class HistoryView extends Component {
  constructor(props) {
    super(props);
    this.state = {
      error: null,
      isLoaded: false,
      categories: [],
      qualityRatings: [],
      entries: [],
      moreEntriesUrl: null,
      entriesCount: null,
      queryParams: {
        date_start: moment(),
        date_end: moment(),
        category: "",
        quality_rating: "",
        entry: "",
      },
    };
    this.getCategoryName = this.getCategoryName.bind(this);
    this.loadMoreEntries = this.loadMoreEntries.bind(this);
    this.handleQueryChange = this.handleQueryChange.bind(this);
    this.composeFilterUrl = this.composeFilterUrl.bind(this);
    this.getFilteredEntries = this.getFilteredEntries.bind(this);

    this.timeout = 0;
  }

  componentDidMount() {
    axios.get('/api/entries/')
      .then(
        (response) => {
          let oldestEntry = response.data.results[0];
          let qPs = {...this.state.queryParams};
          qPs.date_start = moment(oldestEntry.date);
          this.setState({
            entries: response.data.results,
            moreEntriesUrl: response.data.next,
            entriesCount: response.data.count,
            queryParams: qPs
          });
          return axios.get('/api/categories/')
        }
      )
      .then(
        (response) => {
          this.setState({
            categories: response.data
          });
          return axios.get('/api/quality-ratings/')
        }
      )
      .then(
        (response) => {
          this.setState({
            isLoaded: true, // Need for the widgets.
            qualityRatings: response.data
          });
        }
      )
      .catch(
        (error) => {
          this.setState({
            isLoaded: true,
            error
          });
        }
      );
  }

  //TODO deal with filters.
  loadMoreEntries() {
    axios.get(this.state.moreEntriesUrl)
      .then(
        (response) => {
          this.setState((prevState) => {
            return {
              entries: prevState.entries.concat(response.data.results),
              moreEntriesUrl: response.data.next,
            };
          });
        },
        (error) => {
          this.setState({
            isLoaded: true,
            error
          });
        }
      );
  }

  /*
   * For EntryWidget. We don't update category in PATCH, so we just need the
   * name, not the pk.
   * Also using in composeFilterUrl.
  */
  getCategoryName(pk) {
    let categoryObject = this.state.categories.find(category => category.pk === pk);
    return categoryObject.category
  }

/*
 * For axios calls when filtering. Pass the qPs object, not this.state,
 * b/c state will not have updated yet to match qPs.
*/
  composeFilterUrl(queryParams) {
    let qPs = {...queryParams};
    let dateKeys = ['date_start', 'date_end'];

    let base = '/api/entries/';
    let queryString = '?';
    for (let k in qPs) {
      if (dateKeys.includes(k)) {
        qPs[k] = qPs[k].format('YYYY-MM-DD'); // Date states are never falsy
      }
      if (k === 'category' && qPs[k]) {
        qPs[k] = this.getCategoryName(Number(qPs[k]));
      }

      queryString += k + "=" + qPs[k] + "&";
    }
    queryString = queryString.slice(0, -1);
    let url = base + queryString;
    return url;
  }

  getFilteredEntries(url) {
    axios.get(url)
      .then(
        (response) => {
          this.setState({
            entries: response.data.results,
            moreEntriesUrl: response.data.next,
            entriesCount: response.data.count,
          });
        },
        (error) => {
          this.setState({
            isLoaded: true,
            error
          });
        }
      );
  }

/*
 *  Partially applied method for controlled component updating.
 */
  handleQueryChange(field) {
    return (e) => {
      let qPs = {...this.state.queryParams};
      qPs[field] = e.target ? e.target.value : e; // if its just e, it's a date.
      this.setState({
        queryParams: qPs
      });
      let filterUrl = this.composeFilterUrl(qPs);

      if (field === 'entry') {
        if (this.timeout) {
          clearTimeout(this.timeout);
        }
        this.timeout = setTimeout(() => {
          this.getFilteredEntries(filterUrl);
        }, 300);
      } else {
        this.getFilteredEntries(filterUrl);
      }
    }
  }

  render() {
    const { error, isLoaded, entries, qualityRatings } = this.state;
    if (error) {
      return
Error: {error.message}
;
    } else if (!isLoaded) {
      return (

          <CustomProgress />

      );
    } else {
      let entryWidgets = entries.map(datum =>
        <EntryWidget
          key={datum.url}
          url={datum.url}
          date={datum.date}
          category={this.getCategoryName(datum.category)}
          rating={datum.quality_rating}
          entry={datum.entry}
          qualityRatings={qualityRatings}
          handleDelete={this.handleDelete}
          handleSave={this.handleUpdate}
        />
      );
      return (
        <React.Fragment>
          <Drawer
            variant='permanent'
            classes={{
              paper: this.props.classes.drawerPaper,
            }}
          >
            {'Hello'}
            <DatePicker
              className={this.props.classes.datePicker}
              value={this.state.queryParams.date_start}
              onChange={this.handleQueryChange("date_start")}
              disableFuture={true}
              keyboard
              label="Choose a start date"
            />
            <DatePicker
              className={this.props.classes.datePicker}
              value={this.state.queryParams.date_end}
              onChange={this.handleQueryChange("date_end")}
              disableFuture={true}
              keyboard
              label="Choose a end date"
            />
            <TextField
              id="select-category"
              select
              label="Category"
              className={this.props.classes.textField}
              value={this.state.queryParams.category}
              onChange={this.handleQueryChange("category")}
              SelectProps={{
                native: true,
              }}
              margin="normal"
            >
              <option key={"0"} value={""} />
              {this.state.categories.map(category => (
                <option key={category.pk} value={category.pk}>
                  {category.category}
                </option>
              ))}
            </TextField>
            <TextField
              id="select-rating"
              select
              label="Rating"
              className={this.props.classes.textField}
              value={this.state.queryParams.quality_rating}
              onChange={this.handleQueryChange("quality_rating")}
              SelectProps={{
                native: true,
              }}
              margin="normal"
            >
              <option key={"0"} value={""} />
              {this.state.qualityRatings.map(rating => (
                <option key={rating} value={rating}>
                  {rating}
                </option>
              ))}
            </TextField>
            <TextField
              id="filter-entries"
              label="Entry Text Contains"
              className={this.props.classes.textField}
              value={this.state.queryParams.entry}
              onChange={this.handleQueryChange("entry")}
              margin="normal"
              multiline
            >
            </TextField>
          </Drawer>

          <InfiniteScroll
            hasMore={this.state.moreEntriesUrl ? true : false}
            loader={<CustomProgress />}
            initialLoad={false}
            loadMore={this.loadMoreEntries}
          >

              {entryWidgets}

          </InfiniteScroll>
        </React.Fragment>
      )
    }
  }

}

export default withStyles(styles)(HistoryView);
<commit_msg>I think I fixed the glitch<commit_after>import React, {Component} from 'react';
import { withStyles } from 'material-ui/styles';
import axios from 'axios';
import moment from 'moment';
import { DatePicker } from 'material-ui-pickers';
import Drawer from 'material-ui/Drawer';
import Typography from 'material-ui/Typography';
import TextField from 'material-ui/TextField';
import InfiniteScroll from 'react-infinite-scroller';

import CustomProgress from '../CustomProgress/CustomProgress.js';
import EntryWidget from '../EntryWidget/EntryWidget.js';

axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.xsrfHeaderName = 'X-CSRFToken';

const styles = theme => ({
  root: {
    margin: '25px auto 50px',
    width: '100%',
    maxWidth: 720,
    backgroundColor: theme.palette.background.paper,
  },
  drawerPaper: {
    width: 240,
  },
  datePicker: {
    margin: '10px',
  },
  textField: {
    margin: '10px',
    display: 'flex',
  },
});

class HistoryView extends Component {
  constructor(props) {
    super(props);
    this.state = {
      error: null,
      isLoaded: false,
      categories: [],
      qualityRatings: [],
      entries: [],
      moreEntriesUrl: null,
      entriesCount: null,
      queryParams: {
        date_start: null,
        date_end: null,
        category: "",
        quality_rating: "",
        entry: "",
      },
    };
    this.getCategoryName = this.getCategoryName.bind(this);
    this.loadMoreEntries = this.loadMoreEntries.bind(this);
    this.handleQueryChange = this.handleQueryChange.bind(this);
    this.composeFilterUrl = this.composeFilterUrl.bind(this);
    this.getFilteredEntries = this.getFilteredEntries.bind(this);

    this.timeout = 0;
  }

  componentDidMount() {
    axios.get('/api/entries/')
      .then(
        (response) => {
          // let oldestEntry = response.data.results[0];
          // let qPs = {...this.state.queryParams};
          // qPs.date_start = moment(oldestEntry.date);
          this.setState({
            entries: response.data.results,
            moreEntriesUrl: response.data.next,
            entriesCount: response.data.count,
            // queryParams: qPs
          });
          return axios.get('/api/categories/')
        }
      )
      .then(
        (response) => {
          this.setState({
            categories: response.data
          });
          return axios.get('/api/quality-ratings/')
        }
      )
      .then(
        (response) => {
          this.setState({
            isLoaded: true, // Need for the widgets.
            qualityRatings: response.data
          });
        }
      )
      .catch(
        (error) => {
          this.setState({
            isLoaded: true,
            error
          });
        }
      );
  }

  //TODO deal with filters.
  loadMoreEntries() {
    if (this.state.moreEntriesUrl) {
      axios.get(this.state.moreEntriesUrl)
        .then(
          (response) => {
            this.setState((prevState) => {
              return {
                entries: prevState.entries.concat(response.data.results),
                moreEntriesUrl: response.data.next,
              };
            });
          },
          (error) => {
            console.log(error);
            this.setState({
              isLoaded: true,
              error
            });
          }
        );
    }
  }

  /*
   * For EntryWidget. We don't update category in PATCH, so we just need the
   * name, not the pk.
   * Also using in composeFilterUrl.
  */
  getCategoryName(pk) {
    let categoryObject = this.state.categories.find(category => category.pk === pk);
    return categoryObject.category
  }

/*
 * For axios calls when filtering. Pass the qPs object, not this.state,
 * b/c state will not have updated yet to match qPs.
*/
  composeFilterUrl(queryParams) {
    let qPs = {...queryParams};
    let dateKeys = ['date_start', 'date_end'];

    let base = '/api/entries/';
    let queryString = '?';
    for (let k in qPs) {
      if (dateKeys.includes(k)) {
        if (qPs[k]) {
          qPs[k] = qPs[k].format('YYYY-MM-DD'); // Date states are never falsy
        } else {
          qPs[k] = ""
        }
      }
      if (k === 'category' && qPs[k]) {
        qPs[k] = this.getCategoryName(Number(qPs[k]));
      }

      queryString += k + "=" + qPs[k] + "&";
    }
    queryString = queryString.slice(0, -1);
    let url = base + queryString;
    return url;
  }

  getFilteredEntries(url) {
    axios.get(url)
      .then(
        (response) => {
          this.setState({
            entries: response.data.results,
            moreEntriesUrl: response.data.next,
            entriesCount: response.data.count,
          });
        },
        (error) => {
          this.setState({
            isLoaded: true,
            error
          });
        }
      );
  }

/*
 *  Partially applied method for controlled component updating.
 */
  handleQueryChange(field) {
    return (e) => {
      let qPs = {...this.state.queryParams};
      qPs[field] = e.target ? e.target.value : e; // if its just e, it's a date.
      this.setState({
        queryParams: qPs
      });
      let filterUrl = this.composeFilterUrl(qPs);

      if (field === 'entry') {
        if (this.timeout) {
          clearTimeout(this.timeout);
        }
        this.timeout = setTimeout(() => {
          this.getFilteredEntries(filterUrl);
        }, 300);
      } else {
        this.getFilteredEntries(filterUrl);
      }
    }
  }

  render() {
    const { error, isLoaded, entries, qualityRatings } = this.state;
    if (error) {
      return
Error: {error.message}
;
    } else if (!isLoaded) {
      return (

          <CustomProgress />

      );
    } else {
      let entryWidgets = entries.map(datum =>
        <EntryWidget
          key={datum.url}
          url={datum.url}
          date={datum.date}
          category={this.getCategoryName(datum.category)}
          rating={datum.quality_rating}
          entry={datum.entry}
          qualityRatings={qualityRatings}
          handleDelete={this.handleDelete}
          handleSave={this.handleUpdate}
        />
      );
      return (
        <React.Fragment>
          <Drawer
            variant='permanent'
            classes={{
              paper: this.props.classes.drawerPaper,
            }}
          >
            {'Hello'}
            <DatePicker
              className={this.props.classes.datePicker}
              value={this.state.queryParams.date_start}
              onChange={this.handleQueryChange("date_start")}
              disableFuture={true}
              keyboard
              label="Choose a start date"
            />
            <DatePicker
              className={this.props.classes.datePicker}
              value={this.state.queryParams.date_end}
              onChange={this.handleQueryChange("date_end")}
              disableFuture={true}
              keyboard
              label="Choose a end date"
            />
            <TextField
              id="select-category"
              select
              label="Category"
              className={this.props.classes.textField}
              value={this.state.queryParams.category}
              onChange={this.handleQueryChange("category")}
              SelectProps={{
                native: true,
              }}
              margin="normal"
            >
              <option key={"0"} value={""} />
              {this.state.categories.map(category => (
                <option key={category.pk} value={category.pk}>
                  {category.category}
                </option>
              ))}
            </TextField>
            <TextField
              id="select-rating"
              select
              label="Rating"
              className={this.props.classes.textField}
              value={this.state.queryParams.quality_rating}
              onChange={this.handleQueryChange("quality_rating")}
              SelectProps={{
                native: true,
              }}
              margin="normal"
            >
              <option key={"0"} value={""} />
              {this.state.qualityRatings.map(rating => (
                <option key={rating} value={rating}>
                  {rating}
                </option>
              ))}
            </TextField>
            <TextField
              id="filter-entries"
              label="Entry Text Contains"
              className={this.props.classes.textField}
              value={this.state.queryParams.entry}
              onChange={this.handleQueryChange("entry")}
              margin="normal"
              multiline
            >
            </TextField>
          </Drawer>

          <InfiniteScroll
            hasMore={this.state.moreEntriesUrl ? true : false}
            loader={<CustomProgress />}
            initialLoad={false}
            loadMore={this.loadMoreEntries}
          >

              {entryWidgets}

          </InfiniteScroll>
        </React.Fragment>
      )
    }
  }

}

export default withStyles(styles)(HistoryView);
<|endoftext|>