当前位置:   article > 正文

第24次修改了可删除可持久保存的前端html备忘录:文本编辑框不再隐藏,又增加了哔哩哔哩搜索和必应搜索

第24次修改了可删除可持久保存的前端html备忘录:文本编辑框不再隐藏,又增加了哔哩哔哩搜索和必应搜索

第24次修改了可删除可持久保存的前端html备忘录:文本编辑框不再隐藏,又增加了哔哩哔哩搜索和必应搜索.

  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>与妖为邻备忘录</title>
  7. </head>
  8. <style>
  9. /* ******制定统一规则 开始 */
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. box-sizing: border-box;
  14. list-style: none;
  15. user-select: none;
  16. color: #fffbfb;
  17. text-shadow: 1px 1px 1px #000;
  18. }
  19. input,
  20. button {
  21. cursor: pointer;
  22. border-radius: 5px;
  23. font-size: 18px;
  24. border: 1px solid rgb(134, 133, 133);
  25. color: rgb(252, 223, 4);
  26. background-color: #ff02029c;
  27. }
  28. /* ******制定统一规则 结束 */
  29. /* **页面背景样式:.body_background 开始*/
  30. body {
  31. min-height: 100vh;
  32. /* background: radial-gradient(at 60% 0%, #3a6073, #1c2522); */
  33. /* background: linear-gradient(to bottom, #022c05, #000000); */
  34. background: #3a6073;
  35. /* background: #303745; */
  36. /* background: #1c2522; */
  37. background-size: cover;
  38. animation: bodybackground 16s infinite;
  39. }
  40. /* **页面背景样式:.body_background*****结束 */
  41. /* 头部标题.header_title 开始 */
  42. .header_title {
  43. position: fixed;
  44. top: 2px;
  45. left: 2px;
  46. width: 140px;
  47. height: 66px;
  48. border-radius: 50%;
  49. color: rgb(255, 255, 255);
  50. /* 图片 img*/
  51. img {
  52. float: left;
  53. width: 66px;
  54. height: 66px;
  55. border-radius: 50%;
  56. transition: transform 0.3s ease;
  57. &:hover {
  58. transform: scale(1.1);
  59. }
  60. }
  61. h2 {
  62. background-color: #f30303;
  63. border-radius: 50%;
  64. background-image: linear-gradient(to top left,
  65. rgba(0, 0, 0, 0.2),
  66. rgba(0, 0, 0, 0.2) 30%,
  67. rgba(0, 0, 0, 0));
  68. box-shadow: inset 4px 4px 4px rgba(255, 255, 255, 0.6),
  69. inset -4px -4px 5px rgba(0, 0, 0, 0.6);
  70. border: 0px solid black;
  71. }
  72. .my_name {
  73. letter-spacing: -8px;
  74. }
  75. }
  76. /* 头部标题.header_title 结束 */
  77. /* **********头部中心.header_center 开始 */
  78. .header_center {
  79. height: 66px;
  80. color: rgb(255, 255, 255);
  81. text-align: center;
  82. max-width: 1450px;
  83. margin: 0 auto;
  84. .summary {
  85. position: fixed;
  86. top: 0;
  87. left: 10%;
  88. }
  89. /* 修改说明.update_summary 开始 */
  90. .update_summary {
  91. font-size: 20px;
  92. font-weight: 700;
  93. position: relative;
  94. cursor: pointer;
  95. right: -700px;
  96. color: #f40b0b;
  97. }
  98. .update_summary:hover+.css_summary_collapse {
  99. grid-template-rows: 1fr;
  100. }
  101. .css_summary_collapse {
  102. display: grid;
  103. grid-template-rows: 0fr;
  104. transition: grid-template-rows 0.3s cubic-bezier(0.34, 0.69, 0.1, 1);
  105. div {
  106. background-color: #012705;
  107. overflow: hidden;
  108. width: 180px;
  109. margin: 0 1200px;
  110. z-index: 9999;
  111. p {
  112. position: relative;
  113. color: #ffffff;
  114. margin: 0 auto;
  115. }
  116. }
  117. }
  118. /* 修改说明.update_summary 结束 */
  119. /* 当前时间 #current_time 开始*/
  120. #current_time {
  121. position: fixed;
  122. color: #ffea00;
  123. font-size: 30px;
  124. top: 20px;
  125. left: 50%;
  126. }
  127. /* 当前时间 #current_time 结束*/
  128. /* 头部导航区.header_nav 开始 */
  129. .header_nav {
  130. position: fixed;
  131. top: 35px;
  132. left: 15%;
  133. font-size: 20px;
  134. border-bottom: 2px solid #f6f4db;
  135. .header_pagination {
  136. display: inline-block;
  137. /* 在第一个分页链接和最后一个分页链接添加圆角:开始 */
  138. li:first-child a {
  139. border-top-left-radius: 5px;
  140. border-bottom-left-radius: 5px;
  141. }
  142. li:last-child a {
  143. border-top-right-radius: 5px;
  144. border-bottom-right-radius: 5px;
  145. }
  146. /* 在第一个分页链接和最后一个分页链接添加圆角:结束 */
  147. li {
  148. list-style: none;
  149. display: inline;
  150. .home_page {
  151. background-color: #4CAF50;
  152. color: white;
  153. border: 1px solid #4CAF50;
  154. &:hover {
  155. background-color: #ddd;
  156. color: rgb(245, 5, 5);
  157. }
  158. }
  159. a {
  160. float: left;
  161. margin: 0 15px;
  162. text-decoration: none;
  163. transition: background-color .3s;
  164. border: 1px solid #ddd;
  165. color: rgb(252, 232, 130);
  166. &:hover:not(.home_page) {
  167. background-color: #ddd;
  168. font-size: 26px;
  169. color: rgb(255, 255, 255);
  170. }
  171. }
  172. }
  173. }
  174. }
  175. /* 头部导航区.header_nav 结束 */
  176. #openButton {
  177. font-size: 20px;
  178. &:hover {
  179. background-color: #4CAF50;
  180. color: white;
  181. font-size: 24px;
  182. }
  183. }
  184. }
  185. /* **********头部中心.header_center 结束 */
  186. /* 中部编辑文本区 .edit_text和搜索区.memo_search *******************开始 */
  187. /* ****************编辑文本区 .edit_text 开始 */
  188. .edit_text {
  189. position: fixed;
  190. flex-direction: column;
  191. box-sizing: border-box;
  192. top: 70px;
  193. left: 180px;
  194. width: 1284px;
  195. border: 1px solid rgb(134, 133, 133);
  196. #myForm {
  197. border: 1px solid rgb(134, 133, 133);
  198. display: flex;
  199. flex-direction: column;
  200. box-sizing: border-box;
  201. width: 530px;
  202. border-radius: 10px;
  203. input[type="file"] {
  204. margin: 3px;
  205. height: 30px;
  206. background-color: #11b711a7;
  207. }
  208. textarea {
  209. z-index: 9999;
  210. font-size: 20px;
  211. margin: 3px;
  212. color: #ffffff;
  213. text-shadow: 1px 1px 1px #000;
  214. background-color: #062506b5;
  215. &::placeholder {
  216. font-size: 20px;
  217. color: #ffffff;
  218. }
  219. }
  220. .abb-text,
  221. input[type="reset"] {
  222. width: 55px;
  223. margin: 3px 58px;
  224. }
  225. }
  226. /* 文本操作窗口按钮删除按钮.delete 开始 */
  227. .delete {
  228. position: sticky;
  229. top: 0px;
  230. background: #f30303;
  231. &:hover {
  232. background: #000;
  233. }
  234. }
  235. /* 文本操作窗口按钮删除按钮.delete 结束 */
  236. /* ****编辑文本区 .edit_text 结束 */
  237. /* 搜索区.memo_search 开始 */
  238. .memo_search {
  239. position: absolute;
  240. border-radius: 10px;
  241. top: -2px;
  242. left: 630px;
  243. input {
  244. /* background-color: #11b711a7; */
  245. &::placeholder {
  246. font-size: 20px;
  247. color: #ffffff;
  248. }
  249. }
  250. input[type="text"] {
  251. background: linear-gradient(to top left, #022c05, #000000);
  252. font-size: 25px;
  253. width: 440px;
  254. border-radius: 5px 0 0 5px;
  255. margin: 2px 5px;
  256. border: 0px;
  257. outline: none;
  258. cursor: text;
  259. }
  260. input[type="button"],
  261. button {
  262. position: relative;
  263. top: -1px;
  264. left: -8px;
  265. border: 0px;
  266. outline: none;
  267. background-color: #e4ede4b5;
  268. padding: 2px 0px;
  269. border-radius: 0 5px 5px 0;
  270. &:hover {
  271. background-color: #ff0202;
  272. color: #ffffff;
  273. }
  274. }
  275. }
  276. #baidu_list {
  277. height: auto;
  278. border: 1px solid #ccc;
  279. display: none;
  280. position: absolute;
  281. top: 130px;
  282. left: 7px;
  283. }
  284. #baidu_search ul li {
  285. width: 498px;
  286. height: 30px;
  287. line-height: 30px;
  288. text-indent: 10px;
  289. font-size: 16px;
  290. list-style: none;
  291. }
  292. #baidu_search li a {
  293. text-decoration: none;
  294. }
  295. #baidu_search ul li:hover {
  296. display: block;
  297. background: #ccc;
  298. font-size: 30px;
  299. color: #fff;
  300. z-index: 999;
  301. }
  302. /* 搜索区.memo_search 结束 */
  303. }
  304. /* 中部编辑文本区 .edit_text和搜索区.memo_search *******************结束 */
  305. /* *****左侧本地连接.local_connection 开始 ***** */
  306. .local_connection {
  307. position: fixed;
  308. top: 75px;
  309. left: 0;
  310. width: 170px;
  311. text-align: center;
  312. a {
  313. text-decoration: none;
  314. margin: 10px 0px;
  315. color: #ffea07;
  316. display: flex;
  317. justify-content: center;
  318. &:hover {
  319. color: #ff0303;
  320. font-size: 22px;
  321. }
  322. }
  323. }
  324. /* *****左侧本地连接.local_connection 结束 ***** */
  325. /* ***右侧常用网站 .right_websites开始 */
  326. .right_websites {
  327. position: fixed;
  328. top: 75px;
  329. right: 0;
  330. width: 170px;
  331. text-align: center;
  332. a {
  333. text-decoration: none;
  334. margin: 10px 0px;
  335. color: #ffea07;
  336. display: flex;
  337. justify-content: center;
  338. &:hover {
  339. color: #ff0303;
  340. font-size: 22px;
  341. }
  342. }
  343. }
  344. /* ***右侧常用网站 .right_websites结束 */
  345. /* ****底部备忘内容区:.memo_content_area *****开始 */
  346. .memo_content_area {
  347. border: 1px solid rgb(134, 133, 133);
  348. max-width: 1300px;
  349. margin: 100px 180px;
  350. font-size: 20px;
  351. span {
  352. user-select: text;
  353. color: #0d7b1c;
  354. &:hover {
  355. color: #ffffff;
  356. }
  357. sub {
  358. position: sticky;
  359. top: 0px;
  360. color: rgb(252, 181, 181);
  361. text-shadow: 1px 1px 1px #030303;
  362. box-shadow:
  363. inset -2px -2px 3px rgba(255, 255, 255, 0.6),
  364. inset 2px 2px 3px rgba(0, 0, 0, 0.6);
  365. margin: 0px 10px;
  366. user-select: text;
  367. border-radius: 20px;
  368. }
  369. }
  370. .finish {
  371. /* text-decoration: underline; */
  372. /* text-decoration-color: rgb(255, 0, 0); */
  373. background-color: rgb(191, 210, 255);
  374. color: rgb(255, 250, 250);
  375. text-shadow: 1px 1px 1px #030303;
  376. box-shadow:
  377. inset -2px -2px 3px rgba(255, 255, 255, 0.6),
  378. inset 2px 2px 3px rgba(0, 0, 0, 0.6);
  379. }
  380. a {
  381. text-decoration: none;
  382. color: #ebf704;
  383. }
  384. }
  385. /* ****底部备忘内容区:.memo_content_area *****结束 */
  386. </style>
  387. <body>
  388. <!-- 左侧本地连接.local_connection 开始 -->
  389. <div class="local_connection">
  390. <span>本地连接</span>
  391. <hr />
  392. <ul>
  393. <li><a href="D:\My homepage\本地连接\js生成随机数.html">随机数生成器</a></li>
  394. <li><a href="D:\My homepage\本地连接\本地连接计算器.html">计算器</a></li>
  395. <li><a href="D:\My homepage\本地连接\todos备忘录.html">todos备忘录</a></li>
  396. <!-- <li><a href="D:\My homepage\本地连接\长久保存todos.html" >todos保存</a></li> -->
  397. </ul>
  398. </div>
  399. <!-- 左侧本地连接.local_connection 结束 --------------------------------------------------------------------------------->
  400. <!-- 右侧常用网站 .right_websites开始-->
  401. <div class="right_websites">
  402. <span>常用网站</span>
  403. <hr />
  404. <ul>
  405. <li><a href="https://cn.bing.com/search?q=%E7%BF%BB%E8%AF%91&qs=
  406. n&form=QBRE&sp=-1&lq=0&sm=csrmain&pq=%E7%BF%BB%E8%AF%91&sc
  407. =10-2&sk=&cvid=08CF7C75398B4C3C97E7AEC5D3D0921F&ghsh=0&ghacc=0&ghpl=" title="在线翻译" class=""
  408. target="_blank">在线翻译</a></li>
  409. <li><a
  410. href="https://act.mihoyo.com/ys/app/interactive-map/index.html?bbs_presentation_style=no_header&lang=zh-cn&utm_source=bbs&utm_medium=mys&utm_campaign=pcicon&_markerFps=24#/map/2?shown_types=NaN,-1084,508,2&center=2008.50,-1084.00&zoom=-3.00"
  411. title="原神大地图" class="" target="_blank">原神大地图</a></li>
  412. <li><a href="https://www.bilibili.com/" title="bilibili" class="" target="_blank">哔哩哔哩</a></li>
  413. <li><a href="https://www.dedexuexi.com/" target="_blank"> 建站学习网 </a></li>
  414. <li><a href="https://www.runoob.com/" title=" 菜鸟教程" class="" target="_blank">菜鸟教程</a></li>
  415. <li><a href="https://developer.mozilla.org/zh-CN/" title="MDN网络文档" class="" target="_blank">MDN网络文档</a></li>
  416. </li>
  417. <li><a href="https://cn.vuejs.org/" target="_blank"> JavaScript 框架vue </a></li>
  418. <li><a href="https://www.w3ccoo.com/" target="_blank"> w3schools 教程 </a></li>
  419. <li><a href="https://zh.javascript.info/" target="_blank"> 现代 JavaScript 教程 </a></li>
  420. <li><a href="https://www.dedexuexi.com/tool/3D/" target="_blank"></a></li>
  421. <li><a href="https://element-plus.org/zh-CN/" target="_blank">Vue3组件库</a></li>
  422. <li><a href="https://blog.csdn.net/lulei5153?spm=1011.2415.3001.5343" title="与妖为邻CSDN博客" class=""
  423. target="_blank">与妖为邻的CSDN博客</a>
  424. </ul>
  425. </div>
  426. <!-- 右侧常用网站 .right_websites结束---------------------------------------------------------------------------------------->
  427. <!-- -------头部标题.header_title 开始 -->
  428. <div class="header_title">
  429. <img src="file:///D:\My homepage\img\jpg\tuzi3.jpg" alt="与妖为邻">
  430. <h2 class="my_name">与妖为邻</h2>
  431. <h2 class="memo">备忘录</h2>
  432. </div>
  433. <!-- 头部中心.header_center 开始 --修改说明.summary 开始 -->
  434. <div class="header_center">
  435. <!-- 修改说明.summary 开始-->
  436. <div class="summary">浏览器主页,整理本地资源!备忘日常生活、各类教程、网页素材! key=todotext
  437. </div> <span class="update_summary">第24次(0.4.0)更新</span>
  438. <div class="css_summary_collapse">
  439. <div class="update_notes">
  440. <p>第24次(0.4.0)更新:文本编辑框不再隐藏,又增加了哔哩哔哩搜索和必应搜索。</p>
  441. </div>
  442. </div>
  443. <!-- 修改说明.summary 结束-->
  444. <div id="current_time">当前时间</div>
  445. <div class="header_nav">
  446. <ul class="header_pagination">
  447. <li><a href="file:///C:\Users\90917\Desktop\备忘录.html" class="home_page">首页</a></li>
  448. <li><a href="D:\My homepage\本地连接\mylogs原生备忘录.html">日志</a></li>
  449. <li><a href="D:\My homepage\img">相册</a></li>
  450. <li><a href="#">更多</a></li>
  451. <li><a href="D:\My homepage\本地连接\html5代码账号密码备忘录样本.html">联系我</a></li>
  452. </ul>
  453. <button id="openButton">打开本地文件</button>
  454. </div>
  455. </div>
  456. <!-- 头部中心 .header_center 结束-->
  457. <!-- 中部编辑文本区 .edit_text和搜索区.memo_search -----开始 -->
  458. <div class="edit_text ">
  459. <form id="myForm">
  460. <input type="file" name="inputfile" accept="text/plain, text/css, text/html, text/javascript, text/markdown"
  461. class="background3D" />
  462. <textarea class="up-textarea" name="uptextarea" rows="1" cols="30%"
  463. placeholder="选择本地txt、js、css或html文件,文件内容会被自动读取"></textarea>
  464. <div>
  465. <button type="text" class="abb-text">添加</button>
  466. <input type="reset" value="重置">
  467. <button id="delete" class="delete">对选择进行删除</button>
  468. </div>
  469. </form>
  470. <!-- 搜索区.memo_search 开始-->
  471. <div class="memo_search">
  472. <div id="bilibili_search">
  473. <form onsubmit="return bilibili_text()">
  474. <input type="text" class="bilibili_text" placeholder="哔哩哔哩" autocomplete="off" autofocus>
  475. <!-- <input type="button" name="btn" id="bilibili_btn" value="哔哩哔哩" onclick="return search" /> -->
  476. <button onclick="return search">
  477. 哔哩哔哩
  478. </button>
  479. </form>
  480. <!-- <ul id=""></ul> -->
  481. <div id="bing_search">
  482. <form onsubmit="return bing_text()">
  483. <input type="text" class="bing_text" placeholder="必应搜索">
  484. <button onclick="return search">
  485. 必应搜索
  486. </button>
  487. </form>
  488. <!-- <ul id=""></ul> -->
  489. </div>
  490. <div id="baidu_search">
  491. <p>
  492. <input type="text" id="baidu_text" placeholder="百度一下,你就知道">
  493. <input type="button" name="btn" id="baidu_btn" value="百度一下" />
  494. </p>
  495. <ul id="baidu_list"></ul>
  496. </div>
  497. </div>
  498. </div>
  499. <!-- 搜索区.memo_search 结束-->
  500. </div>
  501. <!-- 中部编辑文本区 .edit_text和搜索区.memo_search -----结束 -->
  502. <!-- ------------备忘内容区:.memo_content_area *****开始 ----------------------------------------------->
  503. <div class="memo_content_area" id="memo">
  504. </div>
  505. <!-- ------------备忘内容区:.memo_content_area *****结束 ------------------------------------------------>
  506. </div>
  507. </body>
  508. <script>
  509. /* *********当前时间*current_time********************************************************* */
  510. var current_time = document.getElementById("current_time");
  511. function showTime(time) {
  512. var now = new Date();
  513. var year = now.getFullYear();
  514. var month = now.getMonth();
  515. var day = now.getDate();
  516. var hour = now.getHours();
  517. var minu = now.getMinutes();
  518. var second = now.getSeconds();
  519. month = month + 1;
  520. var arr_work = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
  521. var week = arr_work[now.getDay()];
  522. month = month < 10 ? "0" + month : month;//时间月份个位补0
  523. day = day < 10 ? "0" + day : day;
  524. hour = hour < 10 ? "0" + hour : hour;
  525. minu = minu < 10 ? "0" + minu : minu;
  526. second = second < 10 ? "0" + second : second;
  527. var time = year + "年" + month + "月" + day + "日 " + week + " " + hour + ":" + minu + ":" + second;
  528. current_time.innerHTML = time;
  529. }
  530. window.setInterval("showTime(current_time)", 1000);
  531. /* *********************当前时间.current_time 结束***************************************************** */
  532. /****提示弹窗无需点击的函数*****开始*****************************************/
  533. function displayAlert(type, data, time) {
  534. var prompt = document.createElement("div");
  535. if (type == "success") {
  536. prompt.style.width = "200px";
  537. prompt.style.backgroundColor = "#009900";
  538. } else if (type == "error") {
  539. prompt.style.width = "280px";
  540. prompt.style.backgroundColor = "#990000";
  541. } else if (type == "info") {
  542. prompt.style.backgroundColor = " #e6b800";
  543. prompt.style.width = "600px";
  544. } else {
  545. return;
  546. }
  547. prompt.id = "prompt";
  548. prompt.style.textAlign = "center";
  549. prompt.style.position = "fixed";
  550. prompt.style.height = "60px";
  551. prompt.style.marginLeft = "-100px";
  552. prompt.style.marginTop = "-30px";
  553. prompt.style.left = "30%";
  554. prompt.style.top = "30%";
  555. prompt.style.color = "white";
  556. prompt.style.fontSize = "25px";
  557. prompt.style.borderRadius = "20px";
  558. prompt.style.textAlign = "center";
  559. prompt.style.lineHeight = "60px";
  560. if (document.getElementById("") == null) {
  561. document.body.appendChild(prompt);
  562. prompt.innerHTML = data;
  563. setTimeout(function () {
  564. document.body.removeChild(prompt);
  565. }, time);
  566. }
  567. }
  568. /****提示弹窗无需点击的函数*****结束*****************************************/
  569. /*中部 哔哩哔哩#bilibili_search *******************开始 */
  570. function bilibili_text() {
  571. if (document.querySelector(".bilibili_text").value != "") {
  572. window.location.href = "https://search.bilibili.com/all?keyword=" + document.querySelector(".bilibili_text").value;
  573. document.querySelector(".bilibili_text").value = "";
  574. }
  575. return false;
  576. }
  577. /*中部 哔哩哔哩#bilibili_search *******************结束 */
  578. /*中部必应搜索:#bing_search *******************开始 */
  579. function bing_text() {
  580. if (document.querySelector(".bing_text").value != "") {
  581. window.location.href = "https://cn.bing.com/search?q=" + document.querySelector(".bing_text").value;
  582. document.querySelector(".bing_text").value = "";
  583. }
  584. return false;
  585. }
  586. /*中部必应搜索:#bing_search *******************结束 */
  587. /* 中部百度搜索:#baidu_search *******************开始 */
  588. var txt = document.getElementById("baidu_text");
  589. var oUl = document.getElementById("baidu_list");
  590. var oBtn = document.getElementById("baidu_btn");
  591. txt.onkeyup = function () {
  592. oUl.innerHTML = "";
  593. var val = txt.value;
  594. var oScript = document.createElement("script");//动态创建script标签
  595. oScript.src = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + val + "&cb=callback";
  596. //添加链接及回调函数
  597. document.body.appendChild(oScript);//添加script标签
  598. document.body.removeChild(oScript);//删除script标签
  599. }
  600. //回调函数
  601. function callback(data) {
  602. data.s.forEach(function (value) {
  603. var oLi = document.createElement("li");
  604. oLi.innerHTML = "<a href=\"https://www.baidu.com/s?wd=" + value + "\">" + value + "</a>";
  605. oUl.appendChild(oLi);
  606. })
  607. oUl.style.display = "block";
  608. }
  609. //点击跳转到百度页面,并搜索其中内容
  610. oBtn.onclick = function () {
  611. var val = txt.value;
  612. location.href = "http://www.baidu.com.cn/s?wd=" + val + "&cl=3";
  613. }
  614. /* 中部百度搜索区:#baidu_search *******************结束 */
  615. /*
  616. /***********************备忘内容区:.memo_content_area *****开始*******************************/
  617. var uptext = document.querySelector(".up-textarea");
  618. var addto = document.querySelector(".abb-text");
  619. var text = document.querySelector(".memo_content_area");
  620. /*************添加事件*****************/
  621. addto.onclick = function () {
  622. inserhtml(uptext.value, '');
  623. // 添加后清空输入框
  624. uptext.value = '';
  625. // 焦点放回输入框
  626. uptext.focus();
  627. savetodo();
  628. }
  629. /*************savetodo函数****************/
  630. var savetodo = function () {
  631. let todoarr = [];
  632. let todojs = {};
  633. var econtent = document.querySelectorAll('.JS_content');
  634. for (let index = 0; index < econtent.length; index++) {
  635. todojs.name = econtent[index].innerHTML;
  636. todojs.finish = econtent[index].classList.contains('finish');
  637. todoarr.push(todojs);
  638. todojs = {};
  639. }
  640. save(todoarr);
  641. }
  642. var loadtodo = function () {
  643. let todoarr = load();
  644. for (let index = 0; index < todoarr.length; index++) {
  645. inserhtml(todoarr[index].name, todoarr[index].finish ? 'finish' : '');
  646. }
  647. }
  648. /*********本地持久储存(localStorage)函数*****************************/
  649. var save = function (arr) {
  650. /**JSON.stringify(arr) 先将数组转换为字符串 *localStorage.todotext 然后将字符串保存到本地的todotext中*/
  651. localStorage.todotext = JSON.stringify(arr);
  652. }
  653. /**
  654. *读取函数,把todotext转成数组
  655. *然后返回数组*/
  656. var load = function (arr) {
  657. var arr = JSON.parse(localStorage.todotext);
  658. return arr;
  659. }
  660. /**********************finish样式函数*****************************/
  661. /**********************按钮点击事件*****************************/
  662. text.onclick = function () {
  663. var tg = event.target;
  664. // 获取父元素下的所有子元素
  665. var tgkids = tg.parentElement.children;
  666. /*******************************对复选框的点击事件******************************/
  667. if (tgkids[0].checked) {
  668. tgkids[1].classList.add("finish");
  669. }
  670. else {
  671. tgkids[1].classList.remove("finish");
  672. }
  673. // 保存更改的样式
  674. savetodo();
  675. /***********************对选择的进行删除********************************************/
  676. var Select = document.getElementById("delete");
  677. Select.onclick = function () {
  678. if (confirm("是否删除所选?")) {
  679. var check = document.getElementsByName("checkbox");
  680. for (var i = 0; i < check.length; i++) {
  681. if (check[i].checked) {
  682. check[i].parentElement.remove();
  683. i--;
  684. // 删除后保存
  685. savetodo();
  686. }
  687. }
  688. }
  689. }
  690. }
  691. var inserhtml = function (val, cls) {
  692. text.insertAdjacentHTML("beforeend",
  693. `<div>
  694. <input type="checkbox" name='checkbox'>
  695. <span class='JS_content ${cls}'>${val}</span> </div>`
  696. )
  697. }
  698. loadtodo();
  699. /**************************打开URL按钮的JavaScript******************************************/
  700. // 获取打开URL按钮元素
  701. var openBtn = document.getElementById("openButton");
  702. // 添加点击事件处理程序
  703. openBtn.addEventListener('click', function () {
  704. // 获取文件路径
  705. // 这里假设您已经有一个函数来获取文件路径,例如 prompt('请输入文件路径', 'D:/前端学习', '_blank');
  706. var filePath = prompt("请输入网站地址或者本地文件路径", "D:\My homepage");
  707. if (filePath) {
  708. // 使用window.location对象的assign()方法导航到指定文件
  709. // window.location.assign(filePath);
  710. // 或者使用window.open()方法打开新窗口导航到指定文件
  711. window.open(filePath);
  712. } else {
  713. displayAlert('info', '未提供有效的文件路径!', 1500);
  714. // alert("未提供有效的文件路径!");
  715. }
  716. });
  717. /**************************本地文件读取的函数******************************************/
  718. window.onload = function () {
  719. var text = document.getElementsByName('uptextarea')[0],
  720. inputFile = document.getElementsByName('inputfile')[0];
  721. //上传文件
  722. inputFile.onchange = function () {
  723. console.log(this.files);
  724. var reader = new FileReader();
  725. reader.readAsText(this.files[0], 'UTF-8');
  726. reader.onload = function (e) {
  727. // urlData就是对应的文件内容
  728. var urlData = this.result;
  729. text.value = urlData;
  730. };
  731. };
  732. };
  733. /**************************复制文本******************************************/
  734. var oContent = document.getElementById('memo');
  735. oContent.ondragend = function () {
  736. document.execCommand("Copy");
  737. // alert("复制成功")
  738. displayAlert('error', '复制成功!', 1500);
  739. };
  740. </script>
  741. </html>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/444688
推荐阅读
相关标签
  

闽ICP备14008679号