Commit 070717a5 authored by Tommy Chan's avatar Tommy Chan

select first bgid in xml as background

parent 5a4cd6ab
......@@ -21,6 +21,8 @@ class File {
const data = ace.edit("XMLCode").getValue();
if (!data) {
dialog.err(window.lang.empty_textarea_error, window.lang.error);
return null;
......@@ -98,9 +100,32 @@ class File {
let editor = ace.edit("XMLCode");
editor.setValue(data, -1);
editor.getSession().setUndoManager(new ace.UndoManager());
let getbgid = data.indexOf("bgid");
let getbgidlast = getPosition(data, 'bgid', 2);
if (getbgid!=0) {
getbgid += 5;
if (getbgid < getbgidlast) {
let foundbgid = "";
for (let i = getbgid; i < getbgidlast-2; i++) {
foundbgid += data.charAt(i);
}
//console.log(foundbgid);
for (let i = 0; i < document.getElementById("bg_selector").length; ++i){
if (document.getElementById("bg_selector").options[i].value == foundbgid){
//bgid found in select option and select it
document.getElementById("bg_selector").value = foundbgid;
}
}
}
}
};
reader.readAsText(file);
}
}
......@@ -4,6 +4,10 @@ const $ = require('jquery');
const dialog = require('dialog');
const Languages = require('./js/Languages.js');
function getPosition(string, subString, index) {
return string.split(subString, index).join(subString).length;
}
$(document).ready(function () {
// Check for API support
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment