PageSourceSearch

https://www.city.morioka.iwate.jp/_template_/_site_/_default_/_res/js/ml_top.js

js city.morioka.iwate.jp collected 2026-10-02 05:16:54 UTC 4,608 bytes, 154 lines download raw bytes

1//------------------------------------------------------------------------------
2//	メールマガジン連携(トップ)
3//	Copyright (C) 2021 FUTUREINN CO., LTD. All Rights Reserved.
4//------------------------------------------------------------------------------
5(function(){
6	var $ = FI.jQuery;
7	
8	//---------------------------------------
9	// ▼ 設定
10	//---------------------------------------
11	// トップページ:表示タイプ
12	// 1:配信日・件名・本文、2:配信日・件名・省略本文、3:配信日・件名(デフォルト)
13	d_type = 1;
14	// トップページ:表示件数 1~10件
15	d_count = 10;
16	// トップページ:表示時間 1~72時間
17	d_time = 72;
18	
19	// 表示タイプ2の時のカット文字数
20	var cut = '140';
21	//---------------------------------------
22
23	//メイン処理
24	$(function() {
25
26		//メルマガ連携エリアのID
27		$ml_area = $('#kinkyumail');
28
29		//メルマガ内容のID
30		$ml_contents = $('#ml_contents');
31
32		if(!$ml_area.length || !$ml_contents.length){
33			return;
34		}
35
36		//詳細ページのURL
37		$ml_detail_a = $('#ml_detail').find('a');
38
39		var link = ""
40		if($ml_detail_a.length > 0 ){
41			link = $ml_detail_a.attr('href');
42		}
43
44		//メルマガ一覧取得
45		$.ajax({
46			type: "GET",
47			url: "/mldata/all_mails.json",
48			//url: "/_template_/_site_/_default_/_res/js/mldata/all_mails.json",
49			dataType:"json",
50			cache: false
51		}).then(
52			//成功時
53			function (all_mails) {
54				var mails = all_mails.datas.sort()
55				if(mails.length > 0){
56					$('#nokinkyu').hide();
57					var now = new Date();
58					var v_flg = false;
59					for (let i = 0; i < d_count; i++) {
60						var html = "";
61						if(mails.length > 0){
62							var d_path = mails.pop();
63							var d = d_path.match(".+/(.+?)\.[a-z]+([\?#;].*)?$")[1];
64							var da = [d.substr(0,4) , d.substr(4,2) , d.substr(6,2) , d.substr(8,2) , d.substr(10,2) , d.substr(12,2)] //年月日時分秒
65							var date = new Date(da[0] , da[1]-1 , da[2] , da[3] , da[4] , da[5]);//月は0-11表記
66							//規定時間以内だったら内容を作成
67							if((now-date)/3600000 < d_time){
68								v_flg = true;
69								//非同期処理対応のため挿入する位置を決めてから内容を取得
70								var c_id = "ml_top_no_" + i;
71								switch (d_type){
72									case 1:
73									case 2:
74										$ml_contents.append('<p id="' + c_id + '"></p>');
75										break;
76									default:
77										if($ml_contents.find('ul').length == 0){
78											$ml_contents.append('<ul class="objectlink"></ul>');
79										}
80										$ml_contents.find('ul').append('<li id="' + c_id + '"></li>');
81								}
82								make_detail(d_path,da,c_id)
83							}
84						}
85					}
86					if(v_flg){
87						$('#kinkyubtn p').addClass("active");
88						$('#kinkyuarea').show();
89					} else{
90						$('#nokinkyu').show();
91					}
92				}
93			},
94			//失敗時
95			function () {
96				console.log("NG:all_mails");
97				$('#nokinkyu').show();
98			}
99		);
100
101		// --メルマガ詳細作成
102		function make_detail(d_path,da,c_id){
103			var html = "";
104			$.ajax({
105				type: "GET",
106				url: d_path,
107				dataType:"json",
108				cache: false
109			}).then(
110				function (data) {
111					var str_date = parseInt(da[1]) + "月" + parseInt(da[2]) + "日 " + parseInt(da[3]) + "時" + parseInt(da[4]) + "分配信"
112					var body = $("<div>" + data.body + "</div>").text();	//HTMLタグ除去
113					switch (d_type){
114						case 1:
115							html += "<h3>" + data.subject;
116							html += "<span class=\"textright\">" + str_date + "</span>";
117							html += "</h3>\n";
118							html += "<p>" + chg_urllink(body).replace(/\n/g, '<br>') + "</p>\n";
119							break;
120						case 2:
121							html += "<h3>" + data.subject;
122							html += "<span class=\"textright\">" + str_date + "</span>";
123							html += "</h3>\n";
124							if(cut < body.length) {
125								html += "<p>" + body.substr(0,(cut)) + ' …' + "</p>\n";
126							}else{
127								html += "<p>" + body + "</p>\n";
128							}
129							break;
130						default:
131							if(link){
132								html += "<li><a href=\"" + link + "#" + da.join('') + "\">"+ data.subject + " [" + str_date + "]" +"</a></li>\n";
133							}else{
134								html += "<li>" + data.subject + " [" + str_date + "]" +"</li>\n";
135							}
136					}
137					$("#" + c_id).replaceWith(html);
138					},
139				function () {
140					console.log("NG:detail_mail / " + d_path);
141					$('#nokinkyu').show();
142				}
143			);
144		};
145
146		// --Aタグ置換
147		function chg_urllink(str) {
148			var rep = str;
149			rep = rep.replace(/(https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#\u3000-\u30FE\u4E00-\u9FA0\uFF01-\uFFE3]+)/g, '<a href="$1" target="_blank">$1</a>');
150			return rep;
151		};
152
153	});
154})();

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.