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
9e7fe56e
Commit
9e7fe56e
authored
Oct 04, 2015
by
chriseth
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'd11e9-gh-pages' into preservePreviousContent
Conflicts: index.html
parents
ec718645
ad567503
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
190 additions
and
8 deletions
+190
-8
ballot.sol.js
ballot.sol.js
+1
-0
index.html
index.html
+134
-7
browser-solidity.css
stylesheets/browser-solidity.css
+55
-1
No files found.
ballot.sol.js
View file @
9e7fe56e
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
var
multi
=
function
(
func
)
{
return
func
.
toString
().
match
(
/
[^]
*
\/\*([^]
*
)\*\/\}
$/
)[
1
];
}
var
multi
=
function
(
func
)
{
return
func
.
toString
().
match
(
/
[^]
*
\/\*([^]
*
)\*\/\}
$/
)[
1
];
}
var
BALLOT_EXAMPLE
=
multi
(
function
(){
/*contract Ballot {
var
BALLOT_EXAMPLE
=
multi
(
function
(){
/*contract Ballot {
struct Voter {
struct Voter {
uint weight;
uint weight;
bool voted;
bool voted;
...
...
index.html
View file @
9e7fe56e
...
@@ -50,6 +50,9 @@ THE SOFTWARE.
...
@@ -50,6 +50,9 @@ THE SOFTWARE.
<div
id=
"editor"
>
<div
id=
"editor"
>
<div
id=
"files"
>
<span
class=
"newFile"
title=
"New File"
>
+
</span>
</div>
<div
id=
"input"
></div>
<div
id=
"input"
></div>
</div>
</div>
...
@@ -79,20 +82,121 @@ THE SOFTWARE.
...
@@ -79,20 +82,121 @@ THE SOFTWARE.
// ----------------- editor ----------------------
// ----------------- editor ----------------------
var
SOL_CACHE_KEY
=
"sol-cache"
;
var
SOL_CACHE_FILE
=
"Untitled"
var
SOL_CACHE_FILES_KEY
=
"sol-cache-files"
;
var
editor
=
ace
.
edit
(
"input"
);
var
editor
=
ace
.
edit
(
"input"
);
var
session
=
editor
.
getSession
();
var
session
=
editor
.
getSession
();
var
Range
=
ace
.
require
(
'ace/range'
).
Range
;
var
Range
=
ace
.
require
(
'ace/range'
).
Range
;
var
errMarkerId
=
null
;
var
errMarkerId
=
null
;
var
solCache
=
window
.
localStorage
.
getItem
(
SOL_CACHE_KEY
);
var
solFiles
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
SOL_CACHE_FILES_KEY
)
)
||
[
SOL_CACHE_FILE
];
editor
.
setValue
(
solCache
||
BALLOT_EXAMPLE
,
1
);
if
(
solFiles
.
length
===
0
)
solFiles
=
[
SOL_CACHE_FILE
];
window
.
localStorage
.
setItem
(
SOL_CACHE_FILES_KEY
,
JSON
.
stringify
(
solFiles
)
);
var
solCache
=
window
.
localStorage
.
getItem
(
SOL_CACHE_FILE
)
||
BALLOT_EXAMPLE
;
window
.
localStorage
.
setItem
(
SOL_CACHE_FILE
,
solCache
)
editor
.
setValue
(
solCache
,
1
);
session
.
setMode
(
"ace/mode/javascript"
);
session
.
setMode
(
"ace/mode/javascript"
);
session
.
setTabSize
(
4
);
session
.
setTabSize
(
4
);
session
.
setUseSoftTabs
(
true
);
session
.
setUseSoftTabs
(
true
);
// ----------------- file selector-------------
var
count
=
0
;
var
$filesEl
=
$
(
'#files'
);
$filesEl
.
on
(
'click'
,
'.newFile'
,
function
(){
count
++
;
var
name
=
'Unititled'
+
count
;
solFiles
.
push
(
name
)
SOL_CACHE_FILE
=
name
;
window
.
localStorage
.
setItem
(
SOL_CACHE_FILES_KEY
,
JSON
.
stringify
(
solFiles
)
);
window
.
localStorage
.
setItem
(
SOL_CACHE_FILE
,
''
);
updateFiles
();
})
$filesEl
.
on
(
'click'
,
'.file:not(.active)'
,
showFileHandler
)
$filesEl
.
on
(
'click'
,
'.file.active'
,
function
(
ev
){
var
$fileTabEl
=
$
(
this
)
var
originalName
=
$fileTabEl
.
find
(
'.name'
).
text
()
ev
.
preventDefault
()
if
(
$
(
this
).
find
(
'input'
).
length
>
0
)
return
false
;
var
$fileNameInputEl
=
$
(
'<input value="'
+
originalName
+
'"/>'
);
$fileTabEl
.
html
(
$fileNameInputEl
)
$fileNameInputEl
.
focus
()
$fileNameInputEl
.
select
()
$fileNameInputEl
.
on
(
'blur'
,
handleRename
)
$fileNameInputEl
.
keyup
(
handleRename
);
function
handleRename
(
ev
)
{
ev
.
preventDefault
()
if
(
ev
.
which
&&
ev
.
which
!==
13
)
return
false
;
var
newName
=
ev
.
target
.
value
;
var
$new
=
null
if
(
newName
!==
originalName
&&
confirm
(
"Are you sure you want to rename: "
+
originalName
+
" to "
+
newName
+
'?'
))
{
solFiles
.
splice
(
solFiles
.
indexOf
(
originalName
),
1
,
newName
);
window
.
localStorage
.
setItem
(
newName
,
window
.
localStorage
.
getItem
(
originalName
)
);
window
.
localStorage
.
setItem
(
SOL_CACHE_FILES_KEY
,
JSON
.
stringify
(
solFiles
)
);
window
.
localStorage
.
removeItem
(
originalName
)
SOL_CACHE_FILE
=
newName
;
}
updateFiles
()
return
false
;
}
return
false
;
})
$filesEl
.
on
(
'click'
,
'.file .remove'
,
function
(
ev
){
ev
.
preventDefault
();
var
name
=
$
(
this
).
parent
().
find
(
'.name'
).
text
()
if
(
confirm
(
"Are you sure you want to remove: "
+
name
+
" from local storage?"
))
{
var
index
=
solFiles
.
indexOf
(
name
);
solFiles
.
splice
(
index
,
1
);
window
.
localStorage
.
setItem
(
SOL_CACHE_FILES_KEY
,
JSON
.
stringify
(
solFiles
)
);
SOL_CACHE_FILE
=
solFiles
[
Math
.
max
(
0
,
index
-
1
)]
window
.
localStorage
.
removeItem
(
name
)
updateFiles
()
}
return
false
;
});
function
showFileHandler
(
ev
)
{
ev
.
preventDefault
()
SOL_CACHE_FILE
=
$
(
this
).
find
(
'.name'
).
text
();
updateFiles
()
return
false
;
}
function
fileTabFromName
(
name
)
{
return
$
(
'#files .file'
).
filter
(
function
(){
return
$
(
this
).
find
(
'.name'
).
text
()
==
name
;
})
}
function
updateFiles
()
{
$filesEl
.
find
(
'.file'
).
remove
()
for
(
var
f
in
solFiles
)
{
if
(
solFiles
[
f
])
$filesEl
.
append
(
fileTabTemplate
(
solFiles
[
f
])
);
}
var
active
=
fileTabFromName
(
SOL_CACHE_FILE
);
active
.
addClass
(
'active'
)
editor
.
setValue
(
window
.
localStorage
.
getItem
(
SOL_CACHE_FILE
)
||
''
,
1
);
$
(
'#input'
).
toggle
(
typeof
SOL_CACHE_FILE
===
'string'
)
}
function
fileTabTemplate
(
name
){
return
$
(
'<span class="file"><span class="name">'
+
name
+
'</span><span class="remove">x</span></span>'
);
}
SOL_CACHE_FILE
=
solFiles
[
0
]
updateFiles
();
// ----------------- version selector-------------
// ----------------- version selector-------------
// var soljsonSources is provided by bin/list.js
// var soljsonSources is provided by bin/list.js
...
@@ -183,14 +287,19 @@ THE SOFTWARE.
...
@@ -183,14 +287,19 @@ THE SOFTWARE.
var
previousInput
=
''
;
var
previousInput
=
''
;
var
sourceAnnotations
=
[];
var
sourceAnnotations
=
[];
var
compile
=
function
()
{
var
compile
=
function
()
{
editor
.
getSession
().
clearAnnotations
();
editor
.
getSession
().
clearAnnotations
();
sourceAnnotations
=
[];
sourceAnnotations
=
[];
editor
.
getSession
().
removeMarker
(
errMarkerId
);
editor
.
getSession
().
removeMarker
(
errMarkerId
);
$
(
'#output'
).
empty
();
$
(
'#output'
).
empty
();
var
input
=
editor
.
getValue
();
var
input
=
editor
.
getValue
();
window
.
localStorage
.
setItem
(
SOL_CACHE_FILE
,
input
);
var
inputIncludingImports
=
includeLocalImports
(
input
);
var
optimize
=
document
.
querySelector
(
'#optimize'
).
checked
;
var
optimize
=
document
.
querySelector
(
'#optimize'
).
checked
;
try
{
try
{
var
data
=
$
.
parseJSON
(
compileJSON
(
input
,
optimize
?
1
:
0
));
var
data
=
$
.
parseJSON
(
compileJSON
(
inputIncludingImports
,
optimize
?
1
:
0
));
}
catch
(
exception
)
{
}
catch
(
exception
)
{
renderError
(
"Uncaught JavaScript Exception:
\
n"
+
exception
);
renderError
(
"Uncaught JavaScript Exception:
\
n"
+
exception
);
return
;
return
;
...
@@ -205,11 +314,12 @@ THE SOFTWARE.
...
@@ -205,11 +314,12 @@ THE SOFTWARE.
renderContracts
(
data
,
input
);
renderContracts
(
data
,
input
);
}
}
var
compileTimeout
=
null
;
var
compileTimeout
=
null
;
var
onChange
=
function
()
{
var
onChange
=
function
()
{
var
input
=
editor
.
getValue
();
var
input
=
editor
.
getValue
();
if
(
input
===
""
)
{
if
(
input
===
""
)
{
window
.
localStorage
.
setItem
(
SOL_CACHE_KEY
,
''
)
window
.
localStorage
.
setItem
(
SOL_CACHE_FILE
,
''
)
return
;
return
;
}
}
if
(
input
===
previousInput
)
if
(
input
===
previousInput
)
...
@@ -225,6 +335,25 @@ THE SOFTWARE.
...
@@ -225,6 +335,25 @@ THE SOFTWARE.
previousInput
=
''
;
previousInput
=
''
;
onChange
();
onChange
();
};
};
function
includeLocalImports
(
input
)
{
var
importRegex
=
/import
\s[\'\"]([^\'\"]
+
)[\'\"]
;/g
var
imports
=
[];
var
matches
=
[];
var
match
;
while
((
match
=
importRegex
.
exec
(
input
))
!==
null
)
{
if
(
match
[
1
]
&&
solFiles
.
indexOf
(
match
[
1
])
!==
-
1
)
{
imports
.
push
(
match
[
1
]
)
matches
.
push
(
match
[
0
]
)
}
}
for
(
var
i
in
imports
)
{
imported
=
includeLocalImports
(
window
.
localStorage
.
getItem
(
imports
[
i
]
)
)
input
=
input
.
replace
(
matches
[
i
],
imported
);
}
return
input
;
}
if
(
Module
)
if
(
Module
)
onCompilerLoaded
();
onCompilerLoaded
();
...
@@ -288,8 +417,6 @@ THE SOFTWARE.
...
@@ -288,8 +417,6 @@ THE SOFTWARE.
};
};
var
renderContracts
=
function
(
data
,
source
)
{
var
renderContracts
=
function
(
data
,
source
)
{
window
.
localStorage
.
setItem
(
SOL_CACHE_KEY
,
source
);
$
(
'#output'
).
empty
();
$
(
'#output'
).
empty
();
for
(
var
contractName
in
data
.
contracts
)
{
for
(
var
contractName
in
data
.
contracts
)
{
var
contract
=
data
.
contracts
[
contractName
];
var
contract
=
data
.
contracts
[
contractName
];
...
...
stylesheets/browser-solidity.css
View file @
9e7fe56e
...
@@ -10,12 +10,66 @@ body {
...
@@ -10,12 +10,66 @@ body {
width
:
auto
;
width
:
auto
;
bottom
:
0px
;
bottom
:
0px
;
right
:
37em
;
right
:
37em
;
}
#files
{
font-size
:
15px
;
height
:
2.5em
;
box-sizing
:
border-box
;
line-height
:
2em
;
padding
:
0.5em
0.5em
0
;
}
#files
.file
,
#files
.newFile
{
display
:
inline-block
;
padding
:
0
0.6em
;
box-sizing
:
border-box
;
background-color
:
#f0f0f0
;
cursor
:
pointer
;
margin-right
:
0.5em
;
position
:
relative
;
}
#files
.newFile
{
background-color
:
#B1EAC5
;
font-weight
:
bold
;
color
:
#4E775D
;
}
#files
.file.active
{
font-weight
:
bold
;
border-bottom
:
0
none
;
padding-right
:
2.5em
;
}
}
#files
.file
.remove
{
position
:
absolute
;
right
:
0
;
top
:
0
;
height
:
1.25em
;
width
:
1.25em
;
line-height
:
1em
;
border-radius
:
1em
;
color
:
#FF8080
;
display
:
none
;
margin
:
0.4em
;
text-align
:
center
;
}
#files
.file
input
{
background-color
:
transparent
;
border
:
0
none
;
border-bottom
:
1px
dotted
black
;
line-height
:
1em
;
margin
:
0.5em
0
;
}
#files
.file.active
.remove
{
display
:
inline-block
;
}
#input
{
#input
{
font-size
:
15px
;
font-size
:
15px
;
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
2.5em
;
left
:
0
;
left
:
0
;
right
:
0
;
right
:
0
;
bottom
:
0
;
bottom
:
0
;
...
...
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