Battery drain

Battery drain

BY 09 Aug 2016 Web Application Development

Hello Guys,
I develop a watch face but i don’t know why this one sucking up a lot of battery
anyone can help me to resolve this battery drain issuse and optimize this code?

 

var battery_level, battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery,
    eis = document.getElementById("dials"),
	sstp, z = document.getElementById("landing-cover"),
	dtt = null;
z.addEventListener("touchstart", function() {
	dth();
}, false);

function dth() {
	if (dtt === null) {
		dtt = setTimeout(function() {
			dtt = null;
		}, 300);
	} else {
		clearTimeout(dtt);
		dtt = null;
		window.location.href = "content/setting.html";
	}
}

function displayWeekDay() {
	var g = tizen.time.getCurrentDateTime(),
		a = g.getDay(),
		e = g.getDate(),
		c = g.getMonth();
	if (e < 10) {
		e = "0" + e;
	}
	var b = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
		d = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
		f = b[a] + " " + e + " " + d[c];
	document.getElementById("layer13l").innerHTML = e;
	document.getElementById("l19").innerHTML = f;
}
function displayboth() {
	var b = tizen.time.getCurrentDateTime(),
		c = b.getSeconds(),
		a = b.getMilliseconds();
	setAnimationStyle(eis, NEEDLE_DATA, "START", "END", ((a + (c * 1000)) / 60000));
	if (sstp === 1) {
		animRequest = window.webkitRequestAnimationFrame(displayboth);
	}
}

function displaydigi() {
	var b = tizen.time.getCurrentDateTime(),
		d = b.getMinutes(),
		a = b.getHours(),
		e = document.getElementById("l16"),
		c = document.getElementById("l17");
	e.innerHTML = a;
	c.innerHTML = d;
	if (d < 10) {
		c.innerHTML = "0" + d;
	}
}

function initLUXWatch() {
	displayTime();
	displayWeekDay();
	document.getElementById("landing-cover").className = "active";
	sstp = 1;
}

function ambientLUXWatch() {
	displayATime();
	displayWeekDay();
	document.getElementById("landing-cover").className = "nactive";
	sstp = 0;
}


function bev() {
	window.addEventListener("timetick", function() {
		ambientLUXWatch();
	});
	window.addEventListener("ambientmodechanged", function(a) {
		if (a.detail.ambientMode === true) {
			ambientLUXWatch();
		} else {
			initLUXWatch();
		}
	});
	document.addEventListener("visibilitychange", function() {
		if (!document.hidden) {
			initLUXWatch();
		}
	});
}
window.onload = function() {
	flud();
	bev();
	initLUXWatch();
	
};

 

Written by