Skip to content

Commit

Permalink
✨ 作成一覧の追加
Browse files Browse the repository at this point in the history
  • Loading branch information
r74tech committed Aug 28, 2023
1 parent 9c392ec commit ac31ac4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/css/wikidot.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,11 @@ a#account-topbutton:focus + div#account-options {

code, .code {
background-color: unset;
}

#page-index {
background-color: #F3F3F3;
border: 1px solid #CCC;
padding: 0.5em 1em;
margin: 1em 0;
}
6 changes: 6 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ <h1 id="actionarea-title">Edit Page</h1>
<li>The display of Sidebar can be changed from Advanced Settings.</li>
</ul>
</div>
<div id="page-index">
<h2>作成履歴</h2>
<ul id="page-index-list">

</ul>
</div>
</td>
</tr>
</tbody>
Expand Down
34 changes: 34 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ const handleDOMContentLoaded = async () => {
} else {
loadlocales();
}
populatePageIndexList();

const url = new URL(window.location.href);
const pathname = url.pathname;
Expand Down Expand Up @@ -589,6 +590,39 @@ function formatDateForRevisionData(dateString) {
}


function populatePageIndexList() {
// ページのリストを表示する要素を取得
const pageIndexList = document.getElementById('page-index-list');

if (!pageIndexList) {
console.error('page-index-list element not found.');
return;
}

// ローカルストレージのすべてのキーを走査
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key && key.startsWith('FtmlStorage[')) {
// shortId を抽出
const shortId = key.match(/\[([^\]]+)\]/)[1];

const data = JSON.parse(localStorage.getItem(key));
const title = data.title || 'Untitled'; // タイトルがない場合のデフォルト値

// 新しいリンク要素を作成
const linkElem = document.createElement('a');
linkElem.href = `/share/${shortId}`;
linkElem.textContent = title;
linkElem.target = "_blank"; // 新しいタブで開く

// リンク要素をリスト要素に追加
const listItem = document.createElement('li');
listItem.appendChild(linkElem);
pageIndexList.appendChild(listItem);
}
}
}

// Event listeners...
document.addEventListener('DOMContentLoaded', handleDOMContentLoaded);
if (editpageField) editpageField.addEventListener('input', handleEditpageInput);
Expand Down

0 comments on commit ac31ac4

Please sign in to comment.