autoformat more easy files

This commit is contained in:
Zeke Sikelianos 2016-03-25 12:57:17 -07:00 committed by Kevin Sawicki
parent 67fa250020
commit 3855a774ab
19 changed files with 1068 additions and 1076 deletions

View file

@ -1,16 +1,16 @@
window.onload = function() {
window.onload = function () {
// Use menu API to show context menu.
InspectorFrontendHost.showContextMenuAtPoint = createMenu;
InspectorFrontendHost.showContextMenuAtPoint = createMenu
// Use dialog API to override file chooser dialog.
return (WebInspector.createFileSelectorElement = createFileSelectorElement);
};
return (WebInspector.createFileSelectorElement = createFileSelectorElement)
}
var convertToMenuTemplate = function(items) {
var fn, i, item, len, template;
template = [];
fn = function(item) {
var transformed;
var convertToMenuTemplate = function (items) {
var fn, i, item, len, template
template = []
fn = function (item) {
var transformed
transformed = item.type === 'subMenu' ? {
type: 'submenu',
label: item.label,
@ -27,55 +27,55 @@ var convertToMenuTemplate = function(items) {
type: 'normal',
label: item.label,
enabled: item.enabled
};
if (item.id != null) {
transformed.click = function() {
DevToolsAPI.contextMenuItemSelected(item.id);
return DevToolsAPI.contextMenuCleared();
};
}
return template.push(transformed);
};
for (i = 0, len = items.length; i < len; i++) {
item = items[i];
fn(item);
if (item.id != null) {
transformed.click = function () {
DevToolsAPI.contextMenuItemSelected(item.id)
return DevToolsAPI.contextMenuCleared()
}
}
return template.push(transformed)
}
return template;
};
for (i = 0, len = items.length; i < len; i++) {
item = items[i]
fn(item)
}
return template
}
var createMenu = function(x, y, items) {
const remote = require('electron').remote;
const Menu = remote.Menu;
const menu = Menu.buildFromTemplate(convertToMenuTemplate(items));
var createMenu = function (x, y, items) {
const remote = require('electron').remote
const Menu = remote.Menu
const menu = Menu.buildFromTemplate(convertToMenuTemplate(items))
// The menu is expected to show asynchronously.
return setTimeout(function() {
return menu.popup(remote.getCurrentWindow());
});
};
return setTimeout(function () {
return menu.popup(remote.getCurrentWindow())
})
}
var showFileChooserDialog = function(callback) {
var dialog, files, remote;
remote = require('electron').remote;
dialog = remote.dialog;
files = dialog.showOpenDialog({});
var showFileChooserDialog = function (callback) {
var dialog, files, remote
remote = require('electron').remote
dialog = remote.dialog
files = dialog.showOpenDialog({})
if (files != null) {
return callback(pathToHtml5FileObject(files[0]));
return callback(pathToHtml5FileObject(files[0]))
}
};
}
var pathToHtml5FileObject = function(path) {
var blob, fs;
fs = require('fs');
blob = new Blob([fs.readFileSync(path)]);
blob.name = path;
return blob;
};
var pathToHtml5FileObject = function (path) {
var blob, fs
fs = require('fs')
blob = new Blob([fs.readFileSync(path)])
blob.name = path
return blob
}
var createFileSelectorElement = function(callback) {
var fileSelectorElement;
fileSelectorElement = document.createElement('span');
fileSelectorElement.style.display = 'none';
fileSelectorElement.click = showFileChooserDialog.bind(this, callback);
return fileSelectorElement;
};
var createFileSelectorElement = function (callback) {
var fileSelectorElement
fileSelectorElement = document.createElement('span')
fileSelectorElement.style.display = 'none'
fileSelectorElement.click = showFileChooserDialog.bind(this, callback)
return fileSelectorElement
}