/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

define(['jquery', 'backbone'],
        function ($, Backbone) {

            var Debug = {
                writeMessage: function (msg) {
                    var prevMsg = window.localStorage.getItem("debugMessages");
                    if(prevMsg === null)
                        prevMsg = "";
                    window.localStorage.setItem("debugMessages", prevMsg + "\n" + msg);
                },
                readMessage: function () {
                    return window.localStorage.getItem("debugMessages");
                },
                clearMessage: function () {
                    window.localStorage.setItem("debugMessages","");
                },
                testFastClick: function (element) {
                    var self = this;
                    var teTime, cTime;

                    element.addEventListener('touchend', function (event) {
                        teTime = Date.now();
                        self.writeMessage("touchend event: " + teTime);
                    }, false);

                    element.addEventListener('click', function (event) {
                        cTime = Date.now();

                        self.writeMessage("click event: " + cTime);

                        self.writeMessage("Diff Time event: " + (cTime - teTime));
                    }, false);
                }
            };

            return Debug;
        });