Browse Source

Quick updates

master
KaKi87 3 years ago
parent
commit
8386625989
  1. 61
      js/index.js

61
js/index.js

@ -4,7 +4,7 @@ let release = {
dev: 'KaKi87',
devcontact: 'Twitter @KaKi_87, Discord KaKi87#2368'
};
document.querySelectorAll('.version').forEach((el) => { el.innerText = release.version; });
document.querySelectorAll('.version').forEach((el) => { el.textContent = release.version; });
let mobile = (/(android|windows phone|ios)/i).test(window.navigator.userAgent);
@ -65,11 +65,11 @@ let wrapper = {
document.querySelector('#progress .bar').style.width = p + '%';
if(p % n === 0){
if(i < (a.length + b.length)){
document.querySelector('#progress .details').innerText = a[i] ? 'INITIATING : ' + a[i] : 'ACQUIRING : ' + b[i - a.length];
document.querySelector('#progress .details').textContent = a[i] ? 'INITIATING : ' + a[i] : 'ACQUIRING : ' + b[i - a.length];
i++;
}
else
document.querySelector('#progress .details').innerText = release.version;
document.querySelector('#progress .details').textContent = release.version;
}
}
else {
@ -83,7 +83,7 @@ let wrapper = {
}, 250);
},
status: (text, callback) => {
document.querySelector('#status').innerText = text;
document.querySelector('#status').textContent = text;
document.querySelector('#status').style.opacity = '1';
setTimeout(() => {
document.querySelector('#status').style.opacity = '0';
@ -111,11 +111,11 @@ let wrapper = {
sWindow.destroyAll();
document.querySelector('#output').style.color = 'red';
let i = 5;
document.querySelector('#output').innerText = 'SAMARITAN SHUTDOWN IN : ' + i;
document.querySelector('#output').textContent = 'SAMARITAN SHUTDOWN IN : ' + i;
let countdown = setInterval(() => {
if(i > 0){
i--;
document.querySelector('#output').innerText = 'SAMARITAN SHUTDOWN IN : ' + i;
document.querySelector('#output').textContent = 'SAMARITAN SHUTDOWN IN : ' + i;
if(i === 0){
setTimeout(() => {
document.querySelector('#output').style.visibility = 'hidden';
@ -181,9 +181,9 @@ Submit command
*/
document.querySelector('#submit').onclick = () => {
let cmd = document.querySelector('#cmd span').innerText;
let cmd = document.querySelector('#cmd span').textContent;
if(cmd.length > 0){
document.querySelector('#cmd span').innerText = '';
document.querySelector('#cmd span').textContent = '';
sam.search(cmd);
}
};
@ -196,7 +196,7 @@ let output = {
// Word
w: (w) => {
marker.solid();
document.querySelector('#output').innerText = w;
document.querySelector('#output').textContent = w;
document.querySelector('#hr').style.width = (w.length * 21) + 'px';
},
// Sentence
@ -216,7 +216,7 @@ let output = {
}, 450);
},
clear: () => {
document.querySelector('#output').innerText = '\xa0';
document.querySelector('#output').textContent = '\xa0';
setTimeout(() => {
document.querySelector('#hr').style.removeProperty('width');
marker.blink();
@ -227,15 +227,18 @@ let output = {
if(s.state === true){
document.querySelector('#output').classList.add('calculating');
marker.dots();
setTimeout(() => {
let newSettings = { state: false };
if(typeof(s.callback) === 'function')
Object.assign(newSettings, newSettings, { callback: s.callback });
output.calculating(newSettings);
}, s.duration * 1000);
if(s.duration){
setTimeout(() => {
let newSettings = { state: false };
if(typeof(s.callback) === 'function')
Object.assign(newSettings, newSettings, { callback: s.callback });
output.calculating(newSettings);
}, s.duration * 1000);
}
}
else {
document.querySelector('#output').classList.remove('calculating');
marker.blink();
if(typeof(s.callback) === 'function')
s.callback();
}
@ -324,7 +327,7 @@ let sam = {
break;
}
}
}
};
let cleverbot = {
process: (query) => {
@ -414,8 +417,8 @@ let sWindow = {
setTimeout(() => {
w.style.visibility = 'visible';
try {
if(parseInt(s.maxHeight) < 300 || s.forceHeight)
w.querySelector('.content').style.maxHeight = s.maxHeight;
if(s.maxHeight < 300 || s.forceHeight)
w.querySelector('.content').style.maxHeight = `${s.maxHeight}px`;
else
w.querySelector('.content').style.maxHeight = '300px';
} catch(e){
@ -429,7 +432,7 @@ let sWindow = {
if(inline === undefined) inline = false;
let el = document.createElement('span');
if(content.type !== 'normal') el.className = content.type;
el.innerText = content.text;
el.textContent = content.text;
if(!inline){
w.querySelector('.content').appendChild(el);
}
@ -571,7 +574,7 @@ let showCredits = () => {
{ type: 'title red', text: 'Total contributors : 5' }
],
forceHeight: true,
maxHeight: '335px'
maxHeight: 335
});
};
@ -611,7 +614,7 @@ let showCommands = () => {
bottom: '80px',
left: '123px'
},
maxHeight: '210px',
maxHeight: 210,
content: [
{ type: 'title', text: 'User Interface' },
{ type: 'normal', text: '- HELP : show help\n- SHUTDOWN : shutdown Samaritan'
@ -653,7 +656,7 @@ let clock = () => {
]
});
let clockInterval = setInterval(() => {
try { document.querySelector('#clock .content span').innerText = new Date().toTimeString().split(' ')[0]; }
try { document.querySelector('#clock .content span').textContent = new Date().toTimeString().split(' ')[0]; }
catch(e) { clearInterval(clockInterval); }
}, 50);
};
@ -698,7 +701,7 @@ let timer = () => {
let timerInterval = setInterval(() => {
let t2 = new Date();
let dt = t2 - t1;
try { document.querySelector('#timer .content span').innerText = SecondsToHHMMSSM(dt / 1000); }
try { document.querySelector('#timer .content span').textContent = SecondsToHHMMSSM(dt / 1000); }
catch(e) { clearInterval(timerInterval); }
}, 50);
};
@ -731,7 +734,7 @@ let countdown = {
el.countdownInterval = setInterval(() => {
let d = end - Date.now() / 1000;
try {
el.innerText = SecondsToHHMMSSM(Math.abs(d));
el.textContent = SecondsToHHMMSSM(Math.abs(d));
if(d < 0){
window.dispatchEvent(new Event('countdown.TIMEOUT'));
if(S) return;
@ -789,13 +792,13 @@ let apple = (testing) => {
sam.hold = (query) => {
if(query === 'i hate apple'){
sam.hold = false;
document.querySelector('#apple > .title').innerText = 'Error';
document.querySelector('#apple > .title').textContent = 'Error';
document.querySelector('#apple').content([
{ type: 'normal', text: 'new data acquired' },
{ type: 'redText', text: 'classification error' },
]);
setTimeout(() => {
document.querySelector('#apple > .title').innerText = 'Asset identified';
document.querySelector('#apple > .title').textContent = 'Asset identified';
document.querySelector('#apple > .title').classList.remove('red');
document.querySelector('#apple').closable = true;
document.querySelector('#apple').content([
@ -809,7 +812,7 @@ let apple = (testing) => {
}
};
let nlp = (sentence, keywords, final) => {
let nlp = (sentence, keywords = [], final) => {
sWindow.new({
id: 'nlp',
class: 'thin_border',
@ -826,7 +829,7 @@ let nlp = (sentence, keywords, final) => {
document.querySelector('#nlp .content').innerHTML = '<div class="header"><span class="title">subject</span>admin<br><span class="sub_header"> nlp active</span></div><div class="audio"></div><div class="sentence"></div>';
sentence.trim().split(' ').forEach((word) => {
document.querySelector('#nlp .sentence').appendChild(span = document.createElement('span'));
span.innerText = word;
span.textContent = word;
span.className = 'data word';
if(keywords.indexOf(word) !== -1){
span.classList.add('relevant_keyword');

Loading…
Cancel
Save