PageSourceSearch

https://tinyvoice.com/wp-content/themes/tinyvoice/js/common.js?ver=1785976808

js tinyvoice.com collected 2026-10-02 19:10:14 UTC 8,418 bytes, 260 lines download raw bytes

1$(function() {
2
3	// コメント系処理 - ボタンクラス名 .submit-comment
4	$(document).on('click','.submit-comment',function(e) {
5		$('.submit-comment').prop('disabled', true);
6		var target = $(this).closest('.reply-comment').find('textarea');
7		var that = $(this);
8		if(target.val() == ""){
9			return false;
10		}
11		var postData = {
12			flag_creator_community_id : target.data('id'),
13			flag_creator_post_id : target.data('id'),
14			body 				 : target.val(),
15			parent_id 			 : target.data('parent')
16		};
17
18		var path = location.pathname;
19
20		if(path.match(/community/)){
21			var postUrl = '/community_ajax/';
22		}else if(path.match(/post/)){
23			var postUrl = '/post_ajax/';
24		}
25
26		$.ajax({
27			'method'   : 'get',
28			'dataType' : 'json',
29			'data'     : postData,
30			'url'      : postUrl
31		}).done(function(ret){
32			console.log('ret: ', ret);
33
34			if(ret.saveData.commented_name !== null) {
35				ret.saveData.commented_name = ret.saveData.commented_name.replace(/&/g, '&lt;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, "&#x27;")
36			} else {
37				ret.saveData.commented_name = 'No Name';
38			}
39			ret.saveData.body = ret.saveData.body.replace(/&/g, '&lt;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, "&#x27;")
40
41			var innerClass = "reply";
42			if(ret.saveData.parent_id == 0){
43				innerClass = "";
44			}
45
46			var html = '';
47			if(ret.saveData.parent_id == 0){
48				html += '<div class="postinner-comment">';
49			}
50
51			let userLink = ret.saveData.user_link;
52			let noLinkCeatorClass = '';
53			if(ret.saveData.user_link == null) {
54				userLink = '';
55				noLinkCeatorClass = ' nolink';
56			}
57
58			html += '	<div class="postinner-comment-' + innerClass + 'list">';
59			html += '	<div class="postinner-comment-inner flexbox align-start">';
60			html += '		<div class="postinner-comment-userimage-wrap">';
61			html += '		  <a href="' + userLink + '" class="postinner-comment-userimage' + noLinkCeatorClass + '" style="background-image: url(' + ret.saveData.commented_icon + '); display:block;"></a>';
62			html += '		</div>';
63			html += '		<div class="postinner-comment-body">';
64			html += '			<a href="' + userLink + '" class="postinner-comment-username' + noLinkCeatorClass + '">' + ret.saveData.commented_name+ '</a>';
65			html += '			<p class="postinner-comment-content">' + ret.saveData.body + '</p>';
66			html += '		</div>';
67			html += '		<!--';
68			html += '		<div class="postinner-comment-ellipsis table-more">';
69			html += '			<svg class="icon icon-icon-preview_hide"><use xlink:href="#icon-icon-preview_hide"></use></svg>';
70			html += '			<div class="popup-triangle" style="display:none;"></div>';
71			html += '			<ul class="more-popup" style="display:none;">';
72			html += '				<li class="more-popup-list"><a href="#" class="hide-display"><span class="hide-display-icon"><svg class="icon icon-icon-preview_hide"><use xlink:href="#icon-icon-preview_hide"></use></svg></span>非表示にする</a></li>';
73			html += '			</ul>';
74			html += '		</div>';
75			html += '		-->';
76			html += '	</div>';
77			html += '	<div class="postinner-comment-iconlist flexbox align-center justify-end">';
78			html += '		<p class="postinner-comment-icon postinner-comment-date">' + ret.saveData.post_date_format + '</p>';
79
80			if(ret.saveData.parent_id == 0){
81			/*
82			html += '		<div class="postinner-comment-icon reply-comment-button">';
83			html += '			<i class="fas fa-reply"></i>';
84			html += '		</div>';
85			*/
86			}
87
88			// html += '		<div class="postinner-comment-icon postinner-comment-like">';
89			// html += '			<svg class="icon icon-icon-heart like"><use xlink:href="#icon-icon-heart"></use></svg>';
90			// html += '			<p class="like-counter">0</p>';
91			// html += '		</div>';
92			html += '	</div>';
93			html += '	</div>';
94
95			if(ret.saveData.parent_id == 0){
96			html += '	<div class="reply-comment" style="display:none;">';
97			html += '		<div class="postinner-comment-inner flexbox align-start">';
98			html += '			<div class="postinner-comment-userimage-wrap">';
99			html += '			  <a class="postinner-comment-userimage" style="background-image: url(' + ret.saveData.commented_icon + ';display:block;)"></a>';
100			html += '			</div>';
101			html += '			<div class="reply-comment-body">';
102			html += '				<textarea class="post-comment" type="text" value="" data-parent="' + ret.saveData.id + '" data-id="' + ret.saveData.flag_creator_post_id + '" placeholder="コメントする"></textarea>';
103			html += '				<div class="submit-comment-wrap">';
104			html += '					<button type="submit" class="submit-comment">送信する</button>';
105			html += '				</div>';
106			html += '			</div>';
107			html += '		</div>';
108			html += '	</div>';
109			html += '</div>';
110			html += '</div>';
111			}
112
113
114			if(ret.saveData.parent_id == 0){
115				target.closest('.postinner-comment').before(html);
116			}else{
117				target.closest('.reply-comment').removeClass('switchon');
118				target.closest('.postinner-comment').find('.reply-comment').before(html);
119			}
120			$('.submit-comment').prop('disabled', false);
121			target.val('');
122		});
123	});
124
125
126	//like処理
127	$(document).on('click','.postinner-like,.postinner-comment-like',function(e) {
128		var target = $(this).find('.like-counter');
129		var likeicon = $(this).find('.icon-icon-heart');
130		var counterText = target.text();
131		var counterNumber = parseInt(counterText) + 1;
132		target.text(counterNumber);
133
134		if(!$(this).hasClass('.postinner-liked')){
135			$(this).addClass('postinner-liked');
136		}
137		var model = likeicon.data('model');
138		var parent_id = likeicon.data('parent_id');
139		var child_id = likeicon.data('child_id');
140
141		var path = location.pathname;
142
143		if(path.match(/community/)){
144			var postUrl = '/community_ajax_like/';
145		}else if(path.match(/post/)){
146			var postUrl = '/post_ajax_like/';
147		}
148
149		var postData = {
150			model : model,
151			parent_id : parent_id,
152			child_id : child_id,
153			liked : counterNumber
154		};
155
156		$.ajax({
157			'method'   : 'get',
158			'dataType' : 'json',
159			'data'     : postData,
160			'url'      : postUrl
161		});
162	});
163
164
165	//コメント非表示処理
166	$(document).on('click','.hide_comment',function(e) {
167
168		if (window.confirm("コメントを削除してもよろしいですか?")) {
169			var model = $(this).data('model');
170			var parent_id = $(this).data('parent_id');
171			var child_id  = $(this).data('child_id');
172			var segment = $(this).data('segment');
173
174			var path = location.pathname;
175
176			if(path.match(/community/)){
177				var postUrl = '/community_ajax_remove_comment/';
178			}else if(path.match(/post/)){
179				var postUrl = '/post_ajax_remove_comment/';
180			}
181
182			var postData = {
183				model : model,
184				parent_id : parent_id,
185				child_id : child_id,
186				segment : segment
187			};
188
189			$.ajax({
190				'method'   : 'get',
191				'dataType' : 'json',
192				'data'     : postData,
193				'url'      : postUrl
194			}).done(function(){
195				var ret = location.reload();
196			});
197		}
198	});
199
200	//Posts コメントを表示ボタン
201	$(document).on('click','.more-comment',function(e) {
202		$(this).nextAll().show();
203		$(this).hide();
204		return false;
205  	});
206
207	// community hide
208	$(document).on('click','.community-hide-display',function(e) {
209		if (confirm('非表示にしますか?')) {
210			var id = $(this).data('id');
211			$('#community-post-' + id).fadeOut("slow");
212			$.ajax({
213				'method': 'get',
214				'dataType': 'json',
215				'url': '/community_ajax_hide/',
216				'data': {
217					'id': id
218				},
219			}).done(function () {
220			});
221		}
222		return false;
223	});
224
225	//community,postバリデーション
226	$(document).on('click','.editor-button.save,.editor-button.post',function(e) {
227		var f = false;
228		$('.input-content').each(function(index){
229			if(index == 0)
230				return true; //continue;
231			if($(this).val() == "")
232				f = true;
233		});
234		if(f){
235			//alert("空のアンケート要素");
236			return false;
237		}
238		if($("#survey_form tbody").children().length === 2){
239			//alert("アンケートが一つだけ");
240			return false;
241		}
242
243	 });
244	 //summernoteが空欄かどうか
245	$(".editor-button.save,.editor-button.post").on("click",function(){
246		if($(".note-editable").text().length == 0) {
247			return false;
248		}
249	});
250
251	//アンケート処理
252	$(function() {
253		$("#survey").on("click", function() { //まだアンケートがなければ項目を二つ生成
254		 if($("#survey_form tbody").children().length === 2){
255		   $("#survey_form tbody tr:first-child").clone(true).appendTo("#survey_form tbody");
256		   $("#survey_form tbody tr:last-child").css("display", "block");
257		 }
258		});
259	  });
260});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.