Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
a451c5f3
Commit
a451c5f3
authored
Jan 13, 2017
by
chriseth
Committed by
GitHub
Jan 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #375 from ethereum/config-file
Add config file API
parents
fae021f4
a71c688d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
5 deletions
+53
-5
app.js
src/app.js
+15
-4
config.js
src/app/config.js
+36
-0
editor.js
src/app/editor.js
+2
-1
No files found.
src/app.js
View file @
a451c5f3
...
...
@@ -11,6 +11,7 @@ var GistHandler = require('./app/gist-handler')
var
gistHandler
=
new
GistHandler
()
var
Storage
=
require
(
'./app/storage'
)
var
Config
=
require
(
'./app/config'
)
var
Editor
=
require
(
'./app/editor'
)
var
Renderer
=
require
(
'./app/renderer'
)
var
Compiler
=
require
(
'./app/compiler'
)
...
...
@@ -40,6 +41,7 @@ var run = function () {
var
self
=
this
this
.
event
=
new
EventManager
()
var
storage
=
new
Storage
()
var
config
=
new
Config
(
storage
)
function
loadFiles
(
files
)
{
for
(
var
f
in
files
)
{
...
...
@@ -368,6 +370,7 @@ var run = function () {
// ----------------- resizeable ui ---------------
var
EDITOR_SIZE_KEY
=
'editor-size-cache'
var
EDITOR_WINDOW_SIZE
=
'editorWindowSize'
var
dragging
=
false
$
(
'#dragbar'
).
mousedown
(
function
(
e
)
{
...
...
@@ -405,15 +408,23 @@ var run = function () {
$
(
document
).
unbind
(
'mousemove'
)
dragging
=
false
setEditorSize
(
delta
)
storage
.
set
(
EDITOR_SIZE_KEY
,
delta
)
config
.
set
(
EDITOR_WINDOW_SIZE
,
delta
)
reAdjust
()
}
})
// convert old browser-solidity
if
(
storage
.
exists
(
EDITOR_SIZE_KEY
))
{
setEditorSize
(
storage
.
get
(
EDITOR_SIZE_KEY
))
if
(
!
config
.
exists
(
EDITOR_WINDOW_SIZE
))
{
config
.
set
(
EDITOR_WINDOW_SIZE
,
storage
.
get
(
EDITOR_SIZE_KEY
))
}
storage
.
remove
(
EDITOR_SIZE_KEY
)
}
if
(
config
.
exists
(
EDITOR_WINDOW_SIZE
))
{
setEditorSize
(
config
.
get
(
EDITOR_WINDOW_SIZE
))
}
else
{
storage
.
set
(
EDITOR_SIZE_KEY
,
getEditorSize
())
config
.
set
(
EDITOR_WINDOW_SIZE
,
getEditorSize
())
}
// ----------------- toggle right hand panel -----------------
...
...
@@ -421,7 +432,7 @@ var run = function () {
var
hidingRHP
=
false
$
(
'.toggleRHP'
).
click
(
function
()
{
hidingRHP
=
!
hidingRHP
setEditorSize
(
hidingRHP
?
0
:
storage
.
get
(
EDITOR_SIZE_KEY
))
setEditorSize
(
hidingRHP
?
0
:
config
.
get
(
EDITOR_WINDOW_SIZE
))
$
(
'.toggleRHP i'
).
toggleClass
(
'fa-angle-double-right'
,
!
hidingRHP
)
$
(
'.toggleRHP i'
).
toggleClass
(
'fa-angle-double-left'
,
hidingRHP
)
})
...
...
src/app/config.js
0 → 100644
View file @
a451c5f3
'use strict'
var
utils
=
require
(
'./utils'
)
var
CONFIG_FILE
=
utils
.
fileKey
(
'.browser-solidity.json'
)
function
Config
(
storage
)
{
this
.
items
=
{}
// load on instantiation
try
{
var
config
=
storage
.
get
(
CONFIG_FILE
)
if
(
config
)
{
this
.
items
=
JSON
.
parse
(
config
)
}
}
catch
(
exception
)
{
}
this
.
exists
=
function
(
key
)
{
return
this
.
items
[
key
]
!==
undefined
}
this
.
get
=
function
(
key
)
{
return
this
.
items
[
key
]
}
this
.
set
=
function
(
key
,
content
)
{
this
.
items
[
key
]
=
content
try
{
storage
.
set
(
CONFIG_FILE
,
JSON
.
stringify
(
this
.
items
))
}
catch
(
exception
)
{
}
}
}
module
.
exports
=
Config
src/app/editor.js
View file @
a451c5f3
...
...
@@ -95,7 +95,8 @@ function Editor (loadingFromGist, storage) {
function
getFiles
()
{
var
files
=
[]
storage
.
keys
().
forEach
(
function
(
f
)
{
if
(
utils
.
isCachedFile
(
f
))
{
// NOTE: as a temporary measure do not show the config file in the editor
if
(
utils
.
isCachedFile
(
f
)
&&
(
f
!==
(
utils
.
fileKey
(
'.browser-solidity.json'
))))
{
files
.
push
(
f
)
if
(
!
sessions
[
f
])
sessions
[
f
]
=
newEditorSession
(
f
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment