Skip to content
This repository was archived by the owner on May 13, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DocType HTML>

<HTML>
<Head>
<Meta Charset = "UTF-8" />
<Meta Http-Equiv = "Refresh" Content = "5;URL=/SimpleThread/" />
<Link Rel = "Shortcut Icon" Href = "/SimpleThread/Error/favicon.ico" />

<Title>404 Not Found</Title>

<Link Rel = "StyleSheet" Href = "https://genbuproject.github.io/Programs/StyleSheets/Back.css" />

<Script Src = "/SimpleThread/Error/Main.js"></Script>
<Link Rel = "StyleSheet" Href = "/SimpleThread/Error/Main.css" />
</Head>

<Body>
<Div Class = "Title">
<Img Src = "/SimpleThread/Error/favicon.ico" Width = "64" Height = "64" />404 Not Found
</Div>

<Div Class = "Message">
<P>
お探しのページが見つかりませんでした。
</P>

5秒後に<A Href = "/SimpleThread/" Target = "_parent">メインページ</A>へ移動します…
</Div>
</Body>
</HTML>
71 changes: 71 additions & 0 deletions Dialog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Dialog[ID^="Dialogs"] {
Width: 65%;
}

Dialog[ID^="Dialogs"] Div.mdl-textfield {
Width: 100%;
}

*.mdl-switch__child-hide {
Display: None;
}



#Dialogs_Profile_InfoViewer_Content {
Display: Flex;
Flex-Direction: Row;
Align-Items: Flex-Start;

Font-Size: Medium;
}

#Dialogs_Profile_InfoViewer_Content_Photo {
Width: 20%;

Margin-Right: 5%;
Border-Radius: 100%;
}

#Dialogs_Profile_InfoViewer_Content_Photo::Before {
Content: "";

Display: Block;
Padding-Top: 100%;
}

#Dialogs_Profile_InfoViewer_Content_Info {
Flex: 1;
}

#Dialogs_Profile_InfoViewer_Content_Info_Detail {
Padding: 1em 0 4em 0;

White-Space: Pre-Wrap;
}

#Dialogs_Profile_InfoViewer_Content_Info_Links {
Padding: 1em 0 0;
}

Img[Data-Component="Dialogs_Profile_InfoViewer_Content_Info_Links_Link_Icon"] {
Width: 1em;
}



#Dialogs_Thread_InfoViewer_Content_Overview {
Padding: 1em 0 4em 0;
}

#Dialogs_Thread_InfoViewer_Content_Detail {
Padding: 1em 0 0;

White-Space: Pre-Wrap;
}



#Dialogs_Thread_Poster_Content_Text-Input {
Resize: None;
}
276 changes: 276 additions & 0 deletions Dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
window.addEventListener("DOMContentLoaded", () => {
let watchers = {};

new DOM('@Dialog').forEach((dialog) => {
dialogPolyfill.registerDialog(dialog);

if (dialog.querySelector('Button[Data-Action="Dialog_Submit"]')) {
dialog.addEventListener("keydown", (event) => {
if (event.ctrlKey && event.keyCode == 13) dialog.querySelector('Button[Data-Action="Dialog_Submit"]').click();
});
}

dialog.querySelectorAll('Dialog *[Required]').forEach((input) => {
input.addEventListener("input", () => {
let result = true;

dialog.querySelectorAll('Dialog *[Required]').forEach(requiredField => {
if (requiredField.value.replace(/\s/g, "").length == 0) {
result = false;
return;
}
});

if (result) {
dialog.querySelector('Button[Data-Action="Dialog_Submit"]').classList.remove("mdl-button--disabled");
} else {
dialog.querySelector('Button[Data-Action="Dialog_Submit"]').classList.add("mdl-button--disabled");
}
});
});

dialog.querySelectorAll('Dialog Button[Data-Action="Dialog_Close"]').forEach((btn) => {
btn.addEventListener("click", () => {
btn.offsetParent.close();
});
});
});



new DOM("#Dialogs_Profile_DeleteConfirmer_Content_Email-Input").addEventListener("input", () => {
if (new DOM("#Dialogs_Profile_DeleteConfirmer_Content_Email-Input").value == base.user.email) {
new DOM("#Dialogs_Profile_DeleteConfirmer_Btns_Yes").classList.remove("mdl-button--disabled");
} else {
new DOM("#Dialogs_Profile_DeleteConfirmer_Btns_Yes").classList.add("mdl-button--disabled");
}
});

new DOM("#Dialogs_Profile_DeleteConfirmer_Btns_Yes").addEventListener("click", (event) => {
if (!event.currentTarget.classList.contains("mdl-button--disabled")) {
if (new DOM("#Dialogs_Profile_DeleteConfirmer_Content_Email-Input").value == base.user.email) {
base.delete();
} else {
new DOM("#Dialogs_Profile_DeleteConfirmer_Content_Email").classList.add("is-invalid");
}
}
});



watchers["Dialogs_Profile_InfoViewer_UID"] = {
valueObj: { value: "" },
watcher: null
}; watchers["Dialogs_Profile_InfoViewer_UID"].watcher = new DOM.Watcher({
target: watchers["Dialogs_Profile_InfoViewer_UID"].valueObj,
onGet: () => { watchers["Dialogs_Profile_InfoViewer_UID"].valueObj.value = new DOM("#Dialogs_Profile_InfoViewer_UID").value },

onChange: (watcher) => {
base.Database.get(base.Database.ONCE, `users/${watcher.newValue}`, (res) => {
new DOM("#Dialogs_Profile_InfoViewer_Content_Photo").dataset.uid = watcher.newValue,
new DOM("#Dialogs_Profile_InfoViewer_Content_Info_Name").textContent = res.userName,
new DOM("#Dialogs_Profile_InfoViewer_Content_Info_Detail").textContent = res.detail;

while (new DOM("#Dialogs_Profile_InfoViewer_Content_Info_Links").childNodes.length > 0) new DOM("#Dialogs_Profile_InfoViewer_Content_Info_Links").childNodes[0].remove();

if (res.links) {
for (let i = 0; i < res.links.length; i++) {
let link = new Component.Dialogs.Profile.InfoViewer.Links.Link(res.links[i].name, res.links[i].url);

new DOM("#Dialogs_Profile_InfoViewer_Content_Info_Links").appendChild(link);
}
}
});
}
});



new DOM("@#Dialogs_Thread_InfoInputer *[Required]").forEach((input) => {
input.addEventListener("input", () => {
let result = true;

let list = [
new DOM("#Dialogs_Thread_InfoInputer_Content_Name-Input"),
new DOM("#Dialogs_Thread_InfoInputer_Content_Overview-Input")
];

if (new DOM("#Dialogs_Thread_InfoInputer_Content_Secured-Input").checked) list.push(new DOM("#Dialogs_Thread_InfoInputer_Content_Password-Input"));

list.forEach(requiredField => {
if (requiredField.value.replace(/\s/g, "").length == 0) {
result = false;
return;
}
});

if (result) {
new DOM("#Dialogs_Thread_InfoInputer").querySelector('Button[Data-Action="Dialog_Submit"]').classList.remove("mdl-button--disabled");
} else {
new DOM("#Dialogs_Thread_InfoInputer").querySelector('Button[Data-Action="Dialog_Submit"]').classList.add("mdl-button--disabled");
}
});
});

new DOM("#Dialogs_Thread_InfoInputer_Content_Secured-Input").addEventListener("change", (event) => {
let result = true;

switch (event.target.checked) {
case true:
new DOM("#Dialogs_Thread_InfoInputer_Content_Password").classList.remove("mdl-switch__child-hide");

[new DOM("#Dialogs_Thread_InfoInputer_Content_Name-Input"), new DOM("#Dialogs_Thread_InfoInputer_Content_Overview-Input"), new DOM("#Dialogs_Thread_InfoInputer_Content_Password-Input")].forEach(requiredField => {
if (requiredField.value.replace(/\s/g, "").length == 0) {
result = false;
return;
}
});

if (result) {
new DOM("#Dialogs_Thread_InfoInputer").querySelector('Button[Data-Action="Dialog_Submit"]').classList.remove("mdl-button--disabled");
} else {
new DOM("#Dialogs_Thread_InfoInputer").querySelector('Button[Data-Action="Dialog_Submit"]').classList.add("mdl-button--disabled");
}

break;

case false:
new DOM("#Dialogs_Thread_InfoInputer_Content_Password").classList.add("mdl-switch__child-hide");

[new DOM("#Dialogs_Thread_InfoInputer_Content_Name-Input"), new DOM("#Dialogs_Thread_InfoInputer_Content_Overview-Input")].forEach(requiredField => {
if (requiredField.value.replace(/\s/g, "").length == 0) {
result = false;
return;
}
});

if (result) {
new DOM("#Dialogs_Thread_InfoInputer").querySelector('Button[Data-Action="Dialog_Submit"]').classList.remove("mdl-button--disabled");
} else {
new DOM("#Dialogs_Thread_InfoInputer").querySelector('Button[Data-Action="Dialog_Submit"]').classList.add("mdl-button--disabled");
}

break;
}
});

new DOM("#Dialogs_Thread_InfoInputer_Btns_OK").addEventListener("click", (event) => {
if (!event.currentTarget.classList.contains("mdl-button--disabled")) {
base.Database.transaction("threads", (res) => {
let now = new Date().getTime();

base.Database.set("threads/" + res.length, {
title: new DOM("#Dialogs_Thread_InfoInputer_Content_Name-Input").value,
overview: new DOM("#Dialogs_Thread_InfoInputer_Content_Overview-Input").value,
detail: new DOM("#Dialogs_Thread_InfoInputer_Content_Detail-Input").value,

jobs: {
Owner: (() => {
let owner = {}; owner[base.user.uid] = "";
return owner;
})(),

Admin: {

}
},

createdAt: now,

data: [
{
uid: "!SYSTEM",
content: new DOM("#Dialogs_Thread_InfoInputer_Content_Name-Input").value,
createdAt: now
}
],

password: new DOM("#Dialogs_Thread_InfoInputer_Content_Secured-Input").checked ? Encrypter.encrypt(new DOM("#Dialogs_Thread_InfoInputer_Content_Password-Input").value) : ""
});

new DOM("#Dialogs_Thread_InfoInputer").close();
parent.document.querySelector("IFrame.mdl-layout__content").src = "Thread/Viewer/?tid=" + res.length;
});
}
});



new DOM("#Dialogs_Thread_PasswordConfirmer_Btns_OK").addEventListener("click", (event) => {
if (!event.currentTarget.classList.contains("mdl-button--disabled")) {
if (Encrypter.encrypt(new DOM("#Dialogs_Thread_PasswordConfirmer_Content_Password-Input").value) == new DOM("#Dialogs_Thread_PasswordConfirmer_Password").value) {
sessionStorage.setItem("com.GenbuProject.SimpleThread.currentPassword", new DOM("#Dialogs_Thread_PasswordConfirmer_Content_Password-Input").value);
new DOM("$IFrame.mdl-layout__content").src = new DOM("#Dialogs_Thread_PasswordConfirmer_Link").value;

new DOM("#Dialogs_Thread_PasswordConfirmer_Link").value = "",
new DOM("#Dialogs_Thread_PasswordConfirmer_Password").value = "";
} else {
new DOM("#Dialogs_Thread_PasswordConfirmer_Content_Password").classList.add("is-invalid");
}
}
});

new DOM("#Dialogs_Thread_PasswordConfirmer_Btns_Cancel").addEventListener("click", (event) => {
new DOM("$IFrame.mdl-layout__content").src = "/SimpleThread/Thread/";
});



watchers["Dialogs_Thread_InfoViewer_TID"] = {
valueObj: { value: "0" },
watcher: null
}; watchers["Dialogs_Thread_InfoViewer_TID"].watcher = new DOM.Watcher({
target: watchers["Dialogs_Thread_InfoViewer_TID"].valueObj,
onGet: () => { watchers["Dialogs_Thread_InfoViewer_TID"].valueObj.value = new DOM("#Dialogs_Thread_InfoViewer_TID").value },

onChange: (watcher) => {
base.Database.get(base.Database.ONCE, `threads/${watcher.newValue}`, (res) => {
new DOM("#Dialogs_Thread_InfoViewer_Content_Name").textContent = res.title,
new DOM("#Dialogs_Thread_InfoViewer_Content_Overview").textContent = res.overview,
new DOM("#Dialogs_Thread_InfoViewer_Content_Detail").textContent = res.detail;

URL.filter(new DOM("#Dialogs_Thread_InfoViewer_Content_Overview").textContent).forEach((urlString) => {
new DOM("#Dialogs_Thread_InfoViewer_Content_Overview").innerHTML = new DOM("#Dialogs_Thread_InfoViewer_Content_Overview").innerHTML.replace(urlString, `<A Href = "${urlString}" Target = "_blank">${urlString}</A>`);
});

URL.filter(new DOM("#Dialogs_Thread_InfoViewer_Content_Detail").textContent).forEach((urlString) => {
new DOM("#Dialogs_Thread_InfoViewer_Content_Detail").innerHTML = new DOM("#Dialogs_Thread_InfoViewer_Content_Detail").innerHTML.replace(urlString, `<A Href = "${urlString}" Target = "_blank">${urlString}</A>`);
});
});
}
});



new DOM("#Dialogs_Thread_Poster_Btns_OK").addEventListener("click", (event) => {
if (!event.currentTarget.classList.contains("mdl-button--disabled")) {
base.Database.transaction("threads/" + new DOM("#Dialogs_Thread_Poster_TID").value + "/data", (res) => {
base.Database.set("threads/" + new DOM("#Dialogs_Thread_Poster_TID").value + "/data/" + res.length, {
uid: base.user.uid,
content: new DOM("#Dialogs_Thread_Poster_Content_Text-Input").value,
createdAt: new Date().getTime()
});

new DOM("#Dialogs_Thread_Poster_Btns_OK").classList.add("mdl-button--disabled"),
new DOM("#Dialogs_Thread_Poster_Content_Text").classList.remove("is-dirty"),
new DOM("#Dialogs_Thread_Poster_Content_Text-Input").value = "";

new DOM("#Page").contentDocument.querySelector("#FlowPanel_Btns_CreatePost").removeAttribute("Disabled");

new DOM("#Dialogs_Thread_Poster").close();
});
}
});

new DOM("#Dialogs_Thread_Poster_Btns_Cancel").addEventListener("click", () => {
new DOM("#Dialogs_Thread_Poster_Btns_OK").classList.add("mdl-button--disabled"),
new DOM("#Dialogs_Thread_Poster_Content_Text").classList.remove("is-dirty"),
new DOM("#Dialogs_Thread_Poster_Content_Text-Input").value = "";

new DOM("#Page").contentDocument.querySelector("#FlowPanel_Btns_CreatePost").removeAttribute("Disabled");
});



for (let watcherName in watchers) DOM.Watcher.addWatcher(watchers[watcherName].watcher);
});
Loading