Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Page refreshing #31

Merged
merged 2 commits into from Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/AppInspector/app/util/Component.js
Expand Up @@ -73,7 +73,7 @@ Ext.define('AI.util.Component', {


// Ext JS 5 breaks the older ComponentManager API // Ext JS 5 breaks the older ComponentManager API
if (Ext.versions.extjs && Ext.versions.extjs.major > 4) { if (Ext.versions.extjs && Ext.versions.extjs.major > 4) {
all = Ext.Object.getValues(Ext.ComponentManager.all); all = Ext.ComponentManager.getAll();
} }
else { else {
all = Ext.ComponentManager.all.getArray(); all = Ext.ComponentManager.all.getArray();
Expand Down
22 changes: 0 additions & 22 deletions app/background.js

This file was deleted.

8 changes: 8 additions & 0 deletions app/background/background.html
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script src="background.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions app/background/background.js
@@ -0,0 +1,22 @@
'use strict';

// monitor page refresh
chrome.extension.onConnect.addListener(function (port) {

//when devtools-page connects (when App Inspector is actually opened)
if (port.name === 'AppInspector') {

//add event listener for tab refresh
//NOTE: this fires across ALL tabs!
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {

//changeInfo has multiple statuses... only fire on complete
if (changeInfo.status === 'complete') {
port.postMessage({
tabId : tabId,
message : 'refreshed!'
});
}
});
}
});
4 changes: 3 additions & 1 deletion app/devtools-page.html
Expand Up @@ -3,7 +3,9 @@


<head> <head>
<title>App Inspector for Sencha</title> <title>App Inspector for Sencha</title>
<script type="text/javascript" src="devtools-page.js"></script> <script type="text/javascript" src="devtools/panel.js"></script>
<script type="text/javascript" src="devtools/elements.js"></script>
<script type="text/javascript" src="devtools/right-click.js"></script>
</head> </head>


<body> <body>
Expand Down
24 changes: 4 additions & 20 deletions app/devtools-page.js → app/devtools/elements.js
@@ -1,26 +1,10 @@
// http://developer.chrome.com/extensions/devtools.html
'use strict'; 'use strict';


/**
* Sencha Panel
*/
chrome.devtools.panels.create('Sencha', 'resources/images/panel_icon.png', 'AppInspector/index.html', function(senchaPanel) {
// right-click context menu
// chrome.contextMenus.create({
// 'title': 'Open App Inspector for Sencha...',
// 'contexts': ['all'],
// 'onclick': function(info, tab) {
// //TODO: one day allow the user to open DevTools and navigate directly to the Sencha Tab
// // but right now this isn't possible
// // http://stackoverflow.com/questions/6801577/can-i-programmatically-open-the-devtools-from-a-google-chrome-extension
// }
// });
});

/** /**
* Elements Side Panel * Elements Side Panel
*/ */
var elementsPanel = chrome.devtools.panels.elements, var elementsPanel = chrome.devtools.panels.elements,

pageDetectSenchaComponent = function pageDetectSenchaComponent() { pageDetectSenchaComponent = function pageDetectSenchaComponent() {
var cmp, data, xtype, var cmp, data, xtype,
selectedEl = $0, //https://developers.google.com/chrome-developer-tools/docs/commandline-api#0_-_4 selectedEl = $0, //https://developers.google.com/chrome-developer-tools/docs/commandline-api#0_-_4
Expand Down Expand Up @@ -56,13 +40,13 @@ var elementsPanel = chrome.devtools.panels.elements,
return data; return data;
}; };


elementsPanel.createSidebarPane('Sencha Component', function(sidebar) { elementsPanel.createSidebarPane('Sencha Component', function (sidebar) {
var onSelectionChanged = function() { var onSelectionChanged = function () {
sidebar.setExpression('(' + pageDetectSenchaComponent.toString() + ')()'); sidebar.setExpression('(' + pageDetectSenchaComponent.toString() + ')()');
}; };


onSelectionChanged(); onSelectionChanged();


// selection listener // selection listener
elementsPanel.onSelectionChanged.addListener(onSelectionChanged); elementsPanel.onSelectionChanged.addListener(onSelectionChanged);
}); });
35 changes: 35 additions & 0 deletions app/devtools/panel.js
@@ -0,0 +1,35 @@
'use strict';

/**
* Create Sencha Panel
* http://developer.chrome.com/extensions/devtools.html
*/
chrome.devtools.panels.create(
'Sencha',
'resources/images/panel_icon.png',
'AppInspector/index.html',

function (senchaPanel) {
var READY;

senchaPanel.onShown.addListener(function (panelWindow) {
if (READY) { return; }
READY = true;

//connect to logic in background.js
var port = chrome.runtime.connect({ name : 'AppInspector' }),
tabId = chrome.devtools.inspectedWindow.tabId;

//when messages are received from background.js
port.onMessage.addListener(function (msg) {

//we only care about the tab which we're debugging
if (msg.tabId === tabId) {

//refresh AppInspector
panelWindow.location.reload(true);
}
});
});
}
);
13 changes: 13 additions & 0 deletions app/devtools/right-click.js
@@ -0,0 +1,13 @@
'use strict';

// right-click context menu

// chrome.contextMenus.create({
// 'title': 'Open App Inspector for Sencha...',
// 'contexts': ['all'],
// 'onclick': function(info, tab) {
// //TODO: one day allow the user to open DevTools and navigate directly to the Sencha Tab
// // but right now this isn't possible
// // http://stackoverflow.com/questions/6801577/can-i-programmatically-open-the-devtools-from-a-google-chrome-extension
// }
// });
4 changes: 1 addition & 3 deletions app/manifest.json
Expand Up @@ -11,9 +11,7 @@
}, },
"default_locale" : "en", "default_locale" : "en",
"background" : { "background" : {
"scripts" : [ "page" : "background/background.html"
"background.js"
]
}, },
"devtools_page" : "devtools-page.html", "devtools_page" : "devtools-page.html",
"content_security_policy" : "script-src 'self' 'unsafe-eval'; object-src 'self'", "content_security_policy" : "script-src 'self' 'unsafe-eval'; object-src 'self'",
Expand Down