Skip to content
This repository was archived by the owner on May 13, 2018. It is now read-only.

Commit 8d43eda

Browse files
committed
プロフィールビューアのリンク反映。
1 parent c61ed20 commit 8d43eda

5 files changed

Lines changed: 113 additions & 71 deletions

File tree

Dialog.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ Dialog[ID^="Dialogs"] Div.mdl-textfield {
4242
White-Space: Pre-Wrap;
4343
}
4444

45-
#Dialogs_Profile_InfoViewer_Content_Info_Link {
45+
#Dialogs_Profile_InfoViewer_Content_Info_Links {
4646
Padding: 1em 0 0;
4747
}
4848

49-
#Dialogs_Profile_InfoViewer_Content_Info_Link Img {
49+
Img[UUID="Dialogs_Profile_InfoViewer_Content_Info_Links_Link_Icon"] {
5050
Width: 1em;
5151
}
5252

Dialog.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ window.addEventListener("DOMContentLoaded", () => {
3838

3939
onChange: (watcher) => {
4040
base.Database.get(base.Database.ONCE, `users/${watcher.newValue}`, (res) => {
41-
console.log(res);
42-
4341
DOM("#Dialogs_Profile_InfoViewer_Content_Photo").dataset.uid = watcher.newValue,
4442
DOM("#Dialogs_Profile_InfoViewer_Content_Info_Name").textContent = res.userName,
4543
DOM("#Dialogs_Profile_InfoViewer_Content_Info_Detail").textContent = res.detail;
4644

45+
while (DOM("#Dialogs_Profile_InfoViewer_Content_Info_Links").childNodes.length > 0) DOM("#Dialogs_Profile_InfoViewer_Content_Info_Links").childNodes[0].remove();
46+
4747
if (res.links) {
4848
for (let i = 0; i < res.links.length; i++) {
49-
49+
let link = new Components.Dialogs.Profile.InfoViewer.Links.Link(res.links[i].name, res.links[i].url);
50+
51+
DOM("#Dialogs_Profile_InfoViewer_Content_Info_Links").appendChild(link);
5052
}
5153
}
5254
});

includes/Components.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<Section ID = "Dialogs">
2+
<Div UUID = "Dialogs_Profile_InfoViewer_Content_Info_Links_Link">
3+
<Img UUID = "Dialogs_Profile_InfoViewer_Content_Info_Links_Link_Icon" Src = "${urlOrigin}/favicon.ico" />
4+
<A Href = "${url}" Target = "_blank">${urlTitle}</A>
5+
</Div>
6+
</Section>
7+
18
<Section UUID = "Threadlist">
29
<A UUID = "Threadlist_Thread" Class = "mdl-list__item" Href = "Viewer/?tid=${tid}">
310
<Span Class = "mdl-list__item-primary-content">

includes/Components.js

Lines changed: 98 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,81 +14,122 @@ class Components {
1414

1515
static get componentIds () {
1616
return {
17+
Dialogs: {
18+
Profile: {
19+
InfoViewer: {
20+
ROOT: '#Dialogs_Profile_InfoViewer',
21+
PHOTO: '#Dialogs_Profile_InfoViewer_Content_Photo',
22+
NAME: '#Dialogs_Profile_InfoViewer_Content_Info_Name',
23+
DETAIL: '#Dialogs_Profile_InfoViewer_Content_Info_Detail',
24+
25+
LINKS: {
26+
ROOT: '#Dialogs_Profile_InfoViewer_Content_Info_Links',
27+
LINK: '[UUID="Dialogs_Profile_InfoViewer_Content_Info_Links_Link"]'
28+
}
29+
}
30+
}
31+
},
32+
1733
Threadlist: {
18-
ROOT: "Threadlist",
19-
THREAD: "Threadlist_Thread"
34+
ROOT: '#Threadlist',
35+
THREAD: '[UUID="Threadlist_Thread"]'
2036
},
2137

2238
Thread: {
23-
ROOT: "Thread",
24-
POST: "Thread_Post"
39+
ROOT: '#Thread',
40+
POST: '[UUID="Thread_Post"]'
2541
}
2642
}
2743
}
2844

2945

3046

31-
static get Threadlist () {
32-
return Object.create(null, {
33-
Thread: {
34-
value: (() => {
35-
function Thread (tid, title) {
36-
if (!this.constructor) throw new TypeError("Please use the 'new' operator, the component can't be called as a function.");
47+
static get Dialogs () {
48+
return {
49+
Profile: {
50+
InfoViewer: {
51+
Links: {
52+
Link: (() => {
53+
function Link (urlTitle, url) {
54+
if (!this.constructor) throw new TypeError("Please use the 'new' operator, the component can't be called as a function.");
55+
56+
let component = document.importNode(Components.componentsDoc.querySelector(`*${Components.componentIds.Dialogs.Profile.InfoViewer.LINKS.LINK}`), true);
57+
58+
let componentWrapper = DOM("ComponentWrapper");
59+
componentWrapper.appendChild(component);
60+
61+
componentWrapper.firstElementChild.outerHTML = componentWrapper.firstElementChild.outerHTML.replaces([
62+
[/\${urlTitle}/g, urlTitle || url || "Untitled"],
63+
[/\${url}/g, url || ""],
64+
[/\${urlOrigin}/g, new URL(url).origin || locaion.origin]
65+
]);
66+
67+
return componentWrapper.firstElementChild;
68+
}; Link.prototype = Object.create(null, {
69+
constructor: { value: Link }
70+
});
71+
72+
return Link;
73+
})()
74+
}
75+
}
76+
}
77+
}
78+
}
3779

38-
let component = document.importNode(Components.componentsDoc.querySelector(`*[UUID="${Components.componentIds.Threadlist.THREAD}"]`), true);
80+
static get Threadlist () {
81+
return {
82+
Thread: (() => {
83+
function Thread (tid, title) {
84+
if (!this.constructor) throw new TypeError("Please use the 'new' operator, the component can't be called as a function.");
3985

40-
let componentWrapper = DOM("ComponentWrapper");
41-
componentWrapper.appendChild(component);
86+
let component = document.importNode(Components.componentsDoc.querySelector(`*${Components.componentIds.Threadlist.THREAD}`), true);
4287

43-
componentWrapper.firstElementChild.outerHTML = componentWrapper.firstElementChild.outerHTML.replaces([
44-
[/\${tid}/g, tid || ""],
45-
[/\${title}/g, title || ""]
46-
]);
88+
let componentWrapper = DOM("ComponentWrapper");
89+
componentWrapper.appendChild(component);
4790

48-
return componentWrapper.firstElementChild;
49-
}; Thread.prototype = Object.create(null, {
50-
constructor: { value: Thread }
51-
});
91+
componentWrapper.firstElementChild.outerHTML = componentWrapper.firstElementChild.outerHTML.replaces([
92+
[/\${tid}/g, tid || ""],
93+
[/\${title}/g, title || ""]
94+
]);
5295

53-
return Thread;
54-
})(),
96+
return componentWrapper.firstElementChild;
97+
}; Thread.prototype = Object.create(null, {
98+
constructor: { value: Thread }
99+
});
55100

56-
enumerable: true
57-
}
58-
})
101+
return Thread;
102+
})()
103+
}
59104
}
60105

61106
static get Thread () {
62-
return Object.create(null, {
63-
Post: {
64-
value: (() => {
65-
function Post (pid, uid, userName, content, createdAt, rnd) {
66-
if (!this.constructor) throw new TypeError("Please use the 'new' operator, the component can't be called as a function.");
67-
68-
let component = document.importNode(Components.componentsDoc.querySelector(`*[UUID="${Components.componentIds.Thread.POST}"]`), true);
69-
70-
let componentWrapper = DOM("ComponentWrapper");
71-
componentWrapper.appendChild(component);
72-
73-
componentWrapper.firstElementChild.outerHTML = componentWrapper.firstElementChild.outerHTML.replaces([
74-
[/\${pid}/g, pid || ""],
75-
[/\${uid}/g, uid || ""],
76-
[/\${userName}/g, userName || ""],
77-
[/\${content}/g, content || ""],
78-
[/\${createdAt}/g, createdAt || ""],
79-
[/\${rnd}/g, rnd || ""]
80-
]);
81-
82-
return componentWrapper.firstElementChild;
83-
}; Post.prototype = Object.create(null, {
84-
constructor: { value: Post }
85-
});
86-
87-
return Post;
88-
})(),
89-
90-
enumerable: true
91-
}
92-
})
107+
return {
108+
Post: (() => {
109+
function Post (pid, uid, userName, content, createdAt, rnd) {
110+
if (!this.constructor) throw new TypeError("Please use the 'new' operator, the component can't be called as a function.");
111+
112+
let component = document.importNode(Components.componentsDoc.querySelector(`*${Components.componentIds.Thread.POST}`), true);
113+
114+
let componentWrapper = DOM("ComponentWrapper");
115+
componentWrapper.appendChild(component);
116+
117+
componentWrapper.firstElementChild.outerHTML = componentWrapper.firstElementChild.outerHTML.replaces([
118+
[/\${pid}/g, pid || ""],
119+
[/\${uid}/g, uid || ""],
120+
[/\${userName}/g, userName || ""],
121+
[/\${content}/g, content || ""],
122+
[/\${createdAt}/g, createdAt || ""],
123+
[/\${rnd}/g, rnd || ""]
124+
]);
125+
126+
return componentWrapper.firstElementChild;
127+
}; Post.prototype = Object.create(null, {
128+
constructor: { value: Post }
129+
});
130+
131+
return Post;
132+
})()
133+
}
93134
}
94135
}

index.html

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,8 @@
151151

152152
<Span Class = "mdl-layout__title">リンク</Span>
153153

154-
<Div ID = "Dialogs_Profile_InfoViewer_Content_Info_Link">
155-
<Div>
156-
<Img Src = "https://plus.google.com/favicon.ico" />
157-
<A Href = "https://plus.google.com/106666684430101995501/" Target = "_blank">Google+</A>
158-
</Div>
154+
<Div ID = "Dialogs_Profile_InfoViewer_Content_Info_Links">
159155

160-
<Div>
161-
<Img Src = "https://github.com/favicon.ico" />
162-
<A Href = "https://github.com/GenbuHase/" Target = "_blank">Github</A>
163-
</Div>
164156
</Div>
165157
</Div>
166158

0 commit comments

Comments
 (0)