📄 inspector.js
字号:
WebInspector.documentClick = function(event){ var anchor = event.target.enclosingNodeOrSelfWithNodeName("a"); if (!anchor) return; // Prevent the link from navigating, since we don't do any navigation by following links normally. event.preventDefault(); function followLink() { // FIXME: support webkit-html-external-link links here. if (anchor.href in WebInspector.resourceURLMap) { if (anchor.hasStyleClass("webkit-html-external-link")) { anchor.removeStyleClass("webkit-html-external-link"); anchor.addStyleClass("webkit-html-resource-link"); } WebInspector.showResourceForURL(anchor.href, anchor.lineNumber, anchor.preferredPanel); } else { var profileStringRegEx = new RegExp("webkit-profile://.+/([0-9]+)"); var profileString = profileStringRegEx.exec(anchor.href); if (profileString) WebInspector.showProfileById(profileString[1]) } } if (WebInspector.followLinkTimeout) clearTimeout(WebInspector.followLinkTimeout); if (anchor.preventFollowOnDoubleClick) { // Start a timeout if this is the first click, if the timeout is canceled // before it fires, then a double clicked happened or another link was clicked. if (event.detail === 1) WebInspector.followLinkTimeout = setTimeout(followLink, 333); return; } followLink();}WebInspector.documentKeyDown = function(event){ if (!this.currentFocusElement) return; if (this.currentFocusElement.handleKeyEvent) this.currentFocusElement.handleKeyEvent(event); else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "KeyDown"]) WebInspector[this.currentFocusElement.id + "KeyDown"](event); if (!event.handled) { var isMac = InspectorController.platform().indexOf("mac-") === 0; switch (event.keyIdentifier) { case "U+001B": // Escape key this.console.visible = !this.console.visible; event.preventDefault(); break; case "U+0046": // F key if (isMac) var isFindKey = event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey; else var isFindKey = event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey; if (isFindKey) { var searchField = document.getElementById("search"); searchField.focus(); searchField.select(); event.preventDefault(); } break; case "U+0047": // G key if (isMac) var isFindAgainKey = event.metaKey && !event.ctrlKey && !event.altKey; else var isFindAgainKey = event.ctrlKey && !event.metaKey && !event.altKey; if (isFindAgainKey) { if (event.shiftKey) { if (this.currentPanel.jumpToPreviousSearchResult) this.currentPanel.jumpToPreviousSearchResult(); } else if (this.currentPanel.jumpToNextSearchResult) this.currentPanel.jumpToNextSearchResult(); event.preventDefault(); } break; } }}WebInspector.documentKeyUp = function(event){ if (!this.currentFocusElement || !this.currentFocusElement.handleKeyUpEvent) return; this.currentFocusElement.handleKeyUpEvent(event);}WebInspector.documentCanCopy = function(event){ if (!this.currentFocusElement) return; // Calling preventDefault() will say "we support copying, so enable the Copy menu". if (this.currentFocusElement.handleCopyEvent) event.preventDefault(); else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"]) event.preventDefault();}WebInspector.documentCopy = function(event){ if (!this.currentFocusElement) return; if (this.currentFocusElement.handleCopyEvent) this.currentFocusElement.handleCopyEvent(event); else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"]) WebInspector[this.currentFocusElement.id + "Copy"](event);}WebInspector.mainKeyDown = function(event){ if (this.currentPanel && this.currentPanel.handleKeyEvent) this.currentPanel.handleKeyEvent(event);}WebInspector.mainKeyUp = function(event){ if (this.currentPanel && this.currentPanel.handleKeyUpEvent) this.currentPanel.handleKeyUpEvent(event);}WebInspector.mainCopy = function(event){ if (this.currentPanel && this.currentPanel.handleCopyEvent) this.currentPanel.handleCopyEvent(event);}WebInspector.animateStyle = function(animations, duration, callback, complete){ if (complete === undefined) complete = 0; var slice = (1000 / 30); // 30 frames per second var defaultUnit = "px"; var propertyUnit = {opacity: ""}; for (var i = 0; i < animations.length; ++i) { var animation = animations[i]; var element = null; var start = null; var current = null; var end = null; for (key in animation) { if (key === "element") element = animation[key]; else if (key === "start") start = animation[key]; else if (key === "current") current = animation[key]; else if (key === "end") end = animation[key]; } if (!element || !end) continue; var computedStyle = element.ownerDocument.defaultView.getComputedStyle(element); if (!start) { start = {}; for (key in end) start[key] = parseInt(computedStyle.getPropertyValue(key)); animation.start = start; } else if (complete == 0) for (key in start) element.style.setProperty(key, start[key] + (key in propertyUnit ? propertyUnit[key] : defaultUnit)); if (!current) { current = {}; for (key in start) current[key] = start[key]; animation.current = current; } function cubicInOut(t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; } var style = element.style; for (key in end) { var startValue = start[key]; var currentValue = current[key]; var endValue = end[key]; if ((complete + slice) < duration) { var delta = (endValue - startValue) / (duration / slice); var newValue = cubicInOut(complete, startValue, endValue - startValue, duration); style.setProperty(key, newValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit)); current[key] = newValue; } else { style.setProperty(key, endValue + (key in propertyUnit ? propertyUnit[key] : defaultUnit)); } } } if (complete < duration) setTimeout(WebInspector.animateStyle, slice, animations, duration, callback, complete + slice); else if (callback) callback();}WebInspector.updateSearchLabel = function(){ if (!this.currentPanel) return; var newLabel = WebInspector.UIString("Search %s", this.currentPanel.toolbarItemLabel); if (this.attached) document.getElementById("search").setAttribute("placeholder", newLabel); else { document.getElementById("search").removeAttribute("placeholder"); document.getElementById("search-toolbar-label").textContent = newLabel; }}WebInspector.toggleAttach = function(){ this.attached = !this.attached;}WebInspector.toolbarDragStart = function(event){ if (!WebInspector.attached && InspectorController.platform() !== "mac-leopard") return; var target = event.target; if (target.hasStyleClass("toolbar-item") && target.hasStyleClass("toggleable")) return; var toolbar = document.getElementById("toolbar"); if (target !== toolbar && !target.hasStyleClass("toolbar-item")) return; toolbar.lastScreenX = event.screenX; toolbar.lastScreenY = event.screenY; WebInspector.elementDragStart(toolbar, WebInspector.toolbarDrag, WebInspector.toolbarDragEnd, event, (WebInspector.attached ? "row-resize" : "default"));}WebInspector.toolbarDragEnd = function(event){ var toolbar = document.getElementById("toolbar"); WebInspector.elementDragEnd(event); delete toolbar.lastScreenX; delete toolbar.lastScreenY;}WebInspector.toolbarDrag = function(event){ var toolbar = document.getElementById("toolbar"); if (WebInspector.attached) { var height = window.innerHeight - (event.screenY - toolbar.lastScreenY); InspectorController.setAttachedWindowHeight(height); } else { var x = event.screenX - toolbar.lastScreenX; var y = event.screenY - toolbar.lastScreenY; // We cannot call window.moveBy here because it restricts the movement // of the window at the edges. InspectorController.moveByUnrestricted(x, y); } toolbar.lastScreenX = event.screenX; toolbar.lastScreenY = event.screenY; event.preventDefault();}WebInspector.elementDragStart = function(element, dividerDrag, elementDragEnd, event, cursor) { if (this._elementDraggingEventListener || this._elementEndDraggingEventListener) this.elementDragEnd(event); this._elementDraggingEventListener = dividerDrag; this._elementEndDraggingEventListener = elementDragEnd; document.addEventListener("mousemove", dividerDrag, true); document.addEventListener("mouseup", elementDragEnd, true); document.body.style.cursor = cursor; event.preventDefault();}WebInspector.elementDragEnd = function(event){ document.removeEventListener("mousemove", this._elementDraggingEventListener, true); document.removeEventListener("mouseup", this._elementEndDraggingEventListener, true); document.body.style.removeProperty("cursor"); delete this._elementDraggingEventListener; delete this._elementEndDraggingEventListener; event.preventDefault();}WebInspector.showConsole = function(){ this.console.show();}WebInspector.showElementsPanel = function(){ this.currentPanel = this.panels.elements;}WebInspector.showResourcesPanel = function(){ this.currentPanel = this.panels.resources;}WebInspector.showScriptsPanel = function(){ this.currentPanel = this.panels.scripts;}WebInspector.showProfilesPanel = function(){ this.currentPanel = this.panels.profiles;}WebInspector.showDatabasesPanel = function(){ this.currentPanel = this.panels.databases;}WebInspector.addResource = function(resource){ this.resources.push(resource); this.resourceURLMap[resource.url] = resource; if (resource.mainResource) { this.mainResource = resource; this.panels.elements.reset(); } if (this.panels.resources) this.panels.resources.addResource(resource);}WebInspector.removeResource = function(resource){ resource.category.removeResource(resource); delete this.resourceURLMap[resource.url]; this.resources.remove(resource, true); if (this.panels.resources) this.panels.resources.removeResource(resource);}WebInspector.addDatabase = function(database){ this.panels.databases.addDatabase(database);}WebInspector.addDOMStorage = function(domStorage){ this.panels.databases.addDOMStorage(domStorage);}WebInspector.debuggerWasEnabled = function(){ this.panels.scripts.debuggerWasEnabled();}WebInspector.debuggerWasDisabled = function(){ this.panels.scripts.debuggerWasDisabled();}WebInspector.profilerWasEnabled = function(){ this.panels.profiles.profilerWasEnabled();}WebInspector.profilerWasDisabled = function(){ this.panels.profiles.profilerWasDisabled();}WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, startingLine){ this.panels.scripts.addScript(sourceID, sourceURL, source, startingLine);}WebInspector.failedToParseScriptSource = function(sourceURL, source, startingLine, errorLine, errorMessage){ this.panels.scripts.addScript(null, sourceURL, source, startingLine, errorLine, errorMessage);}WebInspector.pausedScript = function(){ this.panels.scripts.debuggerPaused();}WebInspector.populateInterface = function(){ for (var panelName in this.panels) { var panel = this.panels[panelName]; if ("populateInterface" in panel) panel.populateInterface(); }}WebInspector.reset = function(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -