Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Remove unused functions #722

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Vue from 'vue';
import Base from './base';
import _ from 'lodash';
import axios from 'axios';
import Routes from './routes';
import VueRouter from 'vue-router';
import VueJsonPretty from 'vue-json-pretty';
import moment from 'moment-timezone';

require('bootstrap');

Expand Down
107 changes: 0 additions & 107 deletions resources/js/base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import moment from 'moment-timezone';

export default {
Expand All @@ -9,43 +8,6 @@ export default {
},

methods: {
/**
* Show the time ago format for the given time.
*/
timeAgo(time) {
moment.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
s: number => number + 's ago',
ss: '%ds ago',
m: '1m ago',
mm: '%dm ago',
h: '1h ago',
hh: '%dh ago',
d: '1d ago',
dd: '%dd ago',
M: 'a month ago',
MM: '%d months ago',
y: 'a year ago',
yy: '%d years ago',
},
});

let secondsElapsed = moment().diff(time, 'seconds');
let dayStart = moment('2018-01-01')
.startOf('day')
.seconds(secondsElapsed);

if (secondsElapsed > 300) {
return moment(time).fromNow(true);
} else if (secondsElapsed < 60) {
return dayStart.format('s') + 's ago';
} else {
return dayStart.format('m:ss') + 'm ago';
}
},

/**
* Format the given date with respect to timezone.
*/
Expand Down Expand Up @@ -83,74 +45,5 @@ export default {
readableTimestamp(timestamp) {
return this.formatDate(timestamp).format('YYYY-MM-DD HH:mm:ss');
},

/**
* Format the tags.
*/
displayableTagsList(tags, truncate = true) {
if (!tags || !tags.length) return '';

return _.reduce(
tags,
(s, n) => {
return (s ? s + ', ' : '') + (truncate ? _.truncate(n) : n);
},
''
);
},

/**
* Show the time in local time.
*/
localTime(time) {
return moment(time + ' Z')
.utc()
.local()
.format('MMMM Do YYYY, h:mm:ss A');
},

/**
* Truncate the given string.
*/
truncate(string, length = 70) {
return _.truncate(string, {
length: length,
separator: /,? +/,
});
},

/**
* Creates a debounced function that delays invoking a callback.
*/
debouncer: _.debounce(callback => callback(), 500),

/**
* Show an error message.
*/
alertError(message) {
this.$root.alert.type = 'error';
this.$root.alert.autoClose = false;
this.$root.alert.message = message;
},

/**
* Show a success message.
*/
alertSuccess(message, autoClose) {
this.$root.alert.type = 'success';
this.$root.alert.autoClose = autoClose;
this.$root.alert.message = message;
},

/**
* Show confirmation message.
*/
alertConfirm(message, success, failure) {
this.$root.alert.type = 'confirmation';
this.$root.alert.autoClose = false;
this.$root.alert.message = message;
this.$root.alert.confirmationProceed = success;
this.$root.alert.confirmationCancel = failure;
},
},
};