123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- @using WeApp.Helpers
- @{
- string id = "env-info";
- }
- @Html.Partial("__/_AreaBox", $"演练信息#{id}")
- <div style="display: none" id="@id-pre">
- </div>
- @using (Html.BeginScripts())
- {
- <script id="env-info-script">
- var $envInfoBody = $('#@id .box-body');
- $envInfoBody.html($('#@id-pre').html());
- var env_infos = [],timer_env;
- function LoadEveInfo(delay) {
- clearTimeout(timer_env);
- $.get({
- url: "/content/data/envInfo.json",
- success: (arr) => {
- while (arr.length != 0) {
- var index = Math.floor(Math.random() * arr.length); // 这里使arr.length
- env_infos.push(arr[index]);
- arr.splice(index, 1);
- }
- RenderEnvInfo(delay);
- }
- });
- }
- function RenderEnvInfo(delayNum) {
- if (env_infos.length) {
- var env = env_infos.pop();
- var html = `
- <div class="px-6 env-info">
- <span>${env.source?env.source+":":""}<span>${env.info}</span></span>
- <span>${new Date().format("hh:mm:ss")}</span>
- </div>`;
- $envInfoBody.append(html);
- window.Scroll2Bottom($('#@id').find('.scroll-box'));
- var delay = delayNum ? 1 + Math.random() * 2 : 50 + Math.random() * 10;
- delayNum--;
- timer_env = setTimeout(() => { RenderEnvInfo(delayNum)}, 1000 * delay);
- } else {
- LoadEveInfo();
- }
- }
- $(function () {
- LoadEveInfo(10);
- });
- </script>
- }
|