function getTimestamps(from, to, step) {
function f(timestamps, current) {
return current.isBefore(to)
? f([...timestamps, current.clone()], current.add(step, 'minutes'))
: [...timestamps, to.clone()];
}
return f([], from)
}
const timestamps = getTimestamps(
moment('1745', 'hmm'),
moment('2000', 'hmm'),
30
);
console.log(
timestamps
.map(t => t.format('HH:mm'))
.toString()
) // 17:45,18:15,18:45,19:15,19:45,20:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<link rel="stylesheet" href="/src/style.foo.css" />
<script src="src/script.foo.js"></script>
</head>
<body>
<div id="nest"></div>
<link rel="stylesheet" href="/src/style.bar.css" />
<script src="src/script.bar.js"></script>
<script>
const nest = document.querySelector("#nest");
const elems = document.querySelectorAll('link[rel="stylesheet"], script[src]');
elems.forEach(el => {
fetch(el.src || el.href)
.then(r => r.text())
.then(src => {
const pre = document.createElement("pre");
const hr = document.createElement("hr");
pre.innerText = src;
nest.appendChild(pre);
nest.appendChild(hr);
});
});
</script>
</body>
</html>
const myIframeDocument = document.querySelector('iframe').contentDocument;
myIframeDocument.querySelectorAll('link[rel="stylesheet"], script[src]');
//ну и дальше тоже самое...
//App.vue
<template>
<div id="app">
<router-link to="/random/12323jlwe">12323jlwe</router-link>|
<router-link to="/random/cxz98c7zf8a">cxz98c7zf8a</router-link>|
<router-link to="/random/90cvuiwa-r">90cvuiwa-r</router-link>
<section class="content">
<router-view :key="$route.fullPath"></router-view>
</section>
</div>
</template>
//main.js
import Vue from "vue";
import Router from "vue-router";
import App from "./App.vue";
Vue.use(Router);
var testComponent = Vue.component("main-section", {
template: `<component :is="template"></component>`,
data() {
return {
template: Vue.compile("<div>please stand by</div>")
};
},
created() {
// axios.post...
setTimeout(() => {
this.template = Vue.compile(`<div>${this.$route.fullPath}</div>`);
}, 2000);
},
mounted() {
console.log("mounted-" + new Date().getTime());
}
});
const router = new Router({
mode: "history",
routes: [{ path: "/random/:random", component: testComponent }]
});
/* eslint-disable no-new */
new Vue({
el: "#app",
router,
render: h => h(App)
});
<script src="//cdnjs.cloudflare.com/ajax/libs/validate.js/0.12.0/validate.min.js"></script>
x[1] = 0, y[1] = 500
x[2] = 100, y[2] = 1200
(500 - 1200)x + (100 - 0)y + (0 * 1200 - 100 * 500) = 0
-700x + 100y - 50000 = 0
100y = 50000 + 700x
y = (50000 + 700x) / 100
y = ((500 + 7x) * 100) / 100
y = 500 + 7x
onUploadProgress({loaded, total}) {
const uploadProgress = Math.round(loaded / total * 100)
store.commit('uploader/setProgress', uploadProgress)
}
export const uploader = {
namespaced: true,
state: {
progress: 0
},
mutations: {
setProgress(state, progress) {
state.progress = progress
}
}
}
computed: {
...mapState('uploader', [
'progress'
])
}
<template>
<div>{{progress}}%</div>
</template>
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var autoprefixer = require('gulp-autoprefixer');
var plumber = require('gulp-plumber');
gulp.task('browser-sync', function(done) {
browserSync.init({
server: {
baseDir: './out'
},
notify: false
});
browserSync.watch('out/').on('change', browserSync.reload);
done()
});
gulp.task('sass', function(done){
gulp.src('app/scss/*.scss')
.pipe(plumber({
errorHandler : function(err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sass({errLogToConsole: true}))
.pipe(sass({outputStyle: 'compact'}))
.pipe(autoprefixer({
browsers: ['last 4 versions'],
cascade: false
}))
.pipe(gulp.dest('out/assets/css'))
.pipe(browserSync.reload({stream: true}));
done()
});
gulp.task('watch', gulp.series('sass', 'browser-sync', function(done) {
gulp.watch('app/**/*.*', gulp.series('sass'));
done()
}));
const jwt = {
payload: {
idle: 900000 // 15min * 60s * 1000ms
}
}
setInterval(() => {
user.logout()
}, jwt.payload.idle)
<InputText
:value="userName"
@input="handleUserName($event)">
</InputText>
computed: {
userName: {
get() {
return this.$store.state.administration.user.name
},
set(value) {
this.$store.commit('setUserName', value)
}
}
},
methods: {
handleUserName(value){
this.userName = value
}
}
methods: {
openPopup() {
this.$store.dispatch('loadUser')
.then(() => {
this.popupOpen = true
})
}
}