Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate viewer functionality into main report (#1594)
- Loading branch information
1 parent
e7c6c50
commit 9ac57cb
Showing
20 changed files
with
372 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 Google Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* Generate a filenamePrefix of hostname_YYYY-MM-DD_HH-MM-SS | ||
* Date/time uses the local timezone, however Node has unreliable ICU | ||
* support, so we must construct a YYYY-MM-DD date format manually. :/ | ||
* @param {!Object} results | ||
* @returns string | ||
*/ | ||
function getFilenamePrefix(results) { | ||
// eslint-disable-next-line no-undef | ||
const hostname = new (URLConstructor || URL)(results.url).hostname; | ||
const date = (results.generatedTime && new Date(results.generatedTime)) || new Date(); | ||
|
||
const timeStr = date.toLocaleTimeString('en-US', {hour12: false}); | ||
const dateParts = date.toLocaleDateString('en-US', { | ||
year: 'numeric', month: '2-digit', day: '2-digit' | ||
}).split('/'); | ||
dateParts.unshift(dateParts.pop()); | ||
const dateStr = dateParts.join('-'); | ||
|
||
const filenamePrefix = `${hostname}_${dateStr}_${timeStr}`; | ||
// replace characters that are unfriendly to filenames | ||
return filenamePrefix.replace(/[\/\?<>\\:\*\|":]/g, '-'); | ||
} | ||
|
||
let URLConstructor; | ||
if (typeof module !== 'undefined' && module.exports) { | ||
URLConstructor = require('./url-shim'); | ||
|
||
module.exports = { | ||
getFilenamePrefix | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
"extends": "../../../.eslintrc.js", | ||
"env": { | ||
"browser": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.