fix live mining page
This commit is contained in:
1 parent
8814bf4b10
commit
6586851348
3 files changed
+14
-17
No files matched your search
+8
-11
@@ -75,6 +75,8 @@ function add_field(fieldname, preselect="")
|
||||
document.getElementById("containfields").appendChild(div);
|
||||
}
|
||||
|
||||
var __host = "http://127.0.0.1:8765";
|
||||
|
||||
function saveConfig()
|
||||
{
|
||||
let mappings = new Array();
|
||||
@@ -89,7 +91,6 @@ function saveConfig()
|
||||
"livemining_deckname": document.querySelector("#deckname").value,
|
||||
"livemining_modelname": document.querySelector("#modelname").value,
|
||||
"livemining_fields": mappings,
|
||||
"livemining_host2": "http://127.0.0.1:8765"
|
||||
};
|
||||
console.log(setstuff);
|
||||
browser.storage.local.set(setstuff);
|
||||
@@ -97,7 +98,7 @@ function saveConfig()
|
||||
|
||||
function loadConfig()
|
||||
{
|
||||
let promise = browser.storage.local.get(["livemining_deckname", "livemining_modelname", "livemining_fields", "livemining_host2"]);
|
||||
let promise = browser.storage.local.get(["livemining_deckname", "livemining_modelname", "livemining_fields"]);
|
||||
promise.then((storage) =>
|
||||
{
|
||||
if(storage["livemining_deckname"] !== undefined)
|
||||
@@ -105,8 +106,9 @@ function loadConfig()
|
||||
if(storage["livemining_modelname"] !== undefined)
|
||||
document.querySelector("#modelname").value = storage["livemining_modelname"];
|
||||
reset_fields();
|
||||
for(let pair of storage["livemining_fields"])
|
||||
add_field(pair[0], pair[1]);
|
||||
if(storage["livemining_fields"] !== undefined)
|
||||
for(let pair of storage["livemining_fields"])
|
||||
add_field(pair[0], pair[1]);
|
||||
}, (e) => {console.log(e);});
|
||||
}
|
||||
|
||||
@@ -115,8 +117,6 @@ function buildpage()
|
||||
{
|
||||
document.getElementById("autofields").onclick = (e) =>
|
||||
{
|
||||
let host = "http://127.0.0.1:8765";
|
||||
|
||||
let request = JSON.parse(`
|
||||
{"action":"modelFieldNames",
|
||||
"version":6,
|
||||
@@ -128,7 +128,7 @@ function buildpage()
|
||||
console.log(json);
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", host, true);
|
||||
xhr.open("POST", __host, true);
|
||||
//xhr.setRequestHeader('Content-type','application/json; charset=utf-8');
|
||||
xhr.addEventListener('load', () =>
|
||||
{
|
||||
@@ -165,7 +165,6 @@ function buildpage()
|
||||
};
|
||||
|
||||
document.getElementById("applyfields").onclick = saveConfig;
|
||||
document.getElementById("host").onclick = saveConfig;
|
||||
|
||||
loadConfig();
|
||||
|
||||
@@ -173,14 +172,12 @@ function buildpage()
|
||||
|
||||
document.getElementById("upgrade").onclick = (e) =>
|
||||
{
|
||||
let host = document.getElementById("host").value;
|
||||
|
||||
let json = `
|
||||
{"action":"upgrade",
|
||||
"version":6
|
||||
}`;
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", host, true);
|
||||
xhr.open("POST", __host, true);
|
||||
xhr.send(json);
|
||||
xhr.addEventListener('load', () =>
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "nazeka",
|
||||
"version": "0.4.4",
|
||||
"version": "0.4.5",
|
||||
"author": "Wareya",
|
||||
"homepage_url": "https://github.com/wareya/nazeka",
|
||||
"description": "A rikai replacement.",
|
||||
|
||||
+5
-5
@@ -2199,14 +2199,14 @@ function send_ankiconnect_command(host, command)
|
||||
browser.runtime.sendMessage({type:"ankiconnect_mine", host:host, command:json});
|
||||
}
|
||||
|
||||
var __host = "http://127.0.0.1:8765"
|
||||
|
||||
async function mine_to_ankiconnect_with_base64_audio(object, audiofname, audiodata)
|
||||
{
|
||||
let object_keys = Object.keys(object);
|
||||
let promise = browser.storage.local.get(["livemining_deckname", "livemining_modelname", "livemining_fields", "livemining_host2"]);
|
||||
let promise = browser.storage.local.get(["livemining_deckname", "livemining_modelname", "livemining_fields"]);
|
||||
promise.then((storage) =>
|
||||
{
|
||||
if(storage["livemining_host2"] === undefined)
|
||||
storage["livemining_host2"] = "http://127.0.0.1:8765";
|
||||
if(storage["livemining_deckname"] === undefined)
|
||||
storage["livemining_deckname"] = "Default";
|
||||
if(storage["livemining_modelname"] === undefined)
|
||||
@@ -2250,7 +2250,7 @@ async function mine_to_ankiconnect_with_base64_audio(object, audiofname, audioda
|
||||
"data": audiodata
|
||||
}
|
||||
};
|
||||
send_ankiconnect_command(storage["livemining_host2"], mediafilecommand);
|
||||
send_ankiconnect_command(__host, mediafilecommand);
|
||||
audioadded = true;
|
||||
}
|
||||
// for some reason not even anki 2.0 supports this
|
||||
@@ -2264,7 +2264,7 @@ async function mine_to_ankiconnect_with_base64_audio(object, audiofname, audioda
|
||||
}
|
||||
}
|
||||
note["params"]["note"]["fields"] = fields;
|
||||
send_ankiconnect_command(storage["livemining_host2"], note);
|
||||
send_ankiconnect_command(__host, note);
|
||||
}, (e) => {console.log(e);});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user