summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2016-07-08 16:25:07 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2016-07-08 16:25:07 +0100
commitd2289594fa71196ec04962e7e4b1e55783c7e410 (patch)
tree64b382109101aedd7ca059f2e51fe6e76d170baa
parent2f59e6be3d7871b707a6597ff8d6afa73368f3a4 (diff)
downloadsievely-d2289594fa71196ec04962e7e4b1e55783c7e410.tar.bz2
More tweaks
-rw-r--r--sievely/blocks.js8
-rw-r--r--sievely/funcs.js19
-rw-r--r--sievely/generator.js5
-rw-r--r--sievely/toolbox.xml25
-rw-r--r--templates/index.html7
5 files changed, 53 insertions, 11 deletions
diff --git a/sievely/blocks.js b/sievely/blocks.js
index 92e5a31..8274d01 100644
--- a/sievely/blocks.js
+++ b/sievely/blocks.js
@@ -22,7 +22,7 @@ Sievely.Blocks.HELP_URL = "https://somewhere/sievely";
Blockly.Blocks['sievely_start'] = {
init: function() {
this.appendDummyInput()
- .appendField("When a message arrives:");
+ .appendField("when a message arrives:");
this.setNextStatement(true, null);
this.setColour(Sievely.Blocks.STATEMENT_HUE);
this.setTooltip('');
@@ -178,7 +178,7 @@ Blockly.Blocks['sievely_discard'] = {
Blockly.Blocks['sievely_mark'] = {
init: function() {
this.appendDummyInput()
- .appendField("Mark message as")
+ .appendField("mark message as")
.appendField(new Blockly.FieldDropdown([["already read", "Seen"], ["unread", "!Seen"], ["high priority", "Flagged"], ["normal priority", "!Flagged"], ["already answered", "Answered"], ["unanswered", "!Answered"]]), "MARK");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
@@ -292,7 +292,9 @@ Blockly.Blocks['sievely_group'] = {
this.andor_ = (kind == "ANYOF") ? "or" : "and";
for (var i = 1; i < this.inputList.length; i++) {
var f = this.inputList[i].fieldRow.pop();
- f.dispose();
+ if (f) {
+ f.dispose();
+ }
this.inputList[i].appendField(this.andor_);
}
}
diff --git a/sievely/funcs.js b/sievely/funcs.js
index 847d0b6..76b7fb1 100644
--- a/sievely/funcs.js
+++ b/sievely/funcs.js
@@ -90,7 +90,11 @@ function loadsieve() {
savebutton.classList.add('disabled');
savebutton.innerHTML = "Saved";
console.log("Save button set to saved on load");
- Sievely.lastSieve = Sievely.Generator.workspaceToCode(Sievely.workspace)
+ Sievely.lastSieve = Sievely.Generator.workspaceToCode(Sievely.workspace);
+ savebutton.classList.remove('sievely-hidden');
+ var loadbutton = document.getElementById('input-load');
+ loadbutton.classList.remove('disabled');
+ loadbutton.innerHTML = "Reload";
}
}
x.open("GET", "/1.0/sieve/get", true);
@@ -135,6 +139,19 @@ Sievely.saveSieveToServer = function() {
return false;
}
+Sievely.loadSieveFromServer = function() {
+ var loadbutton = document.getElementById('input-load');
+ if (loadbutton.classList.contains('disabled')) {
+ console.log("Not loading, button is disabled");
+ return false;
+ }
+ loadbutton.classList.add('disabled');
+ loadbutton.innerHTML = "Loading";
+ console.log("Set button to loading...");
+ loadsieve();
+ return false;
+}
+
Sievely.enableSaveButton_ = function() {
var sievestr = Sievely.Generator.workspaceToCode(Sievely.workspace)
var savebutton = document.getElementById('input-save');
diff --git a/sievely/generator.js b/sievely/generator.js
index 3a4fa90..2a14346 100644
--- a/sievely/generator.js
+++ b/sievely/generator.js
@@ -108,7 +108,7 @@ Sievely.Generator['sievely_header_test'] = function(block) {
Sievely.Generator.ORDER_ANY) || '"X-Sievely"';
var content = Sievely.Generator.valueToCode(block, "CONTENT",
Sievely.Generator.ORDER_ANY) || '"unset"';
- var match = block.fieldToValue('MATCH');
+ var match = block.getFieldValue('MATCH');
return ["header " + match + " " + header + " " + content,
Sievely.Generator.ORDER_ANY];
}
@@ -139,7 +139,7 @@ Sievely.Generator['sievely_discard'] = function(block) {
Sievely.Generator['sievely_comment'] = function(block) {
var val = block.getFieldValue('COMMENT');
val = val.replace(/\*\//, "* /")
- return "/* " + val + " */\n";
+ return "\n/* " + val + " */\n\n";
}
Sievely.Generator['sievely_reject'] = function(block) {
@@ -149,7 +149,6 @@ Sievely.Generator['sievely_reject'] = function(block) {
}
Sievely.Generator['controls_if'] = function(block) {
- console.log(block)
var n = 0;
var argument = Sievely.Generator.valueToCode(block, 'IF' + n,
Sievely.Generator.ORDER_ANY) || 'false';
diff --git a/sievely/toolbox.xml b/sievely/toolbox.xml
index d81240c..6e13ba2 100644
--- a/sievely/toolbox.xml
+++ b/sievely/toolbox.xml
@@ -101,4 +101,29 @@
</block>
</category>
</category>
+ <category name="Useful Miscellany">
+ <block type="sievely_comment">
+ </block>
+ <block type="controls_if">
+ <value name="IF0">
+ <block type="sievely_listcheck">
+ <value name="LISTNAME">
+ <shadow type="text">
+ <field name="TEXT">listname.listdomain.com</field>
+ </shadow>
+ </value>
+ </block>
+ </value>
+ <value name="DO0">
+ <block type="sievely_fileinto">
+ <value name="MAILBOX">
+ <block type="sievely_folder"></block>
+ </value>
+ <next>
+ <block type="sievely_stop"></block>
+ </next>
+ </block>
+ </value>
+ </block>
+ </category>
</xml>
diff --git a/templates/index.html b/templates/index.html
index b0968d1..0fef523 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -37,7 +37,7 @@
<body>
- <nav class="navbar navbar-inverse navbar-fixed-top">
+ <nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
@@ -67,14 +67,13 @@
<button id="input-logout" class="btn btn-failure">Sign out</button>
</form>
<div class="navbar-form navbar-right">
- <button id="input-save" class="btn btn-success disabled" onclick="Sievely.saveSieveToServer()">Saved</button>
+ <button id="input-load" class="btn btn-success disabled" onclick="Sievely.loadSieveFromServer()">Loading</button>
+ <button id="input-save" class="btn btn-success disabled sievely-hidden" onclick="Sievely.saveSieveToServer()">Saved</button>
</div>
</div>
</div>
</nav>
- <div class="jumbotron"></div>
-
<div class="container" id="blocklyArea">
</div> <!-- /container -->