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
2331f49e
Commit
2331f49e
authored
May 18, 2018
by
serapath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CompileTab: refactor event listeners
parent
81de6acf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
38 deletions
+26
-38
compile-tab.js
src/app/tabs/compile-tab.js
+26
-38
No files found.
src/app/tabs/compile-tab.js
View file @
2331f49e
...
...
@@ -22,48 +22,38 @@ class CompileTab {
self
.
data
=
{
autoCompile
:
self
.
_opts
.
config
.
get
(
'autoCompile'
)
||
false
,
compileTimeout
:
null
,
contractsDetails
:
{}
contractsDetails
:
{},
speed
:
100
}
var
appAPI
=
self
.
_api
var
appEvents
=
self
.
_events
appEvents
.
editor
.
register
(
'contentChanged'
,
()
=>
{
scheduleCompilation
()
})
appEvents
.
editor
.
register
(
'sessionSwitched'
,
()
=>
{
scheduleCompilation
()
})
self
.
_events
.
editor
.
register
(
'contentChanged'
,
scheduleCompilation
)
self
.
_events
.
editor
.
register
(
'sessionSwitched'
,
scheduleCompilation
)
function
scheduleCompilation
()
{
if
(
!
opts
.
config
.
get
(
'autoCompile'
))
{
return
}
if
(
compileTimeout
)
{
window
.
clearTimeout
(
compileTimeout
)
}
compileTimeout
=
window
.
setTimeout
(()
=>
{
appAPI
.
runCompiler
()
},
300
)
}
appEvents
.
compiler
.
register
(
'compilationDuration'
,
function
tabHighlighting
(
speed
)
{
if
(
speed
>
1000
)
{
warnCompilationSlow
.
setAttribute
(
'title'
,
`Last compilation took
${
speed
}
ms. We suggest to turn off autocompilation.`
)
if
(
!
self
.
_opts
.
config
.
get
(
'autoCompile'
))
return
if
(
self
.
data
.
compileTimeout
)
window
.
clearTimeout
(
self
.
data
.
compileTimeout
)
self
.
data
.
compileTimeout
=
window
.
setTimeout
(()
=>
appAPI
.
runCompiler
(),
300
)
}
self
.
_events
.
compiler
.
register
(
'compilationDuration'
,
function
tabHighlighting
(
speed
)
{
if
(
self
.
data
.
speed
>
1000
)
{
var
msg
=
`Last compilation took
${
speed
}
ms. We suggest to turn off autocompilation.`
warnCompilationSlow
.
setAttribute
(
'title'
,
msg
)
warnCompilationSlow
.
style
.
display
=
'inline-block'
}
else
{
warnCompilationSlow
.
style
.
display
=
'none'
}
})
appE
vents
.
editor
.
register
(
'contentChanged'
,
function
changedFile
()
{
self
.
_e
vents
.
editor
.
register
(
'contentChanged'
,
function
changedFile
()
{
var
compileTab
=
document
.
querySelector
(
'.compileView'
)
compileTab
.
style
.
color
=
styles
.
colors
.
red
compileIcon
.
classList
.
add
(
`
${
css
.
bouncingIcon
}
`
)
})
appE
vents
.
compiler
.
register
(
'loadingCompiler'
,
function
start
()
{
self
.
_e
vents
.
compiler
.
register
(
'loadingCompiler'
,
function
start
()
{
compileIcon
.
classList
.
add
(
`
${
css
.
spinningIcon
}
`
)
warnCompilationSlow
.
style
.
display
=
'none'
compileIcon
.
setAttribute
(
'title'
,
'compiler is loading, please wait a few moments.'
)
})
appE
vents
.
compiler
.
register
(
'compilationFinished'
,
function
finish
()
{
self
.
_e
vents
.
compiler
.
register
(
'compilationFinished'
,
function
finish
()
{
var
compileTab
=
document
.
querySelector
(
'.compileView'
)
compileTab
.
style
.
color
=
styles
.
colors
.
black
compileIcon
.
style
.
color
=
styles
.
colors
.
black
...
...
@@ -71,19 +61,19 @@ class CompileTab {
compileIcon
.
classList
.
remove
(
`
${
css
.
bouncingIcon
}
`
)
compileIcon
.
setAttribute
(
'title'
,
'idle'
)
})
appE
vents
.
compiler
.
register
(
'compilationStarted'
,
function
start
()
{
self
.
_e
vents
.
compiler
.
register
(
'compilationStarted'
,
function
start
()
{
errorContainer
.
innerHTML
=
''
compileIcon
.
classList
.
remove
(
`
${
css
.
bouncingIcon
}
`
)
compileIcon
.
classList
.
add
(
`
${
css
.
spinningIcon
}
`
)
compileIcon
.
setAttribute
(
'title'
,
'compiling...'
)
})
appE
vents
.
compiler
.
register
(
'compilerLoaded'
,
function
loaded
()
{
self
.
_e
vents
.
compiler
.
register
(
'compilerLoaded'
,
function
loaded
()
{
compileIcon
.
classList
.
remove
(
`
${
css
.
spinningIcon
}
`
)
compileIcon
.
setAttribute
(
'title'
,
''
)
})
appE
vents
.
compiler
.
register
(
'compilationFinished'
,
function
(
success
,
data
,
source
)
{
self
.
_e
vents
.
compiler
.
register
(
'compilationFinished'
,
function
(
success
,
data
,
source
)
{
// reset the contractMetadata list (used by the publish action)
contractsDetails
=
{}
self
.
data
.
contractsDetails
=
{}
// refill the dropdown list
getContractNames
(
success
,
data
)
// hightlight the tab if error
...
...
@@ -96,27 +86,27 @@ class CompileTab {
var
error
=
false
if
(
data
[
'error'
])
{
error
=
true
opts
.
renderer
.
error
(
data
[
'error'
].
formattedMessage
,
$
(
errorContainer
),
{
type
:
data
[
'error'
].
severity
})
self
.
_
opts
.
renderer
.
error
(
data
[
'error'
].
formattedMessage
,
$
(
errorContainer
),
{
type
:
data
[
'error'
].
severity
})
}
if
(
data
[
'errors'
])
{
if
(
data
[
'errors'
].
length
)
error
=
true
data
[
'errors'
].
forEach
(
function
(
err
)
{
opts
.
renderer
.
error
(
err
.
formattedMessage
,
$
(
errorContainer
),
{
type
:
err
.
severity
})
self
.
_
opts
.
renderer
.
error
(
err
.
formattedMessage
,
$
(
errorContainer
),
{
type
:
err
.
severity
})
})
}
if
(
!
error
)
{
if
(
data
.
contracts
)
{
opts
.
compiler
.
visitContracts
((
contract
)
=>
{
opts
.
renderer
.
error
(
contract
.
name
,
$
(
errorContainer
),
{
type
:
'success'
})
self
.
_
opts
.
compiler
.
visitContracts
((
contract
)
=>
{
self
.
_
opts
.
renderer
.
error
(
contract
.
name
,
$
(
errorContainer
),
{
type
:
'success'
})
})
}
}
})
appE
vents
.
staticAnalysis
.
register
(
'staticAnaysisWarning'
,
(
count
)
=>
{
self
.
_e
vents
.
staticAnalysis
.
register
(
'staticAnaysisWarning'
,
(
count
)
=>
{
if
(
count
)
{
opts
.
renderer
.
error
(
`Static Analysis raised
${
count
}
warning(s) that requires your attention.`
,
$
(
errorContainer
),
{
self
.
_
opts
.
renderer
.
error
(
`Static Analysis raised
${
count
}
warning(s) that requires your attention.`
,
$
(
errorContainer
),
{
type
:
'warning'
,
click
:
()
=>
appAPI
.
switchTab
(
'staticanalysisView'
)
click
:
()
=>
self
.
_api
.
switchTab
(
'staticanalysisView'
)
})
}
})
...
...
@@ -141,8 +131,6 @@ class CompileTab {
appAPI
.
runCompiler
()
})
var
compileTimeout
=
null
// ----------------- autoCompile -----------------
var
autoCompileInput
=
compileContainer
.
querySelector
(
'#autoCompile'
)
var
autoCompile
=
false
...
...
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