juice-shop
116 строк · 5.2 Кб
1doctype html
2html(lang='en')
3head
4title _title_
5meta(charset='utf-8')
6meta(name='description', content='')
7meta(name='keywords', content='')
8meta(name='viewport' content='width=device-width, initial-scale=1.0')
9link(rel='icon', type='image/x-icon', href='./assets/public/_favicon_')
10link(rel='stylesheet', href='https://code.getmdl.io/1.3.0/material.min.css')
11link(rel='stylesheet', href='https://fonts.googleapis.com/icon?family=Material+Icons')
12link(rel='stylesheet', href='http://fonts.googleapis.com/css?family=Roboto:300,400,500,700', type='text/css')
13script(src='//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js')
14script(defer='', src='https://code.getmdl.io/1.3.0/material.min.js')
15style.
16video {
17min-width: 320px;
18width: 44vw;
19display: block;
20margin-left: auto;
21margin-right:auto;
22margin-bottom: 5px;
23height: 50vh;
24outline: none;
25}
26@media (max-width: 900px) {
27.mdl-layout-title {
28display: none !important;
29}
30}
31body(style='background: _bgColor_;color:_textColor_;')
32.mdl-layout.mdl-js-layout.mdl-layout--fixed-header
33header.mdl-layout__header.mdl-shadow--8dp(style= 'background: _navColor_; height: auto; min-width: 100%; padding-bottom: 5px; width: 100%;')
34.mdl-layout__header-row
35a(href='./#/' style='color: _textColor_; text-decoration:none; margin-left: -50px;')
36i(class='material-icons', style='display: block;margin-bottom: auto;margin-top: auto; margin-right: 10px;') arrow_back
37a(href='./#/' style='color: _textColor_; text-decoration:none;')
38span(style='margin-right: 20px;')
39| Back
40// Logo
41a(href='./#/')
42img(src='assets/public/images/JuiceShop_Logo.png', style='max-height: 60px; width: auto;', alt='_title_ Logo')
43// Title
44a(href='./#/' style='color: _textColor_; text-decoration:none;')
45span.mdl-layout-title(style='font: 500 20px/32px Roboto,"Helvetica Neue",sans-serif;')
46| _title_
47
48section.section--center.mdl-grid.mdl-grid--no-spacing
49.mdl-card#card.mdl-cell.mdl-cell--12-col.mdl-shadow--8dp(style='width: 45vw; min-width: 320px; height: 58vh; background: _primLight_; margin-bottom: 50px; margin-top: 110px; display: block; margin-left: auto; margin-right:auto; ')
50h1(style='color: _textColor_; font-size: 24px; line-height: 32px; margin-top: 16px; margin-bottom: 16px; font-weight: 400; margin-left: 16px;') Promotion Video
51video(width='85vw', height='240', controls='controls')
52source(src='./video', type='video/mp4')
53
54script#subtitle.
55
56
57script.
58function parse_timestamp(s) {
59var match = s.match(/^(?:([0-9]+):)?([0-5][0-9]):([0-5][0-9](?:[.,][0-9]{0,3})?)/);
60if (match == null) {
61throw 'Invalid timestamp format: ' + s;
62}
63var hours = parseInt(match[1] || "0", 10);
64var minutes = parseInt(match[2], 10);
65var seconds = parseFloat(match[3].replace(',', '.'));
66return seconds + 60 * minutes + 60 * 60 * hours;
67}
68function quick_and_dirty_vtt_or_srt_parser(vtt) {
69var lines = vtt.trim().replace('\\r\n', '\n').split(/[\r\n]/).map(function(line) {
70return line.trim();
71});
72var cues = [];
73var start = null;
74var end = null;
75var payload = null;
76for (var i = 0; i < lines.length; i++) {
77if (lines[i].indexOf('-->') >= 0) {
78var splitted = lines[i].split(/[ \\t]+-->[ \t]+/);
79if (splitted.length != 2) {
80throw 'Error when splitting "-->": ' + lines[i];
81}
82// Already ignoring anything past the "end" timestamp (i.e. cue settings).
83start = parse_timestamp(splitted[0]);
84end = parse_timestamp(splitted[1]);
85} else if (lines[i] == '') {
86if (start && end) {
87var cue = new VTTCue(start, end, payload);
88cues.push(cue);
89start = null;
90end = null;
91payload = null;
92}
93} else if(start && end) {
94if (payload == null) {
95payload = lines[i];
96} else {
97payload += '\\n' + lines[i];
98}
99}
100}
101if (start && end) {
102var cue = new VTTCue(start, end, payload);
103cues.push(cue);
104}
105return cues;
106}
107function init() {
108var video = document.querySelector('video');
109var subtitle = document.getElementById('subtitle');
110var track = video.addTextTrack('subtitles', subtitle.dataset.label, subtitle.dataset.lang);
111track.mode = "showing";
112quick_and_dirty_vtt_or_srt_parser(subtitle.innerHTML).map(function(cue) {
113track.addCue(cue);
114});
115}
116init();
117