Skip to content

Commit

Permalink
Rm moment.js
Browse files Browse the repository at this point in the history
Closes #309
`
  • Loading branch information
machawk1 committed Sep 15, 2020
1 parent 1ccc179 commit 9619a15
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ exclude_paths:
- "mink-plugin/highchartsdata.js"
- "mink-plugin/images/*"
- "mink-plugin/jquery.miller.js/*"
- "mink-plugin/js/jquery-3.4.1.min.js"
- "mink-plugin/moment-with-langs.min.js"
- "mink-plugin/js/jquery-3.4.1.min.js"
3 changes: 1 addition & 2 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mink-plugin/d3.v3/*
mink-plugin/jquery.miller.js/*
mink-plugin/js/select2/*
mink-plugin/js/date.js
mink-plugin/moment-with-langs.min.js
mink-plugin/js/date.js
29 changes: 9 additions & 20 deletions mink-plugin/js/displayMinkUI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global chrome, $, Timemap, moment, tmData */
/* global chrome, $, Timemap, tmData */

var MAX_MEMENTOS_IN_DROPDOWN = 500

Expand Down Expand Up @@ -274,15 +274,8 @@ function archiveURIArchiveDotIs (cb, openInNewTab) {

/* Vars in this namespace get "already declared" error when injected, hence var instead of let */
var years = {}
var monthNames = getMonthNames('en', 'short')

/* Begin date function, TODO: move to separate file */

function getMonthNames (locale, format) {
const formatter = new Intl.DateTimeFormat(locale, { month: format })
return [...Array(12).keys()].map(m => formatter.format(new Date(2020, m)))
}

function getShortMonthNameFromMonthInt (locale, format, monthInt) {
return new Intl.DateTimeFormat(locale, { month: format }).format(new Date(2020, monthInt))
}
Expand All @@ -293,15 +286,6 @@ function getNumberWithOrdinal (n) {
return n + (s[(v - 20) % 10] || s[v] || s[0])
}

/* function getDayNames () {
const dayNames = ['NA']
Array.from({ length: 31 }, (_, d) =>
dayNames.push(getNumberWithOrdinal(d + 1))
)
return dayNames
} */

/* End date functions */

function buildDrilldownYear (mementos) {
Expand Down Expand Up @@ -497,14 +481,19 @@ function buildDrilldownTime (year, month, date) {
let times = []

for (let memento in mementos) {
let datetime = moment(mementos[memento].datetime)
const mementoDatetime = new Date(mementos[memento].datetime)
const mementoYear = mementoDatetime.getFullYear()
const monthName = getShortMonthNameFromMonthInt('en', 'short', mementoDatetime.getMonth())
const mementoDate = mementoDatetime.getDate()

if (datetime.year() !== year || monthNames[datetime.month()] !== month || datetime.date() !== date) {
if (mementoYear !== year || monthName !== month || mementoDate !== date) {
// REJECT
continue
}

mementos[memento].time = addZ(datetime.hour()) + ':' + addZ(datetime.minute()) + ':' + addZ(datetime.second())
mementos[memento].time = addZ(mementoDatetime.getHours()) + ':' +
addZ(mementoDatetime.getMinutes()) + ':' +
addZ(mementoDatetime.getSeconds())
times.push(mementos[memento])
}

Expand Down
1 change: 0 additions & 1 deletion mink-plugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
{
"js": [
"js/jquery-3.4.1.min.js","js/select2/select2.min.js",
"moment-with-langs.min.js",
"jquery.miller.js/jquery.miller.js",

"content.js","timemap.js"],
Expand Down
9 changes: 0 additions & 9 deletions mink-plugin/moment-with-langs.min.js

This file was deleted.

0 comments on commit 9619a15

Please sign in to comment.