Bug 1245649: Turn on no-trailing-spaces. r=Gijs

This commit is contained in:
Dave Townsend 2016-02-03 14:22:33 -08:00
parent c49f3be45c
commit 8508242079
393 changed files with 3076 additions and 3076 deletions

View File

@ -352,7 +352,7 @@ var PlacesCommandHook = {
var parent = aParent !== undefined ?
aParent : PlacesUtils.unfiledBookmarksFolderId;
var descAnno = { name: PlacesUIUtils.DESCRIPTION_ANNO, value: description };
var txn = new PlacesCreateBookmarkTransaction(uri, parent,
var txn = new PlacesCreateBookmarkTransaction(uri, parent,
PlacesUtils.bookmarks.DEFAULT_INDEX,
title, null, [descAnno]);
PlacesUtils.transactionManager.doTransaction(txn);
@ -478,7 +478,7 @@ var PlacesCommandHook = {
},
/**
* Adds a bookmark to the page loaded in the current tab.
* Adds a bookmark to the page loaded in the current tab.
*/
bookmarkCurrentPage: function PCH_bookmarkCurrentPage(aShowEditUI, aParent) {
this.bookmarkPage(gBrowser.selectedBrowser, aParent, aShowEditUI);
@ -540,7 +540,7 @@ var PlacesCommandHook = {
},
/**
* Adds a folder with bookmarks to all of the currently open tabs in this
* Adds a folder with bookmarks to all of the currently open tabs in this
* window.
*/
bookmarkCurrentPages: function PCH_bookmarkCurrentPages() {
@ -570,7 +570,7 @@ var PlacesCommandHook = {
},
/**
* Adds a Live Bookmark to a feed associated with the current page.
* Adds a Live Bookmark to a feed associated with the current page.
* @param url
* The nsIURI of the page the feed was attached to
* @title title
@ -604,7 +604,7 @@ var PlacesCommandHook = {
}),
/**
* Opens the Places Organizer.
* Opens the Places Organizer.
* @param aLeftPaneRoot
* The query to select in the organizer window - options
* are: History, AllBookmarks, BookmarksMenu, BookmarksToolbar,
@ -615,7 +615,7 @@ var PlacesCommandHook = {
// Due to bug 528706, getMostRecentWindow can return closed windows.
if (!organizer || organizer.closed) {
// No currently open places window, so open one with the specified mode.
openDialog("chrome://browser/content/places/places.xul",
openDialog("chrome://browser/content/places/places.xul",
"", "chrome,toolbar=yes,dialog=no,resizable", aLeftPaneRoot);
}
else {
@ -826,7 +826,7 @@ var BookmarksEventHandler = {
* Handler for command event for an item in the bookmarks toolbar.
* Menus and submenus from the folder buttons bubble up to this handler.
* Opens the item.
* @param aEvent
* @param aEvent
* DOMEvent for the command
* @param aView
* The places view which aEvent should be associated with.
@ -908,7 +908,7 @@ var PlacesMenuDNDHandler = {
/**
* Called when the user enters the <menu> element during a drag.
* @param event
* The DragEnter event that spawned the opening.
* The DragEnter event that spawned the opening.
*/
onDragEnter: function PMDH_onDragEnter(event) {
// Opening menus in a Places popup is handled by the view itself.
@ -979,7 +979,7 @@ var PlacesMenuDNDHandler = {
/**
* Determines if a XUL element represents a static container.
* @returns true if the element is a container element (menu or
* @returns true if the element is a container element (menu or
*` menu-toolbarbutton), false otherwise.
*/
_isStaticContainer: function PMDH__isContainer(node) {
@ -996,7 +996,7 @@ var PlacesMenuDNDHandler = {
/**
* Called when the user drags over the <menu> element.
* @param event
* The DragOver event.
* The DragOver event.
*/
onDragOver: function PMDH_onDragOver(event) {
let ip = new InsertionPoint(PlacesUtils.bookmarksMenuFolderId,
@ -1011,7 +1011,7 @@ var PlacesMenuDNDHandler = {
/**
* Called when the user drops on the <menu> element.
* @param event
* The Drop event.
* The Drop event.
*/
onDrop: function PMDH_onDrop(event) {
// Put the item at the end of bookmark menu.

View File

@ -130,7 +130,7 @@ var handleContentContextMenu = function (event) {
disableSetDesktopBg = disableSetDesktopBackground(event.target);
try {
let imageCache =
let imageCache =
Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
.getImgCacheForDocument(doc);
let props =

View File

@ -127,7 +127,7 @@ var security = {
// No mapping required
return name;
},
/**
* Open the cookie manager window
*/
@ -183,7 +183,7 @@ function securityOnLoad(uri, windowInfo) {
/* Set Identity section text */
setText("security-identity-domain-value", info.hostName);
var owner, verifier;
if (info.cert && !info.isBroken) {
// Try to pull out meaningful values. Technically these fields are optional
@ -231,7 +231,7 @@ function securityOnLoad(uri, windowInfo) {
hostHasCookies(uri) ? yesStr : noStr);
setText("security-privacy-passwords-value",
realmHasPasswords(uri) ? yesStr : noStr);
var visitCount = previousVisitCount(info.hostName);
if(visitCount > 1) {
setText("security-privacy-history-value",
@ -242,7 +242,7 @@ function securityOnLoad(uri, windowInfo) {
pageInfoBundle.getString("securityOneVisit"));
}
else {
setText("security-privacy-history-value", noStr);
setText("security-privacy-history-value", noStr);
}
/* Set the Technical Detail section messages */
@ -283,7 +283,7 @@ function securityOnLoad(uri, windowInfo) {
}
setText("security-technical-shortform", hdr);
setText("security-technical-longform1", msg1);
setText("security-technical-longform2", msg2);
setText("security-technical-longform2", msg2);
}
function setText(id, value)
@ -338,13 +338,13 @@ function realmHasPasswords(uri) {
function previousVisitCount(host, endTimeReference) {
if (!host)
return false;
var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService);
var options = historyService.getNewQueryOptions();
options.resultType = options.RESULTS_AS_VISIT;
// Search for visits to this host before today
var query = historyService.getNewQuery();
query.endTimeReference = query.TIME_RELATIVE_TODAY;

View File

@ -121,7 +121,7 @@ var Change = {
_updateStatus: function Change__updateStatus(str, state) {
this._updateStatusWithString(this._str(str), state);
},
_updateStatusWithString: function Change__updateStatusWithString(string, state) {
this._statusRow.hidden = false;
this._status.value = string;

View File

@ -1591,7 +1591,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]></destructor>
<field name="progressmeter" readonly="true">
document.getElementById("addon-progress-notification-progressmeter");
document.getElementById("addon-progress-notification-progressmeter");
</field>
<field name="progresstext" readonly="true">
document.getElementById("addon-progress-notification-progresstext");

View File

@ -114,8 +114,8 @@ function openUILink(url, event, aIgnoreButton, aIgnoreAlt, aAllowThirdPartyFixup
*
* Middle-clicking is the same as Ctrl+clicking (it opens a new tab).
*
* Exceptions:
* - Alt is ignored for menu items selected using the keyboard so you don't accidentally save stuff.
* Exceptions:
* - Alt is ignored for menu items selected using the keyboard so you don't accidentally save stuff.
* (Currently, the Alt isn't sent here at all for menu items, but that will change in bug 126189.)
* - Alt is hard to use in context menus, because pressing Alt closes the menu.
* - Alt can't be used on the bookmarks toolbar because Alt is used for "treat this as something draggable".
@ -416,7 +416,7 @@ function closeMenus(node)
}
// Gather all descendent text under given document node.
function gatherTextUnder ( root )
function gatherTextUnder ( root )
{
var text = "";
var node = root.firstChild;
@ -673,7 +673,7 @@ function makeURLAbsolute(aBase, aUrl)
* This will be used as the referrer. There will be no security check.
* @param [optional] aReferrerPolicy
* Referrer policy - Ci.nsIHttpChannel.REFERRER_POLICY_*.
*/
*/
function openNewTabWith(aURL, aDocument, aPostData, aEvent,
aAllowThirdPartyFixup, aReferrer, aReferrerPolicy) {
@ -728,7 +728,7 @@ function openHelpLink(aHelpTopic, aCalledFromModal, aWhere) {
}
function openPrefsHelp() {
// non-instant apply prefwindows are usually modal, so we can't open in the topmost window,
// non-instant apply prefwindows are usually modal, so we can't open in the topmost window,
// since its probably behind the window.
var instantApply = getBoolPref("browser.preferences.instantApply");

View File

@ -17,7 +17,7 @@ var panelProgressListener = {
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress) {
},
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
{
if (!aRequest)
@ -27,7 +27,7 @@ var panelProgressListener = {
if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO)
return;
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
window.parent.document.getElementById('sidebar-throbber').setAttribute("loading", "true");
}
@ -45,7 +45,7 @@ var panelProgressListener = {
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {
},
onSecurityChange : function(aWebProgress, aRequest, aState) {
onSecurityChange : function(aWebProgress, aRequest, aState) {
},
QueryInterface : function(aIID)

View File

@ -19,7 +19,7 @@ pref("app.update.promptWaitTime", 604800);
// attempts fail.
pref("app.update.url.manual", "https://www.mozilla.org/firefox/aurora/");
// A default value for the "More information about this update" link
// supplied in the "An update is available" page of the update wizard.
// supplied in the "An update is available" page of the update wizard.
pref("app.update.url.details", "https://www.mozilla.org/firefox/aurora/");
// The number of days a binary is permitted to be old

View File

@ -17,7 +17,7 @@ pref("app.update.promptWaitTime", 43200);
// attempts fail.
pref("app.update.url.manual", "https://nightly.mozilla.org");
// A default value for the "More information about this update" link
// supplied in the "An update is available" page of the update wizard.
// supplied in the "An update is available" page of the update wizard.
pref("app.update.url.details", "https://nightly.mozilla.org");
// The number of days a binary is permitted to be old

View File

@ -16,7 +16,7 @@ pref("app.update.promptWaitTime", 172800);
// attempts fail.
pref("app.update.url.manual", "https://www.mozilla.org/firefox/");
// A default value for the "More information about this update" link
// supplied in the "An update is available" page of the update wizard.
// supplied in the "An update is available" page of the update wizard.
pref("app.update.url.details", "https://www.mozilla.org/%LOCALE%/firefox/notes");
// The number of days a binary is permitted to be old

View File

@ -16,7 +16,7 @@ pref("app.update.promptWaitTime", 86400);
// attempts fail.
pref("app.update.url.manual", "https://nightly.mozilla.org");
// A default value for the "More information about this update" link
// supplied in the "An update is available" page of the update wizard.
// supplied in the "An update is available" page of the update wizard.
pref("app.update.url.details", "https://nightly.mozilla.org");
// The number of days a binary is permitted to be old

View File

@ -27,7 +27,7 @@ add_task(function* testPrivateBrowsingCustomizeModeWidget() {
"Widget should not appear as unused in private window");
yield promiseWindowClosed(privateWindow);
CustomizableUI.destroyWidget(kWidgetId);
CustomizableUI.destroyWidget(kWidgetId);
});
add_task(function* asyncCleanup() {

View File

@ -143,7 +143,7 @@ function placementArraysEqual(areaId, actualPlacements, expectedPlacements) {
} else if (expectedPlacements[i] instanceof RegExp) {
ok(expectedPlacements[i].test(actualPlacements[i]),
"Item " + i + " (" + actualPlacements[i] + ") in " +
areaId + " should match " + expectedPlacements[i]);
areaId + " should match " + expectedPlacements[i]);
} else {
ok(false, "Unknown type of expected placement passed to " +
" assertAreaPlacements. Is your test broken?");

View File

@ -77,7 +77,7 @@ function resolveURIInternal(aCmdLine, aArgument) {
// We have interpreted the argument as a relative file URI, but the file
// doesn't exist. Try URI fixup heuristics: see bug 290782.
try {
uri = urifixup.createFixupURI(aArgument, 0);
}
@ -129,7 +129,7 @@ function needHomepageOverride(prefb) {
// a way to make existing profiles retain the default that we removed.
if (savedmstone)
prefb.setBoolPref("browser.rights.3.shown", true);
prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
return (savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE);
@ -195,7 +195,7 @@ function openWindow(parent, url, target, features, args, noExternalArgs) {
return wwatch.openWindow(parent, url, target, features, argstring);
}
// Pass an array to avoid the browser "|"-splitting behavior.
var argArray = Components.classes["@mozilla.org/supports-array;1"]
.createInstance(Components.interfaces.nsISupportsArray);

View File

@ -1232,7 +1232,7 @@ PlacesToolbar.prototype = {
let childRect = child.getBoundingClientRect();
childOverflowed = this.isRTL ? (childRect.left < scrollRect.left)
: (childRect.right > scrollRect.right);
}
child.style.visibility = childOverflowed ? "hidden" : "visible";
}

View File

@ -970,7 +970,7 @@ PlacesController.prototype = {
while (aURIs.length) {
let URIslice = aURIs.splice(0, REMOVE_PAGES_CHUNKLEN);
PlacesUtils.bhistory.removePages(URIslice, URIslice.length);
Services.tm.mainThread.dispatch(() => gen.next(),
Services.tm.mainThread.dispatch(() => gen.next(),
Ci.nsIThread.DISPATCH_NORMAL);
yield unefined;
}

View File

@ -20,7 +20,7 @@ function HistorySidebarInit()
if (gHistoryGrouping == "site")
document.getElementById("bysite").setAttribute("checked", "true");
else if (gHistoryGrouping == "visited")
else if (gHistoryGrouping == "visited")
document.getElementById("byvisited").setAttribute("checked", "true");
else if (gHistoryGrouping == "lastvisited")
document.getElementById("bylastvisited").setAttribute("checked", "true");
@ -28,7 +28,7 @@ function HistorySidebarInit()
document.getElementById("bydayandsite").setAttribute("checked", "true");
else
document.getElementById("byday").setAttribute("checked", "true");
searchHistory("");
}

View File

@ -774,7 +774,7 @@ var PlacesSearchBox = {
get searchFilter() {
return document.getElementById("searchFilter");
},
/**
* Folders to include when searching.
*/
@ -894,7 +894,7 @@ var PlacesSearchBox = {
title = PlacesUIUtils.getString("searchDownloads");
break;
default:
title = PlacesUIUtils.getString("searchBookmarks");
title = PlacesUIUtils.getString("searchBookmarks");
}
this.searchFilter.placeholder = title;
},

View File

@ -230,7 +230,7 @@ PlacesTreeView.prototype = {
if (aRow < 0) {
return null;
}
let node = this._rows[aRow];
if (node !== undefined)
return node;
@ -885,7 +885,7 @@ PlacesTreeView.prototype = {
PlacesUtils.livemarks.getLivemark({ id: aNode.itemId })
.then(aLivemark => {
let shouldInvalidate =
let shouldInvalidate =
!this._controller.hasCachedLivemarkInfo(aNode);
this._controller.cacheLivemarkInfo(aNode, aLivemark);
if (aNewState == Components.interfaces.nsINavHistoryContainerResultNode.STATE_OPENED) {

View File

@ -26,9 +26,9 @@ add_task(function* test() {
ok(placesItems.localName == "scrollbox", "PlacesToolbarItems should not be null");
ok(placesItems.childNodes[0], "PlacesToolbarItems must have at least one child");
/**
/**
* Simulates a drop of a URI onto the bookmarks bar.
*
*
* @param aEffect
* The effect to use for the drop operation: move, copy, or link.
* @param aMimeType
@ -38,22 +38,22 @@ add_task(function* test() {
const uriSpec = "http://www.mozilla.org/D1995729-A152-4e30-8329-469B01F30AA7";
let uri = makeURI(uriSpec);
ChromeUtils.synthesizeDrop(placesItems.childNodes[0],
placesItems,
[[{type: aMimeType,
data: uriSpec}]],
placesItems,
[[{type: aMimeType,
data: uriSpec}]],
aEffect, window);
// Verify that the drop produces exactly one bookmark.
let bookmarkIds = PlacesUtils.bookmarks
.getBookmarkIdsForURI(uri);
ok(bookmarkIds.length == 1, "There should be exactly one bookmark");
PlacesUtils.bookmarks.removeItem(bookmarkIds[0]);
// Verify that we removed the bookmark successfully.
ok(!PlacesUtils.bookmarks.isBookmarked(uri), "URI should be removed");
}
}
// Simulate a bookmark drop for all of the mime types and effects.
let mimeTypes = ["text/plain", "text/unicode", "text/x-moz-url"];
let effects = ["move", "copy", "link"];

View File

@ -49,7 +49,7 @@ function fakeOpenPopup(aPopup) {
popupEvent.initMouseEvent("popupshowing", true, true, window, 0,
0, 0, 0, 0, false, false, false, false,
0, null);
aPopup.dispatchEvent(popupEvent);
aPopup.dispatchEvent(popupEvent);
}
/**
@ -474,7 +474,7 @@ function getViewsForFolder(aFolderId) {
break;
case PlacesUtils.unfiledBookmarksFolderId:
return ["sidebar"]
break;
break;
}
return new Array();
}

View File

@ -228,7 +228,7 @@ add_test(function test_separator()
let id = PlacesUtils.bookmarks.insertSeparator(PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX);
PlacesUtils.annotations.setItemAnnotation(id, "random-anno",
"random-value", 0,
"random-value", 0,
PlacesUtils.annotations.EXPIRE_NEVER);
});

View File

@ -2,9 +2,9 @@
function test() {
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to malware site. Can't use an onload listener here since
// error pages don't fire onload. Also can't register the DOMContentLoaded
// handler here because registering it too soon would mean that we might
@ -30,7 +30,7 @@ function testMalware(event) {
// Confirm that "Ignore this warning" is visible - bug 422410
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for malware");
var style = content.getComputedStyle(el, null);
is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for malware");
@ -65,13 +65,13 @@ function testPhishing(event) {
}
window.removeEventListener("DOMContentLoaded", testPhishing, true);
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for phishing");
var style = content.getComputedStyle(el, null);
is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for phishing");
gBrowser.removeCurrentTab();
finish();
}

View File

@ -21,20 +21,20 @@ function testNormal() {
// open the menu, to force it to update
menu = document.getElementById("menu_HelpPopup");
ok(menu, "Help menu should exist!");
menu.addEventListener("popupshown", testNormal_PopupListener, false);
menu.openPopup(null, "", 0, 0, false, null);
}
function testNormal_PopupListener() {
menu.removeEventListener("popupshown", testNormal_PopupListener, false);
var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
is(reportMenu.hidden, false, "Report phishing menu should be visible on normal sites");
is(errorMenu.hidden, true, "Report error menu item should be hidden on normal sites");
menu.hidePopup();
// Now launch the phishing test. Can't use onload here because error pages don't
// fire normal load events.
window.addEventListener("DOMContentLoaded", testPhishing, true);
@ -50,13 +50,13 @@ function testPhishing() {
function testPhishing_PopupListener() {
menu.removeEventListener("popupshown", testPhishing_PopupListener, false);
var reportMenu = document.getElementById("menu_HelpPopup_reportPhishingtoolmenu");
var errorMenu = document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu");
is(reportMenu.hidden, true, "Report phishing menu should be hidden on phishing sites");
is(errorMenu.hidden, false, "Report error menu item should be visible on phishing sites");
menu.hidePopup();
gBrowser.removeCurrentTab();
finish();
}

View File

@ -17,7 +17,7 @@ function test() {
let previouslySelectedEngine = Services.search.currentEngine;
Services.search.currentEngine = engine;
engine.alias = "b";
let base = "https://www.bing.com/search?q=foo&pc=MOZI";
let url;

View File

@ -2,7 +2,7 @@
PKT_SAVED_OVERLAY is the view itself and contains all of the methods to manipute the overlay and messaging.
It does not contain any logic for saving or communication with the extension or server.
*/
var PKT_SAVED_OVERLAY = function (options)
var PKT_SAVED_OVERLAY = function (options)
{
var myself = this;
this.inited = false;
@ -49,7 +49,7 @@ var PKT_SAVED_OVERLAY = function (options)
};
this.fillSuggestedTags = function()
{
if (!$('.pkt_ext_suggestedtag_detail').length)
if (!$('.pkt_ext_suggestedtag_detail').length)
{
myself.suggestedTagsLoaded = true;
myself.startCloseTimer();
@ -59,16 +59,16 @@ var PKT_SAVED_OVERLAY = function (options)
thePKT_SAVED.sendMessage("getSuggestedTags",
{
url: myself.savedUrl
}, function(resp)
}, function(resp)
{
$('.pkt_ext_suggestedtag_detail').removeClass('pkt_ext_suggestedtag_detail_loading');
if (resp.status == 'success')
if (resp.status == 'success')
{
var newtags = [];
for (var i = 0; i < resp.value.suggestedTags.length; i++)
{
newtags.push(resp.value.suggestedTags[i].tag);
}
}
myself.suggestedTagsLoaded = true;
if (!myself.mouseInside) {
myself.startCloseTimer();
@ -99,25 +99,25 @@ var PKT_SAVED_OVERLAY = function (options)
myself.closeValid = false;
});
};
this.startCloseTimer = function(manualtime)
this.startCloseTimer = function(manualtime)
{
var settime = manualtime ? manualtime : myself.autocloseTiming;
if (typeof myself.autocloseTimer == 'number')
if (typeof myself.autocloseTimer == 'number')
{
clearTimeout(myself.autocloseTimer);
}
myself.autocloseTimer = setTimeout(function()
myself.autocloseTimer = setTimeout(function()
{
if (myself.closeValid || myself.preventCloseTimerCancel)
if (myself.closeValid || myself.preventCloseTimerCancel)
{
myself.preventCloseTimerCancel = false;
myself.closePopup();
}
}, settime);
};
this.stopCloseTimer = function()
this.stopCloseTimer = function()
{
if (myself.preventCloseTimerCancel)
if (myself.preventCloseTimerCancel)
{
return;
}
@ -183,7 +183,7 @@ var PKT_SAVED_OVERLAY = function (options)
if (r.test(myself.userTags[i]) && limit > 0) {
returnlist.push({name:myself.userTags[i]});
limit--;
}
}
}
}
if (!$('.token-input-dropdown-tag').data('init')) {
@ -206,7 +206,7 @@ var PKT_SAVED_OVERLAY = function (options)
else {
myself.hideTagsError();
return {name:myself.sanitizeText(text.toLowerCase())};
}
}
},
onReady: function() {
$('.token-input-dropdown').addClass('token-input-dropdown-tag');
@ -317,11 +317,11 @@ var PKT_SAVED_OVERLAY = function (options)
tags: originaltags
}, function(resp)
{
if (resp.status == 'success')
if (resp.status == 'success')
{
myself.showStateFinalMsg(myself.dictJSON.tagssaved);
}
else if (resp.status == 'error')
else if (resp.status == 'error')
{
$('.pkt_ext_edit_msg').addClass('pkt_ext_edit_msg_error pkt_ext_edit_msg_active').text(resp.error.message);
}
@ -381,7 +381,7 @@ var PKT_SAVED_OVERLAY = function (options)
$('.token-input-token').each(function(index, element) {
activetokenstext += $(element).find('p').text() + '|';
});
var inactivetags = $('.pkt_ext_suggestedtag_detail').find('.token_tag_inactive');
inactivetags.each(function(index,element) {
if (activetokenstext.indexOf('|' + $(element).text() + '|') == -1) {
@ -465,7 +465,7 @@ var PKT_SAVED_OVERLAY = function (options)
};
PKT_SAVED_OVERLAY.prototype = {
create : function()
create : function()
{
if (this.active)
{
@ -580,11 +580,11 @@ PKT_SAVED.prototype = {
{
myself.overlay.showStateError(myself.overlay.dictJSON.pagenotsaved,resp.error.message);
}
}
}
else
{
myself.overlay.showStateError(myself.overlay.dictJSON.pagenotsaved,myself.overlay.dictJSON.errorgeneric);
}
}
return;
}

View File

@ -2,7 +2,7 @@
PKT_SIGNUP_OVERLAY is the view itself and contains all of the methods to manipute the overlay and messaging.
It does not contain any logic for saving or communication with the extension or server.
*/
var PKT_SIGNUP_OVERLAY = function (options)
var PKT_SIGNUP_OVERLAY = function (options)
{
var myself = this;
this.inited = false;
@ -62,7 +62,7 @@ var PKT_SIGNUP_OVERLAY = function (options)
};
PKT_SIGNUP_OVERLAY.prototype = {
create : function()
create : function()
{
var myself = this;

View File

@ -15,10 +15,10 @@
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -96,7 +96,7 @@ var pktApi = (function() {
// Handle non-exception-throwing cases:
// Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
// but... JSON.parse(null) returns 'null', and typeof null === "object",
// but... JSON.parse(null) returns 'null', and typeof null === "object",
// so we must check for that, too.
if (o && typeof o === "object" && o !== null) {
return o;
@ -121,10 +121,10 @@ var pktApi = (function() {
function getSetting(key) {
// TODO : Move this to sqlite or a local file so it's not editable (and is safer)
// https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/Local_Storage
if (!prefBranch.prefHasUserValue(key))
return undefined;
return prefBranch.getComplexValue(key, Components.interfaces.nsISupportsString).data;
}
@ -138,7 +138,7 @@ var pktApi = (function() {
function setSetting(key, value) {
// TODO : Move this to sqlite or a local file so it's not editable (and is safer)
// https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/Local_Storage
if (!value)
prefBranch.clearUserPref(key);
else
@ -159,7 +159,7 @@ var pktApi = (function() {
* The return format: { cookieName:cookieValue, cookieName:cookieValue, ... }
*/
function getCookiesFromPocket() {
var cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
var pocketCookies = cookieManager.getCookiesFromHost(pocketSiteHost);
var cookies = {};

View File

@ -42,7 +42,7 @@ FormSubmitObserver.prototype =
{
this._content = aWindow;
this._tab = aTabChildGlobal;
this._mm =
this._mm =
this._content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell)
.sameTypeRootTreeItem
@ -103,7 +103,7 @@ FormSubmitObserver.prototype =
if (!aInvalidElements.length) {
return;
}
// Insure that this is the FormSubmitObserver associated with the form
// element / window this notification is about.
if (this._content != aFormElement.ownerDocument.defaultView.top.document.defaultView) {
@ -142,7 +142,7 @@ FormSubmitObserver.prototype =
/*
* Internal
*/
/*
* Handles input changes on the form element we've associated a popup
* with. Updates the validation message or closes the popup if form data

View File

@ -146,7 +146,7 @@ this.WinTaskbarJumpList =
/**
* Startup, shutdown, and update
*/
*/
startup: function WTBJL_startup() {
// exit if this isn't win7 or higher.
@ -155,7 +155,7 @@ this.WinTaskbarJumpList =
// Win shell shortcut maintenance. If we've gone through an update,
// this will update any pinned taskbar shortcuts. Not specific to
// jump lists, but this was a convienent place to call it.
// jump lists, but this was a convienent place to call it.
try {
// dev builds may not have helper.exe, ignore failures.
this._shortcutMaintenance();
@ -253,13 +253,13 @@ this.WinTaskbarJumpList =
/**
* Taskbar api wrappers
*/
*/
_startBuild: function WTBJL__startBuild() {
var removedItems = Cc["@mozilla.org/array;1"].
createInstance(Ci.nsIMutableArray);
this._builder.abortListBuild();
if (this._builder.initListBuild(removedItems)) {
if (this._builder.initListBuild(removedItems)) {
// Prior to building, delete removed items from history.
this._clearHistory(removedItems);
return true;
@ -283,7 +283,7 @@ this.WinTaskbarJumpList =
task.args, task.iconIndex, null);
items.appendElement(item, false);
}, this);
if (items.length > 0)
this._builder.addListToBuild(this._builder.JUMPLIST_CATEGORY_TASKS, items);
},
@ -324,7 +324,7 @@ this.WinTaskbarJumpList =
let title = aResult.title || aResult.uri;
let faviconPageUri = Services.io.newURI(aResult.uri, null, null);
let shortcut = this._getHandlerAppItem(title, title, aResult.uri, 1,
let shortcut = this._getHandlerAppItem(title, title, aResult.uri, 1,
faviconPageUri);
items.appendElement(shortcut, false);
this._frequentHashList.push(aResult.uri);
@ -386,8 +386,8 @@ this.WinTaskbarJumpList =
* Jump list item creation helpers
*/
_getHandlerAppItem: function WTBJL__getHandlerAppItem(name, description,
args, iconIndex,
_getHandlerAppItem: function WTBJL__getHandlerAppItem(name, description,
args, iconIndex,
faviconPageUri) {
var file = Services.dirsvc.get("XREExeF", Ci.nsILocalFile);
@ -469,7 +469,7 @@ this.WinTaskbarJumpList =
/**
* Prefs utilities
*/
*/
_refreshPrefs: function WTBJL__refreshPrefs() {
this._enabled = _prefs.getBoolPref(PREF_TASKBAR_ENABLED);
@ -481,7 +481,7 @@ this.WinTaskbarJumpList =
/**
* Init and shutdown utilities
*/
*/
_initTaskbar: function WTBJL__initTaskbar() {
this._builder = _taskbarService.createJumpListBuilder();
@ -499,7 +499,7 @@ this.WinTaskbarJumpList =
Services.obs.addObserver(this, "browser:purge-session-history", false);
_prefs.addObserver("", this, false);
},
_freeObs: function WTBJL__freeObs() {
Services.obs.removeObserver(this, "profile-before-change");
Services.obs.removeObserver(this, "browser:purge-session-history");

View File

@ -31,7 +31,7 @@
* Screen real estate is limited so when there are too many thumbnails to fit
* on the screen, the taskbar stops displaying thumbnails and instead displays
* just the title, icon and close button in a similar fashion to previous
* versions of the taskbar. If there are still too many previews to fit on the
* versions of the taskbar. If there are still too many previews to fit on the
* screen, the taskbar resorts to a scroll up and scroll down button pair to let
* the user scroll through the list of tabs. Since this is undoubtedly
* inconvenient for users with many tabs, the AeroPeek objects turns off all of

View File

@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
this.EXPORTED_SYMBOLS = ["OfflineAppCacheHelper"];
Components.utils.import('resource://gre/modules/LoadContextInfo.jsm');

View File

@ -168,7 +168,7 @@ function test_failed_execute()
function test_bind_undefined()
{
var stmt = createStatement("INSERT INTO test (name) VALUES ('foo')");
expectError(Cr.NS_ERROR_ILLEGAL_VALUE,
() => stmt.bindParameters(undefined));

View File

@ -137,7 +137,7 @@
// "no-spaced-func": 2,
// No trailing whitespace
// "no-trailing-spaces": 2,
"no-trailing-spaces": 2,
// No using undeclared variables
// "no-undef": 2,

View File

@ -52,7 +52,7 @@ function runTest() {
getService(Ci.nsIAlertsService);
ok(true, "Alerts service is available");
} catch (ex) {
todo(false,
todo(false,
"Alerts service is not available.", ex);
return;
}

View File

@ -6,14 +6,14 @@ Components.utils.import("resource://gre/modules/AppConstants.jsm");
function AppPicker() {};
AppPicker.prototype =
AppPicker.prototype =
{
// Class members
_incomingParams:null,
/**
/**
* Init the dialog and populate the application list
*/
*/
appPickerLoad: function appPickerLoad() {
const nsILocalHandlerApp = Components.interfaces.nsILocalHandlerApp;
@ -22,9 +22,9 @@ AppPicker.prototype =
document.title = this._incomingParams.title;
// Header creation - at the very least, we must have
// Header creation - at the very least, we must have
// a mime type:
//
//
// (icon) Zip File
// (icon) filename
//
@ -44,9 +44,9 @@ AppPicker.prototype =
description = filename;
filename = "";
}
// Setup the dialog header information
document.getElementById("content-description").setAttribute("value",
document.getElementById("content-description").setAttribute("value",
description);
document.getElementById("suggested-filename").setAttribute("value",
filename);
@ -60,13 +60,13 @@ AppPicker.prototype =
var list = document.getElementById("app-picker-listbox");
var primaryCount = 0;
if (!fileList || fileList.length == 0) {
// display a message saying nothing is configured
document.getElementById("app-picker-notfound").removeAttribute("hidden");
return;
}
for (var idx = 0; idx < fileList.length; idx++) {
var file = fileList.queryElementAt(idx, nsILocalHandlerApp);
try {
@ -92,9 +92,9 @@ AppPicker.prototype =
}
},
/**
/**
* Retrieve the moz-icon for the app
*/
*/
getFileIconURL: function getFileIconURL(file) {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
@ -111,9 +111,9 @@ AppPicker.prototype =
return "moz-icon://" + urlSpec + "?size=32";
},
/**
/**
* Retrieve the pretty description from the file
*/
*/
getFileDisplayName: function getFileDisplayName(file) {
if (AppConstants.platform == "win") {
if (file instanceof Components.interfaces.nsILocalFileWin) {
@ -179,7 +179,7 @@ AppPicker.prototype =
fp.init(window, this._incomingParams.title, nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterApps);
var fileLoc = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
var startLocation;
@ -190,11 +190,11 @@ AppPicker.prototype =
} else {
startLocation = "Home";
}
fp.displayDirectory =
fp.displayDirectory =
fileLoc.get(startLocation, Components.interfaces.nsILocalFile);
if (fp.show() == nsIFilePicker.returnOK && fp.file) {
var localHandlerApp =
var localHandlerApp =
Components.classes["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Components.interfaces.nsILocalHandlerApp);
localHandlerApp.executable = fp.file;

View File

@ -8,23 +8,23 @@ var Ci = Components.interfaces;
/**
* Dummy nsIAutoCompleteInput source that returns
* the given list of AutoCompleteSearch names.
*
* the given list of AutoCompleteSearch names.
*
* Implements only the methods needed for this test.
*/
function AutoCompleteInputBase(aSearches) {
this.searches = aSearches;
}
AutoCompleteInputBase.prototype = {
// Array of AutoCompleteSearch names
searches: null,
minResultsForPopup: 0,
timeout: 10,
searchParam: "",
textValue: "",
disableAutoComplete: false,
disableAutoComplete: false,
completeDefaultIndex: false,
// Text selection range
@ -40,20 +40,20 @@ AutoCompleteInputBase.prototype = {
this._selStart = aStart;
this._selEnd = aEnd;
},
get searchCount() {
return this.searches.length;
},
getSearchAt: function(aIndex) {
return this.searches[aIndex];
},
onSearchBegin: function() {},
onSearchComplete: function() {},
popupOpen: false,
popupOpen: false,
get popup() {
if (!this._popup) {
this._popup = new AutocompletePopupBase(this);
@ -65,14 +65,14 @@ AutoCompleteInputBase.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput])
}
/**
/**
* nsIAutoCompleteResult implementation
*/
function AutoCompleteResultBase(aValues) {
this._values = aValues;
}
AutoCompleteResultBase.prototype = {
// Arrays
_values: null,
_comments: [],
@ -81,9 +81,9 @@ AutoCompleteResultBase.prototype = {
searchString: "",
searchResult: null,
defaultIndex: -1,
_typeAheadResult: false,
get typeAheadResult() {
return this._typeAheadResult;
@ -100,15 +100,15 @@ AutoCompleteResultBase.prototype = {
getLabelAt: function(aIndex) {
return this.getValueAt(aIndex);
},
getCommentAt: function(aIndex) {
return this._comments[aIndex];
},
getStyleAt: function(aIndex) {
return this._styles[aIndex];
},
getImageAt: function(aIndex) {
return "";
},
@ -123,7 +123,7 @@ AutoCompleteResultBase.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteResult])
}
/**
/**
* nsIAutoCompleteSearch implementation that always returns
* the same result set.
*/
@ -132,29 +132,29 @@ function AutoCompleteSearchBase(aName, aResult) {
this._result = aResult;
}
AutoCompleteSearchBase.prototype = {
// Search name. Used by AutoCompleteController
name: null,
// AutoCompleteResult
_result: null,
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener) {
var result = this._result;
result.searchResult = Ci.nsIAutoCompleteResult.RESULT_SUCCESS;
aListener.onSearchResult(this, result);
},
stopSearch: function() {},
// nsISupports implementation
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory,
Ci.nsIAutoCompleteSearch]),
// nsIFactory implementation
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
@ -180,7 +180,7 @@ AutocompletePopupBase.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompletePopup]),
};
/**
/**
* Helper to register an AutoCompleteSearch with the given name.
* Allows the AutoCompleteController to find the search.
*/
@ -196,15 +196,15 @@ function registerAutoCompleteSearch(aSearch) {
componentManager.registerFactory(cid, desc, name, aSearch);
// Keep the id on the object so we can unregister later
aSearch.cid = cid;
aSearch.cid = cid;
}
/**
* Helper to unregister an AutoCompleteSearch.
/**
* Helper to unregister an AutoCompleteSearch.
*/
function unregisterAutoCompleteSearch(aSearch) {
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aSearch.cid, aSearch);
}

View File

@ -13,40 +13,40 @@
/**
* Dummy nsIAutoCompleteInput source that returns
* the given list of AutoCompleteSearch names.
*
* the given list of AutoCompleteSearch names.
*
* Implements only the methods needed for this test.
*/
function AutoCompleteInput(aSearches) {
this.searches = aSearches;
}
AutoCompleteInput.prototype = {
constructor: AutoCompleteInput,
constructor: AutoCompleteInput,
// Array of AutoCompleteSearch names
searches: null,
minResultsForPopup: 0,
timeout: 10,
searchParam: "",
textValue: "",
disableAutoComplete: false,
disableAutoComplete: false,
completeDefaultIndex: false,
get searchCount() {
return this.searches.length;
},
getSearchAt: function(aIndex) {
return this.searches[aIndex];
},
onSearchBegin: function() {},
onSearchComplete: function() {},
popupOpen: false,
popup: {
popupOpen: false,
popup: {
setSelectedIndex: function(aIndex) {},
invalidate: function() {},
@ -57,9 +57,9 @@ AutoCompleteInput.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
},
// nsISupports implementation
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
@ -72,14 +72,14 @@ AutoCompleteInput.prototype = {
/**
/**
* nsIAutoCompleteResult implementation
*/
function AutoCompleteResult(aValues, aComments, aStyles) {
this._values = aValues;
this._comments = aComments;
this._styles = aStyles;
if (this._values.length > 0) {
this.searchResult = Ci.nsIAutoCompleteResult.RESULT_SUCCESS;
} else {
@ -88,15 +88,15 @@ function AutoCompleteResult(aValues, aComments, aStyles) {
}
AutoCompleteResult.prototype = {
constructor: AutoCompleteResult,
// Arrays
_values: null,
_comments: null,
_styles: null,
searchString: "",
searchResult: null,
defaultIndex: 0,
get matchCount() {
@ -106,19 +106,19 @@ AutoCompleteResult.prototype = {
getValueAt: function(aIndex) {
return this._values[aIndex];
},
getLabelAt: function(aIndex) {
return this.getValueAt(aIndex);
},
getCommentAt: function(aIndex) {
return this._comments[aIndex];
},
getStyleAt: function(aIndex) {
return this._styles[aIndex];
},
getImageAt: function(aIndex) {
return "";
},
@ -136,12 +136,12 @@ AutoCompleteResult.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
}
/**
/**
* nsIAutoCompleteSearch implementation that always returns
* the same result set.
*/
@ -151,25 +151,25 @@ function AutoCompleteSearch(aName, aResult) {
}
AutoCompleteSearch.prototype = {
constructor: AutoCompleteSearch,
// Search name. Used by AutoCompleteController
name: null,
// AutoCompleteResult
_result:null,
_result:null,
/**
* Return the same result set for every search
*/
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
{
aListener.onSearchResult(this, this._result);
},
stopSearch: function() {},
// nsISupports implementation
@ -181,7 +181,7 @@ AutoCompleteSearch.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
},
// nsIFactory implementation
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
@ -190,7 +190,7 @@ AutoCompleteSearch.prototype = {
/**
/**
* Helper to register an AutoCompleteSearch with the given name.
* Allows the AutoCompleteController to find the search.
*/
@ -202,49 +202,49 @@ function registerAutoCompleteSearch(aSearch) {
var cid = uuidGenerator.generateUUID();
var desc = "Test AutoCompleteSearch";
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(cid, desc, name, aSearch);
// Keep the id on the object so we can unregister later
aSearch.cid = cid;
aSearch.cid = cid;
}
/**
* Helper to unregister an AutoCompleteSearch.
/**
* Helper to unregister an AutoCompleteSearch.
*/
function unregisterAutoCompleteSearch(aSearch) {
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aSearch.cid, aSearch);
}
/**
/**
* Test AutoComplete with multiple AutoCompleteSearch sources.
*/
function run_test() {
// Make an AutoCompleteSearch that always returns nothing
var emptySearch = new AutoCompleteSearch("test-empty-search",
var emptySearch = new AutoCompleteSearch("test-empty-search",
new AutoCompleteResult([], [], []));
// Make an AutoCompleteSearch that returns two values
var expectedValues = ["test1", "test2"];
var regularSearch = new AutoCompleteSearch("test-regular-search",
new AutoCompleteResult(expectedValues, [], []));
// Register searches so AutoCompleteController can find them
registerAutoCompleteSearch(emptySearch);
registerAutoCompleteSearch(regularSearch);
var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
getService(Components.interfaces.nsIAutoCompleteController);
getService(Components.interfaces.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our searches
// and confirms results on search complete
var input = new AutoCompleteInput([emptySearch.name, regularSearch.name]);
@ -259,13 +259,13 @@ function run_test() {
do_check_eq(numSearchesStarted, 1);
do_check_eq(controller.searchStatus,
do_check_eq(controller.searchStatus,
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
do_check_eq(controller.matchCount, 2);
// Confirm expected result values
for (var i = 0; i < expectedValues.length; i++) {
do_check_eq(expectedValues[i], controller.getValueAt(i));
do_check_eq(expectedValues[i], controller.getValueAt(i));
}
// Unregister searches
@ -279,7 +279,7 @@ function run_test() {
// Search is asynchronous, so don't let the test finish immediately
do_test_pending();
controller.startSearch("test");
}

View File

@ -12,40 +12,40 @@
/**
* Dummy nsIAutoCompleteInput source that returns
* the given list of AutoCompleteSearch names.
*
* the given list of AutoCompleteSearch names.
*
* Implements only the methods needed for this test.
*/
function AutoCompleteInput(aSearches) {
this.searches = aSearches;
}
AutoCompleteInput.prototype = {
constructor: AutoCompleteInput,
constructor: AutoCompleteInput,
// Array of AutoCompleteSearch names
searches: null,
minResultsForPopup: 0,
timeout: 10,
searchParam: "",
textValue: "",
disableAutoComplete: false,
disableAutoComplete: false,
completeDefaultIndex: false,
get searchCount() {
return this.searches.length;
},
getSearchAt: function(aIndex) {
return this.searches[aIndex];
},
onSearchBegin: function() {},
onSearchComplete: function() {},
popupOpen: false,
popup: {
popupOpen: false,
popup: {
setSelectedIndex: function(aIndex) {},
invalidate: function() {},
@ -56,9 +56,9 @@ AutoCompleteInput.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
},
// nsISupports implementation
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
@ -71,14 +71,14 @@ AutoCompleteInput.prototype = {
/**
/**
* nsIAutoCompleteResult implementation
*/
function AutoCompleteResult(aValues, aComments, aStyles) {
this._values = aValues;
this._comments = aComments;
this._styles = aStyles;
if (this._values.length > 0) {
this.searchResult = Ci.nsIAutoCompleteResult.RESULT_SUCCESS;
} else {
@ -87,15 +87,15 @@ function AutoCompleteResult(aValues, aComments, aStyles) {
}
AutoCompleteResult.prototype = {
constructor: AutoCompleteResult,
// Arrays
_values: null,
_comments: null,
_styles: null,
searchString: "",
searchResult: null,
defaultIndex: 0,
get matchCount() {
@ -109,15 +109,15 @@ AutoCompleteResult.prototype = {
getLabelAt: function(aIndex) {
return this.getValueAt(aIndex);
},
getCommentAt: function(aIndex) {
return this._comments[aIndex];
},
getStyleAt: function(aIndex) {
return this._styles[aIndex];
},
getImageAt: function(aIndex) {
return "";
},
@ -135,12 +135,12 @@ AutoCompleteResult.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
}
/**
/**
* nsIAutoCompleteSearch implementation that always returns
* the same result set.
*/
@ -150,25 +150,25 @@ function AutoCompleteSearch(aName, aResult) {
}
AutoCompleteSearch.prototype = {
constructor: AutoCompleteSearch,
// Search name. Used by AutoCompleteController
name: null,
// AutoCompleteResult
_result: null,
/**
* Return the same result set for every search
*/
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
{
aListener.onSearchResult(this, this._result);
},
stopSearch: function() {},
// nsISupports implementation
@ -180,7 +180,7 @@ AutoCompleteSearch.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
},
// nsIFactory implementation
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
@ -189,7 +189,7 @@ AutoCompleteSearch.prototype = {
/**
/**
* Helper to register an AutoCompleteSearch with the given name.
* Allows the AutoCompleteController to find the search.
*/
@ -201,43 +201,43 @@ function registerAutoCompleteSearch(aSearch) {
var cid = uuidGenerator.generateUUID();
var desc = "Test AutoCompleteSearch";
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(cid, desc, name, aSearch);
// Keep the id on the object so we can unregister later
aSearch.cid = cid;
aSearch.cid = cid;
}
/**
* Helper to unregister an AutoCompleteSearch.
/**
* Helper to unregister an AutoCompleteSearch.
*/
function unregisterAutoCompleteSearch(aSearch) {
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aSearch.cid, aSearch);
}
/**
/**
* Test AutoComplete with a search that returns a null result
*/
function run_test() {
// Make an AutoCompleteSearch that always returns nothing
var emptySearch = new AutoCompleteSearch("test-empty-search",
var emptySearch = new AutoCompleteSearch("test-empty-search",
new AutoCompleteResult([], [], []));
// Register search so AutoCompleteController can find them
registerAutoCompleteSearch(emptySearch);
var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
getService(Components.interfaces.nsIAutoCompleteController);
getService(Components.interfaces.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our search
// and confirms results on search complete
var input = new AutoCompleteInput([emptySearch.name]);
@ -252,7 +252,7 @@ function run_test() {
do_check_eq(numSearchesStarted, 1);
do_check_eq(controller.searchStatus,
do_check_eq(controller.searchStatus,
Ci.nsIAutoCompleteController.STATUS_COMPLETE_NO_MATCH);
do_check_eq(controller.matchCount, 0);
@ -266,7 +266,7 @@ function run_test() {
// Search is asynchronous, so don't let the test finish immediately
do_test_pending();
controller.startSearch("test");
}

View File

@ -6,40 +6,40 @@
/**
* Dummy nsIAutoCompleteInput source that returns
* the given list of AutoCompleteSearch names.
*
* the given list of AutoCompleteSearch names.
*
* Implements only the methods needed for this test.
*/
function AutoCompleteInput(aSearches) {
this.searches = aSearches;
}
AutoCompleteInput.prototype = {
constructor: AutoCompleteInput,
constructor: AutoCompleteInput,
// Array of AutoCompleteSearch names
searches: null,
minResultsForPopup: 0,
timeout: 10,
searchParam: "",
textValue: "",
disableAutoComplete: false,
disableAutoComplete: false,
completeDefaultIndex: false,
get searchCount() {
return this.searches.length;
},
getSearchAt: function(aIndex) {
return this.searches[aIndex];
},
onSearchBegin: function() {},
onSearchComplete: function() {},
popupOpen: false,
popup: {
popupOpen: false,
popup: {
setSelectedIndex: function(aIndex) {},
invalidate: function() {},
@ -50,9 +50,9 @@ AutoCompleteInput.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
},
// nsISupports implementation
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
@ -65,7 +65,7 @@ AutoCompleteInput.prototype = {
/**
/**
* nsIAutoCompleteResult implementation
*/
function AutoCompleteResult(aValues, aComments, aStyles) {
@ -75,15 +75,15 @@ function AutoCompleteResult(aValues, aComments, aStyles) {
}
AutoCompleteResult.prototype = {
constructor: AutoCompleteResult,
// Arrays
_values: null,
_comments: null,
_styles: null,
searchString: "",
searchResult: null,
defaultIndex: 0,
get matchCount() {
@ -97,15 +97,15 @@ AutoCompleteResult.prototype = {
getLabelAt: function(aIndex) {
return this.getValueAt(aIndex);
},
getCommentAt: function(aIndex) {
return this._comments[aIndex];
},
getStyleAt: function(aIndex) {
return this._styles[aIndex];
},
getImageAt: function(aIndex) {
return "";
},
@ -123,12 +123,12 @@ AutoCompleteResult.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
}
/**
/**
* nsIAutoCompleteSearch implementation that always returns
* the same result set.
*/
@ -138,21 +138,21 @@ function AutoCompleteSearch(aName, aResult) {
}
AutoCompleteSearch.prototype = {
constructor: AutoCompleteSearch,
// Search name. Used by AutoCompleteController
name: null,
// AutoCompleteResult
_result:null,
_result:null,
/**
* Return the same result set for every search
*/
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
{
var result = this._result;
if (result._values.length > 0) {
@ -169,7 +169,7 @@ AutoCompleteSearch.prototype = {
}
aListener.onSearchResult(this, result);
},
stopSearch: function() {},
// nsISupports implementation
@ -181,7 +181,7 @@ AutoCompleteSearch.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
},
// nsIFactory implementation
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
@ -190,7 +190,7 @@ AutoCompleteSearch.prototype = {
/**
/**
* Helper to register an AutoCompleteSearch with the given name.
* Allows the AutoCompleteController to find the search.
*/
@ -202,46 +202,46 @@ function registerAutoCompleteSearch(aSearch) {
var cid = uuidGenerator.generateUUID();
var desc = "Test AutoCompleteSearch";
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(cid, desc, name, aSearch);
// Keep the id on the object so we can unregister later
aSearch.cid = cid;
aSearch.cid = cid;
}
/**
* Helper to unregister an AutoCompleteSearch.
/**
* Helper to unregister an AutoCompleteSearch.
*/
function unregisterAutoCompleteSearch(aSearch) {
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aSearch.cid, aSearch);
}
/**
/**
* Test AutoComplete with multiple AutoCompleteSearch sources.
*/
function run_test() {
var expected1 = ["1","2","3"];
var expected2 = ["a","b","c"];
var search1 = new AutoCompleteSearch("search1",
var search1 = new AutoCompleteSearch("search1",
new AutoCompleteResult(expected1, [], []));
var search2 = new AutoCompleteSearch("search2",
new AutoCompleteResult(expected2, [], []));
// Register searches so AutoCompleteController can find them
registerAutoCompleteSearch(search1);
registerAutoCompleteSearch(search2);
var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
getService(Components.interfaces.nsIAutoCompleteController);
getService(Components.interfaces.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our searches
// and confirms results on search complete
var input = new AutoCompleteInput([search1.name, search2.name]);
@ -256,7 +256,7 @@ function run_test() {
do_check_eq(numSearchesStarted, 1);
do_check_eq(controller.searchStatus,
do_check_eq(controller.searchStatus,
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
do_check_eq(controller.matchCount, expected1.length + expected2.length);
@ -271,6 +271,6 @@ function run_test() {
// Search is asynchronous, so don't let the test finish immediately
do_test_pending();
controller.startSearch("test");
}

View File

@ -42,7 +42,7 @@ add_test(function autocomplete_noMatch_success() {
do_check_eq(input.selectionEnd, strLen);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
controller.input = input;
controller.startSearch(INPUT_STR);
@ -77,7 +77,7 @@ add_test(function autocomplete_defaultIndex_exceeds_matchCount() {
do_check_eq(input.selectionEnd, strLen);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
controller.input = input;
controller.startSearch(INPUT_STR);

View File

@ -41,8 +41,8 @@ function doSearch(aSearchString, aResultValue, aOnCompleteCallback) {
registerAutoCompleteSearch(search);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our searches and confirms results.
let input = new AutoCompleteInput([ search.name ]);
input.textValue = aSearchString;

View File

@ -29,8 +29,8 @@ function doSearch(aSearchString, aResultValue, aFinalCompleteValue, aOnCompleteC
registerAutoCompleteSearch(search);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our searches and confirms results.
let input = new AutoCompleteInput([ search.name ]);
input.textValue = aSearchString;

View File

@ -79,8 +79,8 @@ function doSearch(aSearchString, aResultValue, aFinalCompleteValue,
registerAutoCompleteSearch(search);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our searches and confirms results.
let input = new AutoCompleteInput([ search.name ]);
for (var p in aInputProps) {

View File

@ -44,8 +44,8 @@ function doSearch(aSearchString, aResultValue, aFinalCompleteValue, aOnCompleteC
registerAutoCompleteSearch(search);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
// Make an AutoCompleteInput that uses our searches and confirms results.
let input = new AutoCompleteInput([ search.name ]);
input.textValue = aSearchString;

View File

@ -16,7 +16,7 @@ function AutoCompleteTypeAheadResult(aValues) {
AutoCompleteTypeAheadResult.prototype = Object.create(AutoCompleteResultBase.prototype);
/**
/**
* Test AutoComplete with multiple AutoCompleteSearch sources, with one of them
* being hidden from the popup, but can still do typeahead completion.
*/
@ -31,11 +31,11 @@ function run_test() {
// Regular result
var searchNormal = new AutoCompleteSearchBase("search2",
new AutoCompleteResult(["mozillaTest2"]));
// Register searches so AutoCompleteController can find them
registerAutoCompleteSearch(searchNormal);
registerAutoCompleteSearch(searchTypeAhead);
// Make an AutoCompleteInput that uses our searches
// and confirms results on search complete.
var input = new AutoCompleteInputBase([searchTypeAhead.name, searchNormal.name]);
@ -50,7 +50,7 @@ function run_test() {
do_check_eq(input.selectionEnd, strLen);
var controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
controller.input = input;
controller.startSearch(inputStr);

View File

@ -46,7 +46,7 @@ add_test(function test_immediate_search() {
registerAutoCompleteSearch(delayedSearch);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
let input = new AutoCompleteInputBase([delayedSearch.name,
immediateSearch.name]);
@ -91,7 +91,7 @@ add_test(function test_immediate_search_notimeout() {
registerAutoCompleteSearch(delayedSearch);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
let input = new AutoCompleteInputBase([delayedSearch.name,
immediateSearch.name]);
@ -132,7 +132,7 @@ add_test(function test_delayed_search_notimeout() {
registerAutoCompleteSearch(delayedSearch);
let controller = Cc["@mozilla.org/autocomplete/controller;1"].
getService(Ci.nsIAutoCompleteController);
getService(Ci.nsIAutoCompleteController);
let input = new AutoCompleteInputBase([delayedSearch.name]);
input.completeDefaultIndex = true;

View File

@ -12,40 +12,40 @@
/**
* Dummy nsIAutoCompleteInput source that returns
* the given list of AutoCompleteSearch names.
*
* the given list of AutoCompleteSearch names.
*
* Implements only the methods needed for this test.
*/
function AutoCompleteInput(aSearches) {
this.searches = aSearches;
}
AutoCompleteInput.prototype = {
constructor: AutoCompleteInput,
constructor: AutoCompleteInput,
// Array of AutoCompleteSearch names
searches: null,
minResultsForPopup: 0,
timeout: 10,
searchParam: "",
textValue: "",
disableAutoComplete: false,
disableAutoComplete: false,
completeDefaultIndex: false,
get searchCount() {
return this.searches.length;
},
getSearchAt: function(aIndex) {
return this.searches[aIndex];
},
onSearchBegin: function() {},
onSearchComplete: function() {},
popupOpen: false,
popup: {
popupOpen: false,
popup: {
setSelectedIndex: function(aIndex) {},
invalidate: function() {},
@ -56,9 +56,9 @@ AutoCompleteInput.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
},
// nsISupports implementation
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
@ -71,7 +71,7 @@ AutoCompleteInput.prototype = {
/**
/**
* nsIAutoCompleteResult implementation
*/
function AutoCompleteResult(aValues, aComments, aStyles) {
@ -86,15 +86,15 @@ function AutoCompleteResult(aValues, aComments, aStyles) {
}
AutoCompleteResult.prototype = {
constructor: AutoCompleteResult,
// Arrays
_values: null,
_comments: null,
_styles: null,
searchString: "",
searchResult: null,
defaultIndex: 0,
get matchCount() {
@ -108,15 +108,15 @@ AutoCompleteResult.prototype = {
getLabelAt: function(aIndex) {
return this.getValueAt(aIndex);
},
getCommentAt: function(aIndex) {
return this._comments[aIndex];
},
getStyleAt: function(aIndex) {
return this._styles[aIndex];
},
getImageAt: function(aIndex) {
return "";
},
@ -134,11 +134,11 @@ AutoCompleteResult.prototype = {
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
}
/**
/**
* nsIAutoCompleteSearch implementation that always returns
* the same result set.
*/
@ -148,7 +148,7 @@ function AutoCompleteSearch(aName, aResult) {
}
AutoCompleteSearch.prototype = {
constructor: AutoCompleteSearch,
// Search name. Used by AutoCompleteController
name: null,
@ -156,20 +156,20 @@ AutoCompleteSearch.prototype = {
_result: null,
_previousResult: null,
/**
* Return the same result set for every search
*/
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
startSearch: function(aSearchString,
aSearchParam,
aPreviousResult,
aListener)
{
this._previousResult = aPreviousResult;
aListener.onSearchResult(this, this._result);
},
stopSearch: function() {},
// nsISupports implementation
@ -181,7 +181,7 @@ AutoCompleteSearch.prototype = {
throw Components.results.NS_ERROR_NO_INTERFACE;
},
// nsIFactory implementation
createInstance: function(outer, iid) {
return this.QueryInterface(iid);
@ -189,7 +189,7 @@ AutoCompleteSearch.prototype = {
}
/**
/**
* Helper to register an AutoCompleteSearch with the given name.
* Allows the AutoCompleteController to find the search.
*/
@ -201,34 +201,34 @@ function registerAutoCompleteSearch(aSearch) {
var cid = uuidGenerator.generateUUID();
var desc = "Test AutoCompleteSearch";
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(cid, desc, name, aSearch);
// Keep the id on the object so we can unregister later
aSearch.cid = cid;
aSearch.cid = cid;
}
/**
* Helper to unregister an AutoCompleteSearch.
/**
* Helper to unregister an AutoCompleteSearch.
*/
function unregisterAutoCompleteSearch(aSearch) {
var componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aSearch.cid, aSearch);
}
/**
/**
*/
function run_test() {
// Make an AutoCompleteSearch that always returns nothing
var search1 = new AutoCompleteSearch("test-previous-result1",
new AutoCompleteResult(["hello1"], [""], [""]));
var search2 = new AutoCompleteSearch("test-previous-result2",
var search2 = new AutoCompleteSearch("test-previous-result2",
new AutoCompleteResult(["hello2"], [""], [""]));
// Register search so AutoCompleteController can find them
@ -250,7 +250,7 @@ function run_test() {
};
input.onSearchComplete = function() {
do_check_eq(controller.searchStatus,
do_check_eq(controller.searchStatus,
Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
do_check_eq(controller.matchCount, 2);
@ -278,7 +278,7 @@ function run_test() {
// Search is asynchronous, so don't let the test finish immediately
do_test_pending();
controller.startSearch("test");
}

View File

@ -27,7 +27,7 @@ AutoCompleteInput.prototype = {
timeout: 10,
searchParam: "",
textValue: "hello",
disableAutoComplete: false,
disableAutoComplete: false,
completeDefaultIndex: false,
set popupOpen(val) { return val; }, // ignore
get popupOpen() { return false; },
@ -79,7 +79,7 @@ AutoCompleteSearch.prototype = {
}
/**
/**
* Helper to register an AutoCompleteSearch with the given name.
* Allows the AutoCompleteController to find the search.
*/
@ -94,16 +94,16 @@ function registerAutoCompleteSearch(aSearch)
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.registerFactory(cid, desc, name, aSearch);
// Keep the id on the object so we can unregister later
aSearch.cid = cid;
aSearch.cid = cid;
}
/**
* Helper to unregister an AutoCompleteSearch.
/**
* Helper to unregister an AutoCompleteSearch.
*/
function unregisterAutoCompleteSearch(aSearch) {
let componentManager = Components.manager
.QueryInterface(Ci.nsIComponentRegistrar);
.QueryInterface(Ci.nsIComponentRegistrar);
componentManager.unregisterFactory(aSearch.cid, aSearch);
}

View File

@ -2,5 +2,5 @@ function run_test() {
var cmdLine=Components.classes["@mozilla.org/toolkit/command-line;1"].createInstance(Components.interfaces.nsICommandLine);
try {
cmdLine.getArgument(cmdLine.length);
} catch(e) {}
} catch(e) {}
}

View File

@ -18,7 +18,7 @@ window.onload = function()
gTextBoxEval = document.getElementById("TextboxEval");
gEvaluator = document.getElementById("Evaluator");
gFilter = document.getElementById("Filter");
updateSortCommand(gConsole.sortOrder);
updateModeCommand(gConsole.mode);
@ -45,7 +45,7 @@ function changeMode(aMode)
case "All":
gConsole.mode = null;
}
document.persist("ConsoleBox", "mode");
}
@ -63,7 +63,7 @@ function updateSortCommand(aOrder)
{
var orderString = aOrder == 'reverse' ? "Descend" : "Ascend";
var bc = document.getElementById("Console:sort"+orderString);
bc.setAttribute("checked", true);
bc.setAttribute("checked", true);
orderString = aOrder == 'reverse' ? "Ascend" : "Descend";
bc = document.getElementById("Console:sort"+orderString);

View File

@ -12,7 +12,7 @@
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="console-box" extends="xul:box">
<content>
<content>
<xul:stringbundle src="chrome://global/locale/console.properties" role="string-bundle"/>
<xul:vbox class="console-box-internal">
<xul:vbox class="console-rows" role="console-rows" xbl:inherits="dir=sortOrder"/>
@ -89,7 +89,7 @@
this.mCount = 0;
this.mConsoleListener = {
console: this,
console: this,
observe : function(aObject) {
// The message can arrive a little bit after the xbl binding has been
// unbind. So node.appendItem will not be available anymore.
@ -360,7 +360,7 @@
</method>
<!-- UTILITY FUNCTIONS -->
<method name="repeatChar">
<parameter name="aChar"/>
<parameter name="aCol"/>
@ -390,9 +390,9 @@
});
]]></body>
</method>
<constructor> this.init(); </constructor>
<destructor> this.destroy(); </destructor>
<constructor>this.init();</constructor>
<destructor>this.destroy();</destructor>
<!-- Command controller for the copy command -->
<field name="_controller"><![CDATA[({

View File

@ -46,7 +46,7 @@ var ContentPrefTest = {
//**************************************************************************//
// nsISupports
interfaces: [Ci.nsIDirectoryServiceProvider, Ci.nsISupports],
QueryInterface: function ContentPrefTest_QueryInterface(iid) {

View File

@ -6,7 +6,7 @@ function run_test() {
var cps = new ContentPrefInstance(null);
var uri = ContentPrefTest.getURI("http://www.example.com/");
do_check_thrown(function () { cps.setPref(uri, null, 8); });
do_check_thrown(function () { cps.hasPref(uri, null); });
do_check_thrown(function () { cps.getPref(uri, null); });

View File

@ -51,7 +51,7 @@ function run_test() {
cps.removePref(uri, "value");
do_check_eq(cps.hasPref(uri, "value"), true);
// fallback to non private mode value
do_check_eq(cps.getPref(uri, "value"), "foo");
do_check_eq(cps.getPref(uri, "value"), "foo");
do_check_eq(prefObserver.removedCalledNum, num + 1);
num = prefObserver.removedCalledNum;

View File

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var cps = new ContentPrefInstance(null);
function run_test() {
var uri1 = ContentPrefTest.getURI("http://www.domain1.com/");
var uri2 = ContentPrefTest.getURI("http://foo.domain1.com/");
@ -15,7 +15,7 @@ function run_test() {
cps.setPref(uri2, "one", 4);
cps.setPref(uri3, "three", 8);
cps.setPref(uri4, "two", 16);
cps.removePref(uri3, "three"); // uri3 should be removed now
checkForUnusedGroups();
checkForUnusedSettings();
@ -23,7 +23,7 @@ function run_test() {
cps.removePrefsByName("two"); // uri4 should be removed now
checkForUnusedGroups();
checkForUnusedSettings();
cps.removeGroupedPrefs();
checkForUnusedGroups();
checkForUnusedSettings();

View File

@ -11,7 +11,7 @@ const nsICookiePromptService = Components.interfaces.nsICookiePromptService;
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
var params;
var params;
var cookieBundle;
var gDateService = null;
@ -156,7 +156,7 @@ function showhideinfo()
function cookieAcceptNormal()
{
// accept the cookie normally
params.SetInt(nsICookieAcceptDialog.ACCEPT_COOKIE, nsICookiePromptService.ACCEPT_COOKIE);
params.SetInt(nsICookieAcceptDialog.ACCEPT_COOKIE, nsICookiePromptService.ACCEPT_COOKIE);
// And remember that when needed
params.SetInt(nsICookieAcceptDialog.REMEMBER_DECISION, document.getElementById('persistDomainAcceptance').checked);
window.close();
@ -174,7 +174,7 @@ function cookieAcceptSession()
function cookieDeny()
{
// say that the cookie was rejected
params.SetInt(nsICookieAcceptDialog.ACCEPT_COOKIE, nsICookiePromptService.DENY_COOKIE);
params.SetInt(nsICookieAcceptDialog.ACCEPT_COOKIE, nsICookiePromptService.DENY_COOKIE);
// And remember that when needed
params.SetInt(nsICookieAcceptDialog.REMEMBER_DECISION, document.getElementById('persistDomainAcceptance').checked);
window.close();
@ -190,8 +190,8 @@ function GetExpiresString(secondsUntilExpires) {
var expiry = "";
try {
expiry = gDateService.FormatDateTime("", gDateService.dateFormatLong,
gDateService.timeFormatSeconds,
date.getFullYear(), date.getMonth()+1,
gDateService.timeFormatSeconds,
date.getFullYear(), date.getMonth()+1,
date.getDate(), date.getHours(),
date.getMinutes(), date.getSeconds());
} catch(ex) {

View File

@ -826,7 +826,7 @@ CrashStore.prototype = Object.freeze({
// If we have an OOM size, count the crash as an OOM in addition to
// being a main process crash.
if (denormalized.metadata &&
if (denormalized.metadata &&
denormalized.metadata.OOMAllocationSize) {
let oomKey = key + "-oom";
actualCounts.set(oomKey, (actualCounts.get(oomKey) || 0) + 1);

View File

@ -33,7 +33,7 @@ nsDownloadManagerUI.prototype = {
let window = this.recentWindow;
if (window) {
window.focus();
// If we are being asked to show again, with a user interaction reason,
// set the appropriate variable.
if (aReason == Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED)

View File

@ -49,7 +49,7 @@ function test()
finish();
}
// OK, let's pull up the UI
// Linux uses y, everything else is j
var key = navigator.platform.match("Linux") ? "y" : "j";

View File

@ -100,7 +100,7 @@ function test()
finish();
}
waitForExplicitFinish();
window.setTimeout(finishUp, 1000);
}

View File

@ -36,7 +36,7 @@ var DownloadListener = {
},
observe: function (aSubject, aTopic, aData) {
if (aTopic == "dl-start") {
// pause the download if requested
if (this.set.doPause) {

View File

@ -71,7 +71,7 @@ add_task(function* test_execute()
// Give it some state
stmt.bindByIndex(3, dm.DOWNLOAD_FINISHED);
stmt.bindByIndex(4, theGUID);
// Add it!

View File

@ -97,7 +97,7 @@ function stripTags(someHTML) {
}
/**
* Searches through an array of links and returns a JS array
* Searches through an array of links and returns a JS array
* of matching property bags.
*/
const IANA_URI = "http://www.iana.org/assignments/relation/";
@ -114,7 +114,7 @@ function findAtomLinks(rel, links) {
rvLinks.push(linkElement);
continue;
}
// catch relations specified by IANA URI
// catch relations specified by IANA URI
if (relAttribute == IANA_URI + rel) {
rvLinks.push(linkElement);
}
@ -177,8 +177,8 @@ var gNamespaces = {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#":"rdf",
"http://purl.org/rss/1.0/":"rss1",
"http://my.netscape.com/rdf/simple/0.9/":"rss1",
"http://wellformedweb.org/CommentAPI/":"wfw",
"http://purl.org/rss/1.0/modules/wiki/":"wiki",
"http://wellformedweb.org/CommentAPI/":"wfw",
"http://purl.org/rss/1.0/modules/wiki/":"wiki",
"http://www.w3.org/XML/1998/namespace":"xml",
"http://search.yahoo.com/mrss/":"media",
"http://search.yahoo.com/mrss":"media"
@ -209,7 +209,7 @@ FeedResult.prototype = {
// XPCOM stuff
classID: FR_CLASSID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFeedResult])
}
}
function Feed() {
this.subtitle = null;
@ -267,7 +267,7 @@ Feed.prototype = {
if (this.image && bagHasKey(this.image, "url"))
this._resolveImageLink();
this._resetBagMembersToRawText([this.searchLists.subtitle,
this._resetBagMembersToRawText([this.searchLists.subtitle,
this.searchLists.title]);
},
@ -308,7 +308,7 @@ Feed.prototype = {
var feedtype = Ci.nsIFeed.TYPE_FEED;
// For a feed to be marked as TYPE_VIDEO, TYPE_AUDIO and TYPE_IMAGE,
// For a feed to be marked as TYPE_VIDEO, TYPE_AUDIO and TYPE_IMAGE,
// we enforce two things:
//
// 1. all entries must have at least one enclosure
@ -368,7 +368,7 @@ Feed.prototype = {
// reset the bag to raw contents, not text constructs
_resetBagMembersToRawText: function Feed_resetBagMembers(fieldLists) {
for (var i=0; i<fieldLists.length; i++) {
for (var i=0; i<fieldLists.length; i++) {
for (var j=0; j<fieldLists[i].length; j++) {
if (bagHasKey(this.fields, fieldLists[i][j])) {
var textConstruct = this.fields.getProperty(fieldLists[i][j]);
@ -378,7 +378,7 @@ Feed.prototype = {
}
}
},
// XPCOM stuff
classID: FEED_CLASSID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFeed, Ci.nsIFeedContainer])
@ -398,12 +398,12 @@ function Entry() {
this.authors = Cc[ARRAY_CONTRACTID].createInstance(Ci.nsIMutableArray);
this.contributors = Cc[ARRAY_CONTRACTID].createInstance(Ci.nsIMutableArray);
}
Entry.prototype = {
fields: null,
enclosures: null,
mediaContent: null,
searchLists: {
title: ["title", "rss1:title", "atom03:title", "atom:title"],
link: [["link",strToURI],["rss1:link",strToURI]],
@ -419,10 +419,10 @@ Entry.prototype = {
updated: ["pubDate", "atom03:modified", "dc:date", "dcterms:modified",
"atom:updated"]
},
normalize: function Entry_normalize() {
fieldsToObj(this, this.searchLists);
// Assign Atom link if needed
if (bagHasKey(this.fields, "links"))
this._atomLinksToURI();
@ -434,10 +434,10 @@ Entry.prototype = {
if (!this.link && bagHasKey(this.fields, "guid")) {
var guid = this.fields.getProperty("guid");
var isPermaLink = true;
if (bagHasKey(guid, "isPermaLink"))
isPermaLink = guid.getProperty("isPermaLink").toLowerCase() != "false";
if (guid && isPermaLink)
this.link = strToURI(guid.getProperty("guid"));
}
@ -447,8 +447,8 @@ Entry.prototype = {
if (this.published)
this.published = dateParse(this.published);
this._resetBagMembersToRawText([this.searchLists.content,
this.searchLists.summary,
this._resetBagMembersToRawText([this.searchLists.content,
this.searchLists.summary,
this.searchLists.title]);
},
@ -494,7 +494,7 @@ Entry.prototype = {
if (!bagHasKey(previous_enc, "length") && bagHasKey(new_enc, "length"))
previous_enc.setPropertyAsAString("length", new_enc.getPropertyAsAString("length"));
return;
}
@ -591,7 +591,7 @@ Entry.prototype = {
Entry.prototype._atomLinksToURI = Feed.prototype._atomLinksToURI;
Entry.prototype._resolveURI = Feed.prototype._resolveURI;
Entry.prototype._resetBagMembersToRawText =
Entry.prototype._resetBagMembersToRawText =
Feed.prototype._resetBagMembersToRawText;
// TextConstruct represents and element that could contain (X)HTML
@ -633,7 +633,7 @@ TextConstruct.prototype = {
return this.parserUtils.parseFragment(this.text, 0, isXML,
this.base, element);
},
// XPCOM stuff
classID: TEXTCONSTRUCT_CLASSID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFeedTextConstruct])
@ -697,12 +697,12 @@ Person.prototype = {
)
}
/**
/**
* Map a list of fields into properties on a container.
*
* @param container An nsIFeedContainer
* @param fields A list of fields to search for. List members can
* be a list, in which case the second member is
* be a list, in which case the second member is
* transformation function (like parseInt).
*/
function fieldsToObj(container, fields) {
@ -715,8 +715,8 @@ function fieldsToObj(container, fields) {
field = isArray(props) ? props[0] : props;
try {
prop = container.fields.getProperty(field);
}
catch(e) {
}
catch(e) {
}
if (prop) {
prop = isArray(props) ? props[1](prop) : prop;
@ -754,9 +754,9 @@ function rssCatTerm(s, cat) {
// add slash handling?
cat.setPropertyAsAString("term", s.trim());
return cat;
}
}
// post-process a GUID
// post-process a GUID
function rssGuid(s, guid) {
guid.setPropertyAsAString("guid", s.trim());
return guid;
@ -765,7 +765,7 @@ function rssGuid(s, guid) {
// post-process an RSS author element
//
// It can contain a field like this:
//
//
// <author>lawyer@boyer.net (Lawyer Boyer)</author>
//
// or, delightfully, a field like this:
@ -780,7 +780,7 @@ function rssAuthor(s,author) {
// check for RSS2 string format
var chars = s.trim();
var matches = chars.match(/(.*)\((.*)\)/);
var emailCheck =
var emailCheck =
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (matches) {
var match1 = matches[1].trim();
@ -836,7 +836,7 @@ function dateParse(aDateString) {
return date.toUTCString();
}
return null;
}
}
const XHTML_NS = "http://www.w3.org/1999/xhtml";
@ -854,7 +854,7 @@ function XHTMLHandler(processor, isAtom) {
// SVG and MathML. XXX
XHTMLHandler.prototype = {
// look back up at the declared namespaces
// look back up at the declared namespaces
// we always use the same prefixes for our safe stuff
_isInScope: function XH__isInScope(ns) {
for (var i in this._inScopeNS) {
@ -874,7 +874,7 @@ XHTMLHandler.prototype = {
++this._depth;
this._inScopeNS.push([]);
// RFC4287 requires XHTML to be wrapped in a div that is *not* part of
// RFC4287 requires XHTML to be wrapped in a div that is *not* part of
// the content. This prevents people from screwing up namespaces, but
// we need to skip it here.
if (this._isAtom && this._depth == 1 && localName == "div")
@ -887,7 +887,7 @@ XHTMLHandler.prototype = {
for (var i=0; i < attributes.length; ++i) {
uri = attributes.getURI(i);
// XHTML attributes aren't in a namespace
if (uri == "") {
if (uri == "") {
this._buf += (" " + attributes.getLocalName(i) + "='" +
xmlEscape(attributes.getValue(i)) + "'");
} else {
@ -897,10 +897,10 @@ XHTMLHandler.prototype = {
// The attribute value we'll attempt to write
var attributeValue = xmlEscape(attributes.getValue(i));
// it's an allowed attribute NS.
// it's an allowed attribute NS.
// write the attribute
this._buf += (" " + prefix + ":" +
attributes.getLocalName(i) +
this._buf += (" " + prefix + ":" +
attributes.getLocalName(i) +
"='" + attributeValue + "'");
// write an xmlns declaration if necessary
@ -941,7 +941,7 @@ XHTMLHandler.prototype = {
endPrefixMapping: function FP_endPrefixMapping(prefix) {
},
processingInstruction: function XH_processingInstruction() {
},
},
}
/**
@ -972,23 +972,23 @@ ExtensionHandler.prototype = {
++this._depth;
var prefix = gNamespaces[uri] ? gNamespaces[uri] + ":" : "";
var key = prefix + localName;
if (this._depth == 1) {
this._uri = uri;
this._localName = localName;
this._qName = qName;
this._attrs = attrs;
}
// if we descend into another element, we won't send text
this._hasChildElements = (this._depth > 1);
},
endElement: function EH_endElement(uri, localName, qName) {
--this._depth;
if (this._depth == 0) {
var text = this._hasChildElements ? null : this._buf.trim();
this._processor.returnFromExtHandler(this._uri, this._localName,
this._processor.returnFromExtHandler(this._uri, this._localName,
text, this._attrs);
}
},
@ -1001,7 +1001,7 @@ ExtensionHandler.prototype = {
endPrefixMapping: function EH_endPrefixMapping() {
},
processingInstruction: function EH_processingInstruction() {
},
},
};
@ -1010,7 +1010,7 @@ ExtensionHandler.prototype = {
* some characteristics of a feed element. For example, it
* says whether an element can be expected to appear more
* than once inside a given entry or feed.
*/
*/
function ElementInfo(fieldName, containerClass, closeFunc, isArray) {
this.fieldName = fieldName;
this.containerClass = containerClass;
@ -1051,7 +1051,7 @@ function FeedProcessor() {
this._extensionHandler = null;
this._xhtmlHandler = null;
this._haveSentResult = false;
// The nsIFeedResultListener waiting for the parse results
this.listener = null;
@ -1074,7 +1074,7 @@ function FeedProcessor() {
"atom03:content":"text"};
this._stack = [];
this._trans = {
this._trans = {
"START": {
//If we hit a root RSS element, treat as RSS2.
"rss": new FeedElementInfo("RSS2", "rss2"),
@ -1089,7 +1089,7 @@ function FeedProcessor() {
// Treat as Atom 0.3
"atom03:feed": new FeedElementInfo("Atom03", "atom03"),
},
/********* RSS2 **********/
"IN_RSS2": {
"channel": new WrapperElementInfo("channel")
@ -1144,7 +1144,7 @@ function FeedProcessor() {
"media:content": new ElementInfo("mediacontent", null, null, true),
"media:thumbnail": new ElementInfo("mediathumbnail", null, null, true)
},
/********* RSS1 **********/
"IN_RDF": {
// If we hit a rss1:channel, we can verify that we have RSS1
@ -1216,8 +1216,8 @@ function FeedProcessor() {
}
// See startElement for a long description of how feeds are processed.
FeedProcessor.prototype = {
FeedProcessor.prototype = {
// Set ourselves as the SAX handler, and set the base URI
_init: function FP_init(uri) {
this._reader.contentHandler = this;
@ -1235,7 +1235,7 @@ FeedProcessor.prototype = {
// than the root.
_docVerified: function FP_docVerified(version) {
this._result.doc = Cc[FEED_CONTRACTID].createInstance(Ci.nsIFeed);
this._result.doc.baseURI =
this._result.doc.baseURI =
this._xmlBaseStack[this._xmlBaseStack.length - 1];
this._result.doc.fields = this._feed;
this._result.version = version;
@ -1266,7 +1266,7 @@ FeedProcessor.prototype = {
// Parsing functions
parseFromStream: function FP_parseFromStream(stream, uri) {
this._init(uri);
this._reader.parseFromStream(stream, null, stream.available(),
this._reader.parseFromStream(stream, null, stream.available(),
"application/xml");
this._reader = null;
},
@ -1282,7 +1282,7 @@ FeedProcessor.prototype = {
this._reader.parseAsync(requestObserver);
},
// nsIStreamListener
// nsIStreamListener
// The XMLReader will throw sensible exceptions if these get called
// out of order.
@ -1342,7 +1342,7 @@ FeedProcessor.prototype = {
// multiple times, such as the RSS category element and the Atom
// link element. Most of the RSS1/DC elements can occur multiple
// times in theory, but in practice, the only ones that do have
// analogues in Atom.
// analogues in Atom.
//
// Some elements are also groups of attributes or sub-elements,
// while others are simple text fields. For the most part, we don't
@ -1354,7 +1354,7 @@ FeedProcessor.prototype = {
// being dictionaries, whether they are based on attributes like RSS
// cloud, sub-elements like Atom author, or even items and
// entries. These elements are treated as "containers". It's
// theoretically possible for a container to have an attribute with
// theoretically possible for a container to have an attribute with
// the same universal name as a sub-element, but none of the feed
// formats allow this by default, and I don't of any extension that
// works this way.
@ -1383,7 +1383,7 @@ FeedProcessor.prototype = {
// Check to see if we need to hand this off to our XHTML handler.
// The elements we're dealing with will look like this:
//
//
// <title type="xhtml">
// <div xmlns="http://www.w3.org/1999/xhtml">
// A title with <b>bold</b> and <i>italics</i>.
@ -1391,18 +1391,18 @@ FeedProcessor.prototype = {
// </title>
//
// When it returns in returnFromXHTMLHandler, the handler should
// give us back a string like this:
//
// give us back a string like this:
//
// "A title with <b>bold</b> and <i>italics</i>."
//
// The Atom spec explicitly says the div is not part of the content,
// and explicitly allows whitespace collapsing.
//
//
if ((this._result.version == "atom" || this._result.version == "atom03") &&
this._textConstructs[key] != null) {
var type = attributes.getValueFromName("","type");
if (type != null && type.indexOf("xhtml") >= 0) {
this._xhtmlHandler =
this._xhtmlHandler =
new XHTMLHandler(this, (this._result.version == "atom"));
this._reader.contentHandler = this._xhtmlHandler;
return;
@ -1422,14 +1422,14 @@ FeedProcessor.prototype = {
this._extensionHandler.startElement(uri, localName, qName, attributes);
return;
}
// This distinguishes wrappers like 'channel' from elements
// we'd actually like to do something with (which will test true).
this._handlerStack[this._depth] = elementInfo;
this._handlerStack[this._depth] = elementInfo;
if (elementInfo.isWrapper) {
this._state = "IN_" + elementInfo.fieldName.toUpperCase();
this._stack.push([this._feed, this._state]);
}
}
else if (elementInfo.feedVersion) {
this._state = "IN_" + elementInfo.fieldName.toUpperCase();
@ -1458,7 +1458,7 @@ FeedProcessor.prototype = {
//LOG("</" + localName + ">");
if (elementInfo && !elementInfo.isWrapper)
this._closeComplexElement(elementInfo);
// cut down xml:base context
if (this._xmlBaseStack.length == this._depth + 1)
this._xmlBaseStack = this._xmlBaseStack.slice(0, this._depth);
@ -1476,18 +1476,18 @@ FeedProcessor.prototype = {
this._buf += data;
},
// TODO: It would be nice to check new prefixes here, and if they
// don't conflict with the ones we've defined, throw them in a
// don't conflict with the ones we've defined, throw them in a
// dictionary to check.
startPrefixMapping: function FP_startPrefixMapping(prefix, uri) {
},
endPrefixMapping: function FP_endPrefixMapping(prefix) {
},
processingInstruction: function FP_processingInstruction(target, data) {
if (target == "xml-stylesheet") {
var hrefAttribute = data.match(/href=[\"\'](.*?)[\"\']/);
if (hrefAttribute && hrefAttribute.length == 2)
if (hrefAttribute && hrefAttribute.length == 2)
this._result.stylesheet = strToURI(hrefAttribute[1], this._result.uri);
}
},
@ -1500,7 +1500,7 @@ FeedProcessor.prototype = {
function FP__processComplexElement(elementInfo, attributes) {
var obj, key, prefix;
// If the container is an entry/item, it'll need to have its
// If the container is an entry/item, it'll need to have its
// more esoteric properties put in the 'fields' property bag.
if (elementInfo.containerClass == Cc[ENTRY_CONTRACTID]) {
obj = elementInfo.containerClass.createInstance(Ci.nsIFeedEntry);
@ -1532,7 +1532,7 @@ FeedProcessor.prototype = {
}
catch(e) {
}
if (elementInfo.isArray) {
if (!prop) {
container.setPropertyAsInterface(elementInfo.fieldName,
@ -1546,11 +1546,11 @@ FeedProcessor.prototype = {
// on large files. Bug 335638.
newProp.QueryInterface(Ci.nsIMutableArray);
newProp.appendElement(obj,false);
// If new object is an nsIFeedContainer, we want to deal with
// its member nsIPropertyBag instead.
if (isIFeedContainer(obj))
newProp = obj.fields;
newProp = obj.fields;
}
else {
@ -1560,7 +1560,7 @@ FeedProcessor.prototype = {
}
newProp = container.getProperty(elementInfo.fieldName);
}
// make our new state name, and push the property onto the stack
var newState = "IN_" + elementInfo.fieldName.toUpperCase();
this._stack.push([newProp, newState, obj]);
@ -1598,7 +1598,7 @@ FeedProcessor.prototype = {
if (isArray)
container.replaceElementAt(element, container.length - 1, false);
},
_prefixForNS: function FP_prefixForNS(uri) {
if (!uri)
return "";
@ -1649,10 +1649,10 @@ FeedProcessor.prototype = {
// we don't take random elements inside rdf:RDF
if (this._state == "IN_RDF")
return;
// Grab the top of the stack
var top = this._stack[this._stack.length - 1];
if (!top)
if (!top)
return;
var container = top[0];
@ -1661,10 +1661,10 @@ FeedProcessor.prototype = {
var contract = this._handlerStack[this._depth].containerClass;
// check if it's something specific, but not an entry
if (contract && contract != Cc[ENTRY_CONTRACTID]) {
var el = container.queryElementAt(container.length - 1,
var el = container.queryElementAt(container.length - 1,
Ci.nsIFeedElementBase);
// XXX there must be a way to flatten these interfaces
if (contract == Cc[PERSON_CONTRACTID])
if (contract == Cc[PERSON_CONTRACTID])
el.QueryInterface(Ci.nsIFeedPerson);
else
return; // don't know about this interface
@ -1673,13 +1673,13 @@ FeedProcessor.prototype = {
var prefix = gNamespaces[uri];
// synonyms
if ((uri == "" ||
if ((uri == "" ||
prefix &&
((prefix.indexOf("atom") > -1) ||
(prefix.indexOf("rss") > -1))) &&
(prefix.indexOf("rss") > -1))) &&
(propName == "url" || propName == "href"))
propName = "uri";
try {
if (el[propName] !== "undefined") {
var propValue = chars;
@ -1695,14 +1695,14 @@ FeedProcessor.prototype = {
// ignore XPConnect errors
}
// the rest of the function deals with entry- and feed-level stuff
return;
}
return;
}
else {
container = container.queryElementAt(container.length - 1,
container = container.queryElementAt(container.length - 1,
Ci.nsIWritablePropertyBag2);
}
}
// Make the buffer our new property
var propName = this._prefixForNS(uri) + localName;
@ -1730,7 +1730,7 @@ FeedProcessor.prototype = {
type = "text";
}
}
// If it's rss feed-level description, it's not supposed to have html
if (this._result.version.indexOf("rss") >= 0 &&
this._handlerStack[this._depth].containerClass != ENTRY_CONTRACTID) {
@ -1756,7 +1756,7 @@ FeedProcessor.prototype = {
// Grab the top of the stack
var top = this._stack[this._stack.length - 1];
if (!top)
if (!top)
return;
var container = top[0];
@ -1768,7 +1768,7 @@ FeedProcessor.prototype = {
newProp.base = this._xmlBaseStack[this._xmlBaseStack.length - 1];
container.setPropertyAsInterface(this._prefixForNS(uri) + localName,
newProp);
// XHTML will cause us to peek too far. The XHTML handler will
// send us an end element to call. RFC4287-valid feeds allow a
// more graceful way to handle this. Unfortunately, we can't count

View File

@ -14,7 +14,7 @@
* |
* - head.js
* |
* - xml/ -- rss1/...
* - xml/ -- rss1/...
* |
* -- rss2/...
* |

View File

@ -71,7 +71,7 @@ function filepickerLoad() {
textInputLabel.value = gFilePickerBundle.getString("dirTextInputLabel");
textInputLabel.accessKey = gFilePickerBundle.getString("dirTextInputAccesskey");
}
if ((filePickerMode == nsIFilePicker.modeOpen) ||
(filePickerMode == nsIFilePicker.modeOpenMultiple) ||
(filePickerMode == nsIFilePicker.modeSave)) {
@ -297,7 +297,7 @@ function selectOnOK()
var message =
gFilePickerBundle.getFormattedString("confirmFileReplacing",
[file.path]);
promptService = Components.classes[NS_PROMPTSERVICE_CONTRACTID].getService(Components.interfaces.nsIPromptService);
var rv = promptService.confirm(window, confirmTitle, message);
if (rv) {
@ -360,7 +360,7 @@ function selectOnOK()
retvals.files = gFilesEnumerator;
retvals.buttonStatus = ret;
return (ret != nsIFilePicker.returnCancel);
}
@ -420,7 +420,7 @@ function onClick(e) {
function convertColumnIDtoSortType(columnID) {
var sortKey;
switch (columnID) {
case "FilenameColumn":
sortKey = nsIFileView.sortName;
@ -436,7 +436,7 @@ function convertColumnIDtoSortType(columnID) {
sortKey = 0;
break;
}
return sortKey;
}
@ -444,7 +444,7 @@ function handleColumnClick(columnID) {
var sortType = convertColumnIDtoSortType(columnID);
var sortOrder = (treeView.sortType == sortType) ? !treeView.reverseSort : false;
treeView.sort(sortType, sortOrder);
// set the sort indicator on the column we are sorted by
var sortedColumn = document.getElementById(columnID);
if (treeView.reverseSort) {
@ -452,7 +452,7 @@ function handleColumnClick(columnID) {
} else {
sortedColumn.setAttribute("sortDirection", "ascending");
}
// remove the sort indicator from the rest of the columns
var currCol = sortedColumn.parentNode.firstChild;
while (currCol) {
@ -597,7 +597,7 @@ function populateAncestorList(directory) {
while (menu.hasChildNodes()) {
menu.removeChild(menu.firstChild);
}
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", directory.path);
menuItem.setAttribute("crop", "start");
@ -613,7 +613,7 @@ function populateAncestorList(directory) {
directory = parent;
parent = directory.parent;
}
var menuList = document.getElementById("lookInMenuList");
menuList.selectedIndex = 0;
}
@ -650,7 +650,7 @@ function newDir() {
file);
return false;
}
file = file[0].QueryInterface(nsIFile);
if (file.exists()) {
showErrorDialog("errorNewDirDoesExistTitle",
@ -681,7 +681,7 @@ function newDir() {
}
try {
file.create(nsIFile.DIRECTORY_TYPE, 0755);
file.create(nsIFile.DIRECTORY_TYPE, 0755);
} catch (e) {
showErrorDialog("errorCreateNewDirTitle",
"errorCreateNewDirMessage",
@ -693,7 +693,7 @@ function newDir() {
// we remember and reshow a dirname if something goes wrong
// so that errors can be corrected more easily. If all went well,
// reset the default value to blank
gNewDirName = { value: "" };
gNewDirName = { value: "" };
}
return true;
}
@ -750,7 +750,7 @@ function processPath(path)
nextQuote = path.indexOf('"', quoteSearchStart);
quoteSearchStart = nextQuote + 1;
} while (nextQuote != -1 && path[nextQuote - 1] == '\\');
if (nextQuote == -1) {
// we have a filename with no trailing quote.
// just assume that the filename ends at the end of the string.
@ -807,7 +807,7 @@ function processPathEntry(path, fileArray)
// Unescape quotes
filePath = filePath.replace(/\\\"/g, "\"");
if (filePath[0] == '/') /* an absolute path was entered */
file.initWithPath(filePath);
else if ((filePath.indexOf("/../") > 0) ||

View File

@ -228,7 +228,7 @@ var listener = {
this.mm = null;
}
// Remove the annotation after we've cleaned everything up, to catch any
// incidental crashes from having performed the sanity test.
annotateCrashReport(false);

View File

@ -16,7 +16,7 @@ this.Microformats = {
},
/**
* Retrieves microformats objects of the given type from a document
*
*
* @param name The name of the microformat (required)
* @param rootElement The DOM element at which to start searching (required)
* @param options Literal object with the following options:
@ -28,7 +28,7 @@ this.Microformats = {
* debug - Whether or not we are in debug mode (optional
* - defaults to false)
* @param targetArray An array of microformat objects to which is added the results (optional)
* @return A new array of microformat objects or the passed in microformat
* @return A new array of microformat objects or the passed in microformat
* object array with the new objects added
*/
get: function(name, rootElement, options, targetArray) {
@ -74,7 +74,7 @@ this.Microformats = {
if ((microformatNodes.length == 0) && Microformats[name].alternateClassName) {
var altClass = Microformats.getElementsByClassName(rootElement, Microformats[name].alternateClassName);
if (altClass.length > 0) {
microformatNodes.push(rootElement);
microformatNodes.push(rootElement);
}
}
} else if (Microformats[name].attributeValues) {
@ -82,9 +82,9 @@ this.Microformats = {
Microformats.getElementsByAttribute(rootElement,
Microformats[name].attributeName,
Microformats[name].attributeValues);
}
function isVisible(node, checkChildren) {
if (node.getBoundingClientRect) {
@ -109,7 +109,7 @@ this.Microformats = {
}
return true;
}
/* Create objects for the microformat nodes and put them into the microformats */
/* array */
for (let i = 0; i < microformatNodes.length; i++) {
@ -138,7 +138,7 @@ this.Microformats = {
},
/**
* Counts microformats objects of the given type from a document
*
*
* @param name The name of the microformat (required)
* @param rootElement The DOM element at which to start searching (required)
* @param options Literal object with the following options:
@ -226,7 +226,7 @@ this.Microformats = {
return null;
},
/**
* If the passed in node is a microformat, this function returns a space
* If the passed in node is a microformat, this function returns a space
* separated list of the microformat names that correspond to this node
*
* @param node DOM node to check
@ -276,7 +276,7 @@ this.Microformats = {
}
var toreturn = "";
var testArray = [];
for (let i in item)
{
if (testArray[i]) {
@ -354,9 +354,9 @@ this.Microformats = {
outstring = outstring.replace(/\s+$/, '');
return outstring;
}
if (((((propnode.localName.toLowerCase() == "abbr") || (propnode.localName.toLowerCase() == "html:abbr")) && !propnode.namespaceURI) ||
if (((((propnode.localName.toLowerCase() == "abbr") || (propnode.localName.toLowerCase() == "html:abbr")) && !propnode.namespaceURI) ||
((propnode.localName.toLowerCase() == "abbr") && (propnode.namespaceURI == "http://www.w3.org/1999/xhtml"))) && (propnode.hasAttribute("title"))) {
return propnode.getAttribute("title");
} else if ((propnode.nodeName.toLowerCase() == "img") && (propnode.hasAttribute("alt"))) {
@ -441,7 +441,7 @@ this.Microformats = {
* Basically this is to handle the face that telephone numbers use value
* as the name as one of their subproperties, but value is also used for
* value excerpting (http://microformats.org/wiki/hcard#Value_excerpting)
* @param propnode The DOMNode to check
* @param parentnode The parent node of the property. If it is a subproperty,
* this is the parent property node. If it is not, this is the
@ -668,11 +668,11 @@ this.Microformats = {
for (let i in Microformats[microformat].properties) {
object.__defineGetter__(i, Microformats.parser.getMicroformatPropertyGenerator(node, microformat, i, object));
}
/* The node in the object should be the original node */
object.node = in_node;
/* we also store the node that has been "resolved" */
object.resolvedNode = node;
object.resolvedNode = node;
object.semanticType = microformat;
if (validate) {
Microformats.parser.validate(node, microformat);
@ -683,7 +683,7 @@ this.Microformats = {
return function() {
var result = Microformats.parser.getMicroformatProperty(node, name, property);
// delete microformat[property];
// microformat[property] = result;
// microformat[property] = result;
return result;
};
},
@ -915,7 +915,7 @@ this.Microformats = {
normalizeISO8601: function normalizeISO8601(string)
{
var dateArray = string.match(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:([-+Z])(?:(\d\d)(?::?(\d\d))?)?)?)?)?)?/);
var dateString;
var tzOffset = 0;
if (!dateArray) {
@ -965,13 +965,13 @@ this.Microformats = {
* offset and Z if present to convert the date to local time
* NOTE: I'm using an extra parameter on the date object for this function.
* I set date.time to true if there is a date, otherwise date.time is false.
*
*
* @param string ISO8601 formatted date
* @return JavaScript date object that represents the ISO date.
* @return JavaScript date object that represents the ISO date.
*/
dateFromISO8601: function dateFromISO8601(string) {
var dateArray = string.match(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:([-+Z])(?:(\d\d)(?::?(\d\d))?)?)?)?)?)?/);
var date = new Date(dateArray[1], 0, 1);
date.time = false;
@ -1011,9 +1011,9 @@ this.Microformats = {
if (dateArray[8]) {
var tzOffset = date.getTimezoneOffset();
if (tzOffset < 0) {
date.setMinutes(date.getMinutes() + tzOffset);
date.setMinutes(date.getMinutes() + tzOffset);
} else if (tzOffset > 0) {
date.setMinutes(date.getMinutes() - tzOffset);
date.setMinutes(date.getMinutes() - tzOffset);
}
}
}
@ -1023,10 +1023,10 @@ this.Microformats = {
* Converts a Javascript date object into an ISO 8601 formatted date
* NOTE: I'm using an extra parameter on the date object for this function.
* If date.time is NOT true, this function only outputs the date.
*
*
* @param date Javascript Date object
* @param punctuation true if the date should have -/:
* @return string with the ISO date.
* @return string with the ISO date.
*/
iso8601FromDate: function iso8601FromDate(date, punctuation) {
var string = date.getFullYear().toString();
@ -1077,7 +1077,7 @@ this.Microformats = {
*
* Retrieve elements matching all classes listed in a space-separated string.
* I had to implement my own because I need an Array, not an nsIDomNodeList
*
*
* @param rootElement The DOM element at which to start searching (optional)
* @param className A space separated list of classenames
* @return microformatNodes An array of DOM Nodes, each representing a
@ -1119,7 +1119,7 @@ this.Microformats = {
* Not intended for external consumption. Microformat implementations might use it.
*
* Retrieve elements matching an attribute and an attribute list in a space-separated string.
*
*
* @param rootElement The DOM element at which to start searching (optional)
* @param atributeName The attribute name to match against
* @param attributeValues A space separated list of attribute values
@ -1142,7 +1142,7 @@ this.Microformats = {
}
xpathExpression += "contains(concat(' ', @" + attributeName + ", ' '), ' " + attributeList[i] + " ')";
}
xpathExpression += "]";
xpathExpression += "]";
var xpathResult = (rootNode.ownerDocument || rootNode).evaluate(xpathExpression, rootNode, null, 0, null);
@ -1314,7 +1314,7 @@ var hCard_definition = {
virtual: true
}
},
plural: true
plural: true
},
"fn" : {
required: true

File diff suppressed because it is too large Load Diff

View File

@ -6,102 +6,102 @@ assert = chai.assert;
describe('Microformat.count', function() {
it('count', function(){
var doc,
node,
result;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = html;
doc.body.appendChild(node);
doc.body.appendChild(node);
options ={
'node': node,
};
result = Microformats.count(options);
assert.deepEqual( result, {'h-event': 1,'h-card': 2} );
});
it('count rels', function(){
var doc,
node,
result;
var html = '<link href="http://glennjones.net/notes/atom" rel="notes alternate" title="Notes" type="application/atom+xml" /><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>';
var html = '<link href="http://glennjones.net/notes/atom" rel="notes alternate" title="Notes" type="application/atom+xml" /><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = html;
doc.body.appendChild(node);
doc.body.appendChild(node);
options ={
'node': node,
};
result = Microformats.count(options);
assert.deepEqual( result, {'h-event': 1,'h-card': 2, 'rels': 1} );
});
it('count - no results', function(){
var doc,
node,
result;
var html = '<span class="p-name">Jane</span>';
var html = '<span class="p-name">Jane</span>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = html;
doc.body.appendChild(node);
doc.body.appendChild(node);
options ={
'node': node,
};
result = Microformats.count(options);
assert.deepEqual( result, {} );
});
it('count - no options', function(){
var result;
result = Microformats.count({});
assert.deepEqual( result, {} );
});
it('count - options.html', function(){
var options = {},
result;
options.html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>';
options.html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a><a class="h-card" href="http://janedoe.net"><span class="p-name">Jane</span></a><a class="h-event" href="http://janedoe.net"><span class="p-name">Event</span><span class="dt-start">2015-07-01</span></a>';
result = Microformats.count(options);
assert.deepEqual( result, {'h-event': 1,'h-card': 2} );
});
});

View File

@ -8,7 +8,7 @@ assert = chai.assert;
describe('experimental', function() {
it('h-geo - geo data writen as lat;lon', function(){
var expected = {
'items': [{
'type': ['h-geo'],
@ -20,7 +20,7 @@ describe('experimental', function() {
}],
'rels': {},
'rel-urls': {}
},
},
options = {
'html': '<div class="h-geo">30.267991;-97.739568</div>',
'baseUrl': 'http://example.com',
@ -30,8 +30,8 @@ describe('experimental', function() {
var result = Microformats.get(options);
assert.deepEqual( result, expected );
});
});

View File

@ -6,7 +6,7 @@ assert = chai.assert;
describe('Microformat.getParent', function() {
var HTML = '<div class="h-event"><span class="p-name">Pub</span><span class="dt-start">2015-07-01t17:30z</span></div>';
var emptyExpected = {
"items": [],
@ -33,93 +33,93 @@ describe('Microformat.getParent', function() {
"rel-urls": {}
};
var options = {'dateFormat': 'html5'};
it('getParent with parent', function(){
var doc,
node,
span,
result;
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = HTML;
doc.body.appendChild(node);
span = doc.querySelector('.dt-start');
span = doc.querySelector('.dt-start');
result = Microformats.getParent(span,options);
assert.deepEqual( result, expected );
});
it('getParent without parent', function(){
var doc,
node,
parser,
result;
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = HTML;
doc.body.appendChild(node);
result = Microformats.getParent(node,options);
assert.deepEqual( result, emptyExpected );
});
it('getParent found with option.filters', function(){
var doc,
node,
span,
result;
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = HTML;
doc.body.appendChild(node);
span = doc.querySelector('.dt-start');
span = doc.querySelector('.dt-start');
result = Microformats.getParent( span, {'filters': ['h-event'], 'dateFormat': 'html5'} );
assert.deepEqual( result, expected );
});
it('getParent not found with option.filters', function(){
var doc,
node,
span,
result;
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = HTML;
doc.body.appendChild(node);
span = doc.querySelector('.dt-start');
span = doc.querySelector('.dt-start');
result = Microformats.getParent( span, {'filters': ['h-card'], 'dateFormat': 'html5'} );
assert.deepEqual( result, emptyExpected );
});
it('getParent use option.filters to up through h-*', function(){
var doc,
node,
span,
result;
var altHTML = '<div class="h-entry"><h1 class="p-name">test</h1><div class="e-content">this</div><a class="p-author h-card" href="http://glennjones.net"><span class="p-name">Glenn Jones</span></a><span class="dt-publish">2015-07-01t17:30z</span></div>';
var altExpected = {
"items": [
@ -162,27 +162,27 @@ describe('Microformat.getParent', function() {
"rels": {},
"rel-urls": {}
};
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = altHTML;
doc.body.appendChild(node);
span = doc.querySelector('.h-card .p-name');
span = doc.querySelector('.h-card .p-name');
result = Microformats.getParent( span, {'filters': ['h-entry'], 'dateFormat': 'html5'} );
assert.deepEqual( result, altExpected );
});
it('getParent stop at first h-* parent', function(){
var doc,
node,
span,
result;
var altHTML = '<div class="h-entry"><h1 class="p-name">test</h1><div class="e-content">this</div><a class="p-author h-card" href="http://glennjones.net"><span class="p-name">Glenn Jones</span></a><span class="dt-publish">2015-07-01t17:30z</span></div>';
var altExpected = {
"items": [
@ -198,23 +198,23 @@ describe('Microformat.getParent', function() {
"http://glennjones.net"
]
}
}
}
],
"rels": {},
"rel-urls": {}
};
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
node.innerHTML = altHTML;
doc.body.appendChild(node);
span = doc.querySelector('.h-card .p-name');
span = doc.querySelector('.h-card .p-name');
result = Microformats.getParent( span, options );
assert.deepEqual( result, altExpected );
});
});

View File

@ -6,180 +6,180 @@ assert = chai.assert;
describe('Microformat.hasMicroformats', function() {
it('true - v2 on node', function(){
var doc,
node;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.hasMicroformats( node ) );
});
it('true - v1 on node', function(){
var doc,
node;
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.hasMicroformats( node ) );
});
it('true - v2 filter on node', function(){
var doc,
node;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.hasMicroformats( node, {'filters': ['h-card']} ) );
});
it('true - v1 filter on node', function(){
var doc,
node;
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.hasMicroformats( node, {'filters': ['h-card']} ) );
});
it('false - v2 filter on node', function(){
var doc,
node;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isFalse( Microformats.hasMicroformats( node, {'filters': ['h-entry']} ) );
});
it('false - property', function(){
var doc,
node,
parser;
var html = '<span class="p-name">Glenn</span>';
var html = '<span class="p-name">Glenn</span>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'span' );
node = doc.querySelector( 'span' );
assert.isFalse( Microformats.hasMicroformats( node ) );
});
it('false - no class', function(){
var doc,
node,
parser;
var html = '<span>Glenn</span>';
var html = '<span>Glenn</span>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'span' );
node = doc.querySelector( 'span' );
assert.isFalse( Microformats.hasMicroformats( node ) );
});
it('false - no node', function(){
assert.isFalse( Microformats.hasMicroformats( ) );
});
it('false - undefined node', function(){
assert.isFalse( Microformats.hasMicroformats( undefined ) );
});
it('true - child', function(){
var doc,
node;
var html = '<section><div><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a></div></section>';
var html = '<section><div><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a></div></section>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
assert.isTrue( Microformats.hasMicroformats( node ) );
});
it('true - document', function(){
var doc,
node;
var html = '<html><head></head><body><section><div><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a></div></section></body></html>';
var html = '<html><head></head><body><section><div><a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a></div></section></body></html>';
var dom = new DOMParser();
doc = dom.parseFromString( html, 'text/html' );
assert.isTrue( Microformats.hasMicroformats( doc ) );
});
});

View File

@ -6,141 +6,141 @@ assert = chai.assert;
describe('Microformat.isMicroformat', function() {
it('true - v2', function(){
var doc,
node;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.isMicroformat( node ) );
});
it('true - v1', function(){
var doc,
node;
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.isMicroformat( node ) );
});
it('true - v2 filter', function(){
var doc,
node;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.isMicroformat( node, {'filters': ['h-card']} ) );
});
it('true - v1 filter', function(){
var doc,
node;
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
var html = '<a class="vcard" href="http://glennjones.net"><span class="fn">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isTrue( Microformats.isMicroformat( node, {'filters': ['h-card']} ) );
});
it('false - v2 filter', function(){
var doc,
node;
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
var html = '<a class="h-card" href="http://glennjones.net"><span class="p-name">Glenn</span></a>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'a' );
node = doc.querySelector( 'a' );
assert.isFalse( Microformats.isMicroformat( node, {'filters': ['h-entry']} ) );
});
it('false - property', function(){
var doc,
node;
var html = '<span class="p-name">Glenn</span>';
var html = '<span class="p-name">Glenn</span>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'span' );
node = doc.querySelector( 'span' );
assert.isFalse( Microformats.isMicroformat( node ) );
});
it('false - no class', function(){
var doc,
node;
var html = '<span>Glenn</span>';
var html = '<span>Glenn</span>';
doc = document.implementation.createHTMLDocument('New Document');
node = document.createElement('div');
doc.body.appendChild( node );
node.innerHTML = html;
node = doc.querySelector( 'span' );
node = doc.querySelector( 'span' );
assert.isFalse( Microformats.isMicroformat( node ) );
});
it('false - no node', function(){
assert.isFalse( Microformats.isMicroformat( ) );
});
it('false - undefined node', function(){
assert.isFalse( Microformats.isMicroformat( undefined ) );
});
});

View File

@ -2,7 +2,7 @@
dates
These functions are based on microformats implied rules for parsing date fragments from text.
They are not generalist date utilities and should only be used with the isodate.js module of this library.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies utilities.js, isodate.js
@ -10,10 +10,10 @@
var Modules = (function (modules) {
modules.dates = {
/**
* does text contain am
*
@ -24,8 +24,8 @@ var Modules = (function (modules) {
text = text.toLowerCase();
return(text.indexOf('am') > -1 || text.indexOf('a.m.') > -1);
},
/**
* does text contain pm
*
@ -36,8 +36,8 @@ var Modules = (function (modules) {
text = text.toLowerCase();
return(text.indexOf('pm') > -1 || text.indexOf('p.m.') > -1);
},
/**
* remove am and pm from text and return it
*
@ -47,8 +47,8 @@ var Modules = (function (modules) {
removeAMPM: function( text ) {
return text.replace('pm', '').replace('p.m.', '').replace('am', '').replace('a.m.', '');
},
/**
* simple test of whether ISO date string is a duration i.e. PY17M or PW12
*
@ -64,15 +64,15 @@ var Modules = (function (modules) {
}
return false;
},
/**
* is text a time or timezone
* i.e. HH-MM-SS or z+-HH-MM-SS 08:43 | 15:23:00:0567 | 10:34pm | 10:34 p.m. | +01:00:00 | -02:00 | z15:00 | 0843
*
* @param {String} text
* @return {Boolean}
*/
*/
isTime: function( text ) {
if(modules.utils.isString(text)){
text = text.toLowerCase();
@ -82,7 +82,7 @@ var Modules = (function (modules) {
return true;
}
// has ante meridiem or post meridiem
if( text.match(/^[0-9]/) &&
if( text.match(/^[0-9]/) &&
( this.hasAM(text) || this.hasPM(text) )) {
return true;
}
@ -90,7 +90,7 @@ var Modules = (function (modules) {
if( text.match(':') && !text.match(/t|\s/) ) {
return true;
}
// if it's a number of 2, 4 or 6 chars
if(modules.utils.isNumber(text)){
if(text.length === 2 || text.length === 4 || text.length === 6){
@ -100,7 +100,7 @@ var Modules = (function (modules) {
}
return false;
},
/**
* parses a time from text and returns 24hr time string
@ -108,18 +108,18 @@ var Modules = (function (modules) {
*
* @param {String} text
* @return {String}
*/
*/
parseAmPmTime: function( text ) {
var out = text,
times = [];
// if the string has a text : or am or pm
if(modules.utils.isString(out)) {
//text = text.toLowerCase();
text = text.replace(/[ ]+/g, '');
if(text.match(':') || this.hasAM(text) || this.hasPM(text)) {
if(text.match(':')) {
times = text.split(':');
} else {
@ -127,31 +127,31 @@ var Modules = (function (modules) {
times[0] = text;
times[0] = this.removeAMPM(times[0]);
}
// change pm hours to 24hr number
if(this.hasPM(text)) {
if(times[0] < 12) {
times[0] = parseInt(times[0], 10) + 12;
}
}
// add leading zero's where needed
if(times[0] && times[0].length === 1) {
times[0] = '0' + times[0];
}
// rejoin text elements together
if(times[0]) {
text = times.join(':');
}
}
}
// remove am/pm strings
return this.removeAMPM(text);
},
/**
* overlays a time on a date to return the union of the two
*
@ -159,11 +159,11 @@ var Modules = (function (modules) {
* @param {String} time
* @param {String} format ( Modules.ISODate profile format )
* @return {Object} Modules.ISODate
*/
*/
dateTimeUnion: function(date, time, format) {
var isodate = new modules.ISODate(date, format),
isotime = new modules.ISODate();
isotime.parseTime(this.parseAmPmTime(time), format);
if(isodate.hasFullDate() && isotime.hasTime()) {
isodate.tH = isotime.tH;
@ -178,8 +178,8 @@ var Modules = (function (modules) {
return new modules.ISODate();
}
},
/**
* concatenate an array of date and time text fragments to create an ISODate object
* used for microformat value and value-title rules
@ -187,65 +187,65 @@ var Modules = (function (modules) {
* @param {Array} arr ( Array of Strings )
* @param {String} format ( Modules.ISODate profile format )
* @return {Object} Modules.ISODate
*/
*/
concatFragments: function (arr, format) {
var out = new modules.ISODate(),
i = 0,
value = '';
// if the fragment already contains a full date just return it once
// if the fragment already contains a full date just return it once
if(arr[0].toUpperCase().match('T')) {
return new modules.ISODate(arr[0], format);
}else{
for(i = 0; i < arr.length; i++) {
value = arr[i];
// date pattern
if( value.charAt(4) === '-' && out.hasFullDate() === false ){
out.parseDate(value);
}
// time pattern
if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) {
// split time and timezone
var items = this.splitTimeAndZone(value);
value = items[0];
// parse any use of am/pm
value = this.parseAmPmTime(value);
out.parseTime(value);
// parse any timezone
// parse any timezone
if(items.length > 1){
out.parseTimeZone(items[1], format);
}
}
// timezone pattern
if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') {
if( out.hasTimeZone() === false ){
out.parseTimeZone(value);
}
}
}
return out;
}
},
/**
* parses text by splitting it into an array of time and timezone strings
*
* @param {String} text
* @return {Array} Modules.ISODate
*/
*/
splitTimeAndZone: function ( text ){
var out = [text],
chars = ['-','+','z','Z'],
i = chars.length;
while (i--) {
if(text.indexOf(chars[i]) > -1){
out[0] = text.slice( 0, text.indexOf(chars[i]) );
@ -255,7 +255,7 @@ var Modules = (function (modules) {
}
return out;
}
};

View File

@ -1,9 +1,9 @@
/*
html
Extracts a HTML string from DOM nodes. Was created to get around the issue of not being able to exclude the content
of nodes with the 'data-include' attribute. DO NOT replace with functions such as innerHTML as it will break a
html
Extracts a HTML string from DOM nodes. Was created to get around the issue of not being able to exclude the content
of nodes with the 'data-include' attribute. DO NOT replace with functions such as innerHTML as it will break a
number of microformat include patterns.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-node/master/license.txt
Dependencies utilities.js, domutils.js
@ -11,23 +11,23 @@
var Modules = (function (modules) {
modules.html = {
// elements which are self-closing
selfClosingElt: ['area', 'base', 'br', 'col', 'hr', 'img', 'input', 'link', 'meta', 'param', 'command', 'keygen', 'source'],
/**
* parse the html string from DOM Node
*
* @param {DOM Node} node
* @return {String}
*/
*/
parse: function( node ){
var out = '',
j = 0;
// we do not want the outer container
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
@ -37,47 +37,47 @@ var Modules = (function (modules) {
}
}
}
return out;
},
/**
* walks the DOM tree parsing the html string from the nodes
*
* @param {DOM Document} doc
* @param {DOM Node} node
* @return {String}
*/
*/
walkTreeForHtml: function( node ) {
var out = '',
j = 0;
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
out += modules.domUtils.getElementText( node );
out += modules.domUtils.getElementText( node );
}
// exclude text which has been added with include pattern -
// exclude text which has been added with include pattern -
if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){
// begin tag
out += '<' + node.tagName.toLowerCase();
out += '<' + node.tagName.toLowerCase();
// add attributes
var attrs = modules.domUtils.getOrderedAttributes(node);
for (j = 0; j < attrs.length; j++) {
out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"';
}
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){
out += '>';
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
@ -85,21 +85,21 @@ var Modules = (function (modules) {
}
}
}
// end tag
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){
out += ' />';
out += ' />';
}else{
out += '</' + node.tagName.toLowerCase() + '>';
out += '</' + node.tagName.toLowerCase() + '>';
}
}
}
return (out === '')? undefined : out;
}
}
};
return modules;

View File

@ -1,20 +1,20 @@
/*!
iso date
This module was built for the exact needs of parsing ISO dates to the microformats standard.
* Parses and builds ISO dates to the W3C note, HTML5 or RFC3339 profiles.
* Also allows for profile detection using 'auto'
* Parses and builds ISO dates to the W3C note, HTML5 or RFC3339 profiles.
* Also allows for profile detection using 'auto'
* Outputs to the same level of specificity of date and time that was input
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
/**
* constructor
* parses text to find just the date element of an ISO date/time string i.e. 2008-05-01
@ -22,75 +22,75 @@ var Modules = (function (modules) {
* @param {String} dateString
* @param {String} format
* @return {String}
*/
*/
modules.ISODate = function ( dateString, format ) {
this.clear();
this.format = (format)? format : 'auto'; // auto or W3C or RFC3339 or HTML5
this.setFormatSep();
// optional should be full iso date/time string
// optional should be full iso date/time string
if(arguments[0]) {
this.parse(dateString, format);
}
};
modules.ISODate.prototype = {
/**
* clear all states
*
*/
*/
clear: function(){
this.clearDate();
this.clearTime();
this.clearTimeZone();
this.setAutoProfileState();
},
/**
* clear date states
*
*/
*/
clearDate: function(){
this.dY = -1;
this.dM = -1;
this.dD = -1;
this.dDDD = -1;
},
/**
* clear time states
*
*/
*/
clearTime: function(){
this.tH = -1;
this.tM = -1;
this.tS = -1;
this.tD = -1;
},
/**
* clear timezone states
*
*/
*/
clearTimeZone: function(){
this.tzH = -1;
this.tzM = -1;
this.tzPN = '+';
this.z = false;
},
/**
* resets the auto profile state
*
*/
*/
setAutoProfileState: function(){
this.autoProfile = {
sep: 'T',
@ -100,31 +100,31 @@ var Modules = (function (modules) {
tzZulu: 'Z'
};
},
/**
* parses text to find ISO date/time string i.e. 2008-05-01T15:45:19Z
*
* @param {String} dateString
* @param {String} format
* @return {String}
*/
*/
parse: function( dateString, format ) {
this.clear();
var parts = [],
tzArray = [],
position = 0,
datePart = '',
timePart = '',
timeZonePart = '';
if(format){
this.format = format;
}
// discover date time separtor for auto profile
// Set to 'T' by default
if(dateString.indexOf('t') > -1) {
@ -138,47 +138,47 @@ var Modules = (function (modules) {
}
if(dateString.toUpperCase().indexOf('T') === -1) {
this.autoProfile.sep = ' ';
}
}
dateString = dateString.toUpperCase().replace(' ','T');
// break on 'T' divider or space
if(dateString.indexOf('T') > -1) {
parts = dateString.split('T');
datePart = parts[0];
timePart = parts[1];
// zulu UTC
// zulu UTC
if(timePart.indexOf( 'Z' ) > -1) {
this.z = true;
}
// timezone
if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
tzArray = timePart.split( 'Z' ); // incase of incorrect use of Z
timePart = tzArray[0];
timeZonePart = tzArray[1];
// timezone
if(timePart.indexOf( '+' ) > -1 || timePart.indexOf( '-' ) > -1) {
position = 0;
if(timePart.indexOf( '+' ) > -1) {
position = timePart.indexOf( '+' );
} else {
position = timePart.indexOf( '-' );
}
timeZonePart = timePart.substring( position, timePart.length );
timePart = timePart.substring( 0, position );
}
}
} else {
datePart = dateString;
}
if(datePart !== '') {
this.parseDate( datePart );
if(timePart !== '') {
@ -190,25 +190,25 @@ var Modules = (function (modules) {
}
return this.toString( format );
},
/**
* parses text to find just the date element of an ISO date/time string i.e. 2008-05-01
*
* @param {String} dateString
* @param {String} format
* @return {String}
*/
*/
parseDate: function( dateString, format ) {
this.clearDate();
var parts = [];
// discover timezone separtor for auto profile // default is ':'
if(dateString.indexOf('-') === -1) {
this.autoProfile.tsep = '';
}
}
// YYYY-DDD
parts = dateString.match( /(\d\d\d\d)-(\d\d\d)/ );
if(parts) {
@ -219,7 +219,7 @@ var Modules = (function (modules) {
this.dDDD = parts[2];
}
}
if(this.dDDD === -1) {
// YYYY-MM-DD ie 2008-05-01 and YYYYMMDD ie 20080501
parts = dateString.match( /(\d\d\d\d)?-?(\d\d)?-?(\d\d)?/ );
@ -235,24 +235,24 @@ var Modules = (function (modules) {
}
return this.toString(format);
},
/**
* parses text to find just the time element of an ISO date/time string i.e. 13:30:45
*
* @param {String} timeString
* @param {String} format
* @return {String}
*/
*/
parseTime: function( timeString, format ) {
this.clearTime();
var parts = [];
// discover date separtor for auto profile // default is ':'
if(timeString.indexOf(':') === -1) {
this.autoProfile.tsep = '';
}
}
// finds timezone HH:MM:SS and HHMMSS ie 13:30:45, 133045 and 13:30:45.0135
parts = timeString.match( /(\d\d)?:?(\d\d)?:?(\d\d)?.?([0-9]+)?/ );
if(parts[1]) {
@ -269,30 +269,30 @@ var Modules = (function (modules) {
}
return this.toTimeString(format);
},
/**
* parses text to find just the time element of an ISO date/time string i.e. +08:00
*
* @param {String} timeString
* @param {String} format
* @return {String}
*/
*/
parseTimeZone: function( timeString, format ) {
this.clearTimeZone();
var parts = [];
if(timeString.toLowerCase() === 'z'){
this.z = true;
// set case for z
this.autoProfile.tzZulu = (timeString === 'z')? 'z' : 'Z';
}else{
// discover timezone separtor for auto profile // default is ':'
if(timeString.indexOf(':') === -1) {
this.autoProfile.tzsep = '';
}
}
// finds timezone +HH:MM and +HHMM ie +13:30 and +1330
parts = timeString.match( /([\-\+]{1})?(\d\d)?:?(\d\d)?/ );
if(parts[1]) {
@ -303,29 +303,29 @@ var Modules = (function (modules) {
}
if(parts[3]) {
this.tzM = parts[3];
}
}
}
this.tzZulu = 'z';
this.tzZulu = 'z';
return this.toTimeString( format );
},
/**
* returns ISO date/time string in W3C Note, RFC 3339, HTML5, or auto profile
*
* @param {String} format
* @return {String}
*/
*/
toString: function( format ) {
var output = '';
if(format){
this.format = format;
}
this.setFormatSep();
if(this.dY > -1) {
output = this.dY;
if(this.dM > 0 && this.dM < 13) {
@ -343,26 +343,26 @@ var Modules = (function (modules) {
} else if(this.tH > -1) {
output += this.toTimeString( format );
}
return output;
},
/**
* returns just the time string element of an ISO date/time
* in W3C Note, RFC 3339, HTML5, or auto profile
*
* @param {String} format
* @return {String}
*/
*/
toTimeString: function( format ) {
var out = '';
if(format){
this.format = format;
}
this.setFormatSep();
// time can only be created with a full date
if(this.tH) {
if(this.tH > -1 && this.tH < 25) {
@ -376,10 +376,10 @@ var Modules = (function (modules) {
}
}
}
// time zone offset
// time zone offset
if(this.z) {
out += this.tzZulu;
} else {
@ -394,12 +394,12 @@ var Modules = (function (modules) {
}
return out;
},
/**
* set the current profile to W3C Note, RFC 3339, HTML5, or auto profile
*
*/
*/
setFormatSep: function() {
switch( this.format.toLowerCase() ) {
case 'rfc3339':
@ -432,48 +432,48 @@ var Modules = (function (modules) {
this.tzZulu = this.autoProfile.tzZulu;
}
},
/**
* does current data contain a full date i.e. 2015-03-23
*
* @return {Boolean}
*/
*/
hasFullDate: function() {
return(this.dY !== -1 && this.dM !== -1 && this.dD !== -1);
},
/**
* does current data contain a minimum date which is just a year number i.e. 2015
*
* @return {Boolean}
*/
*/
hasDate: function() {
return(this.dY !== -1);
},
/**
* does current data contain a minimum time which is just a hour number i.e. 13
*
* @return {Boolean}
*/
*/
hasTime: function() {
return(this.tH !== -1);
},
/**
* does current data contain a minimum timezone i.e. -1 || +1 || z
*
* @return {Boolean}
*/
*/
hasTimeZone: function() {
return(this.tzH !== -1);
}
};
modules.ISODate.prototype.constructor = modules.ISODate;
return modules;

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-adr'] = {

View File

@ -1,9 +1,9 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-card'] = {
@ -32,7 +32,7 @@ var Modules = (function (modules) {
'map': 'u-email'
},
'geo': {
'map': 'p-geo',
'map': 'p-geo',
'uf': ['h-geo']
},
'key': {
@ -82,4 +82,4 @@ var Modules = (function (modules) {
return modules;
} (Modules || {}));

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-entry'] = {
@ -26,7 +26,7 @@ var Modules = (function (modules) {
'updated': {
'map': 'dt-updated'
},
'author': {
'author': {
'uf': ['h-card']
},
'category': {
@ -34,7 +34,7 @@ var Modules = (function (modules) {
'relAlt': ['tag']
},
'geo': {
'map': 'p-geo',
'map': 'p-geo',
'uf': ['h-geo']
},
'latitude': {},
@ -47,6 +47,6 @@ var Modules = (function (modules) {
};
return modules;
} (Modules || {}));

View File

@ -1,13 +1,13 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-event'] = {
modules.maps['h-event'] = {
root: 'vevent',
name: 'h-event',
properties: {
@ -53,7 +53,7 @@ var Modules = (function (modules) {
'map': 'u-attach'
},
'status': {},
'rdate': {},
'rdate': {},
'rrule': {}
}
};

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-feed'] = {
@ -18,7 +18,7 @@ var Modules = (function (modules) {
'summary': {
'map': 'p-summary'
},
'author': {
'author': {
'uf': ['h-card']
},
'url': {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-geo'] = {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-item'] = {
@ -27,4 +27,4 @@ var Modules = (function (modules) {
return modules;
} (Modules || {}));

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-listing'] = {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-news'] = {
@ -29,7 +29,7 @@ var Modules = (function (modules) {
'map': 'u-item-license'
},
'principles': {
'map': 'u-principles',
'map': 'u-principles',
'relAlt': ['principles']
}
}

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-org'] = {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-product'] = {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-recipe'] = {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-resume'] = {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-review-aggregate'] = {
@ -21,7 +21,7 @@ var Modules = (function (modules) {
'rating': {},
'average': {},
'best': {},
'worst': {},
'worst': {},
'count': {},
'votes': {},
'category': {

View File

@ -1,10 +1,10 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.maps = (modules.maps)? modules.maps : {};
modules.maps['h-review'] = {

View File

@ -1,32 +1,32 @@
/*
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.rels = {
// xfn
'friend': [ 'yes','external'],
'acquaintance': [ 'yes','external'],
'contact': [ 'yes','external'],
'met': [ 'yes','external'],
'co-worker': [ 'yes','external'],
'colleague': [ 'yes','external'],
'co-resident': [ 'yes','external'],
'neighbor': [ 'yes','external'],
'child': [ 'yes','external'],
'parent': [ 'yes','external'],
'sibling': [ 'yes','external'],
'spouse': [ 'yes','external'],
'kin': [ 'yes','external'],
'muse': [ 'yes','external'],
'crush': [ 'yes','external'],
'date': [ 'yes','external'],
'sweetheart': [ 'yes','external'],
'me': [ 'yes','external'],
// other rel=*
'friend': [ 'yes','external'],
'acquaintance': [ 'yes','external'],
'contact': [ 'yes','external'],
'met': [ 'yes','external'],
'co-worker': [ 'yes','external'],
'colleague': [ 'yes','external'],
'co-resident': [ 'yes','external'],
'neighbor': [ 'yes','external'],
'child': [ 'yes','external'],
'parent': [ 'yes','external'],
'sibling': [ 'yes','external'],
'spouse': [ 'yes','external'],
'kin': [ 'yes','external'],
'muse': [ 'yes','external'],
'crush': [ 'yes','external'],
'date': [ 'yes','external'],
'sweetheart': [ 'yes','external'],
'me': [ 'yes','external'],
// other rel=*
'license': [ 'yes','yes'],
'nofollow': [ 'no','external'],
'tag': [ 'no','yes'],
@ -39,9 +39,9 @@ var Modules = (function (modules) {
'pronunciation': [ 'no','external'],
'payment': [ 'no','external'],
'principles': [ 'no','external']
};
return modules;
} (Modules || {}));

View File

@ -1,19 +1,19 @@
/*!
Parser implied
All the functions that deal with microformats implied rules
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies dates.js, domutils.js, html.js, isodate,js, text.js, utilities.js, url.js
*/
var Modules = (function (modules) {
// check parser module is loaded
if(modules.Parser){
/**
* applies "implied rules" microformat output structure i.e. feed-title, name, photo, url and date
* applies "implied rules" microformat output structure i.e. feed-title, name, photo, url and date
*
* @param {DOM Node} node
* @param {Object} uf (microformat output structure)
@ -23,40 +23,40 @@ var Modules = (function (modules) {
*/
modules.Parser.prototype.impliedRules = function(node, uf, parentClasses) {
var typeVersion = (uf.typeVersion)? uf.typeVersion: 'v2';
// TEMP: override to allow v1 implied properties while spec changes
if(this.options.impliedPropertiesByVersion === false){
typeVersion = 'v2';
}
if(node && uf && uf.properties) {
uf = this.impliedBackwardComp( node, uf, parentClasses );
uf = this.impliedBackwardComp( node, uf, parentClasses );
if(typeVersion === 'v2'){
uf = this.impliedhFeedTitle( uf );
uf = this.impliedName( node, uf );
uf = this.impliedPhoto( node, uf );
uf = this.impliedName( node, uf );
uf = this.impliedPhoto( node, uf );
uf = this.impliedUrl( node, uf );
}
uf = this.impliedValue( node, uf, parentClasses );
uf = this.impliedDate( uf );
// TEMP: flagged while spec changes are put forward
if(this.options.parseLatLonGeo === true){
uf = this.impliedGeo( uf );
}
}
}
return uf;
};
/**
* apply implied name rule
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedName = function(node, uf) {
// implied name rule
/*
@ -74,7 +74,7 @@ var Modules = (function (modules) {
*/
var name,
value;
if(!uf.properties.name) {
value = this.getImpliedProperty(node, ['img', 'area', 'abbr'], this.getNameAttr);
var textFormat = this.options.textFormat;
@ -88,27 +88,27 @@ var Modules = (function (modules) {
uf.properties.name = name;
}
}
return uf;
};
/**
* apply implied photo rule
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedPhoto = function(node, uf) {
// implied photo rule
/*
img.h-x[src] <img class="h-card" alt="Jane Doe" src="jane.jpeg"/>
object.h-x[data] <object class="h-card" data="jane.jpeg"/>Jane Doe</object>
.h-x>img[src]:only-of-type:not[.h-*] <div class="h-card"><img alt="Jane Doe" src="jane.jpeg"/></div>
.h-x>object[data]:only-of-type:not[.h-*] <div class="h-card"><object data="jane.jpeg"/>Jane Doe</object></div>
.h-x>:only-child>img[src]:only-of-type:not[.h-*] <div class="h-card"><span><img alt="Jane Doe" src="jane.jpeg"/></span></div>
.h-x>:only-child>object[data]:only-of-type:not[.h-*] <div class="h-card"><span><object data="jane.jpeg"/>Jane Doe</object></span></div>
.h-x>img[src]:only-of-type:not[.h-*] <div class="h-card"><img alt="Jane Doe" src="jane.jpeg"/></div>
.h-x>object[data]:only-of-type:not[.h-*] <div class="h-card"><object data="jane.jpeg"/>Jane Doe</object></div>
.h-x>:only-child>img[src]:only-of-type:not[.h-*] <div class="h-card"><span><img alt="Jane Doe" src="jane.jpeg"/></span></div>
.h-x>:only-child>object[data]:only-of-type:not[.h-*] <div class="h-card"><span><object data="jane.jpeg"/>Jane Doe</object></span></div>
*/
var value;
if(!uf.properties.photo) {
@ -120,24 +120,24 @@ var Modules = (function (modules) {
}
uf.properties.photo = [modules.utils.trim(value)];
}
}
}
return uf;
};
/**
* apply implied URL rule
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedUrl = function(node, uf) {
// implied URL rule
/*
a.h-x[href] <a class="h-card" href="glenn.html">Glenn</a>
area.h-x[href] <area class="h-card" href="glenn.html">Glenn</area>
.h-x>a[href]:only-of-type:not[.h-*] <div class="h-card" ><a href="glenn.html">Glenn</a><p>...</p></div>
.h-x>a[href]:only-of-type:not[.h-*] <div class="h-card" ><a href="glenn.html">Glenn</a><p>...</p></div>
.h-x>area[href]:only-of-type:not[.h-*] <div class="h-card" ><area href="glenn.html">Glenn</area><p>...</p></div>
*/
var value;
@ -150,18 +150,18 @@ var Modules = (function (modules) {
}
uf.properties.url = [modules.utils.trim(value)];
}
}
}
return uf;
};
/**
* apply implied date rule - if there is a time only property try to concat it with any date property
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedDate = function(uf) {
// implied date rule
// http://microformats.org/wiki/value-class-pattern#microformats2_parsers
@ -176,8 +176,8 @@ var Modules = (function (modules) {
delete uf.dates;
return uf;
};
/**
* get an implied property value from pre-defined tag/attriubte combinations
*
@ -188,10 +188,10 @@ var Modules = (function (modules) {
*/
modules.Parser.prototype.getImpliedProperty = function(node, tagList, getAttrFunction) {
// i.e. img.h-card
var value = getAttrFunction(node),
var value = getAttrFunction(node),
descendant,
child;
if(!value) {
// i.e. .h-card>img:only-of-type:not(.h-card)
descendant = modules.domUtils.getSingleDescendantOfType( node, tagList);
@ -209,17 +209,17 @@ var Modules = (function (modules) {
}
}
}
return value;
};
/**
* get an implied name value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
*/
modules.Parser.prototype.getNameAttr = function(node) {
var value = modules.domUtils.getAttrValFromTagList(node, ['img','area'], 'alt');
if(!value) {
@ -227,14 +227,14 @@ var Modules = (function (modules) {
}
return value;
};
/**
* get an implied photo value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
*/
modules.Parser.prototype.getPhotoAttr = function(node) {
var value = modules.domUtils.getAttrValFromTagList(node, ['img'], 'src');
if(!value && modules.domUtils.hasAttributeValue(node, 'class', 'include') === false) {
@ -242,62 +242,62 @@ var Modules = (function (modules) {
}
return value;
};
/**
* get an implied photo value from a node
*
* @param {DOM Node} node
* @return {String || null}
*/
*/
modules.Parser.prototype.getURLAttr = function(node) {
var value = null;
if(modules.domUtils.hasAttributeValue(node, 'class', 'include') === false){
value = modules.domUtils.getAttrValFromTagList(node, ['a'], 'href');
if(!value) {
value = modules.domUtils.getAttrValFromTagList(node, ['area'], 'href');
}
}
return value;
};
/**
*
*
*
* @param {DOM Node} node
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedValue = function(node, uf, parentClasses){
// intersection of implied name and implied value rules
if(uf.properties.name) {
if(uf.properties.name) {
if(uf.value && parentClasses.root.length > 0 && parentClasses.properties.length === 1){
uf = this.getAltValue(uf, parentClasses.properties[0][0], 'p-name', uf.properties.name[0]);
}
}
// intersection of implied URL and implied value rules
if(uf.properties.url) {
if(parentClasses && parentClasses.root.length === 1 && parentClasses.properties.length === 1){
uf = this.getAltValue(uf, parentClasses.properties[0][0], 'u-url', uf.properties.url[0]);
}
}
}
// apply alt value
if(uf.altValue !== null){
uf.value = uf.altValue.value;
}
delete uf.altValue;
return uf;
};
/**
* get alt value based on rules about parent property prefix
*
@ -306,7 +306,7 @@ var Modules = (function (modules) {
* @param {String} propertyName
* @param {String} value
* @return {Object}
*/
*/
modules.Parser.prototype.getAltValue = function(uf, parentPropertyName, propertyName, value){
if(uf.value && !uf.altValue){
// first p-name of the h-* child
@ -324,14 +324,14 @@ var Modules = (function (modules) {
}
return uf;
};
/**
* if a h-feed does not have a title use the title tag of a page
*
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedhFeedTitle = function( uf ){
if(uf.type && uf.type.indexOf('h-feed') > -1){
// has no name property
@ -345,80 +345,80 @@ var Modules = (function (modules) {
}
return uf;
};
/**
* implied Geo from pattern <abbr class="p-geo" title="37.386013;-122.082932">
*
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedGeo = function( uf ){
var geoPair,
parts,
longitude,
latitude,
valid = true;
if(uf.type && uf.type.indexOf('h-geo') > -1){
// has no latitude or longitude property
if(uf.properties.latitude === undefined || uf.properties.longitude === undefined ){
geoPair = (uf.properties.name)? uf.properties.name[0] : null;
geoPair = (!geoPair && uf.properties.value)? uf.properties.value : geoPair;
if(geoPair){
// allow for the use of a ';' as in microformats and also ',' as in Geo URL
geoPair = geoPair.replace(';',',');
// has sep char
if(geoPair.indexOf(',') > -1 ){
parts = geoPair.split(',');
// only correct if we have two or more parts
if(parts.length > 1){
// latitude no value outside the range -90 or 90
// latitude no value outside the range -90 or 90
latitude = parseFloat( parts[0] );
if(modules.utils.isNumber(latitude) && latitude > 90 || latitude < -90){
valid = false;
}
// longitude no value outside the range -180 to 180
longitude = parseFloat( parts[1] );
if(modules.utils.isNumber(longitude) && longitude > 180 || longitude < -180){
valid = false;
}
if(valid){
uf.properties.latitude = [latitude];
uf.properties.longitude = [longitude];
}
}
}
}
}
}
return uf;
};
/**
* if a backwards compat built structure has no properties add name through this.impliedName
*
* @param {Object} uf
* @return {Object}
*/
*/
modules.Parser.prototype.impliedBackwardComp = function(node, uf, parentClasses){
// look for pattern in parent classes like "p-geo h-geo"
// these are structures built from backwards compat parsing of geo
if(parentClasses.root.length === 1 && parentClasses.properties.length === 1) {
if(parentClasses.root[0].replace('h-','') === this.removePropPrefix(parentClasses.properties[0][0])) {
// if microformat has no properties apply the impliedName rule to get value from containing node
// this will get value from html such as <abbr class="geo" title="30.267991;-97.739568">Brighton</abbr>
if( modules.utils.hasProperties(uf.properties) === false ){
@ -426,12 +426,12 @@ var Modules = (function (modules) {
}
}
}
return uf;
};
}
return modules;

View File

@ -1,7 +1,7 @@
/*!
Parser includes
All the functions that deal with microformats v1 include rules
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies dates.js, domutils.js, html.js, isodate,js, text.js, utilities.js
@ -9,23 +9,23 @@
var Modules = (function (modules) {
// check parser module is loaded
if(modules.Parser){
/**
* appends clones of include Nodes into the DOM structure
*
* @param {DOM node} rootNode
*/
*/
modules.Parser.prototype.addIncludes = function(rootNode) {
this.addAttributeIncludes(rootNode, 'itemref');
this.addAttributeIncludes(rootNode, 'headers');
this.addClassIncludes(rootNode);
};
/**
* appends clones of include Nodes into the DOM structure for attribute based includes
*
@ -39,7 +39,7 @@ var Modules = (function (modules) {
x,
z,
y;
arr = modules.domUtils.getNodesByAttribute(rootNode, attributeName);
x = 0;
i = arr.length;
@ -56,8 +56,8 @@ var Modules = (function (modules) {
x++;
}
};
/**
* appends clones of include Nodes into the DOM structure for class based includes
*
@ -68,7 +68,7 @@ var Modules = (function (modules) {
arr,
x = 0,
i;
arr = modules.domUtils.getNodesByAttributeValue(rootNode, 'class', 'include');
i = arr.length;
while(x < i) {
@ -80,8 +80,8 @@ var Modules = (function (modules) {
x++;
}
};
/**
* appends a clone of an include into another Node using Id
*
@ -91,7 +91,7 @@ var Modules = (function (modules) {
modules.Parser.prototype.apppendInclude = function(node, id){
var include,
clone;
id = modules.utils.trim(id.replace('#', ''));
include = modules.domUtils.getElementById(this.document, id);
if(include) {
@ -100,18 +100,18 @@ var Modules = (function (modules) {
modules.domUtils.appendChild(node, clone);
}
};
/**
* adds an attribute marker to all the child microformat roots
* adds an attribute marker to all the child microformat roots
*
* @param {DOM node} rootNode
*/
*/
modules.Parser.prototype.markIncludeChildren = function(rootNode) {
var arr,
x,
i;
// loop the array and add the attribute
arr = this.findRootNodes(rootNode);
x = 0;
@ -123,17 +123,17 @@ var Modules = (function (modules) {
x++;
}
};
/**
* removes all appended include clones from DOM
* removes all appended include clones from DOM
*
* @param {DOM node} rootNode
*/
*/
modules.Parser.prototype.removeIncludes = function(rootNode){
var arr,
i;
// remove all the items that were added as includes
arr = modules.domUtils.getNodesByAttribute(rootNode, 'data-include');
i = arr.length;
@ -141,8 +141,8 @@ var Modules = (function (modules) {
modules.domUtils.removeChild(rootNode,arr[i]);
}
};
}
return modules;

View File

@ -1,7 +1,7 @@
/*!
Parser rels
All the functions that deal with microformats v2 rel structures
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies dates.js, domutils.js, html.js, isodate,js, text.js, utilities.js, url.js
@ -9,10 +9,10 @@
var Modules = (function (modules) {
// check parser module is loaded
if(modules.Parser){
/**
* finds rel=* structures
*
@ -34,36 +34,36 @@ var Modules = (function (modules) {
item,
value,
arr;
arr = modules.domUtils.getNodesByAttribute(rootNode, 'rel');
x = 0;
i = arr.length;
while(x < i) {
relList = modules.domUtils.getAttribute(arr[x], 'rel');
if(relList) {
items = relList.split(' ');
// add rels
z = 0;
y = items.length;
while(z < y) {
item = modules.utils.trim(items[z]);
// get rel value
value = modules.domUtils.getAttrValFromTagList(arr[x], ['a', 'area'], 'href');
if(!value) {
value = modules.domUtils.getAttrValFromTagList(arr[x], ['link'], 'href');
}
// create the key
if(!out.rels[item]) {
out.rels[item] = [];
}
if(typeof this.options.baseUrl === 'string' && typeof value === 'string') {
var resolved = modules.url.resolve(value, this.options.baseUrl);
// do not add duplicate rels - based on resolved URLs
if(out.rels[item].indexOf(resolved) === -1){
@ -72,8 +72,8 @@ var Modules = (function (modules) {
}
z++;
}
var url = null;
if(modules.domUtils.hasAttribute(arr[x], 'href')){
url = modules.domUtils.getAttribute(arr[x], 'href');
@ -81,8 +81,8 @@ var Modules = (function (modules) {
url = modules.url.resolve(url, this.options.baseUrl );
}
}
// add to rel-urls
var relUrl = this.getRelProperties(arr[x]);
relUrl.rels = items;
@ -90,15 +90,15 @@ var Modules = (function (modules) {
if(url && out['rel-urls'][url] === undefined){
out['rel-urls'][url] = relUrl;
}
}
x++;
}
return out;
};
/**
* gets the properties of a rel=*
*
@ -107,7 +107,7 @@ var Modules = (function (modules) {
*/
modules.Parser.prototype.getRelProperties = function(node){
var obj = {};
if(modules.domUtils.hasAttribute(node, 'media')){
obj.media = modules.domUtils.getAttribute(node, 'media');
}
@ -122,12 +122,12 @@ var Modules = (function (modules) {
}
if(modules.utils.trim(this.getPValue(node, false)) !== ''){
obj.text = this.getPValue(node, false);
}
}
return obj;
};
/**
* finds any alt rel=* mappings for a given node/microformat
*
@ -139,7 +139,7 @@ var Modules = (function (modules) {
var out,
map,
i;
map = this.getMapping(ufName);
if(map) {
for(var key in map.properties) {
@ -147,8 +147,8 @@ var Modules = (function (modules) {
var prop = map.properties[key],
propName = (prop.map) ? prop.map : 'p-' + key,
relCount = 0;
// is property an alt rel=* mapping
// is property an alt rel=* mapping
if(prop.relAlt && modules.domUtils.hasAttribute(node, 'rel')) {
i = prop.relAlt.length;
while(i--) {
@ -165,8 +165,8 @@ var Modules = (function (modules) {
}
return out;
};
/**
* returns whether a node or its children has rel=* microformat
*
@ -176,8 +176,8 @@ var Modules = (function (modules) {
modules.Parser.prototype.hasRel = function(node) {
return (this.countRels(node) > 0);
};
/**
* returns the number of rel=* microformats
*
@ -190,9 +190,9 @@ var Modules = (function (modules) {
}
return 0;
};
}
return modules;

View File

@ -1,9 +1,9 @@
/*
text
Extracts text string from DOM nodes. Was created to extract text in a whitespace-normalized form.
It works like a none-CSS aware version of IE's innerText function. DO NOT replace this module
Extracts text string from DOM nodes. Was created to extract text in a whitespace-normalized form.
It works like a none-CSS aware version of IE's innerText function. DO NOT replace this module
with functions such as textContent as it will reduce the quality of data provided to the API user.
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
Dependencies utilities.js, domutils.js
@ -11,26 +11,26 @@
var Modules = (function (modules) {
modules.text = {
// normalised or whitespace or whitespacetrimmed
textFormat: 'whitespacetrimmed',
textFormat: 'whitespacetrimmed',
// block level tags, used to add line returns
blockLevelTags: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'hr', 'pre', 'table',
'address', 'article', 'aside', 'blockquote', 'caption', 'col', 'colgroup', 'dd', 'div',
'dt', 'dir', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'header', 'hgroup', 'hr',
'li', 'map', 'menu', 'nav', 'optgroup', 'option', 'section', 'tbody', 'testarea',
'address', 'article', 'aside', 'blockquote', 'caption', 'col', 'colgroup', 'dd', 'div',
'dt', 'dir', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'header', 'hgroup', 'hr',
'li', 'map', 'menu', 'nav', 'optgroup', 'option', 'section', 'tbody', 'testarea',
'tfoot', 'th', 'thead', 'tr', 'td', 'ul', 'ol', 'dl', 'details'],
// tags to exclude
// tags to exclude
excludeTags: ['noframe', 'noscript', 'template', 'script', 'style', 'frames', 'frameset'],
/**
* parses the text from the DOM Node
* parses the text from the DOM Node
*
* @param {DOM Node} node
* @param {String} textFormat
@ -50,54 +50,54 @@ var Modules = (function (modules) {
return this.formatText( doc, modules.domUtils.textContent(node), this.textFormat );
}
},
/**
* parses the text from a html string
* parses the text from a html string
*
* @param {DOM Document} doc
* @param {String} text
* @param {String} textFormat
* @return {String}
*/
*/
parseText: function( doc, text, textFormat ){
var node = modules.domUtils.createNodeWithText( 'div', text );
return this.parse( doc, node, textFormat );
},
/**
* parses the text from a html string - only for whitespace or whitespacetrimmed formats
*
* @param {String} text
* @param {String} textFormat
* @return {String}
*/
*/
formatText: function( doc, text, textFormat ){
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(text){
var out = '',
regex = /(<([^>]+)>)/ig;
out = text.replace(regex, '');
if(this.textFormat === 'whitespacetrimmed') {
out = text.replace(regex, '');
if(this.textFormat === 'whitespacetrimmed') {
out = modules.utils.trimWhitespace( out );
}
//return entities.decode( out, 2 );
return modules.domUtils.decodeEntities( doc, out );
}else{
return '';
return '';
}
},
/**
* normalises whitespace in given text
* normalises whitespace in given text
*
* @param {String} text
* @return {String}
*/
*/
normalise: function( doc, text ){
text = text.replace( /&nbsp;/g, ' ') ; // exchanges html entity for space into space char
text = modules.utils.collapseWhiteSpace( text ); // removes linefeeds, tabs and addtional spaces
@ -105,27 +105,27 @@ var Modules = (function (modules) {
text = text.replace( '', '-' ); // correct dash decoding
return modules.utils.trim( text );
},
/**
* walks DOM tree parsing the text from DOM Nodes
*
* @param {DOM Node} node
* @return {String}
*/
*/
walkTreeForText: function( node ) {
var out = '',
j = 0;
if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1){
return out;
}
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
out += modules.domUtils.getElementText( node );
out += modules.domUtils.getElementText( node );
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
@ -135,17 +135,17 @@ var Modules = (function (modules) {
}
}
}
// if it's a block level tag add an additional space at the end
if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1){
out += ' ';
}
}
return (out === '')? undefined : out ;
}
};
return modules;
} (Modules || {}));

View File

@ -1,14 +1,14 @@
/*
Utilities
Copyright (C) 2010 - 2015 Glenn Jones. All Rights Reserved.
MIT License: https://raw.github.com/glennjones/microformat-shiv/master/license.txt
*/
var Modules = (function (modules) {
modules.utils = {
/**
* is the object a string
*
@ -18,7 +18,7 @@ var Modules = (function (modules) {
isString: function( obj ) {
return typeof( obj ) === 'string';
},
/**
* is the object a number
*
@ -28,8 +28,8 @@ var Modules = (function (modules) {
isNumber: function( obj ) {
return !isNaN(parseFloat( obj )) && isFinite( obj );
},
/**
* is the object an array
*
@ -39,8 +39,8 @@ var Modules = (function (modules) {
isArray: function( obj ) {
return obj && !( obj.propertyIsEnumerable( 'length' ) ) && typeof obj === 'object' && typeof obj.length === 'number';
},
/**
* is the object a function
*
@ -50,8 +50,8 @@ var Modules = (function (modules) {
isFunction: function(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
},
/**
* does the text start with a test string
*
@ -62,8 +62,8 @@ var Modules = (function (modules) {
startWith: function( text, test ) {
return(text.indexOf(test) === 0);
},
/**
* removes spaces at front and back of text
*
@ -77,8 +77,8 @@ var Modules = (function (modules) {
return '';
}
},
/**
* replaces a character in text
*
@ -89,13 +89,13 @@ var Modules = (function (modules) {
*/
replaceCharAt: function( text, index, character ) {
if(text && text.length > index){
return text.substr(0, index) + character + text.substr(index+character.length);
return text.substr(0, index) + character + text.substr(index+character.length);
}else{
return text;
}
},
/**
* removes whitespace, tabs and returns from start and end of text
*
@ -106,7 +106,7 @@ var Modules = (function (modules) {
if(text && text.length){
var i = text.length,
x = 0;
// turn all whitespace chars at end into spaces
while (i--) {
if(this.isOnlyWhiteSpace(text[i])){
@ -115,7 +115,7 @@ var Modules = (function (modules) {
break;
}
}
// turn all whitespace chars at start into spaces
i = text.length;
while (x < i) {
@ -129,8 +129,8 @@ var Modules = (function (modules) {
}
return this.trim(text);
},
/**
* does text only contain whitespace characters
*
@ -140,8 +140,8 @@ var Modules = (function (modules) {
isOnlyWhiteSpace: function( text ){
return !(/[^\t\n\r ]/.test( text ));
},
/**
* removes whitespace from text (leaves a single space)
*
@ -151,14 +151,14 @@ var Modules = (function (modules) {
collapseWhiteSpace: function( text ){
return text.replace(/[\t\n\r ]+/g, ' ');
},
/**
* does an object have any of its own properties
*
* @param {Object} obj
* @return {Boolean}
*/
*/
hasProperties: function( obj ) {
var key;
for(key in obj) {
@ -168,15 +168,15 @@ var Modules = (function (modules) {
}
return false;
},
/**
* a sort function - to sort objects in an array by a given property
*
* @param {String} property
* @param {Boolean} reverse
* @return {Int}
*/
*/
sortObjects: function(property, reverse) {
reverse = (reverse) ? -1 : 1;
return function (a, b) {
@ -191,9 +191,9 @@ var Modules = (function (modules) {
return 0;
};
}
};
return modules;
} (Modules || {}));

View File

@ -4,13 +4,13 @@ Unit test for dates
assert = chai.assert;
// Tests the private Modules.dates object
// Modules.dates is unit tested as it has an interface access by other modules
// Tests the private Modules.dates object
// Modules.dates is unit tested as it has an interface access by other modules
describe('Modules.dates', function() {
it('hasAM', function(){
assert.isTrue( Modules.dates.hasAM( '5am' ) );
assert.isTrue( Modules.dates.hasAM( '5AM' ) );
@ -19,8 +19,8 @@ describe('Modules.dates', function() {
assert.isTrue( Modules.dates.hasAM( '5:20 a.m.' ) );
assert.isFalse( Modules.dates.hasAM( '5pm' ) );
});
it('hasPM', function(){
assert.isTrue( Modules.dates.hasPM( '5pm' ) );
assert.isTrue( Modules.dates.hasPM( '5PM' ) );
@ -29,8 +29,8 @@ describe('Modules.dates', function() {
assert.isTrue( Modules.dates.hasPM( '5:20 p.m.' ) );
assert.isFalse( Modules.dates.hasPM( '5am' ) );
});
it('removeAMPM', function(){
assert.equal( Modules.dates.removeAMPM( '5pm' ), '5' );
assert.equal( Modules.dates.removeAMPM( '5 pm' ), '5 ' );
@ -39,8 +39,8 @@ describe('Modules.dates', function() {
assert.equal( Modules.dates.removeAMPM( '5a.m.' ), '5' );
assert.equal( Modules.dates.removeAMPM( '5' ), '5' );
});
it('isDuration', function(){
assert.isTrue( Modules.dates.isDuration( 'PY17M' ) );
assert.isTrue( Modules.dates.isDuration( 'PW12' ) );
@ -50,8 +50,8 @@ describe('Modules.dates', function() {
assert.isFalse( Modules.dates.isDuration( '2015-01-23 13:45' ) );
assert.isFalse( Modules.dates.isDuration( '20150123T1345' ) );
});
it('isTime', function(){
assert.isTrue( Modules.dates.isTime( '8:43' ) );
assert.isTrue( Modules.dates.isTime( '08:43' ) );
@ -67,10 +67,10 @@ describe('Modules.dates', function() {
assert.isFalse( Modules.dates.isTime( '2015-01-23 13:45' ) );
assert.isFalse( Modules.dates.isTime( '20150123T1345' ) );
assert.isFalse( Modules.dates.isTime( 'abc' ) );
assert.isFalse( Modules.dates.isTime( '12345' ) );
assert.isFalse( Modules.dates.isTime( '12345' ) );
});
it('parseAmPmTime', function(){
assert.equal( Modules.dates.parseAmPmTime( '5am' ), '05' );
assert.equal( Modules.dates.parseAmPmTime( '12pm' ), '12' );
@ -82,8 +82,8 @@ describe('Modules.dates', function() {
assert.equal( Modules.dates.parseAmPmTime( '05:34:00' ), '05:34:00' );
assert.equal( Modules.dates.parseAmPmTime( '1:52:04pm' ), '13:52:04' );
});
it('dateTimeUnion', function(){
assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '05:34:00', 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' );
assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '05:34', 'HTML5' ).toString('HTML5'), '2015-01-23 05:34' );
@ -93,8 +93,8 @@ describe('Modules.dates', function() {
assert.equal( Modules.dates.dateTimeUnion( '2015-01-23', '', 'HTML5' ).toString('HTML5'), '2015-01-23' );
assert.equal( Modules.dates.dateTimeUnion( '', '', 'HTML5' ).toString('HTML5'), '' );
});
it('concatFragments', function(){
assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' );
assert.equal( Modules.dates.concatFragments( ['05:34:00', '2015-01-23'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34:00' );
@ -103,11 +103,11 @@ describe('Modules.dates', function() {
assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34', '-01'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34-01' );
assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34', '-01:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34-01:00' );
assert.equal( Modules.dates.concatFragments( ['2015-01-23', '05:34-01:00'], 'HTML5' ).toString('HTML5'), '2015-01-23 05:34-01:00' );
});
});

View File

@ -5,85 +5,85 @@ Unit test for domutils
assert = chai.assert;
// Tests the private Modules.domUtils object
// Modules.domUtils is unit tested as it has an interface access by other modules
// Tests the private Modules.domUtils object
// Modules.domUtils is unit tested as it has an interface access by other modules
describe('Modules.domutils', function() {
it('ownerDocument', function(){
var node = document.createElement('div');
var node = document.createElement('div');
assert.equal( Modules.domUtils.ownerDocument( node ).nodeType, 9);
});
it('innerHTML', function(){
var html = '<a href="http://glennjones.net">Glenn Jones</a>',
node = document.createElement('div');
node.innerHTML = html;
assert.equal( Modules.domUtils.innerHTML( node ), html );
});
it('hasAttribute', function(){
var node = document.createElement('a');
node.href = 'http://glennjones.net';
assert.isTrue( Modules.domUtils.hasAttribute( node, 'href' ) );
assert.isFalse( Modules.domUtils.hasAttribute( node, 'class' ) );
});
it('hasAttributeValue', function(){
var node = document.createElement('a');
node.href = 'http://glennjones.net';
assert.isTrue( Modules.domUtils.hasAttributeValue( node, 'href', 'http://glennjones.net' ) );
assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'href', 'http://example.net' ) );
assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'class', 'test' ) );
});
it('getAttribute', function(){
var node = document.createElement('a');
node.href = 'http://glennjones.net';
assert.equal( Modules.domUtils.getAttribute( node, 'href' ), 'http://glennjones.net' );
});
it('setAttribute', function(){
var node = document.createElement('a');
Modules.domUtils.setAttribute(node, 'href', 'http://glennjones.net')
assert.equal( Modules.domUtils.getAttribute( node, 'href' ), 'http://glennjones.net' );
});
it('removeAttribute', function(){
var node = document.createElement('a');
node.href = 'http://glennjones.net';
Modules.domUtils.removeAttribute(node, 'href')
assert.isFalse( Modules.domUtils.hasAttribute( node, 'href' ) );
});
it('getAttributeList', function(){
var node = document.createElement('a');
node.rel = 'next';
assert.deepEqual( Modules.domUtils.getAttributeList( node, 'rel'), ['next'] );
node.rel = 'next bookmark';
assert.deepEqual( Modules.domUtils.getAttributeList( node, 'rel'), ['next','bookmark'] );
});
it('hasAttributeValue', function(){
var node = document.createElement('a');
node.href = 'http://glennjones.net';
node.rel = 'next bookmark';
assert.isTrue( Modules.domUtils.hasAttributeValue( node, 'href', 'http://glennjones.net' ) );
@ -92,115 +92,115 @@ describe('Modules.domutils', function() {
assert.isTrue( Modules.domUtils.hasAttributeValue( node, 'rel', 'bookmark' ) );
assert.isFalse( Modules.domUtils.hasAttributeValue( node, 'rel', 'previous' ) );
});
it('getNodesByAttribute', function(){
var node = document.createElement('ul');
node.innerHTML = '<li class="h-card">one</li><li>two</li><li class="h-card">three</li>';
assert.equal( Modules.domUtils.getNodesByAttribute( node, 'class' ).length, 2 );
assert.equal( Modules.domUtils.getNodesByAttribute( node, 'href' ).length, 0 );
});
it('getNodesByAttributeValue', function(){
var node = document.createElement('ul');
node.innerHTML = '<li class="h-card">one</li><li>two</li><li class="h-card">three</li><li class="p-name">four</li>';
assert.equal( Modules.domUtils.getNodesByAttributeValue( node, 'class', 'h-card' ).length, 2 );
assert.equal( Modules.domUtils.getNodesByAttributeValue( node, 'class', 'p-name' ).length, 1 );
assert.equal( Modules.domUtils.getNodesByAttributeValue( node, 'class', 'u-url' ).length, 0 );
});
it('getAttrValFromTagList', function(){
var node = document.createElement('a');
node.href = 'http://glennjones.net';
assert.equal( Modules.domUtils.getAttrValFromTagList( node, ['a','area'], 'href' ), 'http://glennjones.net' );
assert.equal( Modules.domUtils.getAttrValFromTagList( node, ['a','area'], 'class' ), null );
assert.equal( Modules.domUtils.getAttrValFromTagList( node, ['p'], 'href' ), null );
});
it('getSingleDescendant', function(){
var html = '<a class="u-url" href="http://glennjones.net">Glenn Jones</a>',
node = document.createElement('div');
node.innerHTML = html,
// one instance of a element
// one instance of a element
assert.equal( Modules.domUtils.getSingleDescendant( node ).outerHTML, html );
// two instances of a element
// two instances of a element
node.appendChild(document.createElement('a'));
assert.equal( Modules.domUtils.getSingleDescendant( node ), null );
});
it('getSingleDescendantOfType', function(){
var html = '<a class="u-url" href="http://glennjones.net">Glenn Jones</a>',
node = document.createElement('div');
node.innerHTML = html,
// one instance of a element
// one instance of a element
assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['a', 'link']).outerHTML, html );
assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['img','area']), null );
node.appendChild(document.createElement('p'));
assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['a', 'link']).outerHTML, html );
// two instances of a element
// two instances of a element
node.appendChild(document.createElement('a'));
assert.equal( Modules.domUtils.getSingleDescendantOfType( node, ['a', 'link']), null );
});
it('appendChild', function(){
var node = document.createElement('div'),
child = document.createElement('a');
Modules.domUtils.appendChild( node, child );
Modules.domUtils.appendChild( node, child );
assert.equal( node.innerHTML, '<a></a>' );
});
it('removeChild', function(){
var node = document.createElement('div'),
child = document.createElement('a');
node.appendChild(child)
assert.equal( node.innerHTML, '<a></a>' );
Modules.domUtils.removeChild( child );
node.appendChild(child)
assert.equal( node.innerHTML, '<a></a>' );
Modules.domUtils.removeChild( child );
assert.equal( node.innerHTML, '' );
});
it('clone', function(){
var node = document.createElement('div');
node.innerHTML = 'text content';
assert.equal( Modules.domUtils.clone( node ).outerHTML, '<div>text content</div>' );
});
it('getElementText', function(){
assert.equal( Modules.domUtils.getElementText( {} ), '' );
});
it('getNodePath', function(){
var node = document.createElement('ul');
node.innerHTML = '<div><ul><li class="h-card">one</li><li>two</li><li class="h-card">three</li><li class="p-name">four</li></ul></div>';
var child = node.querySelector('.p-name');
var child = node.querySelector('.p-name');
assert.deepEqual( Modules.domUtils.getNodePath( child ), [0,0,3] );
});
});

Some files were not shown because too many files have changed in this diff Show More