mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-22 18:47:44 -05:00
fix incorrect Javascript private variable style
It's supposed to be a trailing underscore, not a leading underscore, as described here: https://google.github.io/styleguide/jsguide.html#naming-method-names https://google.github.io/styleguide/jsguide.html#naming-non-constant-field-names and discussed in an earlier PR: https://github.com/scottlamb/moonfire-nvr/pull/48#discussion_r175678736 I fixed these mechanically: rg -l0 'this[.]_' | xargs -0 perl -pi -e 's/this[.]_(\w+)/this.$1_/g' rg -l0 '\s_\w+\(' | xargs -0 perl -pi -e 's/_(\w+)\(/$1_(/g'
This commit is contained in:
@@ -59,8 +59,8 @@ export default class RecordingFormatter {
|
||||
* @param {String} tz Timezone
|
||||
*/
|
||||
constructor(formatStr, tz) {
|
||||
this._timeFormatter = new TimeFormatter(formatStr, tz);
|
||||
this._singleDateStr = null;
|
||||
this.timeFormatter_ = new TimeFormatter(formatStr, tz);
|
||||
this.singleDateStr_ = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ export default class RecordingFormatter {
|
||||
* @param {String} formatStr Time format string
|
||||
*/
|
||||
set timeFormat(formatStr) {
|
||||
this._timeFormatter = new TimeFormatter(formatStr, this._timeFormatter.tz);
|
||||
this.timeFormatter_ = new TimeFormatter(formatStr, this.timeFormatter_.tz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ export default class RecordingFormatter {
|
||||
const duration = recording.duration;
|
||||
const trimmedRange = recording.range90k(trimRange);
|
||||
return {
|
||||
start: this._timeFormatter.formatTimeStamp90k(trimmedRange.startTime90k),
|
||||
end: this._timeFormatter.formatTimeStamp90k(trimmedRange.endTime90k),
|
||||
start: this.timeFormatter_.formatTimeStamp90k(trimmedRange.startTime90k),
|
||||
end: this.timeFormatter_.formatTimeStamp90k(trimmedRange.endTime90k),
|
||||
resolution:
|
||||
recording.videoSampleEntryWidth +
|
||||
'x' +
|
||||
|
||||
@@ -57,8 +57,8 @@ export default class TimeFormatter {
|
||||
* @param {String} tz Timezone, e.g. "America/Los_Angeles"
|
||||
*/
|
||||
constructor(formatStr, tz) {
|
||||
this._formatStr = formatStr || defaultTimeFormat;
|
||||
this._tz = tz;
|
||||
this.formatStr_ = formatStr || defaultTimeFormat;
|
||||
this.tz_ = tz;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ export default class TimeFormatter {
|
||||
* @return {String} Format specification string
|
||||
*/
|
||||
get formatStr() {
|
||||
return this._formatStr;
|
||||
return this.formatStr_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ export default class TimeFormatter {
|
||||
* @return {String} Timezone
|
||||
*/
|
||||
get tz() {
|
||||
return this._tz;
|
||||
return this.tz_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ export default class TimeFormatter {
|
||||
* @return {String} Formatted timestamp
|
||||
*/
|
||||
formatTimeStamp90k(ts90k) {
|
||||
let format = this._formatStr;
|
||||
let format = this.formatStr_;
|
||||
const ms = ts90k / 90.0;
|
||||
const fracFmt = 'FFFFF';
|
||||
const fracLoc = format.indexOf(fracFmt);
|
||||
@@ -114,6 +114,6 @@ export default class TimeFormatter {
|
||||
String(100000 + frac).substr(1) +
|
||||
format.substr(fracLoc + fracFmt.length);
|
||||
}
|
||||
return moment.tz(ms, this._tz).format(format);
|
||||
return moment.tz(ms, this.tz_).format(format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export default class TimeStamp90kFormatter {
|
||||
* @param {String} tz Timezone
|
||||
*/
|
||||
constructor(tz) {
|
||||
this._formatter = new TimeFormatter(internalTimeFormat, tz);
|
||||
this.formatter_ = new TimeFormatter(internalTimeFormat, tz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ export default class TimeStamp90kFormatter {
|
||||
* @return {String} Formatted timestamp
|
||||
*/
|
||||
formatTimeStamp90k(ts90k) {
|
||||
return this._formatter.formatTimeStamp90k(ts90k);
|
||||
return this.formatter_.formatTimeStamp90k(ts90k);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ export default class TimeStamp90kFormatter {
|
||||
formatSameDayShortened(ts1, ts2) {
|
||||
let ts1Formatted = this.formatTimeStamp90k(ts1);
|
||||
let ts2Formatted = this.formatTimeStamp90k(ts2);
|
||||
const timePos = this._formatter.formatStr.indexOf('T');
|
||||
const timePos = this.formatter_.formatStr.indexOf('T');
|
||||
if (timePos != -1) {
|
||||
const datePortion = ts1Formatted.substr(0, timePos);
|
||||
ts1Formatted = datePortion + ' ' + ts1Formatted.substr(timePos + 1);
|
||||
|
||||
@@ -44,8 +44,8 @@ export default class URLBuilder {
|
||||
* @param {Boolean} relative True if relative urls desired
|
||||
*/
|
||||
constructor(base, relative = true) {
|
||||
this._baseUrl = base;
|
||||
this._relative = relative;
|
||||
this.baseUrl_ = base;
|
||||
this.relative_ = relative;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ export default class URLBuilder {
|
||||
* @param {Object} query Object with parameter name/value pairs
|
||||
* @return {URL} URL where query params have been added
|
||||
*/
|
||||
_addQuery(url, query = {}) {
|
||||
addQuery_(url, query = {}) {
|
||||
Object.entries(query).forEach(([k, v]) => url.searchParams.set(k, v));
|
||||
return url;
|
||||
}
|
||||
@@ -74,8 +74,8 @@ export default class URLBuilder {
|
||||
* @return {String} Formatted url, relative if so configured
|
||||
*/
|
||||
makeUrl(path, query = {}) {
|
||||
const url = new URL(path || '', this._baseUrl);
|
||||
this._addQuery(url, query);
|
||||
return this._relative ? url.pathname + url.search : url.href;
|
||||
const url = new URL(path || '', this.baseUrl_);
|
||||
this.addQuery_(url, query);
|
||||
return this.relative_ ? url.pathname + url.search : url.href;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user