Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
47724d97
Commit
47724d97
authored
Jul 05, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add save sketch from web app, added option to electron and fetch name from sketch name input.
parent
d88458fe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
9 deletions
+44
-9
ardublockly/ardublockly.js
ardublockly/ardublockly.js
+18
-4
ardublockly/ardublockly_design.js
ardublockly/ardublockly_design.js
+19
-3
package/electron/app/appmenu.js
package/electron/app/appmenu.js
+7
-2
No files found.
ardublockly/ardublockly.js
View file @
47724d97
...
...
@@ -48,7 +48,7 @@ window.addEventListener('load', function load(event) {
ArduinoMaterial
.
bindActionFunctions_
=
function
()
{
// Navigation buttons
ArduinoMaterial
.
bindClick_
(
'
button_load
'
,
ArduinoMaterial
.
loadUserXmlFile
);
ArduinoMaterial
.
bindClick_
(
'
button_save
'
,
ArduinoMaterial
.
saveXmlFile
);
ArduinoMaterial
.
bindClick_
(
'
button_save
'
,
ArduinoMaterial
.
saveXmlFile
As
);
ArduinoMaterial
.
bindClick_
(
'
button_delete
'
,
ArduinoMaterial
.
discard
);
// Side menu buttons, they also close the side menu
...
...
@@ -57,7 +57,7 @@ ArduinoMaterial.bindActionFunctions_ = function() {
$
(
'
.button-collapse
'
).
sideNav
(
'
hide
'
);
});
ArduinoMaterial
.
bindClick_
(
'
menu_save
'
,
function
()
{
ArduinoMaterial
.
saveXmlFile
();
ArduinoMaterial
.
saveXmlFile
As
();
$
(
'
.button-collapse
'
).
sideNav
(
'
hide
'
);
});
ArduinoMaterial
.
bindClick_
(
'
menu_delete
'
,
function
()
{
...
...
@@ -192,11 +192,25 @@ ArduinoMaterial.loadUserXmlFile = function() {
* Creates an XML file containing the blocks from the Blockly workspace and
* prompts the users to save it into their local file system.
*/
ArduinoMaterial
.
saveXmlFile
=
function
()
{
ArduinoMaterial
.
saveXmlFileAs
=
function
()
{
var
xmlName
=
document
.
getElementById
(
'
sketch_name
'
).
value
;
var
blob
=
new
Blob
(
[
ArduinoMaterial
.
generateXml
()],
{
type
:
'
text/plain;charset=utf-8
'
});
saveAs
(
blob
,
'
ardublockly.xml
'
);
saveAs
(
blob
,
xmlName
+
'
.xml
'
);
};
/**
* Creates an Arduino Sketch file containing the Arduino code generated from
* the Blockly workspace and prompts the users to save it into their local file
* system.
*/
ArduinoMaterial
.
saveSketchFileAs
=
function
()
{
var
sketchName
=
document
.
getElementById
(
'
sketch_name
'
).
value
;
var
blob
=
new
Blob
(
[
ArduinoMaterial
.
generateArduino
()],
{
type
:
'
text/plain;charset=utf-8
'
});
saveAs
(
blob
,
sketchName
+
'
.ino
'
);
};
/**
...
...
ardublockly/ardublockly_design.js
View file @
47724d97
...
...
@@ -200,14 +200,30 @@ ArduinoMaterial.containerFullWidth = function() {
};
/**
* Initialises the sketch name input text
javas
cript to dynamically adjust its
* Initialises the sketch name input text
JavaS
cript to dynamically adjust its
* width to the width of its contents.
*/
ArduinoMaterial
.
sketchNameSizeEffect
=
function
()
{
var
resizeInput
=
function
()
{
$
(
this
).
attr
(
'
size
'
,
$
(
this
).
val
().
length
);
var
inputSize
=
(
$
(
this
).
val
().
length
>
1
)
?
(
$
(
this
).
val
().
length
-
1
)
:
1
;
$
(
this
).
attr
(
'
size
'
,
inputSize
);
};
$
(
'
#sketch_name
'
).
keyup
(
resizeInput
).
each
(
resizeInput
);
var
correctInput
=
function
()
{
// If nothing in the input, add default name
if
(
$
(
this
).
val
()
==
''
)
{
$
(
this
).
val
(
'
Sketch_Name
'
);
$
(
this
).
attr
(
'
size
'
,
10
);
}
// Replace all spaces with underscores
$
(
this
).
val
(
$
(
this
).
val
().
replace
(
/ /g
,
'
_
'
));
};
var
sketchNameInput
=
$
(
'
#sketch_name
'
);
sketchNameInput
.
val
(
'
Sketch_Name
'
);
sketchNameInput
.
attr
(
'
size
'
,
10
);
sketchNameInput
.
keyup
(
resizeInput
).
each
(
resizeInput
);
sketchNameInput
.
blur
(
correctInput
);
};
/**
...
...
package/electron/app/appmenu.js
View file @
47724d97
...
...
@@ -106,12 +106,17 @@ var getFileMenuData = function() {
click
:
function
()
{
BrowserWindow
.
getFocusedWindow
()
.
webContents
.
executeJavaScript
(
"
ArduinoMaterial.saveXmlFile()
"
);
.
executeJavaScript
(
"
ArduinoMaterial.saveXmlFile
As
()
"
);
}
},
{
label
:
'
Save Arduino Sketch as
'
,
accelerator
:
'
Shift+CmdOrCtrl+S
'
,
click
:
functionNotImplemented
click
:
function
()
{
BrowserWindow
.
getFocusedWindow
()
.
webContents
.
executeJavaScript
(
"
ArduinoMaterial.saveSketchFileAs()
"
);
}
}
]
};
...
...
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