parent
36765d8700
commit
b23373c967
5 changed files with 261 additions and 6 deletions
@ -0,0 +1,187 @@ |
||||
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
<title>MkSec Web</title> |
||||
<link rel="stylesheet" href="css/awsm.min.css"> |
||||
<script type="text/javascript"> |
||||
var version = '3.0.6'; |
||||
var themes = JSON.parse('[{"title":"white","prismTheme":""},{"title":"gondola","prismTheme":"tomorrow"},{"title":"mischka","prismTheme":"okaidia"},{"title":"big-stone","prismTheme":"tomorrow"},{"title":"black","prismTheme":""},{"title":"tasman","prismTheme":""},{"title":"pastel-pink","prismTheme":""},{"title":"pearl-lusta","prismTheme":"solarizedlight"}]'); |
||||
var storedVersion = localStorage.getItem('awsm-version'); |
||||
|
||||
if (version !== storedVersion) { |
||||
localStorage.removeItem('awsm-current-theme'); |
||||
localStorage.removeItem('awsm-themes'); |
||||
localStorage.setItem('awsm-version', version); |
||||
} |
||||
|
||||
function getCSSFileName(theme) { |
||||
return 'css/awsm_theme_' + theme + '.min.css'; |
||||
} |
||||
|
||||
function appendStyles(str) { |
||||
var style = document.createElement('style'); |
||||
style.innerHTML = str; |
||||
document.querySelector('head').appendChild(style); |
||||
} |
||||
|
||||
function loadTheme() { |
||||
var theme = localStorage.getItem('awsm-current-theme'); |
||||
|
||||
if (!theme || theme === 'white') return; |
||||
|
||||
reloadTheme(theme); |
||||
} |
||||
|
||||
function reloadTheme(theme) { |
||||
var storedThemesStr = localStorage.getItem('awsm-themes'); |
||||
|
||||
if (!storedThemesStr) return; |
||||
|
||||
var storedThemes = JSON.parse(storedThemesStr); |
||||
|
||||
appendStyles(storedThemes[theme]); |
||||
} |
||||
|
||||
loadTheme(); |
||||
</script> |
||||
<script type="text/javascript">block_aplayer = true;</script> |
||||
<script src="https://cdn.yimian.xyz/ushio-js/ushio-head.min.js"></script> |
||||
<script type="text/javascript"> |
||||
if(!cookie.get('email')){ |
||||
window.location.href='./login.html'; |
||||
} |
||||
</script> |
||||
</head> |
||||
<body> |
||||
<header> |
||||
<h1>MkSec Web</h1> |
||||
<p>Learn English by sentences~ |
||||
</p> |
||||
<nav> |
||||
<ul> |
||||
|
||||
|
||||
<li><a href="https://github.com/iotcat/sentence-generator" target="_blank">GitHub</a></li> |
||||
<li><a href="https://iotcat.me/" target="_blank">Author</a></li> |
||||
<li><a href="./index.html">Home</a></li> |
||||
<li><a href="./logout.html">Logout</a></li> |
||||
<li> |
||||
<select id="theme-changer" onchange="updateTheme(this.value)"> |
||||
<option value="white" selected>white</option> |
||||
<option value="gondola">gondola</option> |
||||
<option value="mischka">mischka</option> |
||||
<option value="big-stone">big-stone</option> |
||||
<option value="black">black</option> |
||||
<option value="tasman">tasman</option> |
||||
<option value="pastel-pink">pastel-pink</option> |
||||
<option value="pearl-lusta">pearl-lusta</option> |
||||
</select> |
||||
</li> |
||||
</ul> |
||||
</nav> |
||||
</header> |
||||
<main> |
||||
<article> |
||||
<section> |
||||
<h2><a id="forms" href="#forms" aria-hidden="true"></a>Upload |
||||
</h2> |
||||
<form onsubmit="upload(); return false;"> |
||||
<fieldset> |
||||
<legend>Box</legend> |
||||
<label for="word-list">Copy your words here, separated by comma, space or line feed.</label> |
||||
<textarea id="word-list"></textarea> |
||||
<input type="submit" value="Submit"> |
||||
</fieldset> |
||||
</form> |
||||
</section> |
||||
</article> |
||||
</main> |
||||
<footer> |
||||
<p style="text-align: center;"> Powered By Ushio | Made with love by <a href="https://iotcat.me">iotcat</a> </p> |
||||
<br> |
||||
</footer> |
||||
<script> |
||||
function loadCSS(path, cb) { |
||||
var xhr = new XMLHttpRequest(); |
||||
xhr.open('GET', path); |
||||
xhr.onreadystatechange = function() { |
||||
if (this.readyState === 4 && this.status === 200) { |
||||
cb(this.responseText); |
||||
} |
||||
}; |
||||
xhr.send(); |
||||
} |
||||
function updateTheme(theme) { |
||||
localStorage.setItem('awsm-current-theme', theme); |
||||
loadCSS(getCSSFileName(theme), function(text) { |
||||
var storedThemesStr = localStorage.getItem('awsm-themes'); |
||||
var storedThemes = JSON.parse(storedThemesStr) || {}; |
||||
storedThemes[theme] = text; |
||||
|
||||
localStorage.setItem('awsm-themes', JSON.stringify(storedThemes)); |
||||
reloadTheme(theme); |
||||
}); |
||||
} |
||||
|
||||
var theme = localStorage.getItem('awsm-current-theme'); |
||||
|
||||
if (theme && theme !== 'white') { |
||||
document.getElementById('theme-changer').value = theme; |
||||
} |
||||
</script> |
||||
<script src="https://cdn.yimian.xyz/ushio-js/ushio-footer.min.js"></script> |
||||
<script type="text/javascript"> |
||||
var upload = async function(){ |
||||
let o = []; |
||||
let wArr = $('#word-list').val().match(/\b[a-zA-Z]+\b/g); |
||||
for(let index = 0; index < wArr.length; index ++){ |
||||
wArr[index] = wArr[index].toLowerCase(); |
||||
try{ |
||||
let arr = (await mksec(wArr[index])); |
||||
o.push(wArr[index]); |
||||
tips.info({ |
||||
message: 'Found '+ wArr[index] |
||||
}); |
||||
}catch(e){ |
||||
tips.warning({ |
||||
message: 'Not found '+ wArr[index] |
||||
}); |
||||
} |
||||
} |
||||
|
||||
$.post('./publish/', { |
||||
email: cookie.get('email'), |
||||
data: JSON.stringify(o) |
||||
}, function(res){ |
||||
if(res.code == 200){ |
||||
tips.success({ |
||||
message: res.message |
||||
}); |
||||
}else{ |
||||
tips.error({ |
||||
message: res.message |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
var mksec = (word) => { |
||||
return new Promise((resolve, reject) => { |
||||
$.get('./mksec/?word='+word) |
||||
.done(function(res){ |
||||
resolve(res); |
||||
}) |
||||
.fail(function(){ |
||||
reject(); |
||||
}) |
||||
}) |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue