Ich habe versucht, mithilfe von Google Apps-Skript ein Toolset zu erstellen. Das Problem dabei ist, dass, soweit ich das beurteilen kann, nur eine Organisationsebene erlaubt ist. Sie können eine Bibliothek namens Stoppuhr erstellen und die Methoden Stoppuhr.start() und Stoppuhr.stop() aufrufen, was ziemlich cool ist.Erstellen einer Namespace-ähnlichen Organisation in einer Google Apps-Skriptbibliothek
Was ich im Sinn hatte, war etwas mehr wie Utils.Stopwatch(). Start() und Utils.Timer.start() usw. Ich denke, es ist sicherlich in Javascript möglich, aber immer brechen Apps Script Autocomplete Funktion muss es in einem bestimmten Format hinzugefügt werden. Unten ist ein Beispiel, das es falsch macht (gibt einen Fehler), aber vielleicht spart etwas Zeit. Es basiert auf this Artikel.
/**
* A stopwatch object.
* @return {Object} The stopwatch methods
*/
function Stopwatch()
{
var current;
/**
* Stop the stopwatch.
* @param {Time} time in miliseconds
*/
function timeInSeconds_(time)
{
return time/1000;
}
return
{
/**
* Start the stopwatch.
*/
start: function()
{
var time = new Date().getTime();
current = timeInSeconds_(time);
},
/**
* Stop the stopwatch.
* @return {decimal} time passed since calling
* start (in seconds)
*/
stop: function()
{
var time = new Date().getTime();
var difference = timeInSeconds_(time) - this.current;
return difference.toFixed(3);
}
};
}
Dank
ich Sie erraten sind Code in diesem Fall wäre 'Utils.Stopwatch() start()' – Eduardo
Ja, das ist richtig, mein schlechtes –