Nick: LadyNurse* Oggetto: re:Esempio:°° Data: 27/6/2009 18.33.22 Visite: 1339
Le modifiche sono state salvate. Annulla La sezione "Più visitati" mostra i siti web a cui accedi con maggiore frequenza. Dopo aver navigato per qualche tempo, visualizzerai i siti più visitati ogni volta che apri una nuova scheda. Per ulteriori informazioni su questa e altre funzionalità consulta il Centro assistenza di Google Toolbar. Modifica miniature logEvent('start of second script block'); /* Element must be positioned and with no padding */ function addRoundedCornersToElement(e) { var first_child = e.firstChild; var roundedCornerClasses = ["rounded-corner-lt", "rounded-corner-rt", "rounded-corner-rb", "rounded-corner-lb"]; for (var i = 0; roundedCornerClasses[i]; ++i) { e.insertBefore(DOM("span", {className: roundedCornerClasses[i]}), first_child); } } function strip(str) { return str.replace(/^\s+/, '').replace(/\s+$/, ''); } function hasClassName(element, className) { var elementClassName = element.className; return elementClassName.length > 0 && (elementClassName == className || new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)); } function addClassName(element, className) { if (!hasClassName(element, className)) element.className += (element.className ? ' ' : '') + className; } function removeClassName(element, className) { element.className = strip(element.className.replace( new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ')); } /* Iterates through all elements with given className and executes action(element). */ function foreachElementWithClassName(className, action) { var elements = document.all; for (var i = 0; i < elements.length; i++) { var element = elements[i]; if (hasClassName(element, className)) { action(element); } } } /* Return a DOM element with tag name |elem| and attributes |attrs|. */ function DOM(elem, attrs) { var elem = document.createElement(elem); for (var attr in attrs) { elem[attr] = attrs[attr]; } return elem; } function restoreTabStops(className) { foreachElementWithClassName(className, function(element) { var value = 0; if (element.oldTabIndex) { value = element.oldTabIndex; } if (element.tabIndex == -1) { element.tabIndex = value; } }); } function disableTabStops(className) { foreachElementWithClassName(className, function(element) { if (element.tabIndex != -1) { element.oldTabIndex = element.tabIndex; element.tabIndex = -1; } }); } function updateTabStops() { if (currentMode == Mode.EDIT) { disableTabStops("nonEditable"); } else { restoreTabStops("nonEditable"); } } var Mode = {INTRO: 1, BASIC: 2, EDIT: 3}; var currentMode = Mode.BASIC; var undoOperationId = 0; var removedThumbnails = []; function switchMode(mode) { switch (mode) { case Mode.INTRO: $("frame").className = "intro"; break; case Mode.BASIC: $("frame").className = "basic"; break; case Mode.EDIT: if (currentMode != Mode.EDIT) { undoOperationId = 0; removedThumbnails = []; } $("frame").className = "edit"; break; } currentMode = mode; updateTabStops(); } function undoChanges() { if (undoOperationId) { chrome.undoRemove(undoOperationId); stopUndo(); chrome.send("getMostVisited"); } usageCounter('NewTabEntryRemoveUndo'); return false; } function stopUndo() { switchMode(currentMode); undoOperationId = 0; } function setUndo(operation_id) { if (operation_id) { undoOperationId = operation_id; addClassName($("frame"), "undo-active"); setTimeout(stopUndo, 60000); } } function doneEditing() { usageCounter('NewTabEntryRemove'); switchMode(Mode.BASIC); if (removedThumbnails.length > 0) { var operation_id = chrome.removeThumbnails(removedThumbnails); chrome.send("getMostVisited"); setUndo(operation_id); } } function pagePostProcessing() { addRoundedCornersToElement($("recentlyBookmarked")); addRoundedCornersToElement($("recentlyBookmarkedIntro")); addRoundedCornersToElement($("recentlyClosedTabs")); addRoundedCornersToElement($("recentlyClosedTabsIntro")); addRoundedCornersToElement($("undo")); $("removeThumbnails").attachEvent( ", function() { switchMode(Mode.EDIT); return false; }); $("removeThumbnails").attachEvent( ", function() { switchMode(Mode.EDIT); return false; }); $("removeThumbnailsDone").attachEvent(", doneEditing); $("undolink").attachEvent(", undoChanges); } function hideThumbnail(url) { removedThumbnails.push(url); chrome.send("getMostVisited", removedThumbnails); } /* Return the DOM element for a "most visited" entry. |page| should be an object with "title" and "url" fields. */ function makeMostVisitedLink(page, index) { /* The HTML we want looks like this: */ var usage_counter_id = "NewTabMostVisited" + (index + 1); var title = DOM("div"); title.appendChild(document.createTextNode(page.title)); var thumbnail = DOM("img", {src: page.thumbnail_url}); var link = DOM("a", {href: page.url, title: page.title, className: "nonEditable"}); link.attachEvent(", unc(page.url, usage_counter_id)); link.style.backgroundImage = "url(" + page.favicon_url + ")"; link.appendChild(title); link.appendChild(thumbnail); var x_icon = DOM("span"); // Allow to go though X icon via tabs x_icon.setAttribute('tabIndex', 0); x_icon.attachEvent(', function() { if (event.keyCode != ESC_KEY_CODE) { hideThumbnail(page.url); }}); x_icon.attachEvent(', function() { hideThumbnail(page.url); }); x_icon.attachEvent(', function() { x_icon.className = ""; }); x_icon.attachEvent(', function() { x_icon.className = "hovered"; }); x_icon.attachEvent(', function() { x_icon.className = "pressed"; }); x_icon.attachEvent(', function() { x_icon.className = "hovered";}); var root = DOM('div', {className: "thumbnail"}); root.appendChild(link); root.appendChild(DOM('div', {className: "overlay"})); root.appendChild(x_icon); return root; } /* This function is called by the browser with the most visited pages list. |pages| is a list of page objects, which have url and title attributes. */ function renderMostVisitedPages(pages) { logEvent('renderMostVisitedPages called: ' + pages.length); if (pages.length < 1 && currentMode != Mode.EDIT) { switchMode(Mode.INTRO); } else { if (currentMode == Mode.INTRO) switchMode(Mode.BASIC); var container = $("mostVisitedContainer"); container.innerHTML = ""; for (var i = 0; page = pages[i]; ++i) { container.appendChild(makeMostVisitedLink(page, i)); } } updateTabStops(); logEvent("renderMostVisitedPages done"); } function updateSection(section, container, entries, on_click_fn) { container.innerHTML = ""; if (entries.length == 0) { removeClassName(section, "visible"); } else { addClassName(section, "visible"); for (var i = 0; entry = entries[i]; ++i) { var link = DOM('a', {href: entry.url, title: entry.title, className: "nonEditable"}); link.style.backgroundImage = 'url("' + entry.icon + '")'; // Usage counter ID link.attachEvent(', on_click_fn(entry.url, i)); link.appendChild(document.createTextNode(entry.title)); container.appendChild(link); } } updateTabStops(); } /* This function is called by the browser when the list of recently bookmarked URLs is available. |entries| is a list of objects with title and url attributes. */ function renderRecentlyBookmarked(entries) { logEvent("renderRecentlyBookmarked called: " + entries.length); updateSection($("recentlyBookmarked"), $("recentlyBookmarkedContainer"), entries, function (url, i) { return unc(url, "NewTabRecentBookmark"); }); logEvent("renderRecentlyBookmarked done"); } /* This function adds incoming information about tabs to the new tab UI. */ function renderRecentlyClosedTabs(entries) { logEvent("renderRecentlyClosedTabs begin"); updateSection($("recentlyClosedTabs"), $("recentlyClosedContainer"), entries, function (url, i) { return usageFunc("NewTabRecentlyClosedTab" + (i+1)); }); logEvent("renderRecentlyClosedTabs done"); } function viewLog() { var lines = []; var start = log[0][1]; for (var i = 0; i < log.length; i++) { lines.push((log[i][1] - start) + ': ' + log[i][0]); } var lognode = document.createElement('pre'); lognode.appendChild(document.createTextNode(lines.join("\n"))); document.body.appendChild(lognode); } logEvent('end of second script block'); ♥ ["Ecco il mio segreto. E' molto semplice: non si vede bene che col cuore. L'essenziale è invisibile agli occhi."]♥
|