@@ -9,6 +9,12 @@ var repComments=(JSON.parse(`{}`));
99var allCommentsCount = 0 ;
1010var allComments = ( JSON . parse ( `{}` ) ) ;
1111
12+
13+ var F_repgroup = "" ;
14+ var F_repid = "" ;
15+ var F_box = "false" ;
16+
17+
1218//console.log(repComments)
1319
1420async function loadData ( ) {
@@ -24,6 +30,9 @@ async function loadData() {
2430 } ;
2531 allCommentsCount = allCommentsCount + 1 ;
2632 } ) ;
33+
34+ let checkBatchDev = ( ( `<svg style="margin: auto 0;" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5 text-blue-500 stroke-white"><path d="M12.01 2.011a3.2 3.2 0 0 1 2.113 .797l.154 .145l.698 .698a1.2 1.2 0 0 0 .71 .341l.135 .008h1a3.2 3.2 0 0 1 3.195 3.018l.005 .182v1c0 .27 .092 .533 .258 .743l.09 .1l.697 .698a3.2 3.2 0 0 1 .147 4.382l-.145 .154l-.698 .698a1.2 1.2 0 0 0 -.341 .71l-.008 .135v1a3.2 3.2 0 0 1 -3.018 3.195l-.182 .005h-1a1.2 1.2 0 0 0 -.743 .258l-.1 .09l-.698 .697a3.2 3.2 0 0 1 -4.382 .147l-.154 -.145l-.698 -.698a1.2 1.2 0 0 0 -.71 -.341l-.135 -.008h-1a3.2 3.2 0 0 1 -3.195 -3.018l-.005 -.182v-1a1.2 1.2 0 0 0 -.258 -.743l-.09 -.1l-.697 -.698a3.2 3.2 0 0 1 -.147 -4.382l.145 -.154l.698 -.698a1.2 1.2 0 0 0 .341 -.71l.008 -.135v-1l.005 -.182a3.2 3.2 0 0 1 3.013 -3.013l.182 -.005h1a1.2 1.2 0 0 0 .743 -.258l.1 -.09l.698 -.697a3.2 3.2 0 0 1 2.269 -.944zm3.697 7.282a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z" fill="currentColor" stroke-width="0"></path></svg>` ) ) ;
35+ let checkBatchCre = ( ( `<svg style="margin: auto 0; color:#f26b30;" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-5 w-5 text-blue-500 stroke-white"><path d="M12.01 2.011a3.2 3.2 0 0 1 2.113 .797l.154 .145l.698 .698a1.2 1.2 0 0 0 .71 .341l.135 .008h1a3.2 3.2 0 0 1 3.195 3.018l.005 .182v1c0 .27 .092 .533 .258 .743l.09 .1l.697 .698a3.2 3.2 0 0 1 .147 4.382l-.145 .154l-.698 .698a1.2 1.2 0 0 0 -.341 .71l-.008 .135v1a3.2 3.2 0 0 1 -3.018 3.195l-.182 .005h-1a1.2 1.2 0 0 0 -.743 .258l-.1 .09l-.698 .697a3.2 3.2 0 0 1 -4.382 .147l-.154 -.145l-.698 -.698a1.2 1.2 0 0 0 -.71 -.341l-.135 -.008h-1a3.2 3.2 0 0 1 -3.195 -3.018l-.005 -.182v-1a1.2 1.2 0 0 0 -.258 -.743l-.09 -.1l-.697 -.698a3.2 3.2 0 0 1 -.147 -4.382l.145 -.154l.698 -.698a1.2 1.2 0 0 0 .341 -.71l.008 -.135v-1l.005 -.182a3.2 3.2 0 0 1 3.013 -3.013l.182 -.005h1a1.2 1.2 0 0 0 .743 -.258l.1 -.09l.698 -.697a3.2 3.2 0 0 1 2.269 -.944zm3.697 7.282a1 1 0 0 0 -1.414 0l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.32 1.497l2 2l.094 .083a1 1 0 0 0 1.32 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z" fill="currentColor" stroke-width="0"></path></svg>` ) ) ;
2736 //console.log(allComments)
2837 //console.log(repComments)
2938 data . reverse ( ) . forEach ( entry => { } ) ;
@@ -43,14 +52,25 @@ async function loadData() {
4352
4453 const usernamePara = document . createElement ( 'p' ) ;
4554 usernamePara . classList . add ( 'username' ) ;
46- usernamePara . textContent = ( entry . name ) ;
47- //usernamePara.textContent = (entry.name+' #'+commentCount);//コメントの読み込み番号を表示
55+ const usernameParaDiv = document . createElement ( 'div' ) ;
56+ usernameParaDiv . style . display = ( 'flex' ) ;
57+ var batchCheck = ( entry . check ) ;
58+ var batchName = ( entry . name ) ;
59+ var batchDiv = usernameParaDiv ;
60+ if ( batchCheck === 'dev' ) {
61+ batchDiv . innerHTML = ( `${ batchName } ${ checkBatchDev } ` ) ;
62+ } else { if ( batchCheck === 'cre' ) {
63+ batchDiv . innerHTML = ( `${ batchName } ${ checkBatchCre } ` ) ;
64+ } else {
65+ batchDiv . innerHTML = ( `${ batchName } ` ) ;
66+ } ; } ;
67+ usernamePara . appendChild ( usernameParaDiv ) ;
4868
4969 const checkDiv = document . createElement ( 'p' ) ;
50- if ( entry . check ) {
51- checkDiv . style . color = '#f26b30' ;
52- checkDiv . textContent = "認証済み" ;
53- } ;
70+ // if (entry.check) {
71+ // checkDiv.style.color = '#f26b30';
72+ // checkDiv.textContent = "認証済み";
73+ // };
5474
5575 const timestampPara = document . createElement ( 'p' ) ;
5676 timestampPara . classList . add ( 'timestamp' ) ;
@@ -93,7 +113,6 @@ async function loadData() {
93113 commentDiv . appendChild ( uuidDiv ) ;
94114 commentLi . appendChild ( commentDiv ) ;
95115 commentLi . appendChild ( commentRepDiv ) ;
96-
97116 commentsContainer . appendChild ( commentLi ) ;
98117 commentCount = commentCount + 1 ;
99118 } ;
@@ -112,13 +131,24 @@ async function loadData() {
112131 REPcommentRepDiv . id = ( `comment_${ repComments [ i ] . uuid } ` ) ;
113132 const REPusernamePara = document . createElement ( 'p' ) ;
114133 REPusernamePara . classList . add ( 'username' ) ;
115- REPusernamePara . textContent = ( repComments [ i ] . name ) ;
116- //REPusernamePara.textContent = (repComments[i].name+' #'+repComments[i].rep);//コメントの読み込み番号を表示
134+ const REPusernameParaDiv = document . createElement ( 'div' ) ;
135+ REPusernameParaDiv . style . display = ( 'flex' ) ;
136+ var batchCheck = ( repComments [ i ] . check ) ;
137+ var batchName = ( repComments [ i ] . name ) ;
138+ var batchDiv = REPusernameParaDiv ;
139+ if ( batchCheck === 'dev' ) {
140+ batchDiv . innerHTML = ( `${ batchName } ${ checkBatchDev } ` ) ;
141+ } else { if ( batchCheck === 'dev' ) {
142+ batchDiv . innerHTML = ( `${ batchName } ${ checkBatchCre } ` ) ;
143+ } else {
144+ batchDiv . innerHTML = ( `${ batchName } ` ) ;
145+ } ; } ;
146+ REPusernamePara . appendChild ( REPusernameParaDiv ) ;
117147 const REPcheckDiv = document . createElement ( 'p' ) ;
118- if ( repComments [ i ] . check ) {
119- REPcheckDiv . style . color = '#f26b30' ;
120- REPcheckDiv . textContent = "認証済み" ;
121- } ;
148+ // if (repComments[i].check) {
149+ // REPcheckDiv.style.color = '#f26b30';
150+ // REPcheckDiv.textContent = "認証済み";
151+ // };
122152 const REPtimestampPara = document . createElement ( 'p' ) ;
123153 REPtimestampPara . classList . add ( 'timestamp' ) ;
124154 REPtimestampPara . textContent = new Date ( repComments [ i ] . timestamp ) . toLocaleString ( ) ;
@@ -147,8 +177,13 @@ async function loadData() {
147177 REPuuidDiv . appendChild ( REPuuidBtn ) ;
148178
149179 const REPcommentRepCommentID = document . createElement ( 'a' ) ;
150- REPcommentRepCommentID . classList . add ( `text-[#6094F8]` ) ;
151- REPcommentRepCommentID . textContent = `@${ allComments [ repComments [ i ] . rep ] . name } `
180+ if ( allComments [ repComments [ i ] . rep ] ) {
181+ REPcommentRepCommentID . classList . add ( `text-[#6094F8]` ) ;
182+ REPcommentRepCommentID . textContent = `@${ allComments [ repComments [ i ] . rep ] . name } `
183+ } else {
184+ REPcommentRepCommentID . style . color = ( `var(--red-500)` ) ;
185+ REPcommentRepCommentID . textContent = `返信元のコメントは削除されています`
186+ }
152187
153188 REPcommentDiv . appendChild ( REPcommentRepCommentID ) ;
154189 REPusernamePara . appendChild ( REPcheckDiv ) ;
@@ -206,7 +241,7 @@ setInterval(() => {
206241 document . getElementById ( 'loadAddComment' ) . style . display = ( 'none' ) ;
207242 } else {
208243 document . getElementById ( 'loadAddComment' ) . style . display = ( 'block' ) ;
209- }
244+ } ;
210245} , 500 ) ;
211246
212247// コメントを通報する機能
@@ -228,7 +263,108 @@ function commentReport(id){
228263} ;
229264
230265function commentRep ( repgroup , repid ) {
231- window . location = '#コメント欄' ;
266+ if ( F_box !== 'false' ) {
267+ //console.warn(repgroup)
268+ let F_repForm = document . getElementById ( `repForm_${ F_box } ` ) ;
269+ F_repForm . remove ( ) ;
270+ F_box = 'false' ;
271+ } ;
272+ F_box = repgroup ;
273+ F_repgroup = repgroup ;
274+ F_repid = repid ;
275+
276+ document . getElementById ( 'form_rep_data' ) . innerHTML = ( ( allComments [ `${ repid } ` ] . name ) + 'のコメントを選択中' )
232277 document . getElementById ( 'field-repgroup' ) . value = `${ repgroup } ` ;
233278 document . getElementById ( 'field-rep' ) . value = `${ repid } ` ;
279+
280+ var repForm = document . getElementById ( `comment_${ repgroup } ` ) ;
281+
282+ let repFormDiv = document . createElement ( 'div' ) ;
283+ repFormDiv . id = ( `repForm_${ repgroup } ` ) ;
284+ repFormDiv . classList . add ( 'fadeUp' , 'comment' , 'commentRep' ) ;
285+
286+ let repFormDivBtnDiv = document . createElement ( 'div' ) ;
287+ repFormDivBtnDiv . classList . add ( 'c-form__submit' ) ;
288+
289+ let repFormDivCloseBtn = document . createElement ( 'button' ) ;
290+ repFormDivCloseBtn . style . marginRight = ( `8px` )
291+ repFormDivCloseBtn . textContent = ( `キャンセル` ) ;
292+ repFormDivCloseBtn . addEventListener ( 'click' , ( ) => {
293+ commentRepFormBoxRem ( repgroup , repid ) ;
294+ } ) ;
295+ let repFormDivSubmitBtn = document . createElement ( 'button' ) ;
296+ repFormDivSubmitBtn . style . marginRight = ( `8px` )
297+ repFormDivSubmitBtn . textContent = ( `送信する` ) ;
298+ repFormDivSubmitBtn . addEventListener ( 'click' , ( ) => {
299+ commentRepFormBoxRemSubmit ( ) ;
300+ commentRepFormBoxRem ( repgroup , repid ) ;
301+ } ) ;
302+ repFormDivBtnDiv . appendChild ( repFormDivSubmitBtn ) ;
303+ repFormDivBtnDiv . appendChild ( repFormDivCloseBtn ) ;
304+
305+
306+ let repFormDivContent = document . createElement ( 'div' ) ;
307+ repFormDivContent . innerHTML = ( `
308+ <form id="rep_commentForm" class="c-form" action="https://docs.google.com/forms/u/0/d/e/1FAIpQLSfIJL-coat1Tl92nVowE17bfkMAnAekuWskkGwNd3h8rX-aIg/formResponse" method="POST" target="rep_rep_hidden_iframe" onsubmit="submitted=true;">
309+ <div class="c-form__item" style="width:100%;"><p class="c-form__input" style="width:100%;" id="rep_form_rep_data"></p></div>
310+ <div class="c-form__item" style="width:100%;">
311+ <input name="entry.1738713134" style="width:100%;" class="c-form__input" id="rep_field_name" type="text" required="required" placeholder="名前を入力" autocomplete="nickname"/>
312+ </div>
313+ <div class="c-form__item" style="width:100%;">
314+ <textarea name="entry.975792514" style="width:100%;" class="c-form__input" id="rep_field_message" placeholder="素敵なコメントを入力" required="required" autocomplete="off"></textarea>
315+ </div>
316+ <div class="c-form__item" style="width:100%;">
317+ <input name="entry.537780005" class="c-form__input" style="width:100%;background-color: var(--background-2);align-items: right;display: none;" id="rep_field_repgroup" type="text" required="required" placeholder="返信コメントグループID"/>
318+ </div>
319+ <div class="c-form__item">
320+ <input name="entry.1032562646" class="c-form__input" style="width:100%;background-color: var(--background-2);align-items: right;display: none;" id="rep_field_rep" type="text" required="required" placeholder="返信コメントID" />
321+ </div>
322+ </form>
323+ <iframe name="rep_hidden_iframe" id="rep_hidden_iframe" style="display: none" onload="if(submitted){window.location='./';}"></iframe>
324+ ` ) ;
325+
326+ repFormDiv . appendChild ( repFormDivContent )
327+ repFormDiv . appendChild ( repFormDivBtnDiv )
328+ repForm . appendChild ( repFormDiv ) ;
329+
330+ document . getElementById ( 'rep_form_rep_data' ) . innerHTML = ( ( allComments [ `${ repid } ` ] . name ) + 'のコメントを選択中' )
331+ document . getElementById ( 'rep_field_repgroup' ) . value = `${ repgroup } ` ;
332+ document . getElementById ( 'rep_field_rep' ) . value = `${ repid } ` ;
333+ window . location = ( `#comment_${ F_box } ` ) ;
334+ } ;
335+
336+ function commentRepReset ( ) {
337+ document . getElementById ( 'form_rep_data' ) . innerHTML = ( '通常コメントモード' ) ;
338+ } ;
339+
340+ function commentRepFormBoxRemSubmit ( ) {
341+ let form_url = ( `https://docs.google.com/forms/u/0/d/e/1FAIpQLSfIJL-coat1Tl92nVowE17bfkMAnAekuWskkGwNd3h8rX-aIg/formResponse` ) ;
342+ var fetch_url = ( `${ form_url } ?entry.1738713134=${ document . getElementById ( 'rep_field_name' ) . value } &entry.975792514=${ document . getElementById ( 'rep_field_message' ) . value } &entry.537780005=${ document . getElementById ( 'rep_field_repgroup' ) . value } &entry.1032562646=${ document . getElementById ( 'rep_field_rep' ) . value } ` ) ;
343+
344+ /// FormData作成
345+ const formData = new FormData ( ) ;
346+ formData . append ( 'entry.1738713134' , `${ document . getElementById ( 'rep_field_name' ) . value } ` ) ;
347+ formData . append ( 'entry.975792514' , `${ document . getElementById ( 'rep_field_message' ) . value } ` ) ;
348+ formData . append ( 'entry.537780005' , `${ document . getElementById ( 'rep_field_repgroup' ) . value } ` ) ;
349+ formData . append ( 'entry.1032562646' , `${ document . getElementById ( 'rep_field_rep' ) . value } ` ) ;
350+ //console.log(fetch_url)
351+ fetch ( form_url , {
352+ method : 'POST' ,
353+
354+ /// OK : FormDataでパラメータ指定
355+ body : formData
356+ } ) . then ( async ( response ) => {
357+ //console.log('response : ',await response.json());
358+ } ) . then ( ( data ) => {
359+ //console.log('data : ', data);
360+ } ) . catch ( ( error ) => {
361+ console . error ( 'error : ' , error ) ;
362+ } ) ;
363+ window . location = ( '#' )
364+ } ;
365+
366+ function commentRepFormBoxRem ( repgroup , repid ) {
367+ var repForm = document . getElementById ( `repForm_${ repgroup } ` ) ;
368+ repForm . remove ( ) ;
369+ F_box = 'false' ;
234370} ;
0 commit comments