final JFrame frame = new JFrame();
frame.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
int width = e.getComponent().getWidth();
int height = e.getComponent().getHeight();
int newWidth = width;
int newHeight = height;
if (width > 600) {
newWidth = 600;
}
if (width < 400) {
newWidth = 400;
}
if (height > 600) {
newHeight = 600;
}
if (height < 400) {
newHeight = 400;
}
if (newHeight != height || newWidth != width) {
frame.setSize(newWidth, newHeight);
}
}
});
angular.element(document.getElementById('foo')).append($compile("<h2 ev-click>add element</h2>")($scope));
fetchUser().then(function(user){
return fetchUserPosts(user.id);
})
Q.spawn(function*(){
var user = yield fetchUser();
var userPosts = yield fetchUserPosts(user.id);
return userPosts;
});
function fetch(url,callback){
var req = new XMLHttpRequest();
req.open("GET",url);
req.onload = function(){
callback(req.responseText);
}
req.send();
}
function insertScript(scriptBody){
var script = document.createElement('script');
script.innerText = scriptBody;
document.body.appendChild(script);
}
var scripts = ["/first.js","second.js"];
var bodies = new Array(scripts.length);
scripts.forEach(function(script,index){
fetch(script,function(body){
bodies[index]=body;
if(bodies.every(function(el){return el})) {
bodies.forEach(insertScript);
}
});
})
"externally_connectable": {
"matches": ["https://somesites.com/*"]
}
if(chrome && chrome.runtime && chrome.runtime.sendMessage){
var editorExtensionId = "уникальный идентификатор раширения";
chrome.runtime.sendMessage(editorExtensionId, {notification:"Some notification"});
}
chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
if (sender.url != "https://somesites.com")
return;
showNotification(request.notification);
});