Skip to content
Permalink
Browse files

Lint run

  • Loading branch information...
pfrazee committed Mar 4, 2019
1 parent c2678aa commit 220e27fa704c8674bc52cc75b6d59e3479f96196
@@ -1,6 +1,6 @@
/**
* Modal
*
*
* NOTES
* - Modal windows are created as-needed, and desroyed when not in use
* - Modal windows are attached to individual BrowserView instances
@@ -1,6 +1,6 @@
/**
* Perm Prompt
*
*
* NOTES
* - Perm Prompt windows are created as-needed, and desroyed when not in use
* - Perm Prompt windows are attached to individual BrowserView instances
@@ -1,6 +1,6 @@
/**
* Shell Menus
*
*
* NOTES
* - There can only ever be one Shell Menu window for a given browser window
* - Shell Menu windows are created with each browser window and then shown/hidden as needed
@@ -56,7 +56,7 @@ const TLS_ERROR_CODES = Object.values({
})
const IS_CODE_INSECURE_RESPONSE = x => x === ERR_CONNECTION_REFUSED || x === ERR_INSECURE_RESPONSE || (x <= -200 && x > -300) || TLS_ERROR_CODES.includes(x)

const Y_POSITION = 78
const Y_POSITION = 78
const DEFAULT_URL = 'beaker://start'
const TRIGGER_LIVE_RELOAD_DEBOUNCE = 500 // throttle live-reload triggers by this amount

@@ -127,7 +127,7 @@ class View {
this.isInpageFindActive = false // is the inpage-finder UI active?
this.currentInpageFindString = undefined // what's the current inpage-finder query string?
this.currentInpageFindResults = undefined // what's the current inpage-finder query results?

// helper state
this.peers = 0 // how many peers does the site have?
this.isBookmarked = false // is the active page bookmarked?
@@ -223,7 +223,7 @@ class View {
var {width, height} = win.getBounds()
this.browserView.setBounds({x: 0, y: Y_POSITION, width, height: height - Y_POSITION})
this.browserView.setAutoResize({width: true, height: true})

this.webContents.focus()
}

@@ -247,7 +247,7 @@ class View {
async updateHistory () {
var url = this.url
var title = this.title

if (!/^beaker:\/\/(start|history)/i.test(url)) {
historyDb.addVisit(0, {url, title})
if (this.isPinned) {
@@ -662,7 +662,7 @@ export function create (win, url, opts = {setActive: false, isPinned: false, foc
win = getTopWindow(win)
url = url || DEFAULT_URL
var view = new View(win, {isPinned: opts.isPinned})

activeViews[win.id] = activeViews[win.id] || []
if (opts.isPinned) {
activeViews[win.id].splice(indexOfLastPinnedView(win), 0, view)
@@ -754,7 +754,7 @@ export function setActive (win, view) {
if (active) {
active.deactivate(true)
}

// activate the new view
view.activate()
windowMenu.onSetCurrentLocation(win, view.url) // give the window-menu a chance to handle the change
@@ -879,7 +879,7 @@ export function emitReplaceState (win) {

export function emitUpdateState (win, view) {
win = getTopWindow(win)
var index = typeof view === 'number' ? index : getAll(win).indexOf(view)
var index = typeof view === 'number' ? view : getAll(win).indexOf(view)
if (index === -1) {
console.warn('WARNING: attempted to update state of a view not on the window')
return
@@ -45,7 +45,7 @@ export function renderPermDesc ({bg, url, permId, permParam, permOpts}) {
case 'network':
if (permParam === '*') return 'Access the network freely'
return 'contact ' + permParam

case 'download':
return html`<span>Download ${permOpts.filename}</span>`

@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html } from './vendor/lit-element/lit-element'
import './modals/create-archive'
import './modals/fork-archive'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import * as bg from './bg-process-rpc'
import commonCSS from './common.css'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import * as bg from './bg-process-rpc'
import commonCSS from './common.css'
@@ -8,7 +9,7 @@ class CreateArchiveModal extends LitElement {
static get properties () {
return {
title: {type: String},
description: {type: String},
description: {type: String}
}
}

@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html } from '../vendor/lit-element/lit-element'
import prettyHash from 'pretty-hash'
import * as bg from './bg-process-rpc'
@@ -17,7 +18,7 @@ class ForkArchiveModal extends LitElement {
return {
state: {type: Number},
title: {type: String},
description: {type: String},
description: {type: String}
}
}

@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import * as bg from './bg-process-rpc'
import commonCSS from './common.css'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import * as bg from './bg-process-rpc'
import commonCSS from './common.css'
@@ -31,7 +32,7 @@ class SelectArchiveModal extends LitElement {
this.description = ''
this.selectedArchiveKey = ''
this.archives = []

// params
this.customTitle = ''
this.buttonLabel = 'Select'
@@ -72,7 +73,7 @@ class SelectArchiveModal extends LitElement {
<div class="wrapper">
${this.currentView === VIEWS.SELECT
? this.renderSelect()
: this.renderCreate() }
: this.renderCreate()}
</div>
`
}
@@ -183,7 +184,7 @@ class SelectArchiveModal extends LitElement {

// event handlers
// =

onChangeTitle (e) {
this.selectedArchiveKey = ''
this.title = e.target.value
@@ -207,7 +208,7 @@ class SelectArchiveModal extends LitElement {
this.selectedArchiveKey = e.currentTarget.dataset.key
this.onSubmit()
}

async onClickGotoCreateView (e) {
this.currentView = VIEWS.CREATE
await this.updateComplete
@@ -1,3 +1,4 @@
/* globals customElements */
import {LitElement, html, css} from '../vendor/lit-element/lit-element'
import {classMap} from '../vendor/lit-element/lit-html/directives/class-map'
import _get from 'lodash.get'
@@ -1,3 +1,4 @@
/* globals customElements */
import {LitElement, html, css} from '../../vendor/lit-element/lit-element'
import * as bg from '../bg-process-rpc'
import buttonResetCSS from './button-reset.css'
@@ -1,3 +1,4 @@
/* globals customElements */
import { ipcRenderer } from 'electron'
import { LitElement, html, css } from '../../vendor/lit-element/lit-element'
import { classMap } from '../../vendor/lit-element/lit-html/directives/class-map'
@@ -293,24 +294,24 @@ class NavbarLocation extends LitElement {
this.lastMousedownLocationTs = Date.now()
}
}

onMouseupLocation (e) {
if (Date.now() - this.lastMousedownLocationTs <= 300) {
// was a fast click (probably not a drag) so select all
let inputEl = e.currentTarget
this.mouseupClickIndex = inputEl.selectionStart
inputEl.select()

// setup double-click override
this.lastMousedownLocationTs = 0
this.lastMouseupLocationTs = Date.now()
}
}

onDblclickLocation (e) {
if (Date.now() - this.lastMouseupLocationTs <= 300) {
e.preventDefault()

// select the text under the cursor
// (we have to do this manually because we previously selected all on mouseup, which f's that default behavior up)
let inputEl = e.currentTarget
@@ -324,13 +325,13 @@ class NavbarLocation extends LitElement {
e.currentTarget.value = this.url
this.isLocationFocused = true
}

onBlurLocation (e) {
// clear the selection range so that the next focusing doesnt carry it over
window.getSelection().empty()
this.isLocationFocused = false
}

onInputLocation (e) {
var rect = this.getClientRects()[0]
bg.views.showMenu('location', {
@@ -437,7 +438,7 @@ class NavbarLocation extends LitElement {
await bg.bookmarks.bookmarkPrivate(this.url, {title: this.title})
bg.views.refreshState(this.activeTabIndex) // pull latest state
}

// show menu
bg.views.toggleMenu('bookmark', {
bounds: {
@@ -1,3 +1,4 @@
/* globals customElements */
import {LitElement, html, css} from '../../vendor/lit-element/lit-element'
import _get from 'lodash.get'
import * as bg from '../bg-process-rpc'
@@ -1,3 +1,4 @@
/* globals customElements */
import {LitElement, html, css} from '../vendor/lit-element/lit-element'
import {classMap} from '../vendor/lit-element/lit-html/directives/class-map'
import {repeat} from '../vendor/lit-element/lit-html/directives/repeat'
@@ -114,7 +115,7 @@ class ShellWindowTabs extends LitElement {
this.draggedTabIndex = index
e.dataTransfer.effectAllowed = 'move'
}

onDragendTab (e, index) {
// TODO needed?
}
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from './vendor/lit-element/lit-element'
import prettyHash from 'pretty-hash'
import * as bg from './perm-prompt/bg-process-rpc'
@@ -37,7 +38,7 @@ class PermPrompt extends LitElement {
let archiveKey = this.permParam
let archiveInfo
try { archiveInfo = await bg.datArchive.getInfo(archiveKey) }
catch (e) {/* ignore */}
catch (e) { /* ignore */ }
this.permOpts.title = archiveInfo && archiveInfo.title ? archiveInfo.title : prettyHash(this.permParam)
}

@@ -83,7 +84,7 @@ class PermPrompt extends LitElement {
onContextMenu (e) {
e.preventDefault() // disable context menu
}

onClickDecision (v) {
return e => this.resolve(v)
}
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html } from './vendor/lit-element/lit-element'
import * as bg from './shell-menus/bg-process-rpc'
import './shell-menus/browser'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import * as bg from './bg-process-rpc'
import commonCSS from './common.css'
@@ -38,7 +39,7 @@ class BookmarkMenu extends LitElement {
this.href = params.url
}
await this.requestUpdate()

// focus and highlight input
var input = this.shadowRoot.querySelector('input')
input.focus()
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import { fromEventStream } from '@beaker/core/web-apis/fg/event-target'
import moment from 'moment'
@@ -50,7 +51,7 @@ class BrowserMenu extends LitElement {
if (this.submenu === 'create-new') {
return this.renderCreateNew()
}

// auto-updater
var autoUpdaterEl = html``
if (this.browserInfo && this.browserInfo.updater.isBrowserUpdatesSupported && this.browserInfo.updater.state === 'downloaded') {
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import _get from 'lodash.get'
import * as bg from './bg-process-rpc'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import _get from 'lodash.get'
import * as bg from './bg-process-rpc'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import { repeat } from '../vendor/lit-element/lit-html/directives/repeat'
import { classMap } from '../vendor/lit-element/lit-html/directives/class-map'
@@ -139,7 +140,7 @@ class LocationMenu extends LitElement {
async queryAutocomplete () {
var finalResults
var searchResults = await bg.history.search(this.inputValue)

// decorate result with bolded regions
// explicitly replace special characters to match sqlite fts tokenization
var searchTerms = this.inputValue.replace(/[:^*-./]/g, ' ').split(' ').filter(Boolean)
@@ -342,4 +343,3 @@ function joinSegments (segments) {
}
return str
}

@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import * as bg from './bg-process-rpc'
import commonCSS from './common.css'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import prettyBytes from 'pretty-bytes'
import _get from 'lodash.get'
@@ -1,3 +1,4 @@
/* globals customElements */
import { LitElement, html, css } from '../vendor/lit-element/lit-element'
import { classMap } from '../vendor/lit-element/lit-html/directives/class-map'
import prettyHash from 'pretty-hash'
@@ -38,12 +39,12 @@ class SiteInfoMenu extends LitElement {
if (IS_DAT_KEY_REGEX.test(permParam)) {
let archiveInfo
try { archiveInfo = await bg.datArchive.getInfo(permParam) }
catch (e) {/* ignore */}
catch (e) { /* ignore */ }
opts.title = archiveInfo && archiveInfo.title ? archiveInfo.title : prettyHash(permParam)
}
return {perm, value, opts}
}))

// render
await this.requestUpdate()

@@ -113,7 +114,7 @@ class SiteInfoMenu extends LitElement {
if (protocol === 'https:' && !isInsecureResponse) {
return 'Your connection to this site is secure.'
}
if (protocol === 'https:' && isInsecureResponse || protocol === 'http:') {
if ((protocol === 'https:' && isInsecureResponse) || protocol === 'http:') {
return html`
<div>
<p>Your connection to this site is not secure.</p>
@@ -166,7 +167,6 @@ class SiteInfoMenu extends LitElement {
onClickLearnMore () {
bg.shellMenus.createTab('https://github.com/beakerbrowser/beaker/wiki/Is-Dat-%22Secure-P2P%3F%22')
}

}
SiteInfoMenu.styles = [inputsCSS, buttonsCSS, css`
.wrapper {
Oops, something went wrong.

0 comments on commit 220e27f

Please sign in to comment.
You can’t perform that action at this time.