如何将 HTML5 本地存储迁移到 mediaWiki

发布于 2024-11-24 03:09:17 字数 3661 浏览 2 评论 0原文

我探索过网络,但找不到如何将 HTML5 本地存储中的数据显示为我的 Wiki 中的内容?我的目标是,如果我必须将任何数据放入 HTML5 代码的本地存储中,它应该显示在我的 Wiki 页面上。我如何将这两者(HTML5/JS 和 MediaWiki)联系起来?我的 HTML 5 代码给出为

<!DOCTYPE HTML>
<html>
   <head>
      <title> HTML5 localStorage (name/value item pairs) demo </title> 

      <style>

          td, th {
              font-family: monospace;
              padding: 4px;
              background-color: #ccc;
          }
          #hoge {
              border: 1px dotted blue;
              padding: 6px;
              background-color: #ccc;
              margin-right: 50%;
         }
         #items_table {
              border: 1px dotted blue;
              padding: 6px;
              margin-top: 12px;
              margin-right: 50%;
         }
         #items_table h2 {
             font-size: 18px;
             margin-top: 0px;
             font-family: sans-serif;
         }
         label {
             vertical-align: top;
         }
        </style>

     </head>

  <body onload="doShowAll()" >

  <h1> HTML5 localStorage (name/value item pairs) demo</h1>

  <form name=editor>

    <div id="hoge">

     <p>

     <label> Value: <textarea name=data cols=41 rows=10></textarea></label>

     </p>

     <p>

      <label>Name: <input name=name></label>
      <input type=button value="getItem()" onclick="doGetItem()">
      <input type=button value="setItem()" onclick="doSetItem()">
      <input type=button value="removeItem()" onclick="doRemoveItem()">
     </p>
   </div>

   <div id="items_table">

     <h2>Items</h2>

     <table id=pairs></table>
     <p>

     <label><input type=button value="clear()" onclick="doClear()"> <i>* clear() removes all items</i></label>
     </p>
   </div>


   <script>

     function doSetItem() {
       var name = document.forms.editor.name.value;
       var data = document.forms.editor.data.value;
       localStorage.setItem(name, data);
       doShowAll();
     }

     function doGetItem() {
       var name = document.forms.editor.name.value;
       document.forms.editor.data.value = localStorage.getItem(name);
       doShowAll();
     }

     function doRemoveItem() {
       var name = document.forms.editor.name.value;
       document.forms.editor.data.value = localStorage.removeItem(name);
       doShowAll();
     }

     function doClear() {
       localStorage.clear();
       doShowAll();
     }

     function doShowAll() {
       var key = "";
       var pairs = "<tr><th>Name</th><th>Value</th></tr>\n";
       var i=0;
       for (i=0; i<=localStorage.length-1; i++) {
         key = localStorage.key(i);
         pairs += "<tr><td>"+key+"</td>\n<td>"+localStorage.getItem(key)+"</td></tr>\n";
       }
       if (pairs == "<tr><th>Name</th><th>Value</th></tr>\n") {
         pairs += "<tr><td><i>empty</i></td>\n<td><i>empty</i></td></tr>\n";
       }
       document.getElementById('pairs').innerHTML = pairs;
     }

   </script>

  </form>

 </body>
</html>

我的 Wiki URL 为: http://localhost:8888/mediawiki/index .php/Main_Page

我的问题是输入到 HTML5 代码文本区域的数据如何显示到我的 Wiki 页面中?我应该在哪里以及如何将此 wiki URL 与本地存储的 HTML5/JS 脚本关联起来?

I have explored the web but could not find how the data in the local storage of HTML5 be shown as a content in my Wiki? My aim is that if I have to put any data in the local storage of my HTML5 code, it should be shown to my Wiki page. How could I relate these two (HTML5/JS and MediaWiki)? My HTML 5 code is given as

<!DOCTYPE HTML>
<html>
   <head>
      <title> HTML5 localStorage (name/value item pairs) demo </title> 

      <style>

          td, th {
              font-family: monospace;
              padding: 4px;
              background-color: #ccc;
          }
          #hoge {
              border: 1px dotted blue;
              padding: 6px;
              background-color: #ccc;
              margin-right: 50%;
         }
         #items_table {
              border: 1px dotted blue;
              padding: 6px;
              margin-top: 12px;
              margin-right: 50%;
         }
         #items_table h2 {
             font-size: 18px;
             margin-top: 0px;
             font-family: sans-serif;
         }
         label {
             vertical-align: top;
         }
        </style>

     </head>

  <body onload="doShowAll()" >

  <h1> HTML5 localStorage (name/value item pairs) demo</h1>

  <form name=editor>

    <div id="hoge">

     <p>

     <label> Value: <textarea name=data cols=41 rows=10></textarea></label>

     </p>

     <p>

      <label>Name: <input name=name></label>
      <input type=button value="getItem()" onclick="doGetItem()">
      <input type=button value="setItem()" onclick="doSetItem()">
      <input type=button value="removeItem()" onclick="doRemoveItem()">
     </p>
   </div>

   <div id="items_table">

     <h2>Items</h2>

     <table id=pairs></table>
     <p>

     <label><input type=button value="clear()" onclick="doClear()"> <i>* clear() removes all items</i></label>
     </p>
   </div>


   <script>

     function doSetItem() {
       var name = document.forms.editor.name.value;
       var data = document.forms.editor.data.value;
       localStorage.setItem(name, data);
       doShowAll();
     }

     function doGetItem() {
       var name = document.forms.editor.name.value;
       document.forms.editor.data.value = localStorage.getItem(name);
       doShowAll();
     }

     function doRemoveItem() {
       var name = document.forms.editor.name.value;
       document.forms.editor.data.value = localStorage.removeItem(name);
       doShowAll();
     }

     function doClear() {
       localStorage.clear();
       doShowAll();
     }

     function doShowAll() {
       var key = "";
       var pairs = "<tr><th>Name</th><th>Value</th></tr>\n";
       var i=0;
       for (i=0; i<=localStorage.length-1; i++) {
         key = localStorage.key(i);
         pairs += "<tr><td>"+key+"</td>\n<td>"+localStorage.getItem(key)+"</td></tr>\n";
       }
       if (pairs == "<tr><th>Name</th><th>Value</th></tr>\n") {
         pairs += "<tr><td><i>empty</i></td>\n<td><i>empty</i></td></tr>\n";
       }
       document.getElementById('pairs').innerHTML = pairs;
     }

   </script>

  </form>

 </body>
</html>

My Wiki URL is: http://localhost:8888/mediawiki/index.php/Main_Page

My question is how the data input into the text area of the HTML5 code could be shown into my Wiki page? Where and how should I relate this wiki URL with the HTML5/JS script for local storage?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

硬不硬你别怂 2024-12-01 03:09:17

您将需要相当多的编程技能才能以正确的方式完成此任务。这里没有人会为你编程。这是可用的最佳资源。

http://diveintohtml5.ep.io/storage.html

您输入了本地主机网址在你的帖子中显然表明你有很多关于 Web 开发的知识。祝你好运。

You're going to need a fair amount of programming skills to go about this in the correct manner. No one here is going to program it for you. Here is the best resource there is available.

http://diveintohtml5.ep.io/storage.html

The fact that you put a localhost url in your post obviously shows that you have quite a bit to learn about web development in general. I wish you luck.

千纸鹤带着心事 2024-12-01 03:09:17

不完全确定这是否是您要问的...但这里没有任何内容...

步骤 1) 从本地存储中读取数据(使用 Caimen 的链接寻求帮助)。

步骤 2)使用 JavaScript 将其分组为 JSON、XML、逗号分隔字符串等...

步骤 3)POST 到服务器(AJAX 或老式 POST)

步骤 4)使用服务器端语言(假设 PHP)进行解析POST 并将其插入到 mediaWiki DB 中

Not entirely sure if this is what you're asking... but here goes nothing...

Step 1) Read the data from your local storage (use Caimen's link for help).

Step 2) Use JavaScript to group it into JSON, XML, comma delimited string, etc...

Step 3) POST to the server (AJAX or old fashioned POST)

Step 4) Use a server-side language (assuming PHP) to parse the POST and insert it into the mediaWiki DB

梦一生花开无言 2024-12-01 03:09:17

我有一种感觉 https://www.odesk.com/ 可能比 StackOverflow 更适合此请求。听起来您好像在要求某人充分参与您的任务并指导您完成整个过程。

这种个人关注通常不是免费的,而且不太可能有人愿意为此投入大量时间。但是,如果您在 oDesk 上向某人付费,您很可能会为您的特定问题找到可行的解决方案。

但是,如果您可以将问题集中到关键点,我们也许可以提供帮助......

I have a feeling that https://www.odesk.com/ might be more suitable for this request than StackOverflow. It sounds like you're asking for someone to get quite involved in your task and guide you through the process.

This kind of personal attention generally isn't free, and it is unlikely someone will want to devote a decent amount of time towards it. However if you pay someone, on say oDesk, you're likely to get a working solution for your specific problem.

However if you can funnel your question down to a key point, we may be able to help with that...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文