don't use Script.resolvePath() in local functions

This commit is contained in:
Andrew Meadows 2016-08-29 17:11:29 -07:00
parent b1d472c9ba
commit b50d24fb00
5 changed files with 27 additions and 17 deletions

View file

@ -164,9 +164,10 @@ function toggleMarketplace() {
}
}
var TOOLS_PATH = Script.resolvePath("assets/images/tools/");
var toolBar = (function () {
var EDIT_SETTING = "io.highfidelity.isEditting"; // for communication with other scripts
var TOOL_ICON_URL = Script.resolvePath("assets/images/tools/");
var that = {},
toolBar,
systemToolbar,
@ -199,7 +200,7 @@ var toolBar = (function () {
}
function addButton(name, image, handler) {
var imageUrl = TOOL_ICON_URL + image;
var imageUrl = TOOLS_PATH + image;
var button = toolBar.addButton({
objectName: name,
imageURL: imageUrl,
@ -232,7 +233,7 @@ var toolBar = (function () {
systemToolbar = Toolbars.getToolbar(SYSTEM_TOOLBAR);
activeButton = systemToolbar.addButton({
objectName: EDIT_TOGGLE_BUTTON,
imageURL: TOOL_ICON_URL + "edit.svg",
imageURL: TOOLS_PATH + "edit.svg",
visible: true,
alpha: 0.9,
buttonState: 1,
@ -1326,13 +1327,14 @@ function pushCommandForSelections(createdEntityData, deletedEntityData) {
UndoStack.pushCommand(applyEntityProperties, undoData, applyEntityProperties, redoData);
}
var ENTITY_PROPERTIES_URL = Script.resolvePath('html/entityProperties.html');
var PropertiesTool = function (opts) {
var that = {};
var url = Script.resolvePath('html/entityProperties.html');
var webView = new OverlayWebWindow({
title: 'Entity Properties',
source: url,
source: ENTITY_PROPERTIES_URL,
toolWindow: true
});

View file

@ -16,8 +16,11 @@
// grab the toolbar
var toolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
var ASSETS_PATH = Script.resolvePath("assets"
var TOOLS_PATH = Script.resolvePath("assets/images/tools/");
function buttonImageURL() {
return Script.resolvePath("assets/images/tools/" + (Users.canKick ? 'kick.svg' : 'ignore.svg'));
return TOOLS_PATH + (Users.canKick ? 'kick.svg' : 'ignore.svg'));
}
// setup the mod button and add it to the toolbar
@ -68,7 +71,7 @@ function buttonClicked(){
button.clicked.connect(buttonClicked);
function overlayURL() {
return Script.resolvePath("assets") + "/images/" + (Users.canKick ? "kick-target.svg" : "ignore-target.svg");
return ASSETS_PATH + "/images/" + (Users.canKick ? "kick-target.svg" : "ignore-target.svg");
}
function updateOverlays() {

View file

@ -124,7 +124,6 @@ var NotificationType = {
var randomSounds = new SoundArray({ localOnly: true }, true);
var numberOfSounds = 2;
for (var i = 1; i <= numberOfSounds; i++) {
randomSounds.addSound(Script.resolvePath("assets/sounds/notification-general"+ i + ".raw"));
}
@ -317,6 +316,8 @@ function notify(notice, button, height, imageProperties, image) {
return notificationText;
}
var CLOSE_NOTIFICATION_ICON = Script.resolvePath("assets/images/close-small-light.svg");
// This function creates and sizes the overlays
function createNotification(text, notificationType, imageProperties) {
var count = (text.match(/\n/g) || []).length,
@ -363,7 +364,7 @@ function createNotification(text, notificationType, imageProperties) {
width: 10.0,
height: 10.0,
subImage: { x: 0, y: 0, width: 10, height: 10 },
imageURL: Script.resolvePath("assets/images/close-small-light.svg"),
imageURL: CLOSE_NOTIFICATION_ICON,
color: { red: 255, green: 255, blue: 255},
visible: true,
alpha: backgroundAlpha
@ -534,7 +535,7 @@ function onDomainConnectionRefused(reason) {
function onSnapshotTaken(path, notify) {
if (notify) {
var imageProperties = {
path: Script.resolvePath("file:///" + path),
path: "file:///" + path,
aspectRatio: Window.innerWidth / Window.innerHeight
}
createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties);

View file

@ -32,9 +32,11 @@ function showFeedWindow() {
DialogsManager.showFeed();
}
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
var outstanding;
function confirmShare(data) {
var dialog = new OverlayWebWindow('Snapshot Review', Script.resolvePath("html/SnapshotReview.html"), 800, 320);
var dialog = new OverlayWebWindow('Snapshot Review', SNAPSHOT_REVIEW_URL, 800, 320);
function onMessage(message) {
// Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following:
// 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.)

View file

@ -13,6 +13,10 @@
(function() { // BEGIN LOCAL_SCOPE
// resolve these paths immediately
var MIN_MAX_BUTTON_SVG = Script.resolvePath("assets/images/tools/min-max-toggle.svg");
var BASE_URL = Script.resolvePath("assets/images/tools/");
var PopUpMenu = function (properties) {
var value = properties.value,
promptOverlay,
@ -25,8 +29,7 @@ var PopUpMenu = function (properties) {
MIN_MAX_BUTTON_SVG_WIDTH = 17.1,
MIN_MAX_BUTTON_SVG_HEIGHT = 32.5,
MIN_MAX_BUTTON_WIDTH = 14,
MIN_MAX_BUTTON_HEIGHT = MIN_MAX_BUTTON_WIDTH,
MIN_MAX_BUTTON_SVG = Script.resolvePath("assets/images/tools/min-max-toggle.svg");
MIN_MAX_BUTTON_HEIGHT = MIN_MAX_BUTTON_WIDTH;
function positionDisplayOptions() {
var y,
@ -223,8 +226,7 @@ var PopUpMenu = function (properties) {
var usersWindow = (function () {
var baseURL = Script.resolvePath("assets/images/tools/"),
WINDOW_WIDTH = 260,
var WINDOW_WIDTH = 260,
WINDOW_MARGIN = 12,
WINDOW_BASE_MARGIN = 6, // A little less is needed in order look correct
WINDOW_FONT = {
@ -261,7 +263,7 @@ var usersWindow = (function () {
WINDOW_BORDER_ALPHA = 0.5,
windowBorder,
MIN_MAX_BUTTON_SVG = baseURL + "min-max-toggle.svg",
MIN_MAX_BUTTON_SVG = BASE_URL + "min-max-toggle.svg",
MIN_MAX_BUTTON_SVG_WIDTH = 17.1,
MIN_MAX_BUTTON_SVG_HEIGHT = 32.5,
MIN_MAX_BUTTON_WIDTH = 14,
@ -293,7 +295,7 @@ var usersWindow = (function () {
scrollbarBackgroundHeight,
scrollbarBarHeight,
FRIENDS_BUTTON_SPACER = 6, // Space before add/remove friends button
FRIENDS_BUTTON_SVG = baseURL + "add-remove-friends.svg",
FRIENDS_BUTTON_SVG = BASE_URL + "add-remove-friends.svg",
FRIENDS_BUTTON_SVG_WIDTH = 107,
FRIENDS_BUTTON_SVG_HEIGHT = 27,
FRIENDS_BUTTON_WIDTH = FRIENDS_BUTTON_SVG_WIDTH,