diff --git a/404.html b/404.html new file mode 100644 index 0000000..7f85db5 --- /dev/null +++ b/404.html @@ -0,0 +1,30 @@ + + + + + + + + + 404 Not Found + + + + + + + + +
+ 404 Not Found +
+ +
+

+ お探しのページが見つかりませんでした。 +

+ + 5秒後にメインページへ移動します… +
+ + \ No newline at end of file diff --git a/Dialog.css b/Dialog.css new file mode 100644 index 0000000..34cd854 --- /dev/null +++ b/Dialog.css @@ -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; +} \ No newline at end of file diff --git a/Dialog.js b/Dialog.js new file mode 100644 index 0000000..b36215c --- /dev/null +++ b/Dialog.js @@ -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, `${urlString}`); + }); + + 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, `${urlString}`); + }); + }); + } + }); + + + + 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); +}); \ No newline at end of file diff --git a/Error/401/index.html b/Error/401/index.html new file mode 100644 index 0000000..4e3e0d2 --- /dev/null +++ b/Error/401/index.html @@ -0,0 +1,31 @@ + + + + + + + + + 401 Required Authorization + + + + + + + + +
+ 401 Required Authorization +
+ +
+

+ お探しのページの閲覧にはログインが必要です。
+ ログインしてからご利用ください。 +

+ + 5秒後にメインページへ移動します… +
+ + \ No newline at end of file diff --git a/Error/403.10/index.html b/Error/403.10/index.html new file mode 100644 index 0000000..2320886 --- /dev/null +++ b/Error/403.10/index.html @@ -0,0 +1,30 @@ + + + + + + + + + 403 Not Allowed + + + + + + + + +
+ 403 Not Allowed +
+ +
+

+ 正規ルートでのアクセスが確認できませんでした。 +

+ + 5秒後にメインページへ移動します… +
+ + \ No newline at end of file diff --git a/Error/406/index.html b/Error/406/index.html new file mode 100644 index 0000000..2a5141a --- /dev/null +++ b/Error/406/index.html @@ -0,0 +1,31 @@ + + + + + + + + + 406 Not Acceptable + + + + + + + + +
+ 406 Not Acceptable +
+ +
+

+ リクエストを正常に認識できませんでした。
+ 不正なリクエストが送信された可能性があります。 +

+ + 5秒後にメインページへ移動します… +
+ + \ No newline at end of file diff --git a/Error/Back.jpg b/Error/Back.jpg new file mode 100644 index 0000000..ea41024 Binary files /dev/null and b/Error/Back.jpg differ diff --git a/Error/Main.css b/Error/Main.css new file mode 100644 index 0000000..611f9bb --- /dev/null +++ b/Error/Main.css @@ -0,0 +1,26 @@ +Body { + Margin: 5% 10% 0 10%; + + Border: Thin Solid LightGray; + Border-Radius: 10px; +} + +Body > Div { + Padding: 10px; +} + +.Title { + Text-Align: Center; + Font-Size: XX-Large; + + BackGround: RGBA(173, 216, 230, 0.25); + Border-Bottom: Thin Solid LightBlue; +} + +.Title > Img { + Vertical-Align: Middle; +} + +.Message > P { + Margin-Top: 0; +} \ No newline at end of file diff --git a/Error/Main.js b/Error/Main.js new file mode 100644 index 0000000..6ecc08a --- /dev/null +++ b/Error/Main.js @@ -0,0 +1,3 @@ +setTimeout(() => { + window.open("/SimpleThread/", "_parent"); +}, 5000); \ No newline at end of file diff --git a/Error/favicon.ico b/Error/favicon.ico new file mode 100644 index 0000000..3dd9541 Binary files /dev/null and b/Error/favicon.ico differ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9cecc1d..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/Main.css b/Main.css new file mode 100644 index 0000000..1c29cd9 --- /dev/null +++ b/Main.css @@ -0,0 +1,7 @@ +#Header_Title { + Max-Width: 45%; + + Overflow: Hidden; + Text-Overflow: Ellipsis; + White-Space: NoWrap; +} \ No newline at end of file diff --git a/Main.js b/Main.js new file mode 100644 index 0000000..99023b1 --- /dev/null +++ b/Main.js @@ -0,0 +1,109 @@ +window.base = new DBLoader("assets/firebase.json", (user) => { + if (user) { + new DOM("#Header_SignInOut").dataset.locales = "main.signOut"; + + base.Database.getInfo(base.Database.ONCE, "users/" + user.uid, (res) => { + new DOM('@A[UUID="ProfilePhoto-Btn"]').forEach((btn) => { + btn.dataset.uid = base.user.uid; + }); + + if (!res.exists()) { + base.Database.set("users/" + user.uid, { + gplusName: user.providerData[0].displayName, + gplusPhoto: user.photoURL, + userName: user.providerData[0].displayName, + detail: "", + links: [] + }); + + new DOM("#Dialogs_Account_CreateNotify").showModal(); + } else { + base.Database.update("users/" + user.uid, { + gplusName: user.providerData[0].displayName, + gplusPhoto: user.photoURL + }); + } + }); + } else { + window.addEventListener("DOMContentLoaded", () => { + new DOM('@*[UUID="ProfilePhoto-Btn"]').forEach((btn) => { + btn.setAttribute("Disabled", ""); + }); + }); + } + + locales.applyToElement(new DOM("#Header_SignInOut")); + + base.Database.get(base.Database.ONCE, "users", (res) => { + for (let uid in res) { + let photoStyle = new Component.Styles.ProfilePhotoManager(uid, res[uid].gplusPhoto); + + document.head.appendChild(photoStyle); + } + }); + + + + let querys = location.querySort(); + + if (querys.TID) { + new DOM("$IFrame.mdl-layout__content").src = "Thread/Viewer/?tid=" + querys.TID; + } +}); + +window.terminal = (() => { + let terminal = new Worker("Terminal.js"); + terminal.addEventListener("message", (event) => { + let message = event.data || {}; + message.code = message.code || "", + message.data = !(message.data != false && !message.data) ? message.data : ""; + + switch (message.code) { + case "Code-SendHasLogined_1": + terminal.postMessage({ + code: "Code-SendHasLogined_2", + data: base.user ? true : false + }); + + break; + } + }); + + return terminal; +})(); + +window.locales = (() => { + let locales = new LangLoader(); + locales.load(localStorage.getItem("com.GenbuProject.SimpleThread.currentLang")); + + return locales; +})(); + + + +window.addEventListener("DOMContentLoaded", () => { + new DOM("$IFrame#Page").addEventListener("load", () => { + try { + !new DOM("#Drawer") || new DOM("#Drawer").classList.remove("is-visible"), + !new DOM("$Div.mdl-layout__obfuscator") || new DOM("$Div.mdl-layout__obfuscator").classList.remove("is-visible"); + } catch (error) {} + + if (new DOM("$IFrame#Page").contentWindow.location.pathname != "/SimpleThread/Thread/Viewer/") locales.applyToElement(new DOM("#Header_Title")); + }); + + new DOM("#Header_SignInOut").addEventListener("click", () => { + switch (new DOM("#Header_SignInOut").dataset.locales) { + case "main.signIn": + base.signInWithRedirect(base.SIGNINTYPE.GOOGLE, ["https://www.googleapis.com/auth/plus.login"]); + break; + + case "main.signOut": + base.signOut(); + break; + + default: + alert("Got to Default."); + break; + } + }); +}); \ No newline at end of file diff --git a/Profile/Profile.css b/Profile/Profile.css new file mode 100644 index 0000000..5ebc9a8 --- /dev/null +++ b/Profile/Profile.css @@ -0,0 +1,39 @@ +* { + Font-Family: "Meiryo UI"; +} + + + +#Profile { + Display: Flex; + Flex-Direction: Row; + Align-Items: Flex-Start; +} + +#Profile_Photo { + Width: 20%; + + Margin-Right: 5%; + + Border-Radius: 100%; +} + +#Profile_Photo::Before { + Content: ""; + + Display: Block; + Padding-Top: 100%; +} + +#Profile_Info { + Display: Flex; + Flex-Direction: Column; + + Flex: 1; + + Padding: 2vmin 0; +} + +#Profile_Info > * { + Width: 100%; +} \ No newline at end of file diff --git a/Profile/Profile.js b/Profile/Profile.js new file mode 100644 index 0000000..d5d101c --- /dev/null +++ b/Profile/Profile.js @@ -0,0 +1,104 @@ +terminal.addEventListener("message", (event) => { + let message = event.data || {}; + message.code = message.code || "", + message.data = !(message.data != false && !message.data) ? message.data : ""; + + switch (message.code) { + case "Code-SendHasLogined": + if (!message.data) location.href = "/SimpleThread/Error/401/"; + break; + } +}); + +window.addEventListener("DOMContentLoaded", () => { + new DOM("#Profile_Photo").dataset.uid = base.user.uid; + + new DOM("#Profile_Info_URL").childNodes[0].querySelector('Span.mdl-list__item-primary-content').dataset.locales = "profile.url"; + locales.applyToElement(new DOM("#Profile_Info_URL").childNodes[0].querySelector('Span.mdl-list__item-primary-content')); + + new DOM("#Profile_Info_URL_Add").addEventListener("click", () => { + new DOM("#Profile_Info_URL").childNodes[new DOM("#Profile_Info_URL").childNodes.length - 1].querySelector('Span.mdl-list__item-primary-content > *:nth-Child(1) > Label').dataset.locales = "profile.url.title", + new DOM("#Profile_Info_URL").childNodes[new DOM("#Profile_Info_URL").childNodes.length - 1].querySelector('Span.mdl-list__item-primary-content > *:nth-Child(2) > Label').dataset.locales = "profile.url.value"; + locales.applyToElement(new DOM("#Profile_Info_URL").childNodes[new DOM("#Profile_Info_URL").childNodes.length - 1].querySelector('Span.mdl-list__item-primary-content > *:nth-Child(1) > Label')), + locales.applyToElement(new DOM("#Profile_Info_URL").childNodes[new DOM("#Profile_Info_URL").childNodes.length - 1].querySelector('Span.mdl-list__item-primary-content > *:nth-Child(2) > Label')); + }); + + + + base.Database.get(base.Database.ONCE, "users", (res) => { + for (let uid in res) { + let photoStyle = new Component.Styles.ProfilePhotoManager(uid, res[uid].gplusPhoto); + + document.head.appendChild(photoStyle); + } + }); + + base.Database.get(base.Database.INTERVAL, "users/" + base.user.uid, (res) => { + res.links = res.links || []; + + new DOM("#Profile_Info_Name").classList.add("is-dirty"), + new DOM("#Profile_Info_Name-Input").value = res.userName; + new DOM("#Profile_Info_Detail").classList.add("is-dirty"), + new DOM("#Profile_Info_Detail-Input").value = res.detail; + + (() => { + let clientListLength = new DOM("#Profile_Info_URL").dataset.listlength; + + if (res.links.length - clientListLength > 0) { + for (let i = 0; i < res.links.length - clientListLength; i++) { + new DOM("#Profile_Info_URL_Add").click(); + } + } else { + for (let i = 0; i < clientListLength - res.links.length; i++) { + new DOM("#Profile_Info_URL").children[0].querySelector('Button[ID*="Remove"]').click(); + } + } + + for (let i = 0; i < res.links.length; i++) { + let currentList = new DOM("#Profile_Info_URL").querySelector('Li[Data-ItemID="' + i + '"]'); + currentList.querySelectorAll("Div").forEach((container) => { + container.classList.add("is-dirty"); + }); + + currentList.querySelector('Input[Data-FieldID="0"]').value = res.links[i].name, + currentList.querySelector('Input[Data-FieldID="1"]').value = res.links[i].url; + } + })(); + }); + + + + new DOM("#Profile_Info_Btns_Save").addEventListener("click", () => { + base.Database.update("users/" + base.user.uid, { + userName: new DOM("#Profile_Info_Name-Input").value, + detail: new DOM("#Profile_Info_Detail-Input").value, + + links: (() => { + let links = []; + + for (let i = 0; i < new DOM("#Profile_Info_URL").dataset.listlength; i++) { + let currentList = new DOM("#Profile_Info_URL").querySelector('Li[Data-ItemID="' + i + '"]'); + + links.push({ + name: currentList.querySelector('Input[Data-FieldID="0"]').value, + url: currentList.querySelector('Input[Data-FieldID="1"]').value + }); + } + + return links; + })() + }); + }); + + + + let doc = parent.document; + + new DOM("#Profile_Info_Btns_Save").addEventListener("click", () => { + doc.querySelector("#Dialogs_Profile_ChangeNotify").showModal(); + }); + + new DOM("#Profile_Info_Btns_Delete").addEventListener("click", () => { + doc.querySelector("#Dialogs_Profile_DeleteConfirmer").showModal(); + }); +}); \ No newline at end of file diff --git a/Profile/index.html b/Profile/index.html new file mode 100644 index 0000000..f62cea8 --- /dev/null +++ b/Profile/index.html @@ -0,0 +1,67 @@ + + + + + + Simple Thread == プロフィール + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+
+ + +
+ +
+ + +
+ +
    + +
    + + +
    +
    +
    +
    + + \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 32ee446..0000000 --- a/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Simple Thread - -## 1. Simple Thread とは? -> "Be Simple, Be Free" をモットーに掲げる、SNSサービス及びフレームワークの総称です。 -> -> 詳しい動作につきましては[こちら](https://genbuproject.github.io/SimpleThread/)をご覧下さい。 - -## 2. Simple Thread の歴史 -> | Date | Detail | -> | ---------- | ---------- | -> | 2017/01/01 | `v1`の構想を開始 | -> | 2017/08/24 | `v2`の構想を開始 | -> | 2017/08/30 | `v2`リリース | -> | 2017/09/05 | `v3`の構想を開始 | -> | 2017/12/01 | `v3_RC1`リリース | - -## 3. 詳細情報 -> * 最新バージョン -> * Stable ... `v2` -> * Latest ... `v3_RC1` \ No newline at end of file diff --git a/ServerInfo/ServerInfo.css b/ServerInfo/ServerInfo.css new file mode 100644 index 0000000..6ad9c52 --- /dev/null +++ b/ServerInfo/ServerInfo.css @@ -0,0 +1,9 @@ +#Top_Logo { + Width: 100%; + + Margin-Bottom: 5vmax; +} + +#ServerInfo { + Width: 100%; +} \ No newline at end of file diff --git a/ServerInfo/ServerInfo.js b/ServerInfo/ServerInfo.js new file mode 100644 index 0000000..e2a10fd --- /dev/null +++ b/ServerInfo/ServerInfo.js @@ -0,0 +1,17 @@ +window.addEventListener("DOMContentLoaded", () => { + base.Database.get(base.Database.INTERVAL, "users", (res) => { + let length = 0; + + for (let key in res) length++; + + new DOM("#ServerInfo_Users").textContent = length - 1; + }); + + base.Database.get(base.Database.INTERVAL, "threads", (res) => { + res = res.filter((thread) => { + if (thread !== "!SYSTEM") return true; + }); + + new DOM("#ServerInfo_Threads").textContent = res.length; + }); +}); \ No newline at end of file diff --git a/ServerInfo/index.html b/ServerInfo/index.html new file mode 100644 index 0000000..852d721 --- /dev/null +++ b/ServerInfo/index.html @@ -0,0 +1,80 @@ + + + + + + + Simple Thread == サーバー情報 + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +

    Server Info

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    項目
    サービス名称Simple Thread
    ユーザー数0
    スレッド数0
    最終更新日2017/11/29
    +
    +
    + + \ No newline at end of file diff --git a/Terminal.js b/Terminal.js new file mode 100644 index 0000000..d872fd2 --- /dev/null +++ b/Terminal.js @@ -0,0 +1,28 @@ +self.addEventListener("message", (event) => { + let message = event.data || {}; + message.code = message.code || "", + message.data = !(message.data != false && !message.data) ? message.data : ""; + + switch (message.code) { + case "Code-Connected": + break; + + case "Code-RequestHasLogined": + self.postMessage({ code: "Code-SendHasLogined_1" }); + break; + + case "Code-SendHasLogined_1": + break; + + case "Code-SendHasLogined_2": + self.postMessage({ + code: "Code-SendHasLogined", + data: message.data + }); + + break; + + case "Code-SendHasLogined": + break; + } +}); \ No newline at end of file diff --git a/Thread/Thread.css b/Thread/Thread.css new file mode 100644 index 0000000..5672457 --- /dev/null +++ b/Thread/Thread.css @@ -0,0 +1,21 @@ +#Threadlist_Tab_Reload { + Display: Inline-Flex; + Align-Items: Center; +} + +#Threadlist_Search_Searcher_Container { + Width: 100%; +} + +#Threadlist > Div[Disabled] { + Display: None; +} + +#Threadlist A { + Text-Decoration: None; + Cursor: Pointer; +} + +#Threadlist A[Disabled] { + Display: None; +} \ No newline at end of file diff --git a/Thread/Thread.js b/Thread/Thread.js new file mode 100644 index 0000000..72f2b1e --- /dev/null +++ b/Thread/Thread.js @@ -0,0 +1,56 @@ +class Util { + static refreshThreadList () { + base.Database.get(base.Database.ONCE, "threads", (res) => { + res = res.filter((thread, index, parent) => { + if (thread !== "!SYSTEM") { + thread.tid = index; + return true; + } + }); + + for (let i = 0; i < res.length; i++) { + let thread = new Component.Threadlist.Thread(res[i].tid, res[i].title, res[i].password); + + new DOM("#Threadlist_Search").appendChild(thread); + if (base.user) if (res[i].jobs.Owner.hasOwnProperty(base.user.uid)) new DOM("#Threadlist_Admin").appendChild(thread); + } + }); + } +} + +window.addEventListener("DOMContentLoaded", () => { + if (!base.user) { + new DOM("$#Threadlist_Tab_Admin").setAttribute("Disabled", ""), + new DOM("$#Threadlist_Admin").setAttribute("Disabled", ""); + } + + Util.refreshThreadList(); + + + + new DOM("#Threadlist_Search_Searcher_Container-Input").addEventListener("input", (event) => { + let list = Array.from(new DOM("#Threadlist_Search").children).splice(1); + list.forEach((thread) => { + if (thread.querySelector("Span:Not(.mdl-list__item-primary-content)").textContent.toLowerCase().indexOf(event.target.value.toLowerCase()) == -1) { + thread.setAttribute("Disabled", ""); + } else { + thread.removeAttribute("Disabled"); + } + }); + }); + + new DOM("#Threadlist_Tab_Reload").addEventListener("click", (event) => { + while (new DOM("#Threadlist_Search").children.length > 1) new DOM("#Threadlist_Search").children[1].remove(); + while (new DOM("#Threadlist_Admin").children.length > 1) new DOM("#Threadlist_Admin").children[1].remove(); + + Util.refreshThreadList(); + }); + + + + let doc = parent.document; + + new DOM("#Threadlist_Admin_Create").addEventListener("click", () => { + doc.querySelector("#Dialogs_Thread_InfoInputer").showModal(); + }); +}); \ No newline at end of file diff --git a/Thread/Viewer/Auth/Auth.css b/Thread/Viewer/Auth/Auth.css new file mode 100644 index 0000000..e69de29 diff --git a/Thread/Viewer/Auth/Auth.js b/Thread/Viewer/Auth/Auth.js new file mode 100644 index 0000000..a680c09 --- /dev/null +++ b/Thread/Viewer/Auth/Auth.js @@ -0,0 +1,15 @@ +window.addEventListener("DOMContentLoaded", () => { + let doc = parent.document; + + if (doc.querySelector("#Dialogs_Thread_PasswordConfirmer_Link").value) { + doc.querySelector("#Dialogs_Thread_PasswordConfirmer").showModal(); + } else { + doc.querySelector("IFrame.mdl-layout__content").src = "Thread/"; + } + + let querys = location.querySort(); + + base.Database.get(base.Database.ONCE, "threads/" + querys.TID, (res) => { + doc.querySelector("#Dialogs_Thread_PasswordConfirmer_Password").value = res.password; + }); +}); \ No newline at end of file diff --git a/Thread/Viewer/Auth/index.html b/Thread/Viewer/Auth/index.html new file mode 100644 index 0000000..1e1550f --- /dev/null +++ b/Thread/Viewer/Auth/index.html @@ -0,0 +1,34 @@ + + + + + + Simple Thread == Authorization + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Thread/Viewer/Viewer.css b/Thread/Viewer/Viewer.css new file mode 100644 index 0000000..76beef8 --- /dev/null +++ b/Thread/Viewer/Viewer.css @@ -0,0 +1,76 @@ +Div[Data-Component="Thread_Post"], Div[Data-Component="Thread_Post-Mine"] { + Width: 100%; + Min-Height: Auto; + + Margin: 5vh 0; +} + +Div[Data-Component="Thread_Post_Header"] > * { + Display: Flex; + Flex-Direction: Row; + Align-Items: Center; + + Font-Size: Medium; +} + +A[Data-Component="Thread_Post_Header_ActorPhoto"] { + Background: Transparent Center / Cover; +} + +A[Data-Component="Thread_Post_Header_ActorPhoto"][Disabled] { + Display: None; +} + +Span[Data-Component="Thread_Post_Header_Actor"] { + Align-Self: Auto; + + Margin-Left: 0.5em; +} + +Span[Data-Component="Thread_Post_Header_CreatedAt"] { + Color: #BDBDBD; + Font-Size: 80%; +} + +Div[Data-Component="Thread_Post_Content"] { + White-Space: Pre-Wrap; +} + + + +#FlowPanel_Btns { + Position: Fixed; + Right: 0; + Bottom: 0; + + Display: Flex; + Flex-Direction: Row-Reverse; + + Padding: 5vh 4vw; + Z-Index: 100; +} + +#FlowPanel_Btns *[Disabled] { + Display: None; +} + +#FlowPanel_Btns > Div { + Margin-Left: 2.5vw; +} + +#FlowPanel_Btns > Div:Last-Child { + Margin-Left: 0; +} + +.FlowPanel_Btns_Row { + Display: Flex; + Flex-Direction: Column; +} + +.FlowPanel_Btns_Row > * { + Margin-Bottom: 2.5vw; +} + +.FlowPanel_Btns_Row > *:Last-Child { + Margin-Bottom: 0; +} \ No newline at end of file diff --git a/Thread/Viewer/Viewer.js b/Thread/Viewer/Viewer.js new file mode 100644 index 0000000..a83ceda --- /dev/null +++ b/Thread/Viewer/Viewer.js @@ -0,0 +1,96 @@ +window.addEventListener("DOMContentLoaded", () => { + let querys = location.querySort(); + + if (!querys.TID) { + location.href = "/SimpleThread/Error/406/"; + } + + if (!base.user) { + new DOM("#FlowPanel_Btns_CreatePost").setAttribute("Disabled", ""); + } + + + + let doc = parent.document; + doc.querySelector("#Dialogs_Thread_InfoViewer_TID").value = querys.TID; + doc.querySelector("#Dialogs_Thread_Poster_TID").value = querys.TID; + + base.Database.get(base.Database.ONCE, "threads/" + querys.TID, (res) => { + doc.querySelector("#Header_Title").textContent = `${res.title}`; + + if (res.password && res.password != Encrypter.encrypt(sessionStorage.getItem("com.GenbuProject.SimpleThread.currentPassword") || "")) { + doc.querySelector("#Dialogs_Thread_PasswordConfirmer_Link").value = location.href; + + doc.querySelector("IFrame.mdl-layout__content").src = `Thread/Viewer/Auth/?tid=${querys.TID}`; + } + }); + + base.Database.get(base.Database.ONCE, "users", (res) => { + for (let uid in res) document.head.appendChild(new Component.Styles.ProfilePhotoManager(uid, res[uid].gplusPhoto)); + }); + + base.Database.get(base.Database.INTERVAL, "threads/" + querys.TID + "/data", (res) => { + resForIncrease = res, resForDecrease = res; + + resForIncrease = resForIncrease.filter((post, index, parent) => { + if (post) { + post.pid = index; + return true; + } + }); + + resForDecrease.forEach((post, index, parent) => { + post.pid = index; + }); + + if (new DOM("#Thread").children.length < resForIncrease.length) { + for (let i = new DOM("#Thread").children.length; i < resForIncrease.length; i++) { + let post = new Component.Thread.Post(resForIncrease[i].pid, resForIncrease[i].uid, "", resForIncrease[i].content, new Date(resForIncrease[i].createdAt).toLocaleString(), base.user.uid == resForIncrease[i].uid && i !== 0); + post.querySelector('A[Data-Component="Thread_Post_Header_ActorPhoto"]').addEventListener("click", () => { + doc.querySelector("#Dialogs_Profile_InfoViewer_UID").value = post.uid; + doc.querySelector("#Dialogs_Profile_InfoViewer").showModal(); + }); + + if (post.querySelector(`UL[Data-Component="${Component.Thread.Post.UUIDS.MENU.ROOT}"]`)) { + setTimeout(() => { + componentHandler.upgradeElement(post.querySelector(`UL[Data-Component="${Component.Thread.Post.UUIDS.MENU.ROOT}"]`)); + }, 100); + + post.querySelector(`Li[Data-Component="${Component.Thread.Post.UUIDS.MENU.DELETE}"]`).addEventListener("click", () => { + base.Database.delete(`threads/${querys.TID}/data/${post.pid}/`); + }); + } + + base.Database.get(base.Database.ONCE, "users/" + post.uid, (userRes) => { + post.querySelector('Span[Data-Component="Thread_Post_Header_Actor"]').textContent = userRes.userName; + }); + + URL.filter(post.querySelector('Div[Data-Component="Thread_Post_Content"]').textContent).forEach((urlString) => { + post.querySelector('Div[Data-Component="Thread_Post_Content"]').innerHTML = post.querySelector('Div[Data-Component="Thread_Post_Content"]').innerHTML.replace(urlString, `${urlString}`); + }); + + new DOM("#Thread").appendChild(post); + } + } else { + new DOM('@Div[Data-Component="Thread_Post"]').forEach((post) => { + if (!resForDecrease[post.dataset.pid]) post.remove(); + }); + + new DOM('@Div[Data-Component="Thread_Post-Mine"]').forEach((post) => { + if (!resForDecrease[post.dataset.pid]) post.remove(); + }); + } + }); + + + + new DOM("#FlowPanel_Btns_CreatePost").addEventListener("click", () => { + doc.querySelector("#Dialogs_Thread_Poster").showModal(); + + new DOM("#FlowPanel_Btns_CreatePost").setAttribute("Disabled", ""); + }); + + new DOM("#FlowPanel_Btns_ShowThreadInfo").addEventListener("click", () => { + doc.querySelector("#Dialogs_Thread_InfoViewer").showModal(); + }); +}); \ No newline at end of file diff --git a/Thread/Viewer/index.html b/Thread/Viewer/index.html new file mode 100644 index 0000000..762cd66 --- /dev/null +++ b/Thread/Viewer/index.html @@ -0,0 +1,70 @@ + + + + + + Simple Thread == スレッドビューア + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    + +
    +
    + + + +
    + +
    + +
    +
    + + \ No newline at end of file diff --git a/Thread/index.html b/Thread/index.html new file mode 100644 index 0000000..f7db75b --- /dev/null +++ b/Thread/index.html @@ -0,0 +1,79 @@ + + + + + + Simple Thread == スレッド一覧 + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + +
    +
    + + \ No newline at end of file diff --git a/Top/Top.css b/Top/Top.css new file mode 100644 index 0000000..8ac72b1 --- /dev/null +++ b/Top/Top.css @@ -0,0 +1,5 @@ +#Top_Logo { + Width: 100%; + + Margin-Bottom: 5vmax; +} \ No newline at end of file diff --git a/Top/Top.js b/Top/Top.js new file mode 100644 index 0000000..e69de29 diff --git a/Top/index.html b/Top/index.html new file mode 100644 index 0000000..959f567 --- /dev/null +++ b/Top/index.html @@ -0,0 +1,51 @@ + + + + + + Simple Thread == トップページ + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + +

    + Simple Threadへようこそ! + 当サービスでは "Be Simple, Be Free" をモットーに、他サービスと比べ自由に話せるスレ板を提供しますΣd(´・ω・`) +

    +
    +
    + + \ No newline at end of file diff --git a/assets/classes/DBLoader.js b/assets/classes/DBLoader.js new file mode 100644 index 0000000..c590abb --- /dev/null +++ b/assets/classes/DBLoader.js @@ -0,0 +1,35 @@ +class DBLoader extends FirebasePlus { + constructor (configUrl = "assets/firebase.json", onload = () => {}) { + let cfgLoader = new JSONLoader(); + + super(cfgLoader.load(configUrl), onload); + } + + + + delete () { + this.reauth([""]).then(() => { + this.Database.get(this.Database.ONCE, "threads/", res => { + res.forEach((thread, threadIndex) => { + if (thread.data) { + for (let uid in thread.jobs.Owner) { + if (uid === this.user.uid) { + this.Database.delete(`threads/${threadIndex}/`); + return; + } + } + + thread.data.forEach((post, postIndex) => { + if (post.uid == this.user.uid) this.Database.delete(`threads/${threadIndex}/data/${postIndex}/`); + }); + } + }); + }); + + this.Database.delete("users/" + this.user.uid); + this.user.delete(); + + location.reload(); + }); + } +} \ No newline at end of file diff --git a/assets/classes/Encrypter.js b/assets/classes/Encrypter.js new file mode 100644 index 0000000..7037adb --- /dev/null +++ b/assets/classes/Encrypter.js @@ -0,0 +1,17 @@ +class Encrypter { + /** + * 文字列をHash(SHA-512)で暗号化する + * @memberof Encrypter + * @static + * + * @param {String} [text=""] + * @param {String} [type="HEX"] + * @returns {String} + */ + static encrypt (text = "", type = "HEX") { + let encrypter = new jsSHA("SHA-512", "TEXT"); + encrypter.update(text); + + return encrypter.getHash(type); + } +} \ No newline at end of file diff --git a/assets/classes/FileLoader.js b/assets/classes/FileLoader.js new file mode 100644 index 0000000..c0c73bd --- /dev/null +++ b/assets/classes/FileLoader.js @@ -0,0 +1,28 @@ +class FileLoader { + constructor () {} + + + + /** + * 指定されたurlからファイルを読み込む + * @memberof FileLoader + * + * @param {String} url + */ + load (url) { + try { + let reader = new XMLHttpRequest(); + reader.open("GET", url || location.href, false); + reader.send(null); + + this.currentData = reader.response; + } catch (error) { + this.currentData = null; + console.error(error); + } + + return this.currentData; + } +}; Object.defineProperties(FileLoader.prototype, { + currentData: { value: null, configurable: true, writable: true, enumerable: true } +}); \ No newline at end of file diff --git a/assets/classes/JSONLoader.js b/assets/classes/JSONLoader.js new file mode 100644 index 0000000..8ae5aeb --- /dev/null +++ b/assets/classes/JSONLoader.js @@ -0,0 +1,16 @@ +class JSONLoader extends FileLoader { + constructor () { super() } + + + + /** + * 指定されたurlからJSONデータを読み込む + * @memberof JSONLoader + * + * @param {String} url + */ + load (url) { + this.currentData = JSON.parse(super.load(url)); + return this.currentData; + } +} \ No newline at end of file diff --git a/assets/classes/LangLoader.js b/assets/classes/LangLoader.js new file mode 100644 index 0000000..7611ba5 --- /dev/null +++ b/assets/classes/LangLoader.js @@ -0,0 +1,53 @@ +class LangLoader extends JSONLoader { + constructor () { + super(); + + localStorage.getItem("com.GenbuProject.SimpleThread.currentLang") || localStorage.setItem("com.GenbuProject.SimpleThread.currentLang", "ja_JP"); + } + + /** + * 指定されたurlからローカライズデータを読み込む + * @memberof LangLoader + * + * @param {String} lang + */ + load (lang) { + return super.load(`/SimpleThread/assets/locales/${lang}.json`); + } + + /** + * ローカライズ処理を実行 + * @memberof LangLoader + * + * @param {Window} windowObj + */ + apply (windowObj) { + let localizedElems = windowObj.document.querySelectorAll('*[Data-Locales]'); + + localizedElems.forEach((elem) => { + if (this.currentData[elem.dataset.locales]) { + if (Array.isArray(this.currentData[elem.dataset.locales])) { + elem.textContent = this.currentData[elem.dataset.locales].join("\n"); + } else { + elem.textContent = this.currentData[elem.dataset.locales]; + } + } + }); + } + + /** + * 指定の要素に対しローカライズ処理を実行 + * @memberof LangLoader + * + * @param {HTMLElement} elem + */ + applyToElement (elem) { + if (this.currentData[elem.dataset.locales]) { + if (Array.isArray(this.currentData[elem.dataset.locales])) { + elem.textContent = this.currentData[elem.dataset.locales].join("\n"); + } else { + elem.textContent = this.currentData[elem.dataset.locales]; + } + } + } +} \ No newline at end of file diff --git a/assets/firebase.json b/assets/firebase.json new file mode 100644 index 0000000..aed32ae --- /dev/null +++ b/assets/firebase.json @@ -0,0 +1,8 @@ +{ + "apiKey": "AIzaSyA62uPkN6WNV41oWWzOdiITMbBF9RDYOhM", + "authDomain": "simple-thread.firebaseapp.com", + "databaseURL": "https://simple-thread.firebaseio.com", + "projectId": "simple-thread", + "storageBucket": "simple-thread.appspot.com", + "messagingSenderId": 646527306803 +} \ No newline at end of file diff --git a/assets/images/Back.jpg b/assets/images/Back.jpg new file mode 100644 index 0000000..ea41024 Binary files /dev/null and b/assets/images/Back.jpg differ diff --git a/assets/images/Logo.png b/assets/images/Logo.png new file mode 100644 index 0000000..d188f08 Binary files /dev/null and b/assets/images/Logo.png differ diff --git a/assets/images/favicon0001.png b/assets/images/favicon0001.png new file mode 100644 index 0000000..30d2adc Binary files /dev/null and b/assets/images/favicon0001.png differ diff --git a/assets/images/favicon0002.png b/assets/images/favicon0002.png new file mode 100644 index 0000000..ef97677 Binary files /dev/null and b/assets/images/favicon0002.png differ diff --git a/assets/includes/Component.html b/assets/includes/Component.html new file mode 100644 index 0000000..7179e09 --- /dev/null +++ b/assets/includes/Component.html @@ -0,0 +1,70 @@ +
    + +
    + +
    +
    + + ${0} +
    +
    + +
    + + + person + ${1} + + + + + + person + ${1} + + + + lock + + +
    + +
    +
    +
    + + ${2} +
    + + ${4} +
    + +
    ${3}
    +
    +
    + +
    +
    + + ${2} +
    + + ${4} + + + +
      +
    • 投稿を削除
    • +
    +
    + +
    ${3}
    +
    +
    +
    \ No newline at end of file diff --git a/assets/includes/Component.js b/assets/includes/Component.js new file mode 100644 index 0000000..0f31456 --- /dev/null +++ b/assets/includes/Component.js @@ -0,0 +1,139 @@ +class Component { + /** + * コンポーネントへの参照 + * @returns {HTMLBodyElement} + */ + static get doc () { + let doc = new DOM("Body"); + + try { + doc.innerHTML = DOM.xhr({ + type: "GET", + url: "/SimpleThread/assets/includes/Component.html", + doesSync: false + }).response; + } catch (error) {} + + return doc; + } + + + + constructor (componentName = "") { + try { + let component = document.importNode(Component.doc.querySelector(`*[Data-Component="${componentName}"]`), true); + + let componentWrapper = new DOM("ComponentWrapper"); + componentWrapper.appendChild(component); + + componentWrapper.firstElementChild.outerHTML = (() => { + let content = componentWrapper.firstElementChild.outerHTML; + + for (let i = 0; i < arguments.length + 1; i++) { + content = content.replace(new RegExp("\\$\\{" + i + "\\}", "g"), arguments[i + 1]); + } + + return content; + })(); + + return componentWrapper.firstElementChild; + } catch (error) { + console.error(error); + } + } + + + + static get Styles () { + return { + ProfilePhotoManager: class ProfilePhotoManager { + static get UUIDS () { + return { + ROOT: 'Styles_ProfilePhoto--Manager' + } + } + + + + constructor (uid = "", photoUrl = "") { + return new Component(ProfilePhotoManager.UUIDS.ROOT, uid, photoUrl); + } + } + } + } + + static get Dialogs () { + return { + Profile: { + InfoViewer: { + Links: { + Link: class Link { + static get UUIDS () { + return { + ROOT: 'Dialogs_Profile_InfoViewer_Content_Info_Links_Link', + ICON: 'Dialogs_Profile_InfoViewer_Content_Info_Links_Link_Icon', + } + } + + + + constructor (urlTitle = "", url = "") { + let self = new Component(Link.UUIDS.ROOT, urlTitle, url); + self.querySelector(`Img[Data-Component="${Link.UUIDS.ICON}"]`).src = `${new URL(url).origin}/favicon.ico` || `${locaion.origin}/favicon.ico`; + + return self; + } + } + } + } + } + } + } + + static get Threadlist () { + return { + Thread: class Thread { + static get UUIDS () { + return { + ROOT: 'Threadlist_Thread', + SECURED: 'Threadlist_Thread-Secured' + } + } + + + + constructor (tid = "", title = "", isSecured = false) { + return new Component(!isSecured ? Thread.UUIDS.ROOT : Thread.UUIDS.SECURED, tid, title); + } + } + } + } + + static get Thread () { + return { + Post: class Post { + static get UUIDS () { + return { + ROOT: 'Thread_Post', + MINE: 'Thread_Post-Mine', + + MENU: { + ROOT: 'Thread_Post_Header_Menu', + DELETE: 'Thread_Post_Header_Menu_MenuItem-Delete' + } + } + } + + + + constructor (pid = "", uid = "", userName = "", content = "", createdAt = new Date().toLocaleString(), isMine = false) { + let self = new Component(!isMine ? Post.UUIDS.ROOT : Post.UUIDS.MINE, pid, uid, userName, content, createdAt, new DOM.Randomizer().generate(16)); + self.pid = pid, + self.uid = uid; + + return self; + } + } + } + } +} \ No newline at end of file diff --git a/assets/includes/Core.css b/assets/includes/Core.css new file mode 100644 index 0000000..2aa3279 --- /dev/null +++ b/assets/includes/Core.css @@ -0,0 +1,39 @@ +Body { + Background: URL("/SimpleThread/assets/images/Back.jpg"); +} + +Main { + Padding: 4vmin; +} + +A:Not([Href]) { + Cursor: Pointer; +} + +*[Data-Locales] { + White-Space: Pre-Line; +} + + + +*[UUID="ProfilePhoto"] { + Width: Auto; + + Background: Transparent Center / Cover; + Border-Radius: 100%; +} + +*[UUID="ProfilePhoto"]::Before { + Content: ""; + + Display: Block; + Padding-Top: 100%; +} + +*[UUID="ProfilePhoto-Btn"] { + Background: Transparent Center / Cover; +} + +*[UUID="ProfilePhoto-Btn"][Disabled] { + Display: None; +} \ No newline at end of file diff --git a/assets/includes/Core.js b/assets/includes/Core.js new file mode 100644 index 0000000..357515a --- /dev/null +++ b/assets/includes/Core.js @@ -0,0 +1,46 @@ +window.base = parent.base || {}; +window.terminal = parent.terminal || {}; +window.locales = parent.locales; + + + +try { + terminal.postMessage({ code: "Code-Connected" }); + terminal.postMessage({ code: "Code-RequestHasLogined" }); +} catch (error) { + location.href = "/SimpleThread/Error/403.10/"; +} + +window.addEventListener("DOMContentLoaded", () => { + locales.apply(this); + + new DOM("@Main").forEach(elem => { + let classes = navigator.isMobile() ? + ["mdl-cell", "mdl-cell--12-col", "mdl-shadow--4dp", "mdl-color--white", "mdl-color-text--grey-800"] : + ["mdl-cell", "mdl-cell--2-offset", "mdl-cell--8-col", "mdl-shadow--4dp", "mdl-color--white", "mdl-color-text--grey-800"]; + + classes.forEach(className => { + elem.classList.add(className); + }); + }); + + new DOM('@A[Href]:Not([Target]):Not([Href^="javascript:"])').forEach((elem) => { + elem.addEventListener("click", (event) => { + event.preventDefault(); + + parent.document.querySelector("IFrame.mdl-layout__content").src = elem.href; + }); + }); + + parent.document.querySelector("IFrame#Page").contentWindow.addEventListener("beforeunload", () => { + parent.document.querySelectorAll("Dialog[Open]").forEach((dialog) => { + dialog.close(); + }); + }); +}); + +window.addEventListener("DOMNodeInserted", (event) => { + if (event.target.nodeName != "#text" && event.relatedNode.dataset && event.relatedNode.dataset.locales) { + locales.applyToElement(event.relatedNode); + } +}); \ No newline at end of file diff --git a/assets/includes/dialog-polyfill.css b/assets/includes/dialog-polyfill.css new file mode 100644 index 0000000..6b38bf0 --- /dev/null +++ b/assets/includes/dialog-polyfill.css @@ -0,0 +1,37 @@ +dialog { + position: absolute; + left: 0; right: 0; + width: -moz-fit-content; + width: -webkit-fit-content; + width: fit-content; + height: -moz-fit-content; + height: -webkit-fit-content; + height: fit-content; + margin: auto; + border: solid; + padding: 1em; + background: white; + color: black; + display: block; +} + +dialog:not([open]) { + display: none; +} + +dialog + .backdrop { + position: fixed; + top: 0; right: 0; bottom: 0; left: 0; + background: rgba(0,0,0,0.1); +} + +._dialog_overlay { + position: fixed; + top: 0; right: 0; bottom: 0; left: 0; +} + +dialog.fixed { + position: fixed; + top: 50%; + transform: translate(0, -50%); +} \ No newline at end of file diff --git a/assets/includes/dialog-polyfill.js b/assets/includes/dialog-polyfill.js new file mode 100644 index 0000000..312647a --- /dev/null +++ b/assets/includes/dialog-polyfill.js @@ -0,0 +1,738 @@ +(function() { + + // nb. This is for IE10 and lower _only_. + var supportCustomEvent = window.CustomEvent; + if (!supportCustomEvent || typeof supportCustomEvent === 'object') { + supportCustomEvent = function CustomEvent(event, x) { + x = x || {}; + var ev = document.createEvent('CustomEvent'); + ev.initCustomEvent(event, !!x.bubbles, !!x.cancelable, x.detail || null); + return ev; + }; + supportCustomEvent.prototype = window.Event.prototype; + } + + /** + * @param {Element} el to check for stacking context + * @return {boolean} whether this el or its parents creates a stacking context + */ + function createsStackingContext(el) { + while (el && el !== document.body) { + var s = window.getComputedStyle(el); + var invalid = function(k, ok) { + return !(s[k] === undefined || s[k] === ok); + } + if (s.opacity < 1 || + invalid('zIndex', 'auto') || + invalid('transform', 'none') || + invalid('mixBlendMode', 'normal') || + invalid('filter', 'none') || + invalid('perspective', 'none') || + s['isolation'] === 'isolate' || + s.position === 'fixed' || + s.webkitOverflowScrolling === 'touch') { + return true; + } + el = el.parentElement; + } + return false; + } + + /** + * Finds the nearest from the passed element. + * + * @param {Element} el to search from + * @return {HTMLDialogElement} dialog found + */ + function findNearestDialog(el) { + while (el) { + if (el.localName === 'dialog') { + return /** @type {HTMLDialogElement} */ (el); + } + el = el.parentElement; + } + return null; + } + + /** + * Blur the specified element, as long as it's not the HTML body element. + * This works around an IE9/10 bug - blurring the body causes Windows to + * blur the whole application. + * + * @param {Element} el to blur + */ + function safeBlur(el) { + if (el && el.blur && el !== document.body) { + el.blur(); + } + } + + /** + * @param {!NodeList} nodeList to search + * @param {Node} node to find + * @return {boolean} whether node is inside nodeList + */ + function inNodeList(nodeList, node) { + for (var i = 0; i < nodeList.length; ++i) { + if (nodeList[i] === node) { + return true; + } + } + return false; + } + + /** + * @param {HTMLFormElement} el to check + * @return {boolean} whether this form has method="dialog" + */ + function isFormMethodDialog(el) { + if (!el || !el.hasAttribute('method')) { + return false; + } + return el.getAttribute('method').toLowerCase() === 'dialog'; + } + + /** + * @param {!HTMLDialogElement} dialog to upgrade + * @constructor + */ + function dialogPolyfillInfo(dialog) { + this.dialog_ = dialog; + this.replacedStyleTop_ = false; + this.openAsModal_ = false; + + // Set a11y role. Browsers that support dialog implicitly know this already. + if (!dialog.hasAttribute('role')) { + dialog.setAttribute('role', 'dialog'); + } + + dialog.show = this.show.bind(this); + dialog.showModal = this.showModal.bind(this); + dialog.close = this.close.bind(this); + + if (!('returnValue' in dialog)) { + dialog.returnValue = ''; + } + + if ('MutationObserver' in window) { + var mo = new MutationObserver(this.maybeHideModal.bind(this)); + mo.observe(dialog, {attributes: true, attributeFilter: ['open']}); + } else { + // IE10 and below support. Note that DOMNodeRemoved etc fire _before_ removal. They also + // seem to fire even if the element was removed as part of a parent removal. Use the removed + // events to force downgrade (useful if removed/immediately added). + var removed = false; + var cb = function() { + removed ? this.downgradeModal() : this.maybeHideModal(); + removed = false; + }.bind(this); + var timeout; + var delayModel = function(ev) { + if (ev.target !== dialog) { return; } // not for a child element + var cand = 'DOMNodeRemoved'; + removed |= (ev.type.substr(0, cand.length) === cand); + window.clearTimeout(timeout); + timeout = window.setTimeout(cb, 0); + }; + ['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(function(name) { + dialog.addEventListener(name, delayModel); + }); + } + // Note that the DOM is observed inside DialogManager while any dialog + // is being displayed as a modal, to catch modal removal from the DOM. + + Object.defineProperty(dialog, 'open', { + set: this.setOpen.bind(this), + get: dialog.hasAttribute.bind(dialog, 'open') + }); + + this.backdrop_ = document.createElement('div'); + this.backdrop_.className = 'backdrop'; + this.backdrop_.addEventListener('click', this.backdropClick_.bind(this)); + } + + dialogPolyfillInfo.prototype = { + + get dialog() { + return this.dialog_; + }, + + /** + * Maybe remove this dialog from the modal top layer. This is called when + * a modal dialog may no longer be tenable, e.g., when the dialog is no + * longer open or is no longer part of the DOM. + */ + maybeHideModal: function() { + if (this.dialog_.hasAttribute('open') && document.body.contains(this.dialog_)) { return; } + this.downgradeModal(); + }, + + /** + * Remove this dialog from the modal top layer, leaving it as a non-modal. + */ + downgradeModal: function() { + if (!this.openAsModal_) { return; } + this.openAsModal_ = false; + this.dialog_.style.zIndex = ''; + + // This won't match the native exactly because if the user set top on a centered + // polyfill dialog, that top gets thrown away when the dialog is closed. Not sure it's + // possible to polyfill this perfectly. + if (this.replacedStyleTop_) { + this.dialog_.style.top = ''; + this.replacedStyleTop_ = false; + } + + // Clear the backdrop and remove from the manager. + this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(this.backdrop_); + dialogPolyfill.dm.removeDialog(this); + }, + + /** + * @param {boolean} value whether to open or close this dialog + */ + setOpen: function(value) { + if (value) { + this.dialog_.hasAttribute('open') || this.dialog_.setAttribute('open', ''); + } else { + this.dialog_.removeAttribute('open'); + this.maybeHideModal(); // nb. redundant with MutationObserver + } + }, + + /** + * Handles clicks on the fake .backdrop element, redirecting them as if + * they were on the dialog itself. + * + * @param {!Event} e to redirect + */ + backdropClick_: function(e) { + if (!this.dialog_.hasAttribute('tabindex')) { + // Clicking on the backdrop should move the implicit cursor, even if dialog cannot be + // focused. Create a fake thing to focus on. If the backdrop was _before_ the dialog, this + // would not be needed - clicks would move the implicit cursor there. + var fake = document.createElement('div'); + this.dialog_.insertBefore(fake, this.dialog_.firstChild); + fake.tabIndex = -1; + fake.focus(); + this.dialog_.removeChild(fake); + } else { + this.dialog_.focus(); + } + + var redirectedEvent = document.createEvent('MouseEvents'); + redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable, window, + e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, + e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget); + this.dialog_.dispatchEvent(redirectedEvent); + e.stopPropagation(); + }, + + /** + * Focuses on the first focusable element within the dialog. This will always blur the current + * focus, even if nothing within the dialog is found. + */ + focus_: function() { + // Find element with `autofocus` attribute, or fall back to the first form/tabindex control. + var target = this.dialog_.querySelector('[autofocus]:not([disabled])'); + if (!target && this.dialog_.tabIndex >= 0) { + target = this.dialog_; + } + if (!target) { + // Note that this is 'any focusable area'. This list is probably not exhaustive, but the + // alternative involves stepping through and trying to focus everything. + var opts = ['button', 'input', 'keygen', 'select', 'textarea']; + var query = opts.map(function(el) { + return el + ':not([disabled])'; + }); + // TODO(samthor): tabindex values that are not numeric are not focusable. + query.push('[tabindex]:not([disabled]):not([tabindex=""])'); // tabindex != "", not disabled + target = this.dialog_.querySelector(query.join(', ')); + } + safeBlur(document.activeElement); + target && target.focus(); + }, + + /** + * Sets the zIndex for the backdrop and dialog. + * + * @param {number} dialogZ + * @param {number} backdropZ + */ + updateZIndex: function(dialogZ, backdropZ) { + if (dialogZ < backdropZ) { + throw new Error('dialogZ should never be < backdropZ'); + } + this.dialog_.style.zIndex = dialogZ; + this.backdrop_.style.zIndex = backdropZ; + }, + + /** + * Shows the dialog. If the dialog is already open, this does nothing. + */ + show: function() { + if (!this.dialog_.open) { + this.setOpen(true); + this.focus_(); + } + }, + + /** + * Show this dialog modally. + */ + showModal: function() { + if (this.dialog_.hasAttribute('open')) { + throw new Error('Failed to execute \'showModal\' on dialog: The element is already open, and therefore cannot be opened modally.'); + } + if (!document.body.contains(this.dialog_)) { + throw new Error('Failed to execute \'showModal\' on dialog: The element is not in a Document.'); + } + if (!dialogPolyfill.dm.pushDialog(this)) { + throw new Error('Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.'); + } + + if (createsStackingContext(this.dialog_.parentElement)) { + console.warn('A dialog is being shown inside a stacking context. ' + + 'This may cause it to be unusable. For more information, see this link: ' + + 'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context'); + } + + this.setOpen(true); + this.openAsModal_ = true; + + // Optionally center vertically, relative to the current viewport. + if (dialogPolyfill.needsCentering(this.dialog_)) { + dialogPolyfill.reposition(this.dialog_); + this.replacedStyleTop_ = true; + } else { + this.replacedStyleTop_ = false; + } + + // Insert backdrop. + this.dialog_.parentNode.insertBefore(this.backdrop_, this.dialog_.nextSibling); + + // Focus on whatever inside the dialog. + this.focus_(); + }, + + /** + * Closes this HTMLDialogElement. This is optional vs clearing the open + * attribute, however this fires a 'close' event. + * + * @param {string=} opt_returnValue to use as the returnValue + */ + close: function(opt_returnValue) { + if (!this.dialog_.hasAttribute('open')) { + throw new Error('Failed to execute \'close\' on dialog: The element does not have an \'open\' attribute, and therefore cannot be closed.'); + } + this.setOpen(false); + + // Leave returnValue untouched in case it was set directly on the element + if (opt_returnValue !== undefined) { + this.dialog_.returnValue = opt_returnValue; + } + + // Triggering "close" event for any attached listeners on the . + var closeEvent = new supportCustomEvent('close', { + bubbles: false, + cancelable: false + }); + this.dialog_.dispatchEvent(closeEvent); + } + + }; + + var dialogPolyfill = {}; + + dialogPolyfill.reposition = function(element) { + var scrollTop = document.body.scrollTop || document.documentElement.scrollTop; + var topValue = scrollTop + (window.innerHeight - element.offsetHeight) / 2; + element.style.top = Math.max(scrollTop, topValue) + 'px'; + }; + + dialogPolyfill.isInlinePositionSetByStylesheet = function(element) { + for (var i = 0; i < document.styleSheets.length; ++i) { + var styleSheet = document.styleSheets[i]; + var cssRules = null; + // Some browsers throw on cssRules. + try { + cssRules = styleSheet.cssRules; + } catch (e) {} + if (!cssRules) { continue; } + for (var j = 0; j < cssRules.length; ++j) { + var rule = cssRules[j]; + var selectedNodes = null; + // Ignore errors on invalid selector texts. + try { + selectedNodes = document.querySelectorAll(rule.selectorText); + } catch(e) {} + if (!selectedNodes || !inNodeList(selectedNodes, element)) { + continue; + } + var cssTop = rule.style.getPropertyValue('top'); + var cssBottom = rule.style.getPropertyValue('bottom'); + if ((cssTop && cssTop !== 'auto') || (cssBottom && cssBottom !== 'auto')) { + return true; + } + } + } + return false; + }; + + dialogPolyfill.needsCentering = function(dialog) { + var computedStyle = window.getComputedStyle(dialog); + if (computedStyle.position !== 'absolute') { + return false; + } + + // We must determine whether the top/bottom specified value is non-auto. In + // WebKit/Blink, checking computedStyle.top == 'auto' is sufficient, but + // Firefox returns the used value. So we do this crazy thing instead: check + // the inline style and then go through CSS rules. + if ((dialog.style.top !== 'auto' && dialog.style.top !== '') || + (dialog.style.bottom !== 'auto' && dialog.style.bottom !== '')) { + return false; + } + return !dialogPolyfill.isInlinePositionSetByStylesheet(dialog); + }; + + /** + * @param {!Element} element to force upgrade + */ + dialogPolyfill.forceRegisterDialog = function(element) { + if (window.HTMLDialogElement || element.showModal) { + console.warn('This browser already supports , the polyfill ' + + 'may not work correctly', element); + } + if (element.localName !== 'dialog') { + throw new Error('Failed to register dialog: The element is not a dialog.'); + } + new dialogPolyfillInfo(/** @type {!HTMLDialogElement} */ (element)); + }; + + /** + * @param {!Element} element to upgrade, if necessary + */ + dialogPolyfill.registerDialog = function(element) { + if (!element.showModal) { + dialogPolyfill.forceRegisterDialog(element); + } + }; + + /** + * @constructor + */ + dialogPolyfill.DialogManager = function() { + /** @type {!Array} */ + this.pendingDialogStack = []; + + var checkDOM = this.checkDOM_.bind(this); + + // The overlay is used to simulate how a modal dialog blocks the document. + // The blocking dialog is positioned on top of the overlay, and the rest of + // the dialogs on the pending dialog stack are positioned below it. In the + // actual implementation, the modal dialog stacking is controlled by the + // top layer, where z-index has no effect. + this.overlay = document.createElement('div'); + this.overlay.className = '_dialog_overlay'; + this.overlay.addEventListener('click', function(e) { + this.forwardTab_ = undefined; + e.stopPropagation(); + checkDOM([]); // sanity-check DOM + }.bind(this)); + + this.handleKey_ = this.handleKey_.bind(this); + this.handleFocus_ = this.handleFocus_.bind(this); + + this.zIndexLow_ = 100000; + this.zIndexHigh_ = 100000 + 150; + + this.forwardTab_ = undefined; + + if ('MutationObserver' in window) { + this.mo_ = new MutationObserver(function(records) { + var removed = []; + records.forEach(function(rec) { + for (var i = 0, c; c = rec.removedNodes[i]; ++i) { + if (!(c instanceof Element)) { + continue; + } else if (c.localName === 'dialog') { + removed.push(c); + } + removed = removed.concat(c.querySelectorAll('dialog')); + } + }); + removed.length && checkDOM(removed); + }); + } + }; + + /** + * Called on the first modal dialog being shown. Adds the overlay and related + * handlers. + */ + dialogPolyfill.DialogManager.prototype.blockDocument = function() { + document.documentElement.addEventListener('focus', this.handleFocus_, true); + document.addEventListener('keydown', this.handleKey_); + this.mo_ && this.mo_.observe(document, {childList: true, subtree: true}); + }; + + /** + * Called on the first modal dialog being removed, i.e., when no more modal + * dialogs are visible. + */ + dialogPolyfill.DialogManager.prototype.unblockDocument = function() { + document.documentElement.removeEventListener('focus', this.handleFocus_, true); + document.removeEventListener('keydown', this.handleKey_); + this.mo_ && this.mo_.disconnect(); + }; + + /** + * Updates the stacking of all known dialogs. + */ + dialogPolyfill.DialogManager.prototype.updateStacking = function() { + var zIndex = this.zIndexHigh_; + + for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) { + dpi.updateZIndex(--zIndex, --zIndex); + if (i === 0) { + this.overlay.style.zIndex = --zIndex; + } + } + + // Make the overlay a sibling of the dialog itself. + var last = this.pendingDialogStack[0]; + if (last) { + var p = last.dialog.parentNode || document.body; + p.appendChild(this.overlay); + } else if (this.overlay.parentNode) { + this.overlay.parentNode.removeChild(this.overlay); + } + }; + + /** + * @param {Element} candidate to check if contained or is the top-most modal dialog + * @return {boolean} whether candidate is contained in top dialog + */ + dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function(candidate) { + while (candidate = findNearestDialog(candidate)) { + for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) { + if (dpi.dialog === candidate) { + return i === 0; // only valid if top-most + } + } + candidate = candidate.parentElement; + } + return false; + }; + + dialogPolyfill.DialogManager.prototype.handleFocus_ = function(event) { + if (this.containedByTopDialog_(event.target)) { return; } + + event.preventDefault(); + event.stopPropagation(); + safeBlur(/** @type {Element} */ (event.target)); + + if (this.forwardTab_ === undefined) { return; } // move focus only from a tab key + + var dpi = this.pendingDialogStack[0]; + var dialog = dpi.dialog; + var position = dialog.compareDocumentPosition(event.target); + if (position & Node.DOCUMENT_POSITION_PRECEDING) { + if (this.forwardTab_) { // forward + dpi.focus_(); + } else { // backwards + document.documentElement.focus(); + } + } else { + // TODO: Focus after the dialog, is ignored. + } + + return false; + }; + + dialogPolyfill.DialogManager.prototype.handleKey_ = function(event) { + this.forwardTab_ = undefined; + if (event.keyCode === 27) { + event.preventDefault(); + event.stopPropagation(); + var cancelEvent = new supportCustomEvent('cancel', { + bubbles: false, + cancelable: true + }); + var dpi = this.pendingDialogStack[0]; + if (dpi && dpi.dialog.dispatchEvent(cancelEvent)) { + dpi.dialog.close(); + } + } else if (event.keyCode === 9) { + this.forwardTab_ = !event.shiftKey; + } + }; + + /** + * Finds and downgrades any known modal dialogs that are no longer displayed. Dialogs that are + * removed and immediately readded don't stay modal, they become normal. + * + * @param {!Array} removed that have definitely been removed + */ + dialogPolyfill.DialogManager.prototype.checkDOM_ = function(removed) { + // This operates on a clone because it may cause it to change. Each change also calls + // updateStacking, which only actually needs to happen once. But who removes many modal dialogs + // at a time?! + var clone = this.pendingDialogStack.slice(); + clone.forEach(function(dpi) { + if (removed.indexOf(dpi.dialog) !== -1) { + dpi.downgradeModal(); + } else { + dpi.maybeHideModal(); + } + }); + }; + + /** + * @param {!dialogPolyfillInfo} dpi + * @return {boolean} whether the dialog was allowed + */ + dialogPolyfill.DialogManager.prototype.pushDialog = function(dpi) { + var allowed = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1; + if (this.pendingDialogStack.length >= allowed) { + return false; + } + if (this.pendingDialogStack.unshift(dpi) === 1) { + this.blockDocument(); + } + this.updateStacking(); + return true; + }; + + /** + * @param {!dialogPolyfillInfo} dpi + */ + dialogPolyfill.DialogManager.prototype.removeDialog = function(dpi) { + var index = this.pendingDialogStack.indexOf(dpi); + if (index === -1) { return; } + + this.pendingDialogStack.splice(index, 1); + if (this.pendingDialogStack.length === 0) { + this.unblockDocument(); + } + this.updateStacking(); + }; + + dialogPolyfill.dm = new dialogPolyfill.DialogManager(); + dialogPolyfill.formSubmitter = null; + dialogPolyfill.useValue = null; + + /** + * Installs global handlers, such as click listers and native method overrides. These are needed + * even if a no dialog is registered, as they deal with
    . + */ + if (window.HTMLDialogElement === undefined) { + + /** + * If HTMLFormElement translates method="DIALOG" into 'get', then replace the descriptor with + * one that returns the correct value. + */ + var testForm = document.createElement('form'); + testForm.setAttribute('method', 'dialog'); + if (testForm.method !== 'dialog') { + var methodDescriptor = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'method'); + if (methodDescriptor) { + // nb. Some older iOS and older PhantomJS fail to return the descriptor. Don't do anything + // and don't bother to update the element. + var realGet = methodDescriptor.get; + methodDescriptor.get = function() { + if (isFormMethodDialog(this)) { + return 'dialog'; + } + return realGet.call(this); + }; + var realSet = methodDescriptor.set; + methodDescriptor.set = function(v) { + if (typeof v === 'string' && v.toLowerCase() === 'dialog') { + return this.setAttribute('method', v); + } + return realSet.call(this, v); + }; + Object.defineProperty(HTMLFormElement.prototype, 'method', methodDescriptor); + } + } + + /** + * Global 'click' handler, to capture the or + +
    + + +
    + アカウントを削除しました。 +
    + +
    + +
    +
    + + +
    + +
    + プロフィールが変更されました。 +
    + +
    + +
    +
    + + + + +
    +
    + 本当にアカウントを削除しますか? + 処理を続行するにはメールアドレスを入力してください。 +
    + +
    + + + + 無効なメールアドレスです +
    +
    + +
    + + +
    +
    + + +
    +
    + +
    + +
    + + リンク + +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + + + + + +
    + + +
    +
    + +
    + + +
    +
    + + +
    +
    + このスレッドはパスワードで保護されています。 + 閲覧にはパスワードが必要です。 +
    + +
    + + + + パスワードが間違っています +
    +
    + +
    + + +
    + + + +
    + + +
    + +
    + + 詳細... +
    +
    + +
    + +
    + + +
    + + +
    +
    + + +
    +
    + +
    + + +
    + + +
    +
    + + + \ No newline at end of file