Layout for webpage of ship «Purga»

July 13, 2014 JavaScript

In accordance with the statement of the problem it was necessary to impose a given layout one-page site with the ability to send a request from client by mail.

The result was such layout.

Russian language provide different endings for numerals. So the javascript code below is actual only for use with Russian language. There is an article about endings.

function plural(n,form1,form2,form5) {

	n = Math.abs(n) % 100;
	var n1 = n % 10;

	if (n > 10 && n < 20) {
		return form5
	};
	if (n1 > 1 && n1 < 5) {
		return form2
	};
	if (n1 == 1) {
		return form1
	};

    return form5;
}

var hour;

hour = 1;
console.log( hour + plural( hour,' час',' часа',' часов' ) );
// 1 час

hour = 3;
console.log( hour + plural( hour,' час',' часа',' часов' ) );
// 3 часа

hour = 1357;
console.log( hour + plural( hour,' час',' часа',' часов' ) );
// 1357 часов

Besides stumbled upon a remarkable library formatter.js for the formatted fill out form fields.