Demo/bin/Debug/front_end/network_module.js
(开头部分) 202KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
WebInspector.BlockedURLsPane=function()
{WebInspector.VBox.call(this,true);this.registerRequiredCSS("network/blockedURLsPane.css");this.contentElement.classList.add("blocked-urls-pane");WebInspector.BlockedURLsPane._instance=this;this._blockedURLsSetting=WebInspector.moduleSetting("blockedURLs");this._blockedURLsSetting.addChangeListener(this._update,this);this._toolbar=new WebInspector.Toolbar(this.contentElement);this._toolbar.element.addEventListener("click",consumeEvent);var addButton=new WebInspector.ToolbarButton(WebInspector.UIString("Add pattern"),"add-toolbar-item");addButton.addEventListener("click",this._addButtonClicked.bind(this));this._toolbar.appendToolbarItem(addButton);var clearButton=new WebInspector.ToolbarButton(WebInspector.UIString("Remove all"),"clear-toolbar-item");clearButton.addEventListener("click",this._removeAll.bind(this));this._toolbar.appendToolbarItem(clearButton);this._emptyElement=this.contentElement.createChild("div","no-blocked-urls");this._emptyElement.createChild("span").textContent=WebInspector.UIString("Requests are not blocked. ");var addLink=this._emptyElement.createChild("span","link");addLink.textContent=WebInspector.UIString("Add pattern.");addLink.href="";addLink.addEventListener("click",this._addButtonClicked.bind(this),false);this._emptyElement.addEventListener("contextmenu",this._emptyElementContextMenu.bind(this),true);this._listElement=this.contentElement.createChild("div","blocked-urls-list");this._blockedCountForUrl=new Map();WebInspector.targetManager.addModelListener(WebInspector.NetworkManager,WebInspector.NetworkManager.EventTypes.RequestFinished,this._onRequestFinished,this);this._updateThrottler=new WebInspector.Throttler(200);this._update();}
WebInspector.BlockedURLsPane.prototype={_emptyElementContextMenu:function(event)
{var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^pattern"),this._addButtonClicked.bind(this));contextMenu.show();},_addButtonClicked:function()
{this._emptyElement.classList.add("hidden");var element=this._createElement("",this._blockedURLsSetting.get().length);this._listElement.appendChild(element);element.scrollIntoView();this._edit("",element,this._addBlockedURL.bind(this));},_edit:function(content,element,onAccept)
{this._editing=true;element.classList.add("blocked-url-editing");var input=element.createChild("input");input.setAttribute("type","text");input.value=content;input.placeholder=WebInspector.UIString("Text pattern to block matching requests; use * for wildcard");input.addEventListener("blur",commit.bind(this),false);input.addEventListener("keydown",keydown.bind(this),false);input.focus();function finish()
{this._editing=false;element.removeChild(input);element.classList.remove("blocked-url-editing");}
function commit()
{if(!this._editing)
return;var text=input.value.trim();finish.call(this);if(text)
onAccept(text);else
this._update();}
function keydown(event)
{if(isEnterKey(event)){event.consume();commit.call(this);}else if(event.keyCode===WebInspector.KeyboardShortcut.Keys.Esc.code||event.keyIdentifier==="U+001B"){event.consume();finish.call(this);this._update();}}},_addBlockedURL:function(url)
{var blocked=this._blockedURLsSetting.get();blocked.push(url);this._blockedURLsSetting.set(blocked);},_removeBlockedURL:function(index)
{var blocked=this._blockedURLsSetting.get();blocked.splice(index,1);this._blockedURLsSetting.set(blocked);},_changeBlockedURL:function(index,url)
{var blocked=this._blockedURLsSetting.get();blocked.splice(index,1,url);this._blockedURLsSetting.set(blocked);},_removeAll:function()
{this._blockedURLsSetting.set([]);},_contextMenu:function(index,event)
{var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^pattern"),this._addButtonClicked.bind(this));contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^pattern"),this._removeBlockedURL.bind(this,index));contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^all"),this._removeAll.bind(this));contextMenu.show();},_update:function()
{if(this._editing)
return Promise.resolve();this._listElement.removeChildren();var blocked=this._blockedURLsSetting.get();for(var index=0;index<blocked.length;index++)
this._listElement.appendChild(this._createElement(blocked[index],index));this._emptyElement.classList.toggle("hidden",!!blocked.length);return Promise.resolve();},_createElement:function(url,index)
{var element=createElementWithClass("div","blocked-url");var label=element.createChild("div","blocked-url-text");label.textContent=url;var count=this._blockedRequestsCount(url);var countElement=element.createChild("div","blocked-count monospace");countElement.textContent=String.sprintf("[%d]",count);countElement.title=WebInspector.UIString(count===1?"%d request blocked by this pattern":"%d requests blocked by this pattern",count);var removeButton=element.createChild("div","remove-button");removeButton.title=WebInspector.UIString("Remove");removeButton.addEventListener("click",this._removeBlockedURL.bind(this,index),false);element.addEventListener("contextmenu",this._contextMenu.bind(this,index),true);element.addEventListener("dblclick",this._edit.bind(this,url,element,this._changeBlockedURL.bind(this,index)),false);return element;},_blockedRequestsCount:function(url)
{if(!url)
return 0;var result=0;for(var blockedUrl of this._blockedCountForUrl.keys()){if(this._matches(url,blockedUrl))
result+=this._blockedCountForUrl.get(blockedUrl);}
return result;},_matches:function(pattern,url)
{var pos=0;var parts=pattern.split("*");for(var index=0;index<parts.length;index++){var part=parts[index];if(!part.length)
continue;pos=url.indexOf(part,pos);if(pos===-1)
return false;pos+=part.length;}
return true;},reset:function()
{this._blockedCountForUrl.clear();},_onRequestFinished:function(event)
{var request=(event.data);if(request.wasBlocked()){var count=this._blockedCountForUrl.get(request.url)||0;this._blockedCountForUrl.set(request.url,count+1);this._updateThrottler.schedule(this._update.bind(this));}},__proto__:WebInspector.VBox.prototype}
WebInspector.BlockedURLsPane._instance=null;WebInspector.BlockedURLsPane.reset=function()
{if(WebInspector.BlockedURLsPane._instance)
WebInspector.BlockedURLsPane._instance.reset();}
WebInspector.BlockedURLsPane.ActionDelegate=function()
{}
WebInspector.BlockedURLsPane.ActionDelegate.prototype={handleAction:function(context,actionId)
{WebInspector.inspectorView.showViewInDrawer("network.blocked-urls");return true;}};WebInspector.EventSourceMessagesView=function(request)
{WebInspector.DataGridContainerWidget.call(this);this.registerRequiredCSS("network/eventSourceMessagesView.css");this.element.classList.add("event-source-messages-view");this._request=request;var columns=[{id:"id",title:WebInspector.UIString("Id"),sortable:true,weight:8},{id:"type",title:WebInspector.UIString("Type"),sortable:true,weight:8},{id:"data",title:WebInspector.UIString("Data"),sortable:false,weight:88},{id:"time",title:WebInspector.UIString("Time"),sortable:true,weight:8}];this._dataGrid=new WebInspector.SortableDataGrid(columns);this._dataGrid.setStickToBottom(true);this._dataGrid.markColumnAsSortedBy("time",WebInspector.DataGrid.Order.Ascending);this._sortItems();this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,this._sortItems,this);this._dataGrid.setName("EventSourceMessagesView");this.appendDataGrid(this._dataGrid);}
WebInspector.EventSourceMessagesView.prototype={wasShown:function()
{this._dataGrid.rootNode().removeChildren();var messages=this._request.eventSourceMessages();for(var i=0;i<messages.length;++i)
this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(messages[i]));this._request.addEventListener(WebInspector.NetworkRequest.Events.EventSourceMessageAdded,this._messageAdded,this);},willHide:function()
{this._request.removeEventListener(WebInspector.NetworkRequest.Events.EventSourceMessageAdded,this._messageAdded,this);},_messageAdded:function(event)
{var message=(event.data);this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(message));},_sortItems:function()
{var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();if(!sortColumnIdentifier)
return;var comparator=WebInspector.EventSourceMessageNode.Comparators[sortColumnIdentifier];if(!comparator)
return;this._dataGrid.sortNodes(comparator,!this._dataGrid.isSortOrderAscending());},__proto__:WebInspector.DataGridContainerWidget.prototype}
WebInspector.EventSourceMessageNode=function(message)
{this._message=message;var time=new Date(message.time*1000);var timeText=("0"+time.getHours()).substr(-2)+":"+("0"+time.getMinutes()).substr(-2)+":"+("0"+time.getSeconds()).substr(-2)+"."+("00"+time.getMilliseconds()).substr(-3);var timeNode=createElement("div");timeNode.createTextChild(timeText);timeNode.title=time.toLocaleString();WebInspector.SortableDataGridNode.call(this,{id:message.eventId,type:message.eventName,data:message.data,time:timeNode});}
WebInspector.EventSourceMessageNode.prototype={__proto__:WebInspector.SortableDataGridNode.prototype}
WebInspector.EventSourceMessageNodeComparator=function(field,a,b)
{var aValue=a._message[field];var bValue=b._message[field];return aValue<bValue?-1:aValue>bValue?1:0;}
WebInspector.EventSourceMessageNode.Comparators={"id":WebInspector.EventSourceMessageNodeComparator.bind(null,"eventId"),"type":WebInspector.EventSourceMessageNodeComparator.bind(null,"eventName"),"time":WebInspector.EventSourceMessageNodeComparator.bind(null,"time")};;WebInspector.FilterSuggestionBuilder=function(keys)
{this._keys=keys;this._valueSets={};this._valueLists={};}
WebInspector.FilterSuggestionBuilder.Filter;WebInspector.FilterSuggestionBuilder.prototype={buildSuggestions:function(input)
{var text=input.value;var end=input.selectionEnd;if(end!=text.length)
return null;var start=input.selectionStart;text=text.substring(0,start);var prefixIndex=text.lastIndexOf(" ")+1;var prefix=text.substring(prefixIndex);if(!prefix)
return[];var negative=prefix.startsWith("-");if(negative)
后面还有 911 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。