Skip to content

Commit

Permalink
Merge pull request #538 from Lexpedite/javascript_warnings
Browse files Browse the repository at this point in the history
Javascript warnings
  • Loading branch information
Gauntlet173 authored May 9, 2023
2 parents 3251dab + eba385e commit e4e9945
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 36 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ As of v0.2-alpha, this project is attempting to adhere to [Semantic Versioning](
While alpha, however, any version may include breaking changes that may not be specifically noted as such,
and breaking changes will not necessarily result in changes to the main version number.

## [v1.6.13-alpha](https://github.com/Lexpedite/blawx/releases/tag/v1.6.13-alpha) 2023-05-09

### Fixes
* Favicon works properly
* JSON errors no longer occur in test editor
* Blockly warnings no longer occur in test editor and code editor

## [v1.6.12-alpha](https://github.com/Lexpedite/blawx/releases/tag/v1.6.12-alpha) 2023-05-09

This release chances how code is generated for projects. To upgrade existing files you may need to
Expand Down
2 changes: 1 addition & 1 deletion blawx/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pathlib import Path

# For adding a version identifier
BLAWX_VERSION = "v1.6.12-alpha"
BLAWX_VERSION = "v1.6.13-alpha"


# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down
2 changes: 1 addition & 1 deletion blawx/static/blawx/blawx-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5461,7 +5461,7 @@ function getKnownCategories() {
// Go through the blocks in the workspace.
// If the block is an object declaration, add the relevant block to the xml
if (all_workspaces[w].xml_content) {
var domObject = Blockly.Xml.textToDom(all_workspaces[w].xml_content);
var domObject = Blockly.utils.xml.textToDom(all_workspaces[w].xml_content);
var tempWorkspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(domObject, tempWorkspace);
var blockList = tempWorkspace.getAllBlocks();
Expand Down
13 changes: 7 additions & 6 deletions blawx/static/blawx/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ runCode = function(button) {
run_xhttp.open("POST", "run/", true);
run_xhttp.setRequestHeader('Content-type', 'application/json');
run_xhttp.setRequestHeader('X-CSRFToken', csrftoken);
run_xhttp.onreadystatechange = function() {
run_xhttp.onload = function() {
//console.log("Response Length: " + this.responseText.length)
output_object = JSON.parse(this.responseText);
// console.log(output_object);
if (output_object.error) {
Expand Down Expand Up @@ -381,7 +382,7 @@ function loadBlocksFile(element) {
var file = element.files[0];
var fr = new FileReader();
fr.onload = function (event) {
var xml = Blockly.Xml.textToDom(event.target.result);
var xml = Blockly.utils.xml.textToDom(event.target.result);
demoWorkspace.clear();
Blockly.Xml.domToWorkspace(xml, demoWorkspace);
};
Expand All @@ -397,7 +398,7 @@ try {
var file = element.files[0];
var fr = new FileReader();
fr.onload = function (event) {
var xml = Blockly.Xml.textToDom(event.target.result);
var xml = Blockly.utils.xml.textToDom(event.target.result);
importWorkspace.clear();
Blockly.Xml.domToWorkspace(xml, importWorkspace);
};
Expand All @@ -418,7 +419,7 @@ getExample = function(example_pk){
xhttp.onreadystatechange = function() {
output_object = JSON.parse(this.responseText);
demoWorkspace.clear();
xml = Blockly.Xml.textToDom(output_object.xml_content);
xml = Blockly.utils.xml.textToDom(output_object.xml_content);
Blockly.Xml.domToWorkspace(xml, demoWorkspace);
}
xhttp.send();
Expand All @@ -441,7 +442,7 @@ load_section_workspace = function(ruledoc_id,workspace_id) {
if (this.responseText) {
output_object = JSON.parse(this.responseText);
if (output_object.xml_content) {
xml = Blockly.Xml.textToDom(output_object.xml_content);
xml = Blockly.utils.xml.textToDom(output_object.xml_content);
Blockly.Xml.domToWorkspace(xml, demoWorkspace);
}
}
Expand All @@ -467,7 +468,7 @@ load_test_workspace = function(ruledoc_id,test_name) {
if (this.responseText) {
output_object = JSON.parse(this.responseText);
if (output_object.xml_content) {
xml = Blockly.Xml.textToDom(output_object.xml_content);
xml = Blockly.utils.xml.textToDom(output_object.xml_content);
Blockly.Xml.domToWorkspace(xml, demoWorkspace);
}
}
Expand Down
54 changes: 27 additions & 27 deletions blawx/static/blawx/drawers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ knownAttributesCallback = function(workspace) {
// Go through the blocks in the workspace.
// If the block is an object declaration, add the relevant block to the xml
if (all_workspaces[w].xml_content) {
var domObject = Blockly.Xml.textToDom(all_workspaces[w].xml_content);
var domObject = Blockly.utils.xml.textToDom(all_workspaces[w].xml_content);
var tempWorkspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(domObject, tempWorkspace);
var blockList = tempWorkspace.getAllBlocks();
Expand All @@ -29,7 +29,7 @@ knownAttributesCallback = function(workspace) {
} else { // all other attribute types use a binary attribute selector
var blockText = "<xml><block type='attribute_selector'><mutation xmlns='http://www.w3.org/1999/xhtml' attributename='" + attribute_name + "' attributetype='" + attribute_type + "' attributeorder='" + dropdown_order + "'></mutation><field name='prefix'>" + text_prefix + "</field><field name='infix'>" + text_infix + "</field><field name='postfix'>" + text_postfix + "</field></block></xml>";
}
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// need to check for repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -53,7 +53,7 @@ knownAttributesCallback = function(workspace) {
} else { // all other attribute types use a binary attribute selector
var blockText = "<xml><block type='attribute_selector'><mutation xmlns='http://www.w3.org/1999/xhtml' attributename='" + attribute_name + "' attributetype='" + attribute_type + "' attributeorder='" + dropdown_order + "'></mutation><field name='prefix'>" + text_prefix + "</field><field name='infix'>" + text_infix + "</field><field name='postfix'>" + text_postfix + "</field></block></xml>";
}
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// need to check for repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -72,7 +72,7 @@ knownRelationshipsCallback = function(workspace) {
// Go through the blocks in the workspace.
// If the block is a relationship declaration, add the relevant block to the xml
if (all_workspaces[w].xml_content) {
var domObject = Blockly.Xml.textToDom(all_workspaces[w].xml_content);
var domObject = Blockly.utils.xml.textToDom(all_workspaces[w].xml_content);
var tempWorkspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(domObject, tempWorkspace);
var blockList = tempWorkspace.getAllBlocks();
Expand Down Expand Up @@ -102,7 +102,7 @@ knownRelationshipsCallback = function(workspace) {
}
blockText += "<field name='postfix'>" + blockList[i].getFieldValue("postfix") + "</field>";
blockText += "</block></xml>";
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// need to check for repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -122,7 +122,7 @@ knownObjectsCallback = function(workspace) {
// Go through the blocks in the workspace.
// If the block is an object declaration, add the relevant block to the xml
if (all_workspaces[w].xml_content) {
var domObject = Blockly.Xml.textToDom(all_workspaces[w].xml_content);
var domObject = Blockly.utils.xml.textToDom(all_workspaces[w].xml_content);
var tempWorkspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(domObject, tempWorkspace);
var blockList = tempWorkspace.getAllBlocks();
Expand All @@ -131,15 +131,15 @@ knownObjectsCallback = function(workspace) {
// Get the name of the entity, insert a block of that type,
var object_name = blockList[i].getFieldValue('object_name');
var blockText = "<xml><block type='object_selector'><field name='object_name'>" + object_name+"</field></block></xml>"
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
// UPDATE THIS WHEN I SWITCH TO INPUTS.
if (blockList[i].type == "data_dictionary") {
var entity_name = blockList[i].getFieldValue('dictionary_name');
var blockText = "<xml><block type='object_selector'><field name='objectName'>" + entity_name+"</field></block></xml>"
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -153,15 +153,15 @@ knownObjectsCallback = function(workspace) {
// Get the name of the entity, insert a block of that type,
var object_name = blockList[i].getFieldValue('object_name');
var blockText = "<xml><block type='object_selector'><field name='object_name'>" + object_name+"</field></block></xml>"
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
// UPDATE THIS WHEN I CHANGE TO INPUTS.
if (blockList[i].type == "data_dictionary") {
var entity_name = blockList[i].getFieldValue('dictionary_name');
var blockText = "<xml><block type='object_selector'><field name='objectName'>" + entity_name+"</field></block></xml>"
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -182,7 +182,7 @@ knownCategoriesCallback = function(workspace) {
// Go through the blocks in the workspace.
// If the block is an object declaration, add the relevant block to the xml
if (all_workspaces[w].xml_content) {
var domObject = Blockly.Xml.textToDom(all_workspaces[w].xml_content);
var domObject = Blockly.utils.xml.textToDom(all_workspaces[w].xml_content);
var tempWorkspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(domObject, tempWorkspace);
var blockList = tempWorkspace.getAllBlocks();
Expand All @@ -192,7 +192,7 @@ knownCategoriesCallback = function(workspace) {
// Get the name of the entity, insert a block of that type,
var category_name = blockList[i].getFieldValue('category_name');
var blockText = "<xml><block type='category_selector'><field name='category_name'>" + category_name + "</field></block></xml>"
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -207,7 +207,7 @@ knownCategoriesCallback = function(workspace) {
// Get the name of the entity, insert a block of that type,
var category_name = blockList[i].getFieldValue('category_name');
var blockText = "<xml><block type='category_selector'><field name='category_name'>" + category_name + "</field></block></xml>"
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -229,7 +229,7 @@ newObjectCallback = function(workspace) {
// Go through the blocks in the workspace.
// If the block is an object declaration, add the relevant block to the xml
if (all_workspaces[w].xml_content) {
var domObject = Blockly.Xml.textToDom(all_workspaces[w].xml_content);
var domObject = Blockly.utils.xml.textToDom(all_workspaces[w].xml_content);
var tempWorkspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(domObject, tempWorkspace);
var blockList = tempWorkspace.getAllBlocks();
Expand All @@ -240,7 +240,7 @@ newObjectCallback = function(workspace) {
var text_prefix = blockList[i].getFieldValue('prefix');
var text_postfix = blockList[i].getFieldValue('postfix');
var blockText = "<xml><block type='object_declaration'><mutation xmlns='http://www.w3.org/1999/xhtml' category_name='" + category_name + "'></mutation><field name='prefix'>" + text_prefix + "</field><field name='postfix'>" + text_postfix + "</field></block></xml>";
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -256,7 +256,7 @@ newObjectCallback = function(workspace) {
var text_prefix = blockList[i].getFieldValue('prefix');
var text_postfix = blockList[i].getFieldValue('postfix');
var blockText = "<xml><block type='object_declaration'><mutation xmlns='http://www.w3.org/1999/xhtml' category_name='" + category_name + "'></mutation><field name='prefix'>" + text_prefix + "</field><field name='postfix'>" + text_postfix + "</field></block></xml>";
var block = Blockly.Xml.textToDom(blockText).firstChild;
var block = Blockly.utils.xml.textToDom(blockText).firstChild;
// Need to add check to make sure I'm not repeatedly adding the same block.
xmlList.push(block);
}
Expand All @@ -265,11 +265,11 @@ newObjectCallback = function(workspace) {
}

var objectEqualityBlockText = '<xml><block type="object_equality"></block></xml>';
var objectEqualityBlock = Blockly.Xml.textToDom(objectEqualityBlockText).firstChild;
var objectEqualityBlock = Blockly.utils.xml.textToDom(objectEqualityBlockText).firstChild;
var objectDisequalityBlockText = '<xml><block type="object_disequality"></block></xml>';
var objectDisequalityBlock = Blockly.Xml.textToDom(objectDisequalityBlockText).firstChild;
var objectDisequalityBlock = Blockly.utils.xml.textToDom(objectDisequalityBlockText).firstChild;
var objectCategoryBlockText = '<xml><block type="new_object_category"></block></xml>';
var objectCategoryBlock = Blockly.Xml.textToDom(objectCategoryBlockText).firstChild;
var objectCategoryBlock = Blockly.utils.xml.textToDom(objectCategoryBlockText).firstChild;
xmlList.push(objectEqualityBlock);
xmlList.push(objectDisequalityBlock);
xmlList.push(objectCategoryBlock);
Expand Down Expand Up @@ -310,7 +310,7 @@ knownRulesCallback = function(workspace) {
// var blocktypes = ['scope']
// for (var i = 0; i < blocktypes.length; i++) {
// var blocktext = '<xml><block type="' + blocktypes[i] + '"></block></xml>';
// var block = Blockly.Xml.textToDom(blocktext).firstChild;
// var block = Blockly.utils.xml.textToDom(blocktext).firstChild;
// xmlList.push(block);
// }

Expand Down Expand Up @@ -339,7 +339,7 @@ knownRulesCallback = function(workspace) {
blocktext += "</field>"
blocktext += '<mutation xmlns="http://www.w3.org/1999/xhtml" section_reference="' + raw_id + '"></mutation>'
blocktext += "</block></xml>"
var block = Blockly.Xml.textToDom(blocktext).firstChild;
var block = Blockly.utils.xml.textToDom(blocktext).firstChild;
xmlList.push(block);
// if (sections[i].attributes.eid.value.startsWith('sec')) {
// var short_ref = sections[i].attributes.eid.value;
Expand All @@ -348,7 +348,7 @@ knownRulesCallback = function(workspace) {
// short_ref = short_ref.replace("__para_",".");
// short_ref = short_ref.replace("__subpara_",".");
// var blocktext = '<xml><block type="doc_selector"><field name="doc_part_name">' + abbreviation + " " + short_ref + '</field></block></xml>';
// var block = Blockly.Xml.textToDom(blocktext).firstChild;
// var block = Blockly.utils.xml.textToDom(blocktext).firstChild;
// xmlList.push(block);
// // console.log("Pushing " + blocktext);
// }
Expand All @@ -365,7 +365,7 @@ primaryDrawerCallback = function(workspace) {
var xmlList = [];
for (var i = 0; i < blocktypes.length; i++) {
var blocktext = '<xml><block type="' + blocktypes[i] + '"></block></xml>';
var block = Blockly.Xml.textToDom(blocktext).firstChild;
var block = Blockly.utils.xml.textToDom(blocktext).firstChild;
xmlList.push(block);
}
// console.log("Creating drawer using " + blocktext)
Expand All @@ -385,26 +385,26 @@ primaryDrawerCallback = function(workspace) {
</block>\
</value>\
</block></xml>';
var queryblock = Blockly.Xml.textToDom(querytext).firstChild;
var queryblock = Blockly.utils.xml.textToDom(querytext).firstChild;
xmlList.push(queryblock)
}
var blocktypes = ['unattributed_constraint','query']
for (var i = 0; i < blocktypes.length; i++) {
var blocktext = '<xml><block type="' + blocktypes[i] + '"></block></xml>';
var block = Blockly.Xml.textToDom(blocktext).firstChild;
var block = Blockly.utils.xml.textToDom(blocktext).firstChild;
xmlList.push(block);
}
// var querytext = '<xml><block type="query">\
// <statement name="query">\
// <block type="holds"></block>\
// </statement>\
// </block></xml>';
// var queryblock = Blockly.Xml.textToDom(querytext).firstChild;
// var queryblock = Blockly.utils.xml.textToDom(querytext).firstChild;
// xmlList.push(queryblock)
var blocktypes = ['assume','json_textfield']
for (var i = 0; i < blocktypes.length; i++) {
var blocktext = '<xml><block type="' + blocktypes[i] + '"></block></xml>';
var block = Blockly.Xml.textToDom(blocktext).firstChild;
var block = Blockly.utils.xml.textToDom(blocktext).firstChild;
xmlList.push(block);
}
return xmlList
Expand Down
2 changes: 1 addition & 1 deletion blawx/static/blawx/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function createImportListener(event) {
request.send(null);
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
var xml = Blockly.Xml.textToDom(request.responseText);
var xml = Blockly.utils.xml.textToDom(request.responseText);
Blockly.Xml.domToWorkspace(xml, importSpace);
}
}
Expand Down
1 change: 1 addition & 0 deletions blawx/templates/base2.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<link href="{% static 'blawx/fonts.css' %}" rel="stylesheet">
<script src="{% static 'blawx/jquery.min.js' %}"></script>
<link rel="stylesheet" href="{% static 'blawx/bootstrap.min.css' %}">
<link rel="shortcut icon" href="{% static 'blawx/favicon.ico' %}" type="image/x-icon" />
<script src="{% static 'blawx/bootstrap.bundle.min.js' %}"></script>
{% block head_extras %}
{% endblock head_extras %}
Expand Down

0 comments on commit e4e9945

Please sign in to comment.