项目文件夹

文件
2026-07-13 12:48:55 +08:00

72 行
2.9 KiB
HTML

<html>
<head>
<meta charset="utf-8" />
<style>
#result {
font-size: 40px;
margin: 20%;
}
a {
color: steelblue;
}
textarea {
width: 50%;
height: 50%;
margin-left: 25%;
margin-top: 5%;
}
</style>
</head>
<script>
//create the worker
var worker = new Worker('./_worker.js')
//respond to it finishing
worker.addEventListener('message', function (msg) {
console.log('worker response:', msg)
// render results in some html:
let rows = msg.data.map(o => `<div>${o.text}</div>`).join('')
// boom.
document.getElementById('result').innerHTML = rows
}, false)
window.onload = function () {
//send the worker some text
let text = document.getElementById('text').value
worker.postMessage(text)
}
</script>
<body>
compromise <a href="https://www.html5rocks.com/en/tutorials/workers/basics/">web-worker</a> demo
<div><a href="https://github.com/spencermountain/compromise/blob/master/demo/plugin.html">view source</a></div>
<p></p>
<textarea id="text">
Now this is a story all about how my life got flipped-turned upside down.
and I'd like to take a minute, just sit right there, I'll tell you how I became the prince of a town called Bel-Air.
In west Philadelphia born and raised, on the playground was where I spent most of my days.
Chillin' out maxin' relaxin' all cool, and all shooting some b-ball outside of the school.
When a couple of guys who were up to no good started making trouble in my neighborhood,
I got in one little fight and my mom got scared, she said, "You're movin' with your auntie and uncle in Bel-Air".
I begged and pleaded with her day after day but she packed my suitcase and sent me on my way.
She gave me a kiss and then she gave me my ticket. I put my Walkman on and said, "I might as well kick it".
First class, yo, this is bad. Drinking orange juice out of a champagne glass.
Is this what the people of Bel-Air living like? Hmm, this might be alright.
But wait I hear they're prissy, bourgeois, all that. Is this the type of place that they just send this cool cat?
I don't think so, I'll see when I get there.
I hope they're prepared for the prince of Bel-Air.
Well, the plane landed and when I came out. There was a dude who looked like a cop standing there with my name out.
I ain't trying to get arrested yet, I just got here.
I sprang with the quickness like lightning, disappeared.
I whistled for a cab and when it came near. The license plate said "Fresh" and it had dice in the mirror.
If anything I could say that this cab was rare, but I thought, "Nah, forget it" – "Yo, home to Bel-Air"!
I pulled up to the house about 7 or 8 and I yelled to the cabbie, "Yo home smell ya later".
I looked at my kingdom, I was finally there. To sit on my throne as the Prince of Bel-Air.
</textarea>
<p class="desc">worker output:</p>
<div id="result"></div>
</body>
</html>