Merge pull request #1069 from AleziaKurdis/CreateApp-BrokenURLReport

Create App: Broken Url Report
This commit is contained in:
Kalila 2021-04-01 17:18:05 -04:00 committed by GitHub
commit 519db8743d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 520 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -35,7 +35,8 @@ Script.include([
"../libraries/gridTool.js",
"entityList/entityList.js",
"entitySelectionTool/entitySelectionTool.js",
"audioFeedback/audioFeedback.js"
"audioFeedback/audioFeedback.js",
"modules/brokenURLReport.js"
]);
var CreateWindow = Script.require('./modules/createWindow.js');

View file

@ -413,12 +413,14 @@ EntityListTool = function(shouldUseEditTabletApp) {
alignGridToSelection();
} else if (data.type === 'alignGridToAvatar') {
alignGridToAvatar();
} else if (data.type === 'brokenURLReport') {
brokenURLReport(selectionManager.selections);
} else if (data.type === 'toggleGridVisibility') {
toggleGridVisibility();
} else if (data.type === 'toggleSnapToGrid') {
that.toggleSnapToGrid();
that.toggleSnapToGrid();
}
};
webView.webEventReceived.connect(onWebEventReceived);

View file

@ -308,7 +308,14 @@
<div class = "menu-item-caption">Align Grid to Avatar</div>
<div class = "menu-item-shortcut">K</div>
</div>
</button>
</button>
<div class="menu-separator"></div>
<button class="menu-button" id="brokenURLReport" >
<div class = "menu-item">
<div class = "menu-item-caption">Generate Broken URL Report</div>
<div class = "menu-item-shortcut"></div>
</div>
</button>
</div>
<div id="menuBackgroundOverlay" ></div>
</body>

View file

@ -273,6 +273,7 @@ let elEntityTable,
elSnapToGridActivatorCaption,
elAlignGridToSelection,
elAlignGridToAvatar,
elBrokenURLReport,
elFilterTypeMultiselectBox,
elFilterTypeText,
elFilterTypeOptions,
@ -359,7 +360,8 @@ function loaded() {
elSnapToGridActivator = document.getElementById("snapToGridActivator");
elSnapToGridActivatorCaption = document.getElementById("snapToGridActivatorCaption");
elAlignGridToSelection = document.getElementById("alignGridToSelection");
elAlignGridToAvatar = document.getElementById("alignGridToAvatar");
elAlignGridToAvatar = document.getElementById("alignGridToAvatar");
elBrokenURLReport = document.getElementById("brokenURLReport");
elFilterTypeMultiselectBox = document.getElementById("filter-type-multiselect-box");
elFilterTypeText = document.getElementById("filter-type-text");
elFilterTypeOptions = document.getElementById("filter-type-options");
@ -597,7 +599,11 @@ function loaded() {
elAlignGridToAvatar.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ type: "alignGridToAvatar" }));
closeAllEntityListMenu();
};
};
elBrokenURLReport.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ type: "brokenURLReport" }));
closeAllEntityListMenu();
};
elToggleSpaceMode.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: "toggleSpaceMode" }));
};

View file

@ -0,0 +1,102 @@
<!DOCTYPE html>
<!--//
// brokenURLReport.html
//
// Created by Alezia Kurdis on February 22, 2021.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//-->
<html>
<head>
<meta charset="utf-8" />
<style>
body {
background-color:#000000;
color:#ffffff;
font-family: Helvetica, Arial, Sans-Serif;
font-weight: 700;
font-size: 12px;
text-align: center;
width: 100%;
}
h1 {
font-size: 18px;
font-weight: 900;
}
table {
text-align: left;
width:96%;
border: 1px solid #DDDDDD;
border-collapse: collapse;
}
td {
border: 1px solid #DDDDDD;
padding: 3px;
}
td.superheader {
font-size: 18px;
text-align: center;
font-weight: 900;
background-color:#999999;
}
td.header {
font-weight: 900;
background-color:#777777;
}
a {
font-size: 22px;
font-weight: 500;
}
a:link {
color: #00b3ff;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: #00b3ff;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: #99e1ff;
background-color: transparent;
text-decoration: none;
}
a:active {
color: #99e1ff;
background-color: transparent;
text-decoration: none;
}
</style>
</head>
<body>
<div id="report">
<div style='text-align: center; width: 100%;'>
<h1>
<br>
<br>
Testing in progress...
</h1>
<br>
<img src='../assets/images/processing.gif'>
</div>
</div>
</body>
<script>
EventBridge.scriptEventReceived.connect(function (message) {
document.getElementById("report").innerHTML = message;
});
function selectEntity(id) {
EventBridge.emitWebEvent(JSON.stringify({
"action": "select",
"entityID": id
}));
}
</script>
</html>

View file

@ -0,0 +1,393 @@
//
// brokenURLReport.js
//
// Created by Alezia Kurdis on February 22, 2021.
// Copyright 2021 Vircadia contributors.
//
// This script reports broken URLs to the Create Application.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var brokenURLReportHttpRequest;
var brokenURLReportUrlList = [];
var brokenURLReportInvalideUrlList = [];
var brokenURLReportProcessedUrlNo = 0;
var brokenURLReportUrlEntry;
var brokenURLReportMessageBox;
var brokenURLReportOverlayWebWindow;
var BROKEN_URL_REPORT_YES_BUTTON = 0x4000;
var BROKEN_URL_REPORT_NO_BUTTON = 0x10000;
var MAX_URL_BEFORE_WARNING_FOR_LONG_PROCESS = 20;
function brokenURLReportRequestUrlValidityCheck(no) {
brokenURLReportHttpRequest = new XMLHttpRequest();
brokenURLReportHttpRequest.requestComplete.connect(brokenURLReportGetResponseStatus);
brokenURLReportHttpRequest.open("GET", brokenURLReportUrlList[no].url);
brokenURLReportHttpRequest.send();
}
function brokenURLReportGetResponseStatus() {
if (brokenURLReportHttpRequest.status === 0 || brokenURLReportHttpRequest.status > 299) {
if (brokenURLReportHttpRequest.status === 0) {
brokenURLReportUrlList[brokenURLReportProcessedUrlNo].validity = "0 - URL not well-formed";
} else {
brokenURLReportUrlList[brokenURLReportProcessedUrlNo].validity = brokenURLReportHttpRequest.status + " - " + brokenURLReportHttpRequest.statusText;
}
brokenURLReportInvalideUrlList.push(brokenURLReportUrlList[brokenURLReportProcessedUrlNo]);
}
brokenURLReportHttpRequest.requestComplete.disconnect(brokenURLReportGetResponseStatus);
brokenURLReportHttpRequest = null;
brokenURLReportProcessedUrlNo = brokenURLReportProcessedUrlNo + 1;
if (brokenURLReportProcessedUrlNo === brokenURLReportUrlList.length) {
brokenURLReportGenerateFormatedReport(brokenURLReportInvalideUrlList);
brokenURLReportUrlList = [];
brokenURLReportInvalideUrlList = [];
brokenURLReportProcessedUrlNo = 0;
} else {
brokenURLReportRequestUrlValidityCheck(brokenURLReportProcessedUrlNo);
}
}
function brokenURLReportGenerateFormatedReport(brokenURLReportInvalideUrlList) {
var brokenURLReportContent = "";
if (brokenURLReportInvalideUrlList.length === 0) {
brokenURLReportContent = "<h1>Broken URL Report<br><br>" + brokenURLReportUrlList.length + " URL tested.<br><font style='color:#00FF00;'>NO ISSUES HAVE BEEN FOUND.</font></h1><br><br><br>";
brokenURLReportContent += "<div style='width: 100%; text-align: left;'><hr><font style='font-size: 11px; font-weight: 500;'><i>This report ignores Asset Server URLs (atp://), local drive paths, and any string not starting with 'http'.</i></font></div>";
Script.setTimeout(function () {
brokenURLReportOverlayWebWindow.emitScriptEvent(brokenURLReportContent);
}, 3000);
return;
}
brokenURLReportContent = " <h1>Broken URL Report</h1>\n";
brokenURLReportContent += " <table>\n";
brokenURLReportContent += " <tr>\n";
brokenURLReportContent += " <td class='superheader'>&nbsp;</td>\n";
brokenURLReportContent += " <td class='superheader' colspan='3'>Entity</td>\n";
brokenURLReportContent += " <td class='superheader' colspan='3'>Broken Url</td>\n";
brokenURLReportContent += " </tr>\n";
brokenURLReportContent += " <tr>\n";
brokenURLReportContent += " <td class='header'>No</td>\n";
brokenURLReportContent += " <td class='header'>Type</td>\n";
brokenURLReportContent += " <td class='header'>Name &amp; ID</td>\n";
brokenURLReportContent += " <td class='header'>&nbsp;</td>\n";
brokenURLReportContent += " <td class='header'>Property</td>\n";
brokenURLReportContent += " <td class='header'>Status</td>\n";
brokenURLReportContent += " <td class='header'>Current URL</td>\n";
brokenURLReportContent += " </tr>\n";
for (var i = 0; i < brokenURLReportInvalideUrlList.length; i++ ){
brokenURLReportContent += " <tr>\n";
brokenURLReportContent += " <td style='color: #999999; width: 5%;'>" + (i + 1) + "</td>\n";
brokenURLReportContent += " <td style='width: 10%;'>" + brokenURLReportInvalideUrlList[i].type + "</td>\n";
brokenURLReportContent += " <td style='width: 40%;'>" + brokenURLReportInvalideUrlList[i].name + "<br><font color='#999999'>" + brokenURLReportInvalideUrlList[i].id + "</font></td>\n";
brokenURLReportContent += " <td style='width: 2%;'><a href='' onclick='selectEntity(" + '"' + brokenURLReportInvalideUrlList[i].id + '"' + "); return false;'>&#9998;</a></td>\n";
brokenURLReportContent += " <td style='color: " + brokenURLReportGetUrlTypeColor(brokenURLReportInvalideUrlList[i].urlType) + "; width: 10%;'>" + brokenURLReportInvalideUrlList[i].urlType + "</td>\n";
brokenURLReportContent += " <td style='background-color: #FF0000; color: #FFFFFF; width: 8%;'>" + brokenURLReportInvalideUrlList[i].validity + "</td>\n";
brokenURLReportContent += " <td style='word-wrap: break-word; width:200px;'>" + brokenURLReportInvalideUrlList[i].url + "</td>\n";
brokenURLReportContent += " </tr>\n";
}
brokenURLReportContent += " </table>\n";
brokenURLReportContent += "<div style='width: 100%; text-align: left;'><br>" + brokenURLReportUrlList.length + " URL tested.<br><br>";
brokenURLReportContent += "<hr><font style='font-size: 11px; font-weight: 500;'><i>This report ignores Asset Server URLs (atp://), local drive paths, and any string not starting with 'http'.</i></font></div>";
Script.setTimeout(function () {
brokenURLReportOverlayWebWindow.emitScriptEvent(brokenURLReportContent);
}, 3000);
}
function brokenURLReportGetUrlTypeColor(urlType) {
var color = "#FFFFFF";
switch (urlType) {
case "script":
color = "#00FF00";
break;
case "serverScripts":
color = "#FF00FF";
break;
case "imageURL":
color = "#00FFFF";
break;
case "materialURL":
color = "#FF6600";
break;
case "modelURL":
color = "#FFFF00";
break;
case "compoundShapeURL":
color = "#6666FF";
break;
case "animation.url":
color = "#6699FF";
break;
case "textures":
color = "#FF0066";
break;
case "xTextureURL":
color = "#0000FF";
break;
case "yTextureURL":
color = "#009966";
break;
case "zTextureURL":
color = "#993366";
break;
case "font":
color = "#FFFFFF";
break;
case "sourceUrl":
color = "#BBFF00";
break;
case "scriptURL":
color = "#FFBBBB";
break;
case "filterURL":
color = "#BBBBFF";
break;
case "skybox.url":
color = "#BBFFFF";
break;
case "ambientLight.ambientURL":
color = "#FF3300";
}
return color;
}
function brokenURLReport(entityIDs) {
if (entityIDs.length === 0) {
audioFeedback.rejection();
Window.alert("You have nothing selected.");
return;
} else {
var properties;
for (var i = 0; i < entityIDs.length; i++ ){
properties = Entities.getEntityProperties(entityIDs[i]);
if (properties.script.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "script",
url: properties.script,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.serverScripts.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "serverScripts",
url: properties.serverScripts,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Image" && properties.imageURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "imageURL",
url: properties.imageURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Material" && properties.materialURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "materialURL",
url: properties.materialURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Model" && properties.modelURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "modelURL",
url: properties.modelURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (
(properties.type === "Zone" || properties.type === "Model" || properties.type === "ParticleEffect")
&& properties.compoundShapeURL.toLowerCase().startsWith("http")
) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "compoundShapeURL",
url: properties.compoundShapeURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Model" && properties.animation.url.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "animation.url",
url: properties.animation.url,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "ParticleEffect" && properties.textures.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "textures",
url: properties.textures,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "PolyVox" && properties.xTextureURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "xTextureURL",
url: properties.xTextureURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "PolyVox" && properties.yTextureURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "yTextureURL",
url: properties.yTextureURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "PolyVox" && properties.zTextureURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "zTextureURL",
url: properties.zTextureURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Text" && properties.font.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "font",
url: properties.font,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Web" && properties.sourceUrl.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "sourceUrl",
url: properties.sourceUrl,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Web" && properties.scriptURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "scriptURL",
url: properties.scriptURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Zone" && properties.filterURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "filterURL",
url: properties.filterURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Zone" && properties.skybox.url.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "skybox.url",
url: properties.skybox.url,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
if (properties.type === "Zone" && properties.ambientLight.ambientURL.toLowerCase().startsWith("http")) {
brokenURLReportUrlEntry = {
id: entityIDs[i],
name: properties.name,
type: properties.type,
urlType: "ambientLight.ambientURL",
url: properties.ambientLight.ambientURL,
validity: "NOT_TESTED"
};
brokenURLReportUrlList.push(brokenURLReportUrlEntry);
}
}
if (brokenURLReportUrlList.length === 0) {
audioFeedback.confirmation();
Window.alert("No 'http' URL has been found within the current selection.");
return;
} else {
if (brokenURLReportUrlList.length > MAX_URL_BEFORE_WARNING_FOR_LONG_PROCESS) {
var message = "Number of http URLs found: " + brokenURLReportUrlList.length + "\n The analysis may take time. Do you want to proceed?";
var answer = Window.confirm(message);
if (!answer) {
return;
}
}
if (brokenURLReportOverlayWebWindow !== undefined) {
brokenURLReportOverlayWebWindow.close();
}
brokenURLReportOverlayWebWindow = new OverlayWebWindow({
title: "Broken URL Report",
source: Script.resolvePath("brokenURLReport.html"),
width: 1000,
height: 600
});
brokenURLReportContent = "";
brokenURLReportRequestUrlValidityCheck(brokenURLReportProcessedUrlNo);
}
}
brokenURLReportOverlayWebWindow.webEventReceived.connect(function (message) {
try {
var data = JSON.parse(message);
} catch(e) {
print("brokenURLReport.js: Error parsing JSON");
return;
}
if (data.action === "select") {
selectionManager.setSelections([data.entityID], this);
}
});
}

View file

@ -1969,7 +1969,7 @@ div.entity-list-menu {
}
div.menu-separator{
width: 90%;
width: 100%;
height: 2px;
background-color: #505050;
}
@ -1987,12 +1987,12 @@ button.menu-button {
}
button.menu-button:hover {
background-color: #00B4EF;
background-color: #919191;
border: none;
}
button.menu-button:active {
background-color: #00B4EF;
background-color: #919191;
border: none;
}