Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "utils is not defined" err, thrown by utils.makeGUID() at line 57 #131

Merged
merged 3 commits into from Jan 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
86 changes: 57 additions & 29 deletions bootstrap.js
Expand Up @@ -198,7 +198,8 @@ function addContextMenuEntry(window) {
$(contextMenuEntryID + "Seperator").hidden = $(contextMenuEntryID).hidden = true;
}
};
let (contextEntry = window.document.createElementNS(XUL, "menuitem")) {
{
let contextEntry = window.document.createElementNS(XUL, "menuitem");
contextEntry.setAttribute("id", contextMenuEntryID);
contextEntry.setAttribute("class", "menuitem-iconic");
contextEntry.setAttribute("image", LOGO);
Expand Down Expand Up @@ -270,42 +271,49 @@ function populateMenuPopupList(window, id, event) {
child = child.nextSibling;
menupop.removeChild(item);
}
let (itemManage = window.document.createElementNS(XUL, "menuitem")) {
{
let itemManage = window.document.createElementNS(XUL, "menuitem");
itemManage.setAttribute("label", l10n("manage.label"));
itemManage.setAttribute("accesskey", l10n("manage.accesskey"));
itemManage.setAttribute("tooltiptext", l10n("manage.tooltip"));
listen(window, itemManage, "command", function() openOptions(window));
menupop.appendChild(itemManage);
}
// Adding menu to create new styles based on current domain/url/blank/Fx Chrome
let (createMenu = window.document.createElementNS(XUL, "menu")) {
{
let createMenu = window.document.createElementNS(XUL, "menu");
createMenu.setAttribute("label", l10n("create.label"));
createMenu.setAttribute("accesskey", l10n("create.accesskey"));
createMenu.setAttribute("tooltiptext", l10n("create.tooltip"));
let (createMenupop = window.document.createElementNS(XUL, "menupopup")) {
{
let createMenupop = window.document.createElementNS(XUL, "menupopup");
createMenupop.setAttribute("class", "popup-internal-box");
let (createItem = window.document.createElementNS(XUL, "menuitem")) {
{
let createItem = window.document.createElementNS(XUL, "menuitem");
createItem.setAttribute("label", l10n("create.blank.label"));
createItem.setAttribute("accesskey", l10n("create.blank.accesskey"));
createItem.setAttribute("tooltiptext", l10n("create.blank.tooltip"));
listen(window, createItem, "command", function() createNew(window, 'blank'));
createMenupop.appendChild(createItem);
}
let (createItem = window.document.createElementNS(XUL, "menuitem")) {
{
let createItem = window.document.createElementNS(XUL, "menuitem");
createItem.setAttribute("label", l10n("create.domain.label"));
createItem.setAttribute("accesskey", l10n("create.domain.accesskey"));
createItem.setAttribute("tooltiptext", l10n("create.domain.tooltip") + " " + getDomain(window));
listen(window, createItem, "command", function() createNew(window, 'domain'));
createMenupop.appendChild(createItem);
}
let (createItem = window.document.createElementNS(XUL, "menuitem")) {
{
let createItem = window.document.createElementNS(XUL, "menuitem");
createItem.setAttribute("label", l10n("create.url.label"));
createItem.setAttribute("accesskey", l10n("create.url.accesskey"));
createItem.setAttribute("tooltiptext", l10n("create.url.tooltip") + " " + getURL(window));
listen(window, createItem, "command", function() createNew(window, 'url'));
createMenupop.appendChild(createItem);
}
let (createItem = window.document.createElementNS(XUL, "menuitem")) {
{
let createItem = window.document.createElementNS(XUL, "menuitem");
createItem.setAttribute("label", l10n("create.fx.label"));
createItem.setAttribute("accesskey", l10n("create.fx.accesskey"));
createItem.setAttribute("tooltiptext", l10n("create.fx.tooltip"));
Expand All @@ -317,13 +325,16 @@ function populateMenuPopupList(window, id, event) {
menupop.appendChild(createMenu);
}
// Adding menu to search for styles related to current page/domain or even blank
let (createMenu = window.document.createElementNS(XUL, "menu")) {
{
let createMenu = window.document.createElementNS(XUL, "menu");
createMenu.setAttribute("label", l10n("find.label"));
createMenu.setAttribute("accesskey", l10n("find.accesskey"));
createMenu.setAttribute("tooltiptext", l10n("find.tooltip"));
let (createMenupop = window.document.createElementNS(XUL, "menupopup")) {
{
let createMenupop = window.document.createElementNS(XUL, "menupopup");
createMenupop.setAttribute("class", "popup-internal-box");
let (createItem = window.document.createElementNS(XUL, "menuitem")) {
{
let createItem = window.document.createElementNS(XUL, "menuitem");
createItem.setAttribute("label", l10n("find.url.label"));
createItem.setAttribute("accesskey", l10n("find.url.accesskey"));
createItem.setAttribute("tooltiptext", l10n("find.url.tooltip") + " " + getURL(window));
Expand All @@ -337,7 +348,8 @@ function populateMenuPopupList(window, id, event) {
});
createMenupop.appendChild(createItem);
}
let (createItem = window.document.createElementNS(XUL, "menuitem")) {
{
let createItem = window.document.createElementNS(XUL, "menuitem");
createItem.setAttribute("label", l10n("find.fx.label"));
createItem.setAttribute("accesskey", l10n("find.fx.accesskey"));
createItem.setAttribute("tooltiptext", l10n("find.fx.tooltip"));
Expand All @@ -351,18 +363,21 @@ function populateMenuPopupList(window, id, event) {
menupop.appendChild(createMenu);
}
// Adding the menu containing sorted stylesheets
let (sortedMenu = window.document.createElementNS(XUL, "menu")) {
{
let sortedMenu = window.document.createElementNS(XUL, "menu");
sortedMenu.setAttribute("label", l10n("sortedMenu.label"));
sortedMenu.setAttribute("accesskey", l10n("sortedMenu.accesskey"));
let (sortedMenupop = window.document.createElementNS(XUL, "menupopup")) {
{
let sortedMenupop = window.document.createElementNS(XUL, "menupopup");
sortedMenupop.setAttribute("class", "popup-internal-box");
sortedStyleSheet.forEach(function(data) {
let sortedItem = window.document.createElementNS(XUL, "menu");
sortedItem.setAttribute("label", data[0]);
sortedItem.setAttribute("class", "menu-iconic");
let sortedItemMenupop = window.document.createElementNS(XUL, "menupopup");
sortedItemMenupop.setAttribute("class", "popup-internal-box");
let (enableAll = window.document.createElementNS(XUL, "menuitem")) {
{
let enableAll = window.document.createElementNS(XUL, "menuitem");
enableAll.setAttribute("label", l10n("enableAll.label"));
enableAll.setAttribute("accesskey", l10n("enableAll.accesskey"));
enableAll.setAttribute("tooltiptext", l10n("enableAll.tooltip"));
Expand All @@ -380,7 +395,8 @@ function populateMenuPopupList(window, id, event) {
});
sortedItemMenupop.appendChild(enableAll);
}
let (disableAll = window.document.createElementNS(XUL, "menuitem")) {
{
let disableAll = window.document.createElementNS(XUL, "menuitem");
disableAll.setAttribute("label", l10n("disableAll.label"));
disableAll.setAttribute("accesskey", l10n("disableAll.accesskey"));
disableAll.setAttribute("tooltiptext", l10n("disableAll.tooltip"));
Expand All @@ -398,7 +414,8 @@ function populateMenuPopupList(window, id, event) {
});
sortedItemMenupop.appendChild(disableAll);
}
let (sep = window.document.createElementNS(XUL, "menuseparator")) {
{
let sep = window.document.createElementNS(XUL, "menuseparator");
sortedItemMenupop.appendChild(sep);
}
for (let i = 1; i < data.length; i++) {
Expand Down Expand Up @@ -448,10 +465,12 @@ function populateMenuPopupList(window, id, event) {
}
menupop.appendChild(sortedMenu);
}
let (sep = window.document.createElementNS(XUL, "menuseparator")) {
{
let sep = window.document.createElementNS(XUL, "menuseparator");
menupop.appendChild(sep);
}
let (enabled = window.document.createElementNS(XUL, "menuitem")) {
{
let enabled = window.document.createElementNS(XUL, "menuitem");
enabled.setAttribute("label", l10n("enabled.label"));
enabled.setAttribute("accesskey", l10n("enabled.accesskey"));
enabled.setAttribute("tooltiptext", l10n("enabled.tooltip"));
Expand All @@ -463,7 +482,8 @@ function populateMenuPopupList(window, id, event) {
});
menupop.appendChild(enabled);
}
let (disabled = window.document.createElementNS(XUL, "menuitem")) {
{
let disabled = window.document.createElementNS(XUL, "menuitem");
disabled.setAttribute("label", l10n("disabled.label"));
disabled.setAttribute("accesskey", l10n("disabled.accesskey"));
disabled.setAttribute("tooltiptext", l10n("disabled.tooltip"));
Expand All @@ -476,7 +496,8 @@ function populateMenuPopupList(window, id, event) {
});
menupop.appendChild(disabled);
}
let (sep = window.document.createElementNS(XUL, "menuseparator")) {
{
let sep = window.document.createElementNS(XUL, "menuseparator");
menupop.appendChild(sep);
}
styleSheetList.forEach(function(style, index) {
Expand Down Expand Up @@ -521,7 +542,7 @@ function populateMenuPopupList(window, id, event) {

function addMenuItem(window) {
function $(id) window.document.getElementById(id);

function removeMenuItem() {
let menuitem = $(toolsMenuitemID);
menuitem && menuitem.parentNode.removeChild(menuitem);
Expand All @@ -531,7 +552,8 @@ function addMenuItem(window) {
removeMenuItem();
if (pref("createToolsMenuButton")) {
// add the new menuitem to File menu
let (menu = window.document.createElementNS(XUL, "menu")) {
{
let menu = window.document.createElementNS(XUL, "menu");
menu.setAttribute("id", toolsMenuitemID);
menu.setAttribute("class", "menu-iconic");
if (pref("createHotKey")) {
Expand All @@ -555,7 +577,8 @@ function addMenuItem(window) {
return;
let appMenu = $("appmenuPrimaryPane");
if (appMenu) {
let (appMenuItem = window.document.createElementNS(XUL, "menu")) {
{
let appMenuItem = window.document.createElementNS(XUL, "menu");
appMenuItem.setAttribute("id", appMenuitemID);
appMenuItem.setAttribute("class", "menu-iconic");
appMenuItem.setAttribute("image", LOGO);
Expand Down Expand Up @@ -670,7 +693,8 @@ function createHotKey(window) {
let USMKeyset = window.document.createElementNS(XUL, "keyset");
USMKeyset.setAttribute("id", keysetID);
// add hotkey
let (optionsKey = window.document.createElementNS(XUL, "key")) {
{
let optionsKey = window.document.createElementNS(XUL, "key");
optionsKey.setAttribute("id", keyID);
optionsKey.setAttribute("key", pref("shortcutKey"));
optionsKey.setAttribute("modifiers", pref("shortcutModifiers"));
Expand Down Expand Up @@ -721,14 +745,16 @@ function addUserStyleHandler(window) {
for (let i = 0; i < links.length; i++) {
switch (links[i].rel) {
case "stylish-code":
let (id = links[i].getAttribute("href").replace("#", "")) {
{
let id = links[i].getAttribute("href").replace("#", "");
let element = document.getElementById(id);
if (element)
code = element.textContent;
}
break;
case "stylish-description":
let (id = links[i].getAttribute("href").replace("#", "")) {
{
let id = links[i].getAttribute("href").replace("#", "");
let element = document.getElementById(id);
if (element)
name = element.textContent;
Expand Down Expand Up @@ -757,14 +783,16 @@ function addUserStyleHandler(window) {
for (let i = 0; i < links.length; i++) {
switch (links[i].rel) {
case "stylish-code":
let (id = links[i].getAttribute("href").replace("#", "")) {
{
let id = links[i].getAttribute("href").replace("#", "");
let element = document.getElementById(id);
if (element)
code = element.textContent;
}
break;
case "stylish-description":
let (id = links[i].getAttribute("href").replace("#", "")) {
{
let id = links[i].getAttribute("href").replace("#", "");
let element = document.getElementById(id);
if (element)
name = element.textContent;
Expand Down
3 changes: 2 additions & 1 deletion scripts/main.js
Expand Up @@ -8,6 +8,7 @@
"use strict";

Cu.import("chrome://userstylemanager-scripts/content/shared.jsm");
Cu.import("resource://services-sync/util.js");

// Global Variable to store the style sheet data
// Format : [status, name, path, url, applies on, date added, date modified, style options, local changes ?]
Expand Down Expand Up @@ -867,4 +868,4 @@ function getURIForFileInUserStyles(filepath) {

unload(function() {
openEditors = null;
});
});
8 changes: 5 additions & 3 deletions scripts/pref.js
Expand Up @@ -96,7 +96,8 @@ pref.observe = function(prefs, callback) {
};

// Initialize default preferences
let (branch = Services.prefs.getDefaultBranch(pref.root)) {
{
let branch = Services.prefs.getDefaultBranch(pref.root);
for (let [key, val] in Iterator(pref.defaults)) {
switch (typeof val) {
case "boolean":
Expand All @@ -113,7 +114,8 @@ let (branch = Services.prefs.getDefaultBranch(pref.root)) {
}

function setPref(k, v) {
let (branch = Services.prefs.getDefaultBranch(pref.root)) {
{
let branch = Services.prefs.getDefaultBranch(pref.root);
switch (typeof v) {
case "boolean":
branch.setBoolPref(k, v);
Expand All @@ -126,4 +128,4 @@ function setPref(k, v) {
break;
}
}
}
}