<commit_before>var canvasElement = document.querySelector('canvas');

var canvas = {
	element: canvasElement,
	context: canvasElement.getContext('2d'),
	backgroundStyle: "#000",
};

var burst = new Image();
burst.src = './img/rays.png';

var wayne = new Image();
wayne.src = './img/wayne.png'

var delphiLogo = new Image();
delphiLogo.src = './img/delphi.png';

var delphiLogos = [];
for(var i =0; i<5; i++){
	delphiLogos.push({scale:Math.random()*100, y: Math.random()*canvas.element.clientHeight-1000, x:Math.random()*canvas.element.clientWidth});
}

var miracle = new Audio('./audio/music.ogg');
miracle.addEventListener('ended', function(){
	this.currentTime = 0;
	this.play();
}, false);
miracle.play();

var mouse = {clientOffset:{}};

onscroll = function(){
	canvas.clientRect = canvas.element.getClientRects()[0];
	mouse.clientOffset.x = canvas.clientRect.left+canvas.origin.x;
	mouse.clientOffset.y = canvas.clientRect.top+canvas.origin.y;
};

(onresize = function(){
	canvas.element.width = canvas.element.clientWidth;
	canvas.element.height = canvas.element.clientHeight;
	canvas.origin = {
		x:Math.floor(canvas.element.width/2),
		y:Math.floor(canvas.element.height/2)
	};
	canvas.origin.distance = {
		top:-canvas.origin.y,
		bottom:canvas.element.height-canvas.origin.y,
		left:-canvas.origin.x,
		right:canvas.element.width-canvas.origin.x
	};
	onscroll();
})();

onmousemove = function(e){
	mouse.x = e.clientX-mouse.clientOffset.x;
	mouse.y = e.clientY-mouse.clientOffset.y;
};

var currentRot = 0;

var wayneObject = {
	x:-250,
	y:canvas.element.clientHeight*2,
	scale: 0
}

function increaseWayne(){
	if(wayneObject.scale < 1.25){
		wayneObject.scale += 0.0005;
	}
}

var waynesAdded = 0;
var lastWayne = 0;
function raiseWayne(){
	if(wayneObject.y<(canvas.element.height/2)+800){
		stageFunc = increaseWayne;
	}
	wayneObject.y-=1;

	if(lastWayne == 0 && waynesAdded < 100){
		delphiLogos.push({scale:Math.random()*100, y: Math.random(), x:Math.random()*canvas.element.clientWidth});
		waynesAdded++;
	}
	lastWayne++;
	if(lastWayne>5) lastWayne = 0;

}

function startWayne(){
	if(wayneObject.scale>1) stageFunc = raiseWayne;
	wayneObject.scale+=0.004;
}
var stageFunc = startWayne;

requestAnimationFrame(loop = function(){
	var origin = canvas.origin,
	ctx = canvas.context,
	width = canvas.element.width,
	height = canvas.element.height;
	ctx.setTransform(1,0,0,1,0,0);
	ctx.fillStyle = canvas.backgroundStyle;
	ctx.fillRect(0,0,width,height);
	ctx.translate(origin.x,origin.y);

	ctx.save();
		ctx.rotate(currentRot*wayneObject.scale*1.2);

		if(width<height){
			ctx.drawImage(burst, -origin.y*1.5, -origin.y*1.5, height*1.5, height*1.5);
		}
		else{
			ctx.drawImage(burst, -origin.x*1.5, -origin.x*1.5, width*1.5, width*1.5);
		}

		currentRot = currentRot + 0.005;
	ctx.restore();

	for(var i=0; i<delphiLogos.length;i++){
		delphiLogos[i].y += .05*delphiLogos[i].scale;
		ctx.drawImage(delphiLogo, -origin.x + delphiLogos[i].x + Math.sin((delphiLogos[i].y*height)/100000)*100, -origin.y+(delphiLogos[i].y%(canvas.element.height+(600))-500), delphiLogos[i].scale, delphiLogos[i].scale);
	}

	ctx.drawImage(wayne, -((500*wayneObject.scale)/2), wayneObject.y-((700*wayneObject.scale))-700, 500*wayneObject.scale, 700*wayneObject.scale);
	stageFunc();

	requestAnimationFrame(loop);
});
<commit_msg>Update main.js<commit_after>var canvasElement = document.querySelector('canvas');

var canvas = {
	element: canvasElement,
	context: canvasElement.getContext('2d'),
	backgroundStyle: "#000",
};

var burst = new Image();
burst.src = '/WaynesWorld/img/rays.png';

var wayne = new Image();
wayne.src = '/WaynesWorld/img/wayne.png'

var delphiLogo = new Image();
delphiLogo.src = '/WaynesWorld/img/delphi.png';

var delphiLogos = [];
for(var i =0; i<5; i++){
	delphiLogos.push({scale:Math.random()*100, y: Math.random()*canvas.element.clientHeight-1000, x:Math.random()*canvas.element.clientWidth});
}

var miracle = new Audio('/WaynesWorld/audio/music.ogg');
miracle.addEventListener('ended', function(){
	this.currentTime = 0;
	this.play();
}, false);
miracle.play();

var mouse = {clientOffset:{}};

onscroll = function(){
	canvas.clientRect = canvas.element.getClientRects()[0];
	mouse.clientOffset.x = canvas.clientRect.left+canvas.origin.x;
	mouse.clientOffset.y = canvas.clientRect.top+canvas.origin.y;
};

(onresize = function(){
	canvas.element.width = canvas.element.clientWidth;
	canvas.element.height = canvas.element.clientHeight;
	canvas.origin = {
		x:Math.floor(canvas.element.width/2),
		y:Math.floor(canvas.element.height/2)
	};
	canvas.origin.distance = {
		top:-canvas.origin.y,
		bottom:canvas.element.height-canvas.origin.y,
		left:-canvas.origin.x,
		right:canvas.element.width-canvas.origin.x
	};
	onscroll();
})();

onmousemove = function(e){
	mouse.x = e.clientX-mouse.clientOffset.x;
	mouse.y = e.clientY-mouse.clientOffset.y;
};

var currentRot = 0;

var wayneObject = {
	x:-250,
	y:canvas.element.clientHeight*2,
	scale: 0
}

function increaseWayne(){
	if(wayneObject.scale < 1.25){
		wayneObject.scale += 0.0005;
	}
}

var waynesAdded = 0;
var lastWayne = 0;
function raiseWayne(){
	if(wayneObject.y<(canvas.element.height/2)+800){
		stageFunc = increaseWayne;
	}
	wayneObject.y-=1;

	if(lastWayne == 0 && waynesAdded < 100){
		delphiLogos.push({scale:Math.random()*100, y: Math.random(), x:Math.random()*canvas.element.clientWidth});
		waynesAdded++;
	}
	lastWayne++;
	if(lastWayne>5) lastWayne = 0;

}

function startWayne(){
	if(wayneObject.scale>1) stageFunc = raiseWayne;
	wayneObject.scale+=0.004;
}
var stageFunc = startWayne;

requestAnimationFrame(loop = function(){
	var origin = canvas.origin,
	ctx = canvas.context,
	width = canvas.element.width,
	height = canvas.element.height;
	ctx.setTransform(1,0,0,1,0,0);
	ctx.fillStyle = canvas.backgroundStyle;
	ctx.fillRect(0,0,width,height);
	ctx.translate(origin.x,origin.y);

	ctx.save();
		ctx.rotate(currentRot*wayneObject.scale*1.2);

		if(width<height){
			ctx.drawImage(burst, -origin.y*1.5, -origin.y*1.5, height*1.5, height*1.5);
		}
		else{
			ctx.drawImage(burst, -origin.x*1.5, -origin.x*1.5, width*1.5, width*1.5);
		}

		currentRot = currentRot + 0.005;
	ctx.restore();

	for(var i=0; i<delphiLogos.length;i++){
		delphiLogos[i].y += .05*delphiLogos[i].scale;
		ctx.drawImage(delphiLogo, -origin.x + delphiLogos[i].x + Math.sin((delphiLogos[i].y*height)/100000)*100, -origin.y+(delphiLogos[i].y%(canvas.element.height+(600))-500), delphiLogos[i].scale, delphiLogos[i].scale);
	}

	ctx.drawImage(wayne, -((500*wayneObject.scale)/2), wayneObject.y-((700*wayneObject.scale))-700, 500*wayneObject.scale, 700*wayneObject.scale);
	stageFunc();

	requestAnimationFrame(loop);
});
<|endoftext|>


<commit_before>"use strict";

document.addEventListener('DOMContentLoaded', function() {
	var options = {
	  name: 'dagre',
      nodeSep: 3,
	  edgeSep: 5,
	  minLen: function( edge ){ return 1; },
	  edgeWeight: function( edge ){ return 2; },
	  fit: true,
	  spacingFactor: 1.1,
	  nodeDimensionsIncludeLabels: true
	};

	var nodeInfo = getModelData();
	nodeInfo.then(function(modelData) {
		setTitle(modelData['title']);

		var nodesArray = modelData['cy_data'];
		var cy = window.cy = cytoscape({
			container: document.getElementById('cy'),
		    elements: nodesArray,
		    layout: options,
		    style: [
			{
			    selector: "node",
			    style: {
			        shape: 'roundrectangle',
			        label: 'data(name)',
                    'font-size' : 30,
			        'border-width': 3,
                    'border-color': 'black',
			        width: 'label',
			        'color': '#000000',
			        'text-valign': 'center',
					'background-image': 'icons/node.png',
			        padding: 10,
		    	}
		    },
			{
			    selector: "node.parent",
			    style: {
					'compound-sizing-wrt-labels': 'include',
                    'background-image' : 'icons/parent.png',
                    'text-rotation' : '90deg',
                    'text-margin-x' : 10
		    	}
		    },
            {
			    selector: "node.parent > node",
			    style: {
			        opacity : 0
		    	}
		    },
            {
			    selector: "node.arrayFeatureExtractor",
			    style: {
					'background-image': 'icons/arrayFeatureExtractor.png'
		    	}
		    },
            {
			    selector: "node.categoricalMapping",
			    style: {
					'background-image': 'icons/categoricalMapping.png'
		    	}
		    },
            {
			    selector: "node.dictVectorizer",
			    style: {
					'background-image': 'icons/dictVectorizer.png'
		    	}
		    },
			{
			    selector: "node.custom",
			    style: {
					'background-image': 'icons/custom.png'
		    	}
		    },
            {
			    selector: "node.featureVectorizer",
			    style: {
					'background-image': 'icons/featureVectorizer.png'
		    	}
		    },
            {
			    selector: "node.glmClassifier",
			    style: {
					'background-image': 'icons/glmClassifier.png'
		    	}
		    },
            {
			    selector: "node.glmRegressor",
			    style: {
					'background-image': 'icons/glmRegressor.png'
		    	}
		    },
            {
			    selector: "node.identity",
			    style: {
					'background-image': 'icons/identity.png'
		    	}
		    },
            {
			    selector: "node.imputer",
			    style: {
					'background-image': 'icons/imputer.png'
		    	}
		    },
            {
			    selector: "node.neuralNetwork",
			    style: {
					'background-image': 'icons/neuralNetwork.png'
		    	}
		    },
            {
			    selector: "node.neuralNetworkClassifier",
			    style: {
					'background-image': 'icons/neuralNetworkClassifier.png'
		    	}
		    },
            {
			    selector: "node.neuralNetworkRegressor",
			    style: {
					'background-image': 'icons/neuralNetworkRegressor.png'
		    	}
		    },
            {
			    selector: "node.normalizer",
			    style: {
					'background-image': 'icons/normalizer.png'
		    	}
		    },
            {
			    selector: "node.oneHotEncoder",
			    style: {
					'background-image': 'icons/oneHotEncoder.png'
		    	}
		    },
            {
			    selector: "node.scaler",
			    style: {
					'background-image': 'icons/scaler.png'
		    	}
		    },
            {
			    selector: "node.supportVectorClassifier",
			    style: {
					'background-image': 'icons/supportVectorClassifier.png'
		    	}
		    },
            {
			    selector: "node.supportVectorRegressor",
			    style: {
					'background-image': 'icons/supportVectorRegressor.png'
		    	}
		    },
            {
			    selector: "node.treeEnsembleClassifier",
			    style: {
					'background-image': 'icons/treeEnsembleClassifier.png'
		    	}
		    },
            {
			    selector: "node.treeEnsembleRegressor",
			    style: {
					'background-image': 'icons/treeEnsembleRegressor.png'
		    	}
		    },
            {
			    selector: "node.convolution",
			    style: {
					'color': 'white',
					'background-image': 'icons/convolution.png'
		    	}
		    },
			{
			    selector: "node.deconvolution",
			    style: {
					'color': 'white',
					'background-image': 'icons/convolution.png'
		    	}
		    },
		    {
			    selector: "node.pooling",
			    style: {
					'color': 'white',
					'background-image': 'icons/pooling.png'
		    	}
		    },
		    {
			    selector: "node.activation",
			    style: {
					'background-image': 'icons/activation.png'
		    	}
		    },
            {
			    selector: "node.add",
			    style: {
					'background-image': 'icons/add.png'
		    	}
		    },
            {
			    selector: "node.average",
			    style: {
					'background-image': 'icons/average.png'
		    	}
		    },
            {
			    selector: "node.batchnorm",
			    style: {
					'background-image': 'icons/batchnorm.png'
		    	}
		    },
            {
			    selector: "node.biDirectionalLSTM",
			    style: {
					'background-image': 'icons/biDirectionalLSTM.png'
		    	}
		    },
            {
			    selector: "node.bias",
			    style: {
					'background-image': 'icons/bias.png'
		    	}
		    },
            {
			    selector: "node.concat",
			    style: {
					'background-image': 'icons/concat.png'
		    	}
		    },
            {
			    selector: "node.crop",
			    style: {
					'background-image': 'icons/crop.png'
		    	}
		    },
            {
			    selector: "node.dot",
			    style: {
					'background-image': 'icons/dot.png'
		    	}
		    },
            {
			    selector: "node.embedding",
			    style: {
					'background-image': 'icons/embedding.png'
		    	}
		    },
            {
			    selector: "node.flatten",
			    style: {
					'background-image': 'icons/flatten.png'
		    	}
		    },
            {
			    selector: "node.gru",
			    style: {
					'background-image': 'icons/gru.png'
		    	}
		    },
            {
			    selector: "node.innerProduct",
			    style: {
					'background-image': 'icons/innerProduct.png'
		    	}
		    },
            {
			    selector: "node.input",
			    style: {
					'background-image': 'icons/input.png'
		    	}
		    },
            {
			    selector: "node.output",
			    style: {
					'background-image': 'icons/output.png'
		    	}
		    },
            {
			    selector: "node.l2normalize",
			    style: {
					'background-image': 'icons/l2normalize.png'
		    	}
		    },
            {
			    selector: "node.loadConstant",
			    style: {
					'background-image': 'icons/loadConstant.png'
		    	}
		    },
            {
			    selector: "node.lrn",
			    style: {
					'background-image': 'icons/lrn.png'
		    	}
		    },
            {
			    selector: "node.max",
			    style: {
					'background-image': 'icons/max.png'
		    	}
		    },
            {
			    selector: "node.min",
			    style: {
					'background-image': 'icons/min.png'
		    	}
		    },
            {
			    selector: "node.multiply",
			    style: {
					'background-image': 'icons/multiply.png'
		    	}
		    },
            {
			    selector: "node.mvn",
			    style: {
					'background-image': 'icons/mvn.png'
		    	}
		    },
            {
			    selector: "node.padding",
			    style: {
					'background-image': 'icons/padding.png'
		    	}
		    },
            {
			    selector: "node.permute",
			    style: {
					'background-image': 'icons/permute.png'
		    	}
		    },
            {
			    selector: "node.pooling",
			    style: {
					'background-image': 'icons/pooling.png'
		    	}
		    },
            {
			    selector: "node.reduce",
			    style: {
					'background-image': 'icons/reduce.png'
		    	}
		    },
            {
			    selector: "node.reorganizeData",
			    style: {
					'background-image': 'icons/reorganizeData.png'
		    	}
		    },
            {
			    selector: "node.reshape",
			    style: {
					'background-image': 'icons/reshape.png'
		    	}
		    },
            {
			    selector: "node.scale",
			    style: {
					'background-image': 'icons/scale.png'
		    	}
		    },
            {
			    selector: "node.sequenceRepeat",
			    style: {
					'background-image': 'icons/sequenceRepeat.png'
		    	}
		    },
            {
			    selector: "node.simpleRecurrent",
			    style: {
					'background-image': 'icons/simpleRecurrent.png'
		    	}
		    },
            {
			    selector: "node.slice",
			    style: {
					'background-image': 'icons/slice.png'
		    	}
		    },
            {
			    selector: "node.softmax",
			    style: {
					'background-image': 'icons/softmax.png'
		    	}
		    },
            {
			    selector: "node.split",
			    style: {
					'background-image': 'icons/split.png'
		    	}
		    },
            {
			    selector: "node.unary",
			    style: {
					'background-image': 'icons/unary.png'
		    	}
		    },
            {
			    selector: "node.uniDirectionalLSTM",
			    style: {
					'background-image': 'icons/uniDirectionalLSTM.png'
		    	}
		    },
            {
			    selector: "node.upsample",
			    style: {
					'background-image': 'icons/upsample.png'
		    	}
		    },
		    {
		    	selector: "edge",
		    	style: {
		    		'curve-style': 'bezier',
		    		'control-point-weights': 1,
		    		'line-color': '#111111',
					'color' : '#000000',
					'border-width': 5,
					'font-size': 20,
		    		'target-arrow-shape': 'triangle',
		    		'target-arrow-color': '#111111',
					 label: 'data(label)',
					'text-background-opacity': 0,
					'text-background-color': '#ffffff',
					'text-background-shape': 'rectangle',
					'text-border-style': 'solid',
					'text-border-opacity': 0,
					'text-border-width': '1px',
					'text-border-color': 'darkgray',
					'text-opacity': 0
		    	}
		    }
		    ]
		});
        cy.fit();
        var childNodeCollection = cy.elements("node.parent > node");
        var childEdges  = childNodeCollection.connectedEdges();
        childEdges.style({'opacity': 0});
		cy.$('node').on('mouseover', function(e){
            var ele = e.target;
		    var keys = Object.keys(ele.data('info'));
		    var div = document.getElementById('node-info');
		    var content = '
';
		    content += '
Parameters
';
		    content += '
';
			content += '
';
		    for (var i = keys.length - 1; i >= 0; i--) {
		  	    if (keys[i] != 'desc') {
                    var val = ele.data('info')[keys[i]].replace(/["]+/g, '');
                    content += keys[i] + ' : ' + val.charAt(0).toUpperCase().replace(/(?:\r\n|\r|\n)/g, '
') + val.slice(1) + '
';
                }
            }
			content += '
';
            if (ele.data('info')["desc"] != undefined) {
                content += '

Description

';
                content += ele.data('info')["desc"].replace(/(?:\r\n|\r|\n)/g, '
') + '
';
            }
            div.innerHTML = content;
		});

		cy.on('tap', 'edge', function (evt) {
           var edge = evt.target;
           var edgeLabel = edge.data().source;
           edge.style({'label': edgeLabel});
           edge.animate({
           		style: {
           			'text-opacity': 1,
		           	'text-margin-x': 15,
		           	'text-border-opacity': 1,
		           	'text-background-opacity': 1
           		}
           });
        });

		cy.on('click', 'node.parent', function(evt){
		    var node = evt.target;
            node.children().style({'opacity': 1});
            node.style({'color' : '#d5e1df'});
            var selectedChildNodeCollection = node.children();
			var parentEdges = node.connectedEdges();
            var selectedChildEdges  = selectedChildNodeCollection.connectedEdges();
            selectedChildEdges.style({'opacity' : 1});

            var selectedChildEdgesTarget = [];

            for(var idx = 0; idx < selectedChildEdges.length; idx++) {
				if (selectedChildEdges[idx].data('target') != node.data().id) {
					selectedChildEdgesTarget.push(selectedChildEdges[idx].data('target'));
				}
			}
			parentEdges.style({'opacity' : 0});

			for(var idx = 0; idx < parentEdges.length; idx++) {
				if (parentEdges[idx].data('target') != node.data().id) {

					if (selectedChildEdgesTarget.includes(parentEdges[idx].data('target')) == false) {
						parentEdges[idx].style({'opacity' : "1"});
					}
				}
			}

            cy.animate({
                fit : {
                    eles : selectedChildNodeCollection,
                    padding : 20
                }
            }, {
                duration: 500
            });

		});

		$('#label-switch').on('click', function(e) {

			var edges = cy.$('edge');
			for(var idx = 0 ; idx < edges.length; idx++) {
				edges[idx].style({label: edges[idx].data().shape});
			}
			if (edges.style().textOpacity == 0) {
				edges.animate({
					style: {
					'text-opacity': 1,
					'text-background-opacity': 1,
					'text-border-opacity': 1
					}
				});
			}
			else {
				edges.animate({
					style: {
					'text-opacity': 0,
					'text-background-opacity': 0,
					'text-border-opacity': 0
					}
				});
			}
		});

		$('#reset-state').on('click', function (e) {
			var childNodes = cy.$("node.parent > node");
			childNodes.style({
					"opacity": 0
				});
			childNodes.connectedEdges().style({
				'opacity': 0
			});
			var parentNodes = cy.$("node.parent");
			parentNodes.style({
				'color': 'black'
			});
			parentNodes.connectedEdges().style({
				'opacity': 1
			});
			var edges = cy.edges();
			for(var idx = 0 ; idx < edges.length; idx++) {
				edges[idx].style({label: null});
			}
			edges.animate({
				style: {
				'text-opacity': 0,
				'text-background-opacity': 0,
				'text-border-opacity': 0
				}
			});
			cy.fit();
		});

	});

});

function setTitle(name) {
	var title = document.getElementById('title');
	title.innerText = name;
}

function getModelData() {
	var graphPromise  = $.ajax({
		url: 'model.json',
		type: 'GET',
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
	})
	.then(function(msg) {
		return msg;
	}
	);
	return Promise.resolve(graphPromise);

}
<commit_msg>Remove .toUpperCase() from first char in val parameter field (#607)<commit_after>"use strict";

document.addEventListener('DOMContentLoaded', function() {
	var options = {
	  name: 'dagre',
      nodeSep: 3,
	  edgeSep: 5,
	  minLen: function( edge ){ return 1; },
	  edgeWeight: function( edge ){ return 2; },
	  fit: true,
	  spacingFactor: 1.1,
	  nodeDimensionsIncludeLabels: true
	};

	var nodeInfo = getModelData();
	nodeInfo.then(function(modelData) {
		setTitle(modelData['title']);

		var nodesArray = modelData['cy_data'];
		var cy = window.cy = cytoscape({
			container: document.getElementById('cy'),
		    elements: nodesArray,
		    layout: options,
		    style: [
			{
			    selector: "node",
			    style: {
			        shape: 'roundrectangle',
			        label: 'data(name)',
                    'font-size' : 30,
			        'border-width': 3,
                    'border-color': 'black',
			        width: 'label',
			        'color': '#000000',
			        'text-valign': 'center',
					'background-image': 'icons/node.png',
			        padding: 10,
		    	}
		    },
			{
			    selector: "node.parent",
			    style: {
					'compound-sizing-wrt-labels': 'include',
                    'background-image' : 'icons/parent.png',
                    'text-rotation' : '90deg',
                    'text-margin-x' : 10
		    	}
		    },
            {
			    selector: "node.parent > node",
			    style: {
			        opacity : 0
		    	}
		    },
            {
			    selector: "node.arrayFeatureExtractor",
			    style: {
					'background-image': 'icons/arrayFeatureExtractor.png'
		    	}
		    },
            {
			    selector: "node.categoricalMapping",
			    style: {
					'background-image': 'icons/categoricalMapping.png'
		    	}
		    },
            {
			    selector: "node.dictVectorizer",
			    style: {
					'background-image': 'icons/dictVectorizer.png'
		    	}
		    },
			{
			    selector: "node.custom",
			    style: {
					'background-image': 'icons/custom.png'
		    	}
		    },
            {
			    selector: "node.featureVectorizer",
			    style: {
					'background-image': 'icons/featureVectorizer.png'
		    	}
		    },
            {
			    selector: "node.glmClassifier",
			    style: {
					'background-image': 'icons/glmClassifier.png'
		    	}
		    },
            {
			    selector: "node.glmRegressor",
			    style: {
					'background-image': 'icons/glmRegressor.png'
		    	}
		    },
            {
			    selector: "node.identity",
			    style: {
					'background-image': 'icons/identity.png'
		    	}
		    },
            {
			    selector: "node.imputer",
			    style: {
					'background-image': 'icons/imputer.png'
		    	}
		    },
            {
			    selector: "node.neuralNetwork",
			    style: {
					'background-image': 'icons/neuralNetwork.png'
		    	}
		    },
            {
			    selector: "node.neuralNetworkClassifier",
			    style: {
					'background-image': 'icons/neuralNetworkClassifier.png'
		    	}
		    },
            {
			    selector: "node.neuralNetworkRegressor",
			    style: {
					'background-image': 'icons/neuralNetworkRegressor.png'
		    	}
		    },
            {
			    selector: "node.normalizer",
			    style: {
					'background-image': 'icons/normalizer.png'
		    	}
		    },
            {
			    selector: "node.oneHotEncoder",
			    style: {
					'background-image': 'icons/oneHotEncoder.png'
		    	}
		    },
            {
			    selector: "node.scaler",
			    style: {
					'background-image': 'icons/scaler.png'
		    	}
		    },
            {
			    selector: "node.supportVectorClassifier",
			    style: {
					'background-image': 'icons/supportVectorClassifier.png'
		    	}
		    },
            {
			    selector: "node.supportVectorRegressor",
			    style: {
					'background-image': 'icons/supportVectorRegressor.png'
		    	}
		    },
            {
			    selector: "node.treeEnsembleClassifier",
			    style: {
					'background-image': 'icons/treeEnsembleClassifier.png'
		    	}
		    },
            {
			    selector: "node.treeEnsembleRegressor",
			    style: {
					'background-image': 'icons/treeEnsembleRegressor.png'
		    	}
		    },
            {
			    selector: "node.convolution",
			    style: {
					'color': 'white',
					'background-image': 'icons/convolution.png'
		    	}
		    },
			{
			    selector: "node.deconvolution",
			    style: {
					'color': 'white',
					'background-image': 'icons/convolution.png'
		    	}
		    },
		    {
			    selector: "node.pooling",
			    style: {
					'color': 'white',
					'background-image': 'icons/pooling.png'
		    	}
		    },
		    {
			    selector: "node.activation",
			    style: {
					'background-image': 'icons/activation.png'
		    	}
		    },
            {
			    selector: "node.add",
			    style: {
					'background-image': 'icons/add.png'
		    	}
		    },
            {
			    selector: "node.average",
			    style: {
					'background-image': 'icons/average.png'
		    	}
		    },
            {
			    selector: "node.batchnorm",
			    style: {
					'background-image': 'icons/batchnorm.png'
		    	}
		    },
            {
			    selector: "node.biDirectionalLSTM",
			    style: {
					'background-image': 'icons/biDirectionalLSTM.png'
		    	}
		    },
            {
			    selector: "node.bias",
			    style: {
					'background-image': 'icons/bias.png'
		    	}
		    },
            {
			    selector: "node.concat",
			    style: {
					'background-image': 'icons/concat.png'
		    	}
		    },
            {
			    selector: "node.crop",
			    style: {
					'background-image': 'icons/crop.png'
		    	}
		    },
            {
			    selector: "node.dot",
			    style: {
					'background-image': 'icons/dot.png'
		    	}
		    },
            {
			    selector: "node.embedding",
			    style: {
					'background-image': 'icons/embedding.png'
		    	}
		    },
            {
			    selector: "node.flatten",
			    style: {
					'background-image': 'icons/flatten.png'
		    	}
		    },
            {
			    selector: "node.gru",
			    style: {
					'background-image': 'icons/gru.png'
		    	}
		    },
            {
			    selector: "node.innerProduct",
			    style: {
					'background-image': 'icons/innerProduct.png'
		    	}
		    },
            {
			    selector: "node.input",
			    style: {
					'background-image': 'icons/input.png'
		    	}
		    },
            {
			    selector: "node.output",
			    style: {
					'background-image': 'icons/output.png'
		    	}
		    },
            {
			    selector: "node.l2normalize",
			    style: {
					'background-image': 'icons/l2normalize.png'
		    	}
		    },
            {
			    selector: "node.loadConstant",
			    style: {
					'background-image': 'icons/loadConstant.png'
		    	}
		    },
            {
			    selector: "node.lrn",
			    style: {
					'background-image': 'icons/lrn.png'
		    	}
		    },
            {
			    selector: "node.max",
			    style: {
					'background-image': 'icons/max.png'
		    	}
		    },
            {
			    selector: "node.min",
			    style: {
					'background-image': 'icons/min.png'
		    	}
		    },
            {
			    selector: "node.multiply",
			    style: {
					'background-image': 'icons/multiply.png'
		    	}
		    },
            {
			    selector: "node.mvn",
			    style: {
					'background-image': 'icons/mvn.png'
		    	}
		    },
            {
			    selector: "node.padding",
			    style: {
					'background-image': 'icons/padding.png'
		    	}
		    },
            {
			    selector: "node.permute",
			    style: {
					'background-image': 'icons/permute.png'
		    	}
		    },
            {
			    selector: "node.pooling",
			    style: {
					'background-image': 'icons/pooling.png'
		    	}
		    },
            {
			    selector: "node.reduce",
			    style: {
					'background-image': 'icons/reduce.png'
		    	}
		    },
            {
			    selector: "node.reorganizeData",
			    style: {
					'background-image': 'icons/reorganizeData.png'
		    	}
		    },
            {
			    selector: "node.reshape",
			    style: {
					'background-image': 'icons/reshape.png'
		    	}
		    },
            {
			    selector: "node.scale",
			    style: {
					'background-image': 'icons/scale.png'
		    	}
		    },
            {
			    selector: "node.sequenceRepeat",
			    style: {
					'background-image': 'icons/sequenceRepeat.png'
		    	}
		    },
            {
			    selector: "node.simpleRecurrent",
			    style: {
					'background-image': 'icons/simpleRecurrent.png'
		    	}
		    },
            {
			    selector: "node.slice",
			    style: {
					'background-image': 'icons/slice.png'
		    	}
		    },
            {
			    selector: "node.softmax",
			    style: {
					'background-image': 'icons/softmax.png'
		    	}
		    },
            {
			    selector: "node.split",
			    style: {
					'background-image': 'icons/split.png'
		    	}
		    },
            {
			    selector: "node.unary",
			    style: {
					'background-image': 'icons/unary.png'
		    	}
		    },
            {
			    selector: "node.uniDirectionalLSTM",
			    style: {
					'background-image': 'icons/uniDirectionalLSTM.png'
		    	}
		    },
            {
			    selector: "node.upsample",
			    style: {
					'background-image': 'icons/upsample.png'
		    	}
		    },
		    {
		    	selector: "edge",
		    	style: {
		    		'curve-style': 'bezier',
		    		'control-point-weights': 1,
		    		'line-color': '#111111',
					'color' : '#000000',
					'border-width': 5,
					'font-size': 20,
		    		'target-arrow-shape': 'triangle',
		    		'target-arrow-color': '#111111',
					 label: 'data(label)',
					'text-background-opacity': 0,
					'text-background-color': '#ffffff',
					'text-background-shape': 'rectangle',
					'text-border-style': 'solid',
					'text-border-opacity': 0,
					'text-border-width': '1px',
					'text-border-color': 'darkgray',
					'text-opacity': 0
		    	}
		    }
		    ]
		});
        cy.fit();
        var childNodeCollection = cy.elements("node.parent > node");
        var childEdges  = childNodeCollection.connectedEdges();
        childEdges.style({'opacity': 0});
		cy.$('node').on('mouseover', function(e){
            var ele = e.target;
		    var keys = Object.keys(ele.data('info'));
		    var div = document.getElementById('node-info');
		    var content = '
';
		    content += '
Parameters
';
		    content += '
';
			content += '
';
		    for (var i = keys.length - 1; i >= 0; i--) {
		  	    if (keys[i] != 'desc') {
                    var val = ele.data('info')[keys[i]].replace(/["]+/g, '');
                    content += keys[i] + ' : ' + val.charAt(0).replace(/(?:\r\n|\r|\n)/g, '
') + val.slice(1) + '
';
                }
            }
			content += '
';
            if (ele.data('info')["desc"] != undefined) {
                content += '

Description

';
                content += ele.data('info')["desc"].replace(/(?:\r\n|\r|\n)/g, '
') + '
';
            }
            div.innerHTML = content;
		});

		cy.on('tap', 'edge', function (evt) {
           var edge = evt.target;
           var edgeLabel = edge.data().source;
           edge.style({'label': edgeLabel});
           edge.animate({
           		style: {
           			'text-opacity': 1,
		           	'text-margin-x': 15,
		           	'text-border-opacity': 1,
		           	'text-background-opacity': 1
           		}
           });
        });

		cy.on('click', 'node.parent', function(evt){
		    var node = evt.target;
            node.children().style({'opacity': 1});
            node.style({'color' : '#d5e1df'});
            var selectedChildNodeCollection = node.children();
			var parentEdges = node.connectedEdges();
            var selectedChildEdges  = selectedChildNodeCollection.connectedEdges();
            selectedChildEdges.style({'opacity' : 1});

            var selectedChildEdgesTarget = [];

            for(var idx = 0; idx < selectedChildEdges.length; idx++) {
				if (selectedChildEdges[idx].data('target') != node.data().id) {
					selectedChildEdgesTarget.push(selectedChildEdges[idx].data('target'));
				}
			}
			parentEdges.style({'opacity' : 0});

			for(var idx = 0; idx < parentEdges.length; idx++) {
				if (parentEdges[idx].data('target') != node.data().id) {

					if (selectedChildEdgesTarget.includes(parentEdges[idx].data('target')) == false) {
						parentEdges[idx].style({'opacity' : "1"});
					}
				}
			}

            cy.animate({
                fit : {
                    eles : selectedChildNodeCollection,
                    padding : 20
                }
            }, {
                duration: 500
            });

		});

		$('#label-switch').on('click', function(e) {

			var edges = cy.$('edge');
			for(var idx = 0 ; idx < edges.length; idx++) {
				edges[idx].style({label: edges[idx].data().shape});
			}
			if (edges.style().textOpacity == 0) {
				edges.animate({
					style: {
					'text-opacity': 1,
					'text-background-opacity': 1,
					'text-border-opacity': 1
					}
				});
			}
			else {
				edges.animate({
					style: {
					'text-opacity': 0,
					'text-background-opacity': 0,
					'text-border-opacity': 0
					}
				});
			}
		});

		$('#reset-state').on('click', function (e) {
			var childNodes = cy.$("node.parent > node");
			childNodes.style({
					"opacity": 0
				});
			childNodes.connectedEdges().style({
				'opacity': 0
			});
			var parentNodes = cy.$("node.parent");
			parentNodes.style({
				'color': 'black'
			});
			parentNodes.connectedEdges().style({
				'opacity': 1
			});
			var edges = cy.edges();
			for(var idx = 0 ; idx < edges.length; idx++) {
				edges[idx].style({label: null});
			}
			edges.animate({
				style: {
				'text-opacity': 0,
				'text-background-opacity': 0,
				'text-border-opacity': 0
				}
			});
			cy.fit();
		});

	});

});

function setTitle(name) {
	var title = document.getElementById('title');
	title.innerText = name;
}

function getModelData() {
	var graphPromise  = $.ajax({
		url: 'model.json',
		type: 'GET',
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
	})
	.then(function(msg) {
		return msg;
	}
	);
	return Promise.resolve(graphPromise);

}
<|endoftext|>


<commit_before>'use strict';

/**
 * @module
 * @author Oleg Dutchenko <dutchenko.o.dev@gmail.com>
 * @version 1.0.0
 */

// ----------------------------------------
// Imports
// ----------------------------------------

const jsBeautify = require('js-beautify');

// ----------------------------------------
// Private
// ----------------------------------------

function cut (pattern, placeholder, markup) {
	let list = [];
	let arr = pattern.exec(markup);

	while (arr !== null) {
		list.push(arr[0]);
		markup = markup.replace(pattern, placeholder);
		arr = pattern.exec(markup);
	}

	return {list, markup};
}

// ----------------------------------------
// Public
// ----------------------------------------

/**
 * Beautify markup
 * @param {string} markup
 * @param {Object} options
 * @returns {string}
 */
function beautify (markup, options) {
	let scriptsPattern = /<script(.)*>(.)*<\/script>/;
	let scriptsPlaceholder = '<script-placeholder></script-placeholder>';
	let scriptsRegExp = new RegExp(scriptsPlaceholder.replace(/\//g, '/'));

	let stylesPattern = /<style(.)*>(.)*<\/style>/;
	let stylesPlaceholder = '<style-placeholder></style-placeholder>';
	let stylesRegExp = new RegExp(stylesPlaceholder.replace(/\//g, '/'));

	let presPattern = /<pre(.)*>(.)*<\/pre>/;
	let presPlaceholder = '<pre-placeholder></pre-placeholder>';
	let presRegExp = new RegExp(presPlaceholder.replace(/\//g, '/'));

	let scriptsCut = cut(scriptsPattern, scriptsPlaceholder, markup);
	let scripts = scriptsCut.list;
	markup = scriptsCut.markup;

	let stylesCut = cut(stylesPattern, stylesPlaceholder, markup);
	let styles = stylesCut.list;
	markup = stylesCut.markup;

	let presCut = cut(presPattern, presPlaceholder, markup);
	let pres = presCut.list;
	markup = presCut.markup;

	markup = jsBeautify.html(markup, options);

	scripts.forEach(code => (markup = markup.replace(scriptsRegExp, code)));
	styles.forEach(code => (markup = markup.replace(stylesRegExp, code)));
	pres.forEach(code => (markup = markup.replace(presRegExp, code)));

	return markup;
}

// ----------------------------------------
// Exports
// ----------------------------------------

module.exports = beautify;
<commit_msg>Update beautify.js<commit_after>'use strict';

/**
 * @module
 * @author Oleg Dutchenko <dutchenko.o.dev@gmail.com>
 * @version 1.0.0
 */

// ----------------------------------------
// Imports
// ----------------------------------------

const jsBeautify = require('js-beautify');

// ----------------------------------------
// Private
// ----------------------------------------

function cut (pattern, placeholder, markup) {
	let list = [];
	let arr = pattern.exec(markup);

	while (arr !== null) {
		list.push(arr[0]);
		markup = markup.replace(pattern, placeholder);
		arr = pattern.exec(markup);
	}

	return {list, markup};
}

// ----------------------------------------
// Public
// ----------------------------------------

/**
 * Beautify markup
 * @param {string} markup
 * @param {Object} options
 * @returns {string}
 */
function beautify (markup, options) {
	let scriptsPattern = /<script(.)*>(|.|\n)*<\/script>/;
	let scriptsPlaceholder = '<script-placeholder></script-placeholder>';
	let scriptsRegExp = new RegExp(scriptsPlaceholder.replace(/\//g, '/'));

	let stylesPattern = /<style(.)*>(|.|\n)*<\/style>/;
	let stylesPlaceholder = '<style-placeholder></style-placeholder>';
	let stylesRegExp = new RegExp(stylesPlaceholder.replace(/\//g, '/'));

	let presPattern = /<pre(.)*>(|.|\n)*<\/pre>/;
	let presPlaceholder = '<pre-placeholder></pre-placeholder>';
	let presRegExp = new RegExp(presPlaceholder.replace(/\//g, '/'));

	let scriptsCut = cut(scriptsPattern, scriptsPlaceholder, markup);
	let scripts = scriptsCut.list;
	markup = scriptsCut.markup;

	let stylesCut = cut(stylesPattern, stylesPlaceholder, markup);
	let styles = stylesCut.list;
	markup = stylesCut.markup;

	let presCut = cut(presPattern, presPlaceholder, markup);
	let pres = presCut.list;
	markup = presCut.markup;

	markup = jsBeautify.html(markup, options);

	scripts.forEach(code => (markup = markup.replace(scriptsRegExp, code)));
	styles.forEach(code => (markup = markup.replace(stylesRegExp, code)));
	pres.forEach(code => (markup = markup.replace(presRegExp, code)));

	return markup;
}

// ----------------------------------------
// Exports
// ----------------------------------------

module.exports = beautify;
<|endoftext|>


<commit_before>/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
*/

/*jshint -W030 */
/*global Windows, WinJS*/
/*global module, require*/

var FTErr = require('./FileTransferError'),
    ProgressEvent = require('org.apache.cordova.file.ProgressEvent'),
    FileUploadResult = require('org.apache.cordova.file.FileUploadResult'),
    FileEntry = require('org.apache.cordova.file.FileEntry');

var appData = Windows.Storage.ApplicationData.current;

// Some private helper functions, hidden by the module
function cordovaPathToNative(path) {

    var cleanPath = String(path);
    // turn / into \\
    cleanPath = cleanPath.replace(/\//g, '\\');
    // turn  \\ into \
    cleanPath = cleanPath.replace(/\\\\/g, '\\');
    // strip end \\ characters
    cleanPath = cleanPath.replace(/\\+$/g, '');
    return cleanPath;
}

function nativePathToCordova(path) {
    return String(path).replace(/\\/g, '/');
}

var fileTransferOps = [];

function FileTransferOperation(state, promise) {
    this.state = state;
    this.promise = promise;
}

FileTransferOperation.PENDING = 0;
FileTransferOperation.DONE = 1;
FileTransferOperation.CANCELLED = 2;

module.exports = {

/*
exec(win, fail, 'FileTransfer', 'upload',
[filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
*/
    upload:function(successCallback, errorCallback, options) {
        var filePath = options[0];
        var server = options[1];
        var fileKey = options[2] || 'source';
        var fileName = options[3];
        var mimeType = options[4];
        var params = options[5];
        // var trustAllHosts = options[6]; // todo
        // var chunkedMode = options[7]; // todo
        var headers = options[8] || {};
        var uploadId = options[9];

        if (!filePath || (typeof filePath !== 'string')) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR,null,server));
            return;
        }

        if (filePath.substr(0, 8) === "file:///") {
            filePath = appData.localFolder.path + filePath.substr(8).split("/").join("\\");
        } else if (filePath.indexOf('ms-appdata:///') === 0) {
            // Handle 'ms-appdata' scheme
            filePath = filePath.replace('ms-appdata:///local', appData.localFolder.path)
                               .replace('ms-appdata:///temp', appData.temporaryFolder.path);
        }
        // normalize path separators
        filePath = cordovaPathToNative(filePath);

        // Create internal download operation object
        fileTransferOps[uploadId] = new FileTransferOperation(FileTransferOperation.PENDING, null);

        Windows.Storage.StorageFile.getFileFromPathAsync(filePath)
        .then(function (storageFile) {

            if(!fileName) {
                fileName = storageFile.name;
            }
            if(!mimeType) {
                // use the actual content type of the file, probably this should be the default way.
                // other platforms probably can't look this up.
                mimeType = storageFile.contentType;
            }

            // check if download isn't already cancelled
            var uploadOp = fileTransferOps[uploadId];
            if (uploadOp && uploadOp.state === FileTransferOperation.CANCELLED) {
                // Here we should call errorCB with ABORT_ERR error
                errorCallback(new FTErr(FTErr.ABORT_ERR, nativePathToCordova(filePath), server));
                return;
            }

            // setting request headers for uploader
            var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader();
            for (var header in headers) {
                if (headers.hasOwnProperty(header)) {
                    uploader.setRequestHeader(header, headers[header]);
                }
            }

            // adding params supplied to request payload
            var transferParts = [];
            for (var key in params) {
                if (params.hasOwnProperty(key)) {
                    var contentPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart();
                    contentPart.setHeader("Content-Disposition", "form-data; name=\"" + key + "\"");
                    contentPart.setText(params[key]);
                    transferParts.push(contentPart);
                }
            }

            // Adding file to upload to request payload
            var fileToUploadPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart(fileKey, fileName);
            fileToUploadPart.setFile(storageFile);
            transferParts.push(fileToUploadPart);

            // create download object. This will throw an exception if URL is malformed
            var uri = new Windows.Foundation.Uri(server);
            try {
                uploader.createUploadAsync(uri, transferParts).then(
                    function (upload) {
                        // update internal TransferOperation object with newly created promise
                        var uploadOperation = upload.startAsync();
                        fileTransferOps[uploadId].promise = uploadOperation;

                        uploadOperation.then(
                            function (result) {
                                // Update TransferOperation object with new state, delete promise property
                                // since it is not actual anymore
                                var currentUploadOp = fileTransferOps[uploadId];
                                if (currentUploadOp) {
                                    currentUploadOp.state = FileTransferOperation.DONE;
                                    currentUploadOp.promise = null;
                                }

                                var response = result.getResponseInformation();
                                // creating a data reader, attached to response stream to get server's response
                                var reader = new Windows.Storage.Streams.DataReader(result.getResultStreamAt(0));
                                reader.loadAsync(result.progress.bytesReceived).then(function(size) {
                                    var responseText = reader.readString(size);
                                    var ftResult = new FileUploadResult(size, response.statusCode, responseText);
                                    successCallback(ftResult);
                                    reader.close();
                                });
                            },
                            function (error) {
                                var source = nativePathToCordova(filePath);

                                // Handle download error here.
                                // Wrap this routines into promise due to some async methods
                                var getTransferError = new WinJS.Promise(function(resolve) {
                                    if (error.message === 'Canceled') {
                                        // If download was cancelled, message property will be specified
                                        resolve(new FTErr(FTErr.ABORT_ERR, source, server, null, null, error));
                                    } else {
                                        // in the other way, try to get response property
                                        var response = upload.getResponseInformation();
                                        if (!response) {
                                            resolve(new FTErr(FTErr.CONNECTION_ERR, source, server));
                                        } else {
                                            var reader = new Windows.Storage.Streams.DataReader(upload.getResultStreamAt(0));
                                            reader.loadAsync(upload.progress.bytesReceived).then(function (size) {
                                                var responseText = reader.readString(size);
                                                resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, server, response.statusCode, responseText, error));
                                                reader.close();
                                            });
                                        }
                                    }
                                });

                                // Update TransferOperation object with new state, delete promise property
                                // since it is not actual anymore
                                var currentUploadOp = fileTransferOps[uploadId];
                                if (currentUploadOp) {
                                    currentUploadOp.state = FileTransferOperation.CANCELLED;
                                    currentUploadOp.promise = null;
                                }

                                // Cleanup, remove incompleted file
                                getTransferError.then(function(transferError) {
                                    storageFile.deleteAsync().then(function() {
                                        errorCallback(transferError);
                                    });
                                });
                            },
                            function (evt) {
                                var progressEvent = new ProgressEvent('progress', {
                                    loaded: evt.progress.bytesSent,
                                    total: evt.progress.totalBytesToSend,
                                    target: evt.resultFile
                                });
                                progressEvent.lengthComputable = true;
                                successCallback(progressEvent, { keepCallback: true });
                            }
                        );
                    },
                    function (err) {
                        var errorObj = new FTErr(FTErr.INVALID_URL_ERR);
                        errorObj.exception = err;
                        errorCallback(errorObj);
                    }
                );
            } catch (e) {
                errorCallback(new FTErr(FTErr.INVALID_URL_ERR));
            }
        }, function(err) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, server, server, null, null, err));
        });
    },

    // [source, target, trustAllHosts, id, headers]
    download:function(successCallback, errorCallback, options) {
        var source = options[0];
        var target = options[1];
        var downloadId = options[3];
        var headers = options[4] || {};

        if (!target) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR));
            return;
        }
        if (target.substr(0, 8) === "file:///") {
            target = appData.localFolder.path + target.substr(8).split("/").join("\\");
        } else if (target.indexOf('ms-appdata:///') === 0) {
            // Handle 'ms-appdata' scheme
            target = target.replace('ms-appdata:///local', appData.localFolder.path)
                           .replace('ms-appdata:///temp', appData.temporaryFolder.path);
        }
        target = cordovaPathToNative(target);

        var path = target.substr(0, target.lastIndexOf("\\"));
        var fileName = target.substr(target.lastIndexOf("\\") + 1);
        if (path === null || fileName === null) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR));
            return;
        }

        var download = null;

        // Create internal download operation object
        fileTransferOps[downloadId] = new FileTransferOperation(FileTransferOperation.PENDING, null);

        var downloadCallback = function(storageFolder) {
            storageFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).then(function(storageFile) {

                // check if download isn't already cancelled
                var downloadOp = fileTransferOps[downloadId];
                if (downloadOp && downloadOp.state === FileTransferOperation.CANCELLED) {
                    // Here we should call errorCB with ABORT_ERR error
                    errorCallback(new FTErr(FTErr.ABORT_ERR, source, target));
                    return;
                }

                // if download isn't cancelled, contunue with creating and preparing download operation
                var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
                for (var header in headers) {
                    if (header.hasOwnProperty(header)) {
                        downloader.setRequestHeader(header, headers[header]);
                    }
                }

                // create download object. This will throw an exception if URL is malformed
                try {
                    var uri = Windows.Foundation.Uri(source);
                    download = downloader.createDownload(uri, storageFile);
                } catch (e) {
                    // so we handle this and call errorCallback
                    errorCallback(new FTErr(FTErr.INVALID_URL_ERR));
                    return;
                }

                var downloadOperation = download.startAsync();
                // update internal TransferOperation object with newly created promise
                fileTransferOps[downloadId].promise = downloadOperation;

                downloadOperation.then(function () {

                    // Update TransferOperation object with new state, delete promise property
                    // since it is not actual anymore
                    var currentDownloadOp = fileTransferOps[downloadId];
                    if (currentDownloadOp) {
                        currentDownloadOp.state = FileTransferOperation.DONE;
                        currentDownloadOp.promise = null;
                    }

                    var nativeURI = storageFile.path.replace(appData.localFolder.path, 'ms-appdata:///local')
                        .replace(appData.temporaryFolder.path, 'ms-appdata:///temp')
                        .replace('\\', '/');

                    successCallback(new FileEntry(storageFile.name, storageFile.path, null, nativeURI));
                }, function(error) {

                    var getTransferError = new WinJS.Promise(function (resolve) {
                        // Handle download error here. If download was cancelled,
                        // message property will be specified
                        if (error.message === 'Canceled') {
                            resolve(new FTErr(FTErr.ABORT_ERR, source, target, null, null, error));
                        } else {
                            // in the other way, try to get response property
                            var response = download.getResponseInformation();
                            if (!response) {
                                resolve(new FTErr(FTErr.CONNECTION_ERR, source, target));
                            } else {
                                var reader = new Windows.Storage.Streams.DataReader(download.getResultStreamAt(0));
                                reader.loadAsync(download.progress.bytesReceived).then(function (bytesLoaded) {
                                    var payload = reader.readString(bytesLoaded);
                                    resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, response.statusCode, payload, error));
                                });
                            }
                        }
                    });
                    getTransferError.then(function (fileTransferError) {

                        // Update TransferOperation object with new state, delete promise property
                        // since it is not actual anymore
                        var currentDownloadOp = fileTransferOps[downloadId];
                        if (currentDownloadOp) {
                            currentDownloadOp.state = FileTransferOperation.CANCELLED;
                            currentDownloadOp.promise = null;
                        }

                        // Cleanup, remove incompleted file
                        storageFile.deleteAsync().then(function() {
                            errorCallback(fileTransferError);
                        });
                    });

                }, function(evt) {

                    var progressEvent = new ProgressEvent('progress', {
                        loaded: evt.progress.bytesReceived,
                        total: evt.progress.totalBytesToReceive,
                        target: evt.resultFile
                    });
                    progressEvent.lengthComputable = true;

                    successCallback(progressEvent, { keepCallback: true });
                });
            }, function(error) {
                errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error));
            });
        };

        var fileNotFoundErrorCallback = function(error) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error));
        };

        Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(downloadCallback, function (error) {
            // Handle non-existent directory
            if (error.number === -2147024894) {
                var parent = path.substr(0, path.lastIndexOf('\\')),
                    folderNameToCreate = path.substr(path.lastIndexOf('\\') + 1);

                Windows.Storage.StorageFolder.getFolderFromPathAsync(parent).then(function(parentFolder) {
                    parentFolder.createFolderAsync(folderNameToCreate).then(downloadCallback, fileNotFoundErrorCallback);
                }, fileNotFoundErrorCallback);
            } else {
                fileNotFoundErrorCallback();
            }
        });
    },

    abort: function (successCallback, error, options) {
        var fileTransferOpId = options[0];

        // Try to find transferOperation with id specified, and cancel its' promise
        var currentOp = fileTransferOps[fileTransferOpId];
        if (currentOp) {
            currentOp.state = FileTransferOperation.CANCELLED;
            currentOp.promise && currentOp.promise.cancel();
        }
    }

};

require("cordova/exec/proxy").add("FileTransfer",module.exports);
<commit_msg>CB-8407 Use File proxy to construct valid FileEntry for download success callback<commit_after>/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
*/

/*jshint -W030 */
/*global Windows, WinJS*/
/*global module, require*/

var FTErr = require('./FileTransferError'),
    ProgressEvent = require('org.apache.cordova.file.ProgressEvent'),
    FileUploadResult = require('org.apache.cordova.file.FileUploadResult'),
    FileProxy = require('org.apache.cordova.file.FileProxy'),
    FileEntry = require('org.apache.cordova.file.FileEntry');

var appData = Windows.Storage.ApplicationData.current;

// Some private helper functions, hidden by the module
function cordovaPathToNative(path) {

    var cleanPath = String(path);
    // turn / into \\
    cleanPath = cleanPath.replace(/\//g, '\\');
    // turn  \\ into \
    cleanPath = cleanPath.replace(/\\\\/g, '\\');
    // strip end \\ characters
    cleanPath = cleanPath.replace(/\\+$/g, '');
    return cleanPath;
}

function nativePathToCordova(path) {
    return String(path).replace(/\\/g, '/');
}

var fileTransferOps = [];

function FileTransferOperation(state, promise) {
    this.state = state;
    this.promise = promise;
}

FileTransferOperation.PENDING = 0;
FileTransferOperation.DONE = 1;
FileTransferOperation.CANCELLED = 2;

module.exports = {

/*
exec(win, fail, 'FileTransfer', 'upload',
[filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
*/
    upload:function(successCallback, errorCallback, options) {
        var filePath = options[0];
        var server = options[1];
        var fileKey = options[2] || 'source';
        var fileName = options[3];
        var mimeType = options[4];
        var params = options[5];
        // var trustAllHosts = options[6]; // todo
        // var chunkedMode = options[7]; // todo
        var headers = options[8] || {};
        var uploadId = options[9];

        if (!filePath || (typeof filePath !== 'string')) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR,null,server));
            return;
        }

        if (filePath.substr(0, 8) === "file:///") {
            filePath = appData.localFolder.path + filePath.substr(8).split("/").join("\\");
        } else if (filePath.indexOf('ms-appdata:///') === 0) {
            // Handle 'ms-appdata' scheme
            filePath = filePath.replace('ms-appdata:///local', appData.localFolder.path)
                               .replace('ms-appdata:///temp', appData.temporaryFolder.path);
        }
        // normalize path separators
        filePath = cordovaPathToNative(filePath);

        // Create internal download operation object
        fileTransferOps[uploadId] = new FileTransferOperation(FileTransferOperation.PENDING, null);

        Windows.Storage.StorageFile.getFileFromPathAsync(filePath)
        .then(function (storageFile) {

            if(!fileName) {
                fileName = storageFile.name;
            }
            if(!mimeType) {
                // use the actual content type of the file, probably this should be the default way.
                // other platforms probably can't look this up.
                mimeType = storageFile.contentType;
            }

            // check if download isn't already cancelled
            var uploadOp = fileTransferOps[uploadId];
            if (uploadOp && uploadOp.state === FileTransferOperation.CANCELLED) {
                // Here we should call errorCB with ABORT_ERR error
                errorCallback(new FTErr(FTErr.ABORT_ERR, nativePathToCordova(filePath), server));
                return;
            }

            // setting request headers for uploader
            var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader();
            for (var header in headers) {
                if (headers.hasOwnProperty(header)) {
                    uploader.setRequestHeader(header, headers[header]);
                }
            }

            // adding params supplied to request payload
            var transferParts = [];
            for (var key in params) {
                if (params.hasOwnProperty(key)) {
                    var contentPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart();
                    contentPart.setHeader("Content-Disposition", "form-data; name=\"" + key + "\"");
                    contentPart.setText(params[key]);
                    transferParts.push(contentPart);
                }
            }

            // Adding file to upload to request payload
            var fileToUploadPart = new Windows.Networking.BackgroundTransfer.BackgroundTransferContentPart(fileKey, fileName);
            fileToUploadPart.setFile(storageFile);
            transferParts.push(fileToUploadPart);

            // create download object. This will throw an exception if URL is malformed
            var uri = new Windows.Foundation.Uri(server);
            try {
                uploader.createUploadAsync(uri, transferParts).then(
                    function (upload) {
                        // update internal TransferOperation object with newly created promise
                        var uploadOperation = upload.startAsync();
                        fileTransferOps[uploadId].promise = uploadOperation;

                        uploadOperation.then(
                            function (result) {
                                // Update TransferOperation object with new state, delete promise property
                                // since it is not actual anymore
                                var currentUploadOp = fileTransferOps[uploadId];
                                if (currentUploadOp) {
                                    currentUploadOp.state = FileTransferOperation.DONE;
                                    currentUploadOp.promise = null;
                                }

                                var response = result.getResponseInformation();
                                // creating a data reader, attached to response stream to get server's response
                                var reader = new Windows.Storage.Streams.DataReader(result.getResultStreamAt(0));
                                reader.loadAsync(result.progress.bytesReceived).then(function(size) {
                                    var responseText = reader.readString(size);
                                    var ftResult = new FileUploadResult(size, response.statusCode, responseText);
                                    successCallback(ftResult);
                                    reader.close();
                                });
                            },
                            function (error) {
                                var source = nativePathToCordova(filePath);

                                // Handle download error here.
                                // Wrap this routines into promise due to some async methods
                                var getTransferError = new WinJS.Promise(function(resolve) {
                                    if (error.message === 'Canceled') {
                                        // If download was cancelled, message property will be specified
                                        resolve(new FTErr(FTErr.ABORT_ERR, source, server, null, null, error));
                                    } else {
                                        // in the other way, try to get response property
                                        var response = upload.getResponseInformation();
                                        if (!response) {
                                            resolve(new FTErr(FTErr.CONNECTION_ERR, source, server));
                                        } else {
                                            var reader = new Windows.Storage.Streams.DataReader(upload.getResultStreamAt(0));
                                            reader.loadAsync(upload.progress.bytesReceived).then(function (size) {
                                                var responseText = reader.readString(size);
                                                resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, server, response.statusCode, responseText, error));
                                                reader.close();
                                            });
                                        }
                                    }
                                });

                                // Update TransferOperation object with new state, delete promise property
                                // since it is not actual anymore
                                var currentUploadOp = fileTransferOps[uploadId];
                                if (currentUploadOp) {
                                    currentUploadOp.state = FileTransferOperation.CANCELLED;
                                    currentUploadOp.promise = null;
                                }

                                // Cleanup, remove incompleted file
                                getTransferError.then(function(transferError) {
                                    storageFile.deleteAsync().then(function() {
                                        errorCallback(transferError);
                                    });
                                });
                            },
                            function (evt) {
                                var progressEvent = new ProgressEvent('progress', {
                                    loaded: evt.progress.bytesSent,
                                    total: evt.progress.totalBytesToSend,
                                    target: evt.resultFile
                                });
                                progressEvent.lengthComputable = true;
                                successCallback(progressEvent, { keepCallback: true });
                            }
                        );
                    },
                    function (err) {
                        var errorObj = new FTErr(FTErr.INVALID_URL_ERR);
                        errorObj.exception = err;
                        errorCallback(errorObj);
                    }
                );
            } catch (e) {
                errorCallback(new FTErr(FTErr.INVALID_URL_ERR));
            }
        }, function(err) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, server, server, null, null, err));
        });
    },

    // [source, target, trustAllHosts, id, headers]
    download:function(successCallback, errorCallback, options) {
        var source = options[0];
        var target = options[1];
        var downloadId = options[3];
        var headers = options[4] || {};

        if (!target) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR));
            return;
        }
        if (target.substr(0, 8) === "file:///") {
            target = appData.localFolder.path + target.substr(8).split("/").join("\\");
        } else if (target.indexOf('ms-appdata:///') === 0) {
            // Handle 'ms-appdata' scheme
            target = target.replace('ms-appdata:///local', appData.localFolder.path)
                           .replace('ms-appdata:///temp', appData.temporaryFolder.path);
        }
        target = cordovaPathToNative(target);

        var path = target.substr(0, target.lastIndexOf("\\"));
        var fileName = target.substr(target.lastIndexOf("\\") + 1);
        if (path === null || fileName === null) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR));
            return;
        }

        var download = null;

        // Create internal download operation object
        fileTransferOps[downloadId] = new FileTransferOperation(FileTransferOperation.PENDING, null);

        var downloadCallback = function(storageFolder) {
            storageFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).then(function(storageFile) {

                // check if download isn't already cancelled
                var downloadOp = fileTransferOps[downloadId];
                if (downloadOp && downloadOp.state === FileTransferOperation.CANCELLED) {
                    // Here we should call errorCB with ABORT_ERR error
                    errorCallback(new FTErr(FTErr.ABORT_ERR, source, target));
                    return;
                }

                // if download isn't cancelled, contunue with creating and preparing download operation
                var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
                for (var header in headers) {
                    if (header.hasOwnProperty(header)) {
                        downloader.setRequestHeader(header, headers[header]);
                    }
                }

                // create download object. This will throw an exception if URL is malformed
                try {
                    var uri = Windows.Foundation.Uri(source);
                    download = downloader.createDownload(uri, storageFile);
                } catch (e) {
                    // so we handle this and call errorCallback
                    errorCallback(new FTErr(FTErr.INVALID_URL_ERR));
                    return;
                }

                var downloadOperation = download.startAsync();
                // update internal TransferOperation object with newly created promise
                fileTransferOps[downloadId].promise = downloadOperation;

                downloadOperation.then(function () {

                    // Update TransferOperation object with new state, delete promise property
                    // since it is not actual anymore
                    var currentDownloadOp = fileTransferOps[downloadId];
                    if (currentDownloadOp) {
                        currentDownloadOp.state = FileTransferOperation.DONE;
                        currentDownloadOp.promise = null;
                    }

                    var nativeURI = storageFile.path.replace(appData.localFolder.path, 'ms-appdata:///local')
                        .replace(appData.temporaryFolder.path, 'ms-appdata:///temp')
                        .replace('\\', '/');

                    // Passing null as error callback here because downloaded file should exist in any case
                    // otherwise the error callback will be hit during file creation in another place
                    FileProxy.resolveLocalFileSystemURI(successCallback, null, [nativeURI]);
                }, function(error) {

                    var getTransferError = new WinJS.Promise(function (resolve) {
                        // Handle download error here. If download was cancelled,
                        // message property will be specified
                        if (error.message === 'Canceled') {
                            resolve(new FTErr(FTErr.ABORT_ERR, source, target, null, null, error));
                        } else {
                            // in the other way, try to get response property
                            var response = download.getResponseInformation();
                            if (!response) {
                                resolve(new FTErr(FTErr.CONNECTION_ERR, source, target));
                            } else {
                                var reader = new Windows.Storage.Streams.DataReader(download.getResultStreamAt(0));
                                reader.loadAsync(download.progress.bytesReceived).then(function (bytesLoaded) {
                                    var payload = reader.readString(bytesLoaded);
                                    resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, response.statusCode, payload, error));
                                });
                            }
                        }
                    });
                    getTransferError.then(function (fileTransferError) {

                        // Update TransferOperation object with new state, delete promise property
                        // since it is not actual anymore
                        var currentDownloadOp = fileTransferOps[downloadId];
                        if (currentDownloadOp) {
                            currentDownloadOp.state = FileTransferOperation.CANCELLED;
                            currentDownloadOp.promise = null;
                        }

                        // Cleanup, remove incompleted file
                        storageFile.deleteAsync().then(function() {
                            errorCallback(fileTransferError);
                        });
                    });

                }, function(evt) {

                    var progressEvent = new ProgressEvent('progress', {
                        loaded: evt.progress.bytesReceived,
                        total: evt.progress.totalBytesToReceive,
                        target: evt.resultFile
                    });
                    progressEvent.lengthComputable = true;

                    successCallback(progressEvent, { keepCallback: true });
                });
            }, function(error) {
                errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error));
            });
        };

        var fileNotFoundErrorCallback = function(error) {
            errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, null, null, error));
        };

        Windows.Storage.StorageFolder.getFolderFromPathAsync(path).then(downloadCallback, function (error) {
            // Handle non-existent directory
            if (error.number === -2147024894) {
                var parent = path.substr(0, path.lastIndexOf('\\')),
                    folderNameToCreate = path.substr(path.lastIndexOf('\\') + 1);

                Windows.Storage.StorageFolder.getFolderFromPathAsync(parent).then(function(parentFolder) {
                    parentFolder.createFolderAsync(folderNameToCreate).then(downloadCallback, fileNotFoundErrorCallback);
                }, fileNotFoundErrorCallback);
            } else {
                fileNotFoundErrorCallback();
            }
        });
    },

    abort: function (successCallback, error, options) {
        var fileTransferOpId = options[0];

        // Try to find transferOperation with id specified, and cancel its' promise
        var currentOp = fileTransferOps[fileTransferOpId];
        if (currentOp) {
            currentOp.state = FileTransferOperation.CANCELLED;
            currentOp.promise && currentOp.promise.cancel();
        }
    }

};

require("cordova/exec/proxy").add("FileTransfer",module.exports);
<|endoftext|>


<commit_before>/*
Copyright 2017 Daniel Jeong (@taekb)

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

function adjust_text() {
	window_width = $(window).width();
	if (window_width <= 1000) {
		adjust_small(window_width);
	}
	else {
		adjust_large();
	}
}

function adjust_large() {
	// Adjust title
	$('.title').css({
		'font-size': '120px',
		'padding-top': '300px',
		'padding-bottom': '300px'
	});

	// Adjust about_photo
	$('.about_photo').css({
		'margin-left': '30px',
		'margin-bottom': '0'
	});

	// Adjust profile lists
	$('.profile a').css('float', 'left');
	$('.profile p').css('display', 'inline-block');

	// Adjust navigation bar
	$('.nav_bar').css('font-size', 'initial');
}

function adjust_small(width) {
	// Adjust title
	$('.title').css({
		'font-size': '55px',
		'padding-top': '150px',
		'padding-bottom': '150px'
	});

	// Adjust about_photo
	$('.about_photo').css({
		'margin-left': '0',
		'margin-bottom': '20px'
	});

	// Adjust profile lists
	$('.profile a').css('float', 'initial');
	$('.profile p').css('display', 'block');

	// Adjust navigation bar
	if (width <= 540) {
		$('.nav_bar').css('font-size', '3px');
	}
	else {
		$('.nav_bar').css('font-size', 'initial');
	}
}

window.onload = adjust_text;

$(window).resize(adjust_text);

function show_text() {
	$('.title').hide();
	$('#about_intro').hide();
	$('#about_intro_2').hide();

	$('.title').fadeIn(1000);
	$('#about_intro').fadeIn(2500);
	$('#about_intro_2').fadeIn(4500);
}

$('a[href*="#"]').click(function(event) {
	var targetElement = $(this.hash);
	event.preventDefault();
	$('html, body').animate({
		scrollTop: $(targetElement).offset().top
	}, 750, function() {
		$(targetElement).focus();
		if ($(targetElement).is(':focus')) {
			return false;
		}
		else {
			$(targetElement).attr('tabindex', '-1');
			$(targetElement).focus();
		};
	});
});

$(document).ready(show_text());
<commit_msg>Update main.js<commit_after>/*
Copyright 2017 Daniel Jeong (@taekb)

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

function adjust_text() {
	window_width = $(window).width();
	if (window_width <= 1000) {
		adjust_small(window_width);
	}
	else {
		adjust_large();
	}
}

function adjust_large() {
	// Adjust title
	$('.title').css({
		'font-size': '120px',
		'padding-top': '300px',
		'padding-bottom': '300px'
	});

	// Adjust about_photo
	$('.about_photo').css({
		'margin-left': '30px',
		'margin-bottom': '0'
	});

	// Adjust profile lists
	$('.profile a').css('float', 'left');
	$('.profile p').css('display', 'inline-block');

	// Adjust navigation bar
	$('.nav_bar').css('font-size', 'initial');
}

function adjust_small(width) {
	// Adjust title
	$('.title').css({
		'font-size': '55px',
		'padding-top': '150px',
		'padding-bottom': '150px'
	});

	// Adjust about_photo
	$('.about_photo').css({
		'margin-left': '0',
		'margin-bottom': '20px'
	});

	// Adjust profile lists
	$('.profile a').css('float', 'initial');
	$('.profile p').css('display', 'block');

	// Adjust navigation bar
	if (width <= 540) {
		$('.nav_bar').css('font-size', '6px');
	}
	else {
		$('.nav_bar').css('font-size', 'initial');
	}
}

window.onload = adjust_text;

$(window).resize(adjust_text);

function show_text() {
	$('.title').hide();
	$('#about_intro').hide();
	$('#about_intro_2').hide();

	$('.title').fadeIn(1000);
	$('#about_intro').fadeIn(2500);
	$('#about_intro_2').fadeIn(4500);
}

$('a[href*="#"]').click(function(event) {
	var targetElement = $(this.hash);
	event.preventDefault();
	$('html, body').animate({
		scrollTop: $(targetElement).offset().top
	}, 750, function() {
		$(targetElement).focus();
		if ($(targetElement).is(':focus')) {
			return false;
		}
		else {
			$(targetElement).attr('tabindex', '-1');
			$(targetElement).focus();
		};
	});
});

$(document).ready(show_text());
<|endoftext|>