Safari: code styling

This commit is contained in:
Deathamns 2014-12-29 18:04:39 +01:00
parent a8e02d4dfa
commit f0ad21fcf5
2 changed files with 22 additions and 19 deletions

View File

@ -153,19 +153,20 @@ vAPI.storage = {
return;
}
var key, size = 0;
var i;
var size = 0;
if ( keys === null ) {
for ( key in this._storage ) {
size += (this._storage[key] || '').length;
for ( i in this._storage ) {
size += (this._storage[i] || '').length;
}
} else {
if ( typeof keys === 'string' ) {
keys = [keys];
}
for ( key = 0; key < keys.length; key++ ) {
size += (this._storage[keys[key]] || '').length;
for ( i = 0; i < keys.length; i++ ) {
size += (this._storage[keys[i]] || '').length;
}
}
@ -630,14 +631,14 @@ vAPI.net.registerListeners = function() {
if ( e.message.url === 'about:blank' ) {
vAPI.tabs.popupCandidate = vAPI.tabs.getTabId(e.target);
e.message = true;
return;
}
} else {
e.message = !vAPI.tabs.onPopup({
url: e.message.url,
tabId: 0,
sourceTabId: vAPI.tabs.getTabId(e.target)
});
}
return;
}

View File

@ -290,12 +290,13 @@ var onBeforeLoad = function(e, details) {
}
// Local mirroring, response should be a data: URL here
if ( typeof response !== 'string' || details.type !== 'script' ) {
if ( typeof response !== 'string' ) {
return;
}
// Content Security Policy with disallowed inline scripts may break things
e.preventDefault();
// Content Security Policy with disallowed inline scripts may break things
details = document.createElement('script');
details.textContent = atob(response.slice(response.indexOf(',', 20) + 1));
@ -394,29 +395,30 @@ document.addEventListener('DOMSubtreeModified', firstMutation, true);
var onContextMenu = function(e) {
var target = e.target;
var tagName = target.tagName.toLowerCase();
var details = {
tagName: target.tagName.toLowerCase(),
tagName: tagName,
pageUrl: location.href,
insideFrame: window !== window.top
};
details.editable = details.tagName === 'textarea' || details.tagName === 'input';
details.editable = tagName === 'textarea' || tagName === 'input';
if ( target.hasOwnProperty('checked') ) {
details.checked = target.checked;
}
if ( details.tagName === 'a' ) {
if ( tagName === 'a' ) {
details.linkUrl = target.href;
}
if ( target.hasOwnProperty('src') ) {
details.srcUrl = target.src;
if ( details.tagName === 'img' ) {
if ( tagName === 'img' ) {
details.mediaType = 'image';
} else if ( details.tagName === 'video' || details.tagName === 'audio' ) {
details.mediaType = details.tagName;
} else if ( tagName === 'video' || tagName === 'audio' ) {
details.mediaType = tagName;
}
}