Skip to content

Commit 7b534d6

Browse files
authored
Merge pull request #19 from RakSrinaNa/develop
Develop
2 parents 110fa3d + 27069ef commit 7b534d6

File tree

15 files changed

+125
-99
lines changed

15 files changed

+125
-99
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [2.2.3] - 2019-11-16
4+
5+
- Update Amcharts to 4.7.10.
6+
- Do not count play time if less than 500ms.
7+
38
## [2.2.2] - 2019-11-09
49

510
- Try to avoid sending watched time twice when switching video.

Mozilla-libs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Library used:
22

33
jQuery 3.4.1 from https://jquery.com/download/ "Download the compressed, production jQuery 3.4.1"
4-
Amcharts 4.7.7 from https://www.amcharts.com/download/ "Download a standalone JavaScript version"
4+
Amcharts 4.7.10 from https://www.amcharts.com/download/ "Download a standalone JavaScript version"
55
Bootstrap 4.3.1 from https://getbootstrap.com/docs/4.3/getting-started/download/#compiled-css-and-js
66
Popper.js 1.15.0 from https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.15.0/umd/popper.js
77
DropboxSDK 4.0.30 from https://www.npmjs.com/package/dropbox/v/4.0.30

includes/js/background.js

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ function notify(title, text, force = false) {
181181
* @param {Object} event The event of the change.
182182
*/
183183
function playerStateChange(event) {
184+
const MINIMUM_WATCH_THRESHOLD = 500; //0.5s
185+
184186
if (event[YTT_STATE_EVENT_STATE_KEY] === YTT_STATE_EVENT_STATE_KEY_PLAYING) {
185187
logDebug(`Started playing at ${event[YTT_STATE_EVENT_TIME_KEY]}s`);
186188
YTTSetBadge('P');
@@ -197,40 +199,6 @@ function playerStateChange(event) {
197199
activePlayers[event[YTT_STATE_EVENT_ID_KEY]] = null;
198200
logDebug(`Ended playing at ${event[YTT_STATE_EVENT_TIME_KEY]}s`);
199201

200-
let currentTime = new Date();
201-
let watchedMilliseconds = currentTime - activePlayer['time'];
202-
203-
let startDayDate = new Date();
204-
startDayDate.setHours(0, 0, 0, 0);
205-
206-
let msSinceThisMorning = currentTime - startDayDate;
207-
let durationsInfo = {};
208-
209-
if (watchedMilliseconds > msSinceThisMorning) {
210-
durationsInfo[YTTGetDayConfigKey()] = {
211-
date: currentTime.getTime(),
212-
duration: new YTTDuration(YTT_DATA_WATCHED, msSinceThisMorning)
213-
};
214-
watchedMilliseconds -= msSinceThisMorning;
215-
let currentDay = startDayDate;
216-
currentDay.setHours(23, 59, 59, 0);
217-
while (watchedMilliseconds > 0) {
218-
currentDay.setTime(currentDay.getTime() - YTT_MS_PER_DAY);
219-
let dayKey = YTTGetDayConfigKey(currentDay);
220-
let watchedThisDay = Math.min(YTT_MS_PER_DAY, watchedMilliseconds);
221-
durationsInfo[dayKey] = {
222-
date: currentDay.getTime(),
223-
duration: new YTTDuration(YTT_DATA_WATCHED, watchedThisDay)
224-
};
225-
watchedMilliseconds -= watchedThisDay;
226-
}
227-
} else {
228-
durationsInfo[YTTGetDayConfigKey()] = {
229-
date: currentTime.getTime(),
230-
duration: new YTTDuration(YTT_DATA_WATCHED, watchedMilliseconds)
231-
};
232-
}
233-
234202
const videoID = activePlayer['vid'];
235203
let size = 0;
236204
for (const key in activePlayers) {
@@ -241,47 +209,84 @@ function playerStateChange(event) {
241209
if (size < 1) {
242210
YTTSetBadge('');
243211
}
244-
YTTGetConfig([YTT_CONFIG_TOTAL_STATS_KEY, YTT_CONFIG_SHARE_ONLINE].concat(Object.keys(durationsInfo).filter(k => durationsInfo.hasOwnProperty(k)))).then(config => {
245-
if (!config[YTT_CONFIG_TOTAL_STATS_KEY]) {
246-
config[YTT_CONFIG_TOTAL_STATS_KEY] = new YTTDay();
212+
213+
let currentTime = new Date();
214+
let watchedMilliseconds = currentTime - activePlayer['time'];
215+
216+
if (watchedMilliseconds > MINIMUM_WATCH_THRESHOLD) {
217+
let startDayDate = new Date();
218+
startDayDate.setHours(0, 0, 0, 0);
219+
220+
let msSinceThisMorning = currentTime - startDayDate;
221+
let durationsInfo = {};
222+
223+
if (watchedMilliseconds > msSinceThisMorning) {
224+
durationsInfo[YTTGetDayConfigKey()] = {
225+
date: currentTime.getTime(),
226+
duration: new YTTDuration(YTT_DATA_WATCHED, msSinceThisMorning)
227+
};
228+
watchedMilliseconds -= msSinceThisMorning;
229+
let currentDay = startDayDate;
230+
currentDay.setHours(23, 59, 59, 0);
231+
while (watchedMilliseconds > 0) {
232+
currentDay.setTime(currentDay.getTime() - YTT_MS_PER_DAY);
233+
let dayKey = YTTGetDayConfigKey(currentDay);
234+
let watchedThisDay = Math.min(YTT_MS_PER_DAY, watchedMilliseconds);
235+
durationsInfo[dayKey] = {
236+
date: currentDay.getTime(),
237+
duration: new YTTDuration(YTT_DATA_WATCHED, watchedThisDay)
238+
};
239+
watchedMilliseconds -= watchedThisDay;
240+
}
247241
} else {
248-
config[YTT_CONFIG_TOTAL_STATS_KEY] = new YTTDay(config[YTT_CONFIG_TOTAL_STATS_KEY]);
242+
durationsInfo[YTTGetDayConfigKey()] = {
243+
date: currentTime.getTime(),
244+
duration: new YTTDuration(YTT_DATA_WATCHED, watchedMilliseconds)
245+
};
249246
}
250247

251-
Object.keys(durationsInfo).filter(k => durationsInfo.hasOwnProperty(k)).forEach(dayKey => {
252-
const durationInfo = durationsInfo[dayKey];
253-
const duration = durationInfo['duration'];
254-
const timestamp = durationInfo['date'];
255-
256-
if (!config[dayKey]) {
257-
config[dayKey] = new YTTDay();
248+
YTTGetConfig([YTT_CONFIG_TOTAL_STATS_KEY, YTT_CONFIG_SHARE_ONLINE].concat(Object.keys(durationsInfo).filter(k => durationsInfo.hasOwnProperty(k)))).then(config => {
249+
if (!config[YTT_CONFIG_TOTAL_STATS_KEY]) {
250+
config[YTT_CONFIG_TOTAL_STATS_KEY] = new YTTDay();
258251
} else {
259-
config[dayKey] = new YTTDay(config[dayKey]);
252+
config[YTT_CONFIG_TOTAL_STATS_KEY] = new YTTDay(config[YTT_CONFIG_TOTAL_STATS_KEY]);
260253
}
261254

262-
config[YTT_CONFIG_TOTAL_STATS_KEY].getWatchedDuration().addDuration(duration);
263-
config[dayKey].getWatchedDuration().addDuration(duration);
255+
Object.keys(durationsInfo).filter(k => durationsInfo.hasOwnProperty(k)).forEach(dayKey => {
256+
const durationInfo = durationsInfo[dayKey];
257+
const duration = durationInfo['duration'];
258+
const timestamp = durationInfo['date'];
264259

265-
logDebug(`Added real time: ${duration.getAsString(true)} for day ${new Date(timestamp)}`);
266-
});
260+
if (!config[dayKey]) {
261+
config[dayKey] = new YTTDay();
262+
} else {
263+
config[dayKey] = new YTTDay(config[dayKey]);
264+
}
267265

268-
YTTSetConfig(config).then(() => {
269-
if (config[YTT_CONFIG_SHARE_ONLINE] === true) {
270-
sendRequestsToAPI(Object.keys(durationsInfo).filter(k => durationsInfo.hasOwnProperty(k)).map(dayKey => {
271-
const durationInfo = durationsInfo[dayKey];
272-
const duration = durationInfo['duration'];
273-
const timestamp = durationInfo['date'];
274-
275-
return {
276-
date: timestamp,
277-
videoID: videoID,
278-
type: 'watched',
279-
duration: duration
280-
};
281-
}));
282-
}
266+
config[YTT_CONFIG_TOTAL_STATS_KEY].getWatchedDuration().addDuration(duration);
267+
config[dayKey].getWatchedDuration().addDuration(duration);
268+
269+
logDebug(`Added real time: ${duration.getAsString(true)} for day ${new Date(timestamp)}`);
270+
});
271+
272+
YTTSetConfig(config).then(() => {
273+
if (config[YTT_CONFIG_SHARE_ONLINE] === true) {
274+
sendRequestsToAPI(Object.keys(durationsInfo).filter(k => durationsInfo.hasOwnProperty(k)).map(dayKey => {
275+
const durationInfo = durationsInfo[dayKey];
276+
const duration = durationInfo['duration'];
277+
const timestamp = durationInfo['date'];
278+
279+
return {
280+
date: timestamp,
281+
videoID: videoID,
282+
type: 'watched',
283+
duration: duration
284+
};
285+
}));
286+
}
287+
});
283288
});
284-
});
289+
}
285290
}
286291
}
287292

includes/js/lib/amcharts/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,44 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55
Please note, that this project, while following numbering syntax, it DOES NOT
66
adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.
77

8+
## [4.7.10] - 2019-11-15
9+
10+
### Added
11+
- Global method `am4core.system.softInvalidate(chart)` added. Call this method if you update data or config of a chart that is in hidden container, after revealing the container, so that labels and possibly other elements can correctly arrange themselves.
12+
13+
### Fixed
14+
- JSON config `MapChart` was breaking on geodata parsing since last release (4.7.9).
15+
- Sometimes `MapChart` used to zoom to a wrong position when using `zoomToMapObject()` method (happened if pan inert animation was not finished at the moment of the function call).
16+
- `Container`'s "grid" layout was incorrectly positioning items if one of its children was disabled.
17+
- Creating a standalone series object (without assigning it to a chart) was resultin in a JS error.
18+
19+
20+
## [4.7.9] - 2019-11-14
21+
22+
### Added
23+
- New `Sprite` property: `showTooltipOn`. Available options: `"hover"` (default), `"hit"`, and `"always"`.
24+
- `ignoreZeroValues` added to `PercentSeries` (default: `false`). If set to `true` it will not show slices with zero values.
25+
26+
### Changed
27+
- `Sprite` property `alwaysShowTooltip` is now being deprecated in favor of `showTooltipOn = "always"`.
28+
- In `WordCloud` words connected with a dash without spaces will not be treated as a single word, e.g. "76-ers" is now a single word rather than two separate words "76" and "ers".
29+
- JSON config based charts will now fail with a critical error if there's incorrect `type` specified for one of the objects.
30+
31+
### Fixed
32+
- Initial chart responsive rules were sometimes not being applied.
33+
- When `MapChart` was zoomed/panned, "always-on" tooltip were remaining in the same place.
34+
- HTML labels with `maxWidth` and `wrap` set were not being sized correctly.
35+
- Sides of `Column3D` were not being colored properly when `fill` was being set via `propertyFields` and string-based hex color codes were used in data.
36+
- After click on chart with `XYCursor` that `behavior = "select*"` its `xRange` and `yRange` was not being reset and could show ranges from previous selection.
37+
- `XYCursor` will now respect order of series when showing their tooltips if they share the same value.
38+
- Tooltip position of rotated and/or scaled sprites was incorrect.
39+
- Changing series of `XYChartScrollbar` was not working properly (old series could remain or new series were not appearing).
40+
- `PictorialSeries`, and `PyramidSeries` were not working properly with slices with `<= 0` values.
41+
- When removing data from a chart using `addData(data, removeCount)`, chart was rmeoving data items from series which had data set explicitly.
42+
- Bullets on a `RadarChart` could be displayed in wrong positions when zooming/hiding series.
43+
- When minimizing series they could animate to incorrect minimum values and adjust min/max values.
44+
45+
846
## [4.7.8] - 2019-11-05
947

1048
### Added

includes/js/lib/amcharts/charts.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/js/lib/amcharts/charts.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/js/lib/amcharts/core.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/js/lib/amcharts/core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/js/lib/amcharts/maps.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/js/lib/amcharts/maps.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)