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