ระบบ affiliate พาร์ทเนอร์ + นับผู้เข้าชม + สายที่เปิดดูบ่อย + ความปลอดภัยรูป
== ระบบพาร์ทเนอร์ (affiliate) ==
- resource/data/affiliates.json — ข้อมูล 11 โปรแกรม (8 ใน footer) + ที่วางลิงก์แนะนำ
- home.init.js: initSponsors() สร้างไทล์ marquee จาก JSON (ไม่ฮาร์ดโค้ดใน HTML)
· มี affiliate_link → <a target=_blank rel="noopener sponsored">
· ยังไม่มีลิงก์ → <span> แสดงรูปเฉย ๆ (กดไม่ได้ ไม่พาไปหน้าเปล่า)
· โหลด JSON ไม่ได้ → คงไทล์ fallback ที่ฝังใน HTML (8 ไทล์)
- เติมลิงก์ affiliate แล้ว 6 แบรนด์: 7-Eleven · Shopee · Lazada · airasia MOVE ·
busonlineticket · Trip.com
== ระบบสถิติ (ฝั่งเบราว์เซอร์ ไม่มี backend) ==
- ui/popular.js — "สายที่เปิดดูบ่อย" ใน footer
· score = hits × 0.5^(อายุวัน/30) — กันคะแนนเฟ้อ (ครึ่งชีวิต 30 วัน)
· ทิ้งข้อมูลที่ตายเกิน 180 วันอัตโนมัติ · เก็บ 2 ตัวเลข/สาย (~24 ไบต์)
· ไม่มีข้อมูล → ใช้ค่าเริ่มต้น 101/902/15/464
- ui/visitors.js — นับผู้เข้าชมจริง (ฐาน 12,834)
· กันเฟ้อ 3 ชั้น: sessionStorage (F5 ไม่นับ) → 1 ครั้ง/วัน → dayKey กันล้าง session
· กดตัวเลข 5 ครั้ง → ช่องกรอกรหัส (SHA-256 ไม่เก็บรหัสจริงในโค้ด) → รีเซ็ตเป็น 0
- หัวข้อ footer เปลี่ยนเป็น "สายที่เปิดดูบ่อย" / "Most Viewed Routes"
== ความปลอดภัยของรูป ==
- images.zip: ลบ EXIF/GPS ทั้งหมด 12 ไฟล์ (piexif — ไม่แตะ pixel data, คง ICC profile)
· ตัด .image/partners/_original/ ออก (ไฟล์สำรองที่ไม่ควรแจก)
· ตรวจแล้ว: GPS=0 · EXIF=0 · รูปเสีย=0 · 39.4 MB → 37 MB
- tcl999-angthong.jpg ย่อ 4032×3024 (2.5 MB) → 700×525 (86 KB) สำหรับใช้บนเว็บ
== UI ==
- nav (mu-topbar) z-index 50 → 1100 + isolation:isolate ที่กรอบแผนที่
(Leaflet ใช้ z-index ถึง 1000 — เดิมปุ่มซูม/ป๊อปอัปทะลุขึ้นทับ nav)
- รูปสำรองสถานี: ไม่มีรูป → แสดง minibus-512x512 (.is-fallback ใช้ object-fit:contain)
- affiliate.json เป็น CRLF ตาม pattern เดิมของโปรเจกต์
This commit is contained in:
1 parent
488b4c6054
commit
74d605f1c4
17 files changed
+624
-29
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -236,7 +236,7 @@
|
||||
"3.เปิดเส้นทางใหม่ เอาจริงๆข้อนี้ก็ยากเพราะข้าราชการจะยอมเปิดเส้นทางใหม่มั้ย ถ้าเปิดเส้นทางใหม่แล้วใครจะมาประมูลใบอนุญาตและกลุ่มผู้โดยสารขาประจำจะมีเพียงพอมั้ยก็ไม่รู้ อยากเสนอให้พิจารณา ได้แก่ ",
|
||||
"รถไฟฟ้าสายสีแดงเข้ม อ่างทอง-ป่าโมก-สถานีชุมทางบ้านภาชี ทั้งๆที่มีสถานีรถไฟชานเมืองอยู่แล้ว แม้ว่าจะอ้อมกว่าเล็กน้อยจะเสนอ เพราะว่าการขึ้นสถานีต้นทางประกันว่ามีที่นั่งแน่นอนและหนีความวุ่นวาย สถานีรถไฟฟ้าอยุธยาต้องวุ่นวายทั้งคนรอรถไฟความเร็วสูง รถไฟฟ้าชานเมือง นักท่องเที่ยว ",
|
||||
"รถไฟฟ้าความเร็วสูง อ่างทอง-ป่าโมก-สถานีรถไฟฟ้าความเร็วสูงอยุธยา ทั้งๆที่ตั้งอยู่ที่เดียวกันนั่นแหละ แต่เสนอเพราะอยากให้เดินทางเร็วสอดคล้องกับเที่ยวรถไฟความเร็วสูงคนที่จะไป อีสานและกรุงเทพ ",
|
||||
"รถไฟฟ้ารางเดี่ยวสีชมพู อ่างทอง-ป่าโมก-MRT แยกปากเกร็ด หรือ ทะเลสาบเมืองทองธานี หรือวัชรพล เชื่อมต่อรถไฟฟ้ารางเดี่ยวสามารถพาไปส่วนต่างๆของนนทบุรีได้และต่อไปรถไฟฟ้าสายสีอื่นๆได้ "
|
||||
"รถไฟฟ้ารางเดี่ยวสีชมพู อ่างทอง-ป่าโมก-MRT แยกปากเกร็ด หรือ ทะเลสาบเมืองทองธานี หรือวัชรพล เชื่อมต่อรถไฟฟ้ารางเดี่ยว ส่งคนชอบดูงานอีเว้นชอบสามารถพาไปส่วนต่างๆของนนทบุรีได้และต่อไปรถไฟฟ้าสายสีอื่นๆได้ "
|
||||
]
|
||||
},
|
||||
"en": {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"date": "2026-10-05",
|
||||
"th": {
|
||||
"title": "กฎหมาย 4 หมวดรถประจำทาง กับทางออกของอ่างทอง",
|
||||
"tag": "ความฝัน",
|
||||
"body": [
|
||||
"ตามกฎหมายควบคุมการขนส่งทางบกแบ่งรถประจำทางออกเป็น 4 หมวด ได้แก่ 1.รถประจำทางในเขตเทศบาล 2.รถจากต่างจังหวัดเข้ากรุงเทพ 3.รถจากจังหวัดหนึ่งถึงอีกจังหวัดหนึ่ง 4.รถภายในจังหวัด",
|
||||
"กรมการขนส่งใช้ระบบให้นิติบุคคล พวก บริษัท ห้างหุ้นส่วน หรือสหกรณ์ใครสนใจก็เข้าไปของใบอนุญาต ซึ่งหลักการนี้ก็ใช้มาตั้งแต่ ปี 2520 กว่าๆ ถึงจะออกกฎระเบียบรองๆตามสภาพบ้านเมืองแต่ปัจจุบันเราก็เห็นสภาพกันอยู่ว่ามันแย่แค่ไหน",
|
||||
"อยากเสนอให้ องค์กรปกครองส่วนท้องถิ่นเข้ามาเดินรถ หมวด1 และหมวด4 ไม่ว่าจะดำเนินการเอง จ้างเหมาเอกชนหรือทำข้อตกลงสำรองจ่ายเฉพาะส่วนต่างที่เอกชน เราก็อาจจะเห็นบางจังหวัดเริ่มทำบ้างแล้ว แต่สำหรับอ่างทองจะเอาเงินจากไหนมาจัดบริการแบบนี้ ส่วนรถหมวด 2 และ 3 ถึงเราจะอยากให้อุดหนุนแต่มันก็เลยคำว่า บริการพื้นฐานไปแล้วก็คงได้แต่ส่งกำลังใจให้มีกำไรและจัดบริการดีๆ"
|
||||
]
|
||||
},
|
||||
"en": {
|
||||
"title": "The 4 bus categories — and a way forward for Ang Thong",
|
||||
"tag": "A dream",
|
||||
"body": [
|
||||
"Under the law governing land transport, buses are divided into 4 categories: (1) buses within a municipality, (2) buses from the provinces into Bangkok, (3) buses from one province to another, and (4) buses within a province.",
|
||||
"The Department of Land Transport works on a juristic-person system — companies, partnerships and cooperatives. Anyone interested applies for a licence. This principle has been in place since around 1977; the rules have been adjusted bit by bit to match the times, but today we can all see for ourselves just how bad things have become.",
|
||||
"I'd like to propose that local administrative organisations step in to run the category 1 and category 4 routes — whether by operating them themselves, contracting out to the private sector, or agreeing to subsidise only the shortfall, with the private operator covering the rest. A few provinces have started doing this already. But where would Ang Thong get the money to fund a service like this? As for categories 2 and 3, even if we'd like to subsidise them, they're already beyond what counts as a basic service — so all we can do is send our encouragement for them to stay profitable and keep running a good service."
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,9 @@
|
||||
background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, .62));
|
||||
}
|
||||
/* --- แผนที่ "เส้นทางที่เสนอ" (ความฝัน) + รายการคลิกได้ + แผงรายละเอียด --- */
|
||||
.blog-mapx { margin: 0 0 16px; position: relative; }
|
||||
/* isolation:isolate — กัก z-index ของ Leaflet (400–1000) ไว้ในกรอบแผนที่
|
||||
ไม่ให้ปุ่มซูม/ป๊อปอัปทะลุขึ้นไปทับ nav (z-index 1100) */
|
||||
.blog-mapx { margin: 0 0 16px; position: relative; isolation: isolate; }
|
||||
/* ป้ายหมวดบนแผนที่ (มุมขวาบน — หลบปุ่มซูมของ Leaflet ที่มุมซ้ายบน) */
|
||||
.blog-mapx-tag {
|
||||
position: absolute; top: 12px; right: 12px; z-index: 500;
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
routeGroups: '../resource/data/route_groups.json',
|
||||
routes: '../resource/data/routes.json',
|
||||
routesMunicipal: '../resource/data/routes_municipal.json',
|
||||
schedules: '../resource/data/schedules.json'
|
||||
schedules: '../resource/data/schedules.json',
|
||||
affiliates: '../resource/data/affiliates.json',
|
||||
};
|
||||
|
||||
// จังหวัดเริ่มต้น (home province ของเว็บนี้) — ใช้เป็นค่า default ของ hero + ตัวเลือก
|
||||
@@ -146,6 +147,50 @@
|
||||
});
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
ไทล์พาร์ทเนอร์ (marquee) — สร้างจาก resource/data/affiliates.json
|
||||
· แก้รายชื่อ/รูป/ลิงก์ที่ไฟล์ JSON ไม่ต้องแตะโค้ด
|
||||
· affiliate_link ว่าง = ยังไม่มีลิงก์ → แสดงเป็นไทล์เฉย ๆ (ไม่เป็นลิงก์ กดไม่ได้)
|
||||
· โหลด JSON ไม่ได้/ว่าง → คงไทล์เดิมที่ฝังใน HTML (fallback ไม่ให้หน้าว่าง)
|
||||
============================================================ */
|
||||
function initSponsors() {
|
||||
var track = document.querySelector('.mu-marquee-track');
|
||||
if (!track) return Promise.resolve();
|
||||
|
||||
return fetchJSON(DATA_URL.affiliates).then(function (d) {
|
||||
var list = (d && d.partners) || [];
|
||||
var tiles = list.filter(function (p) { return p && p.in_footer_marquee && p.tile_image; });
|
||||
if (!tiles.length) return; /* ไม่มีข้อมูล → คงไทล์เดิม */
|
||||
|
||||
var frag = document.createDocumentFragment();
|
||||
tiles.forEach(function (p) {
|
||||
var link = String(p.affiliate_link || '').trim();
|
||||
/* มีลิงก์ = <a> · ยังไม่มี = <span> (กดไม่ได้ ไม่พาไปหน้าเปล่า) */
|
||||
var node = document.createElement(link ? 'a' : 'span');
|
||||
node.className = 'mu-marquee-tile';
|
||||
node.setAttribute('aria-label', p.brand || '');
|
||||
|
||||
var img = document.createElement('img');
|
||||
var src = '../' + String(p.tile_image).replace(/^\.?\//, '');
|
||||
img.src = (window.ImgURL && ImgURL.of) ? ImgURL.of(src) : src;
|
||||
img.alt = p.brand || '';
|
||||
img.decoding = 'async';
|
||||
node.appendChild(img);
|
||||
|
||||
if (link) {
|
||||
node.href = link;
|
||||
node.target = '_blank';
|
||||
node.rel = 'noopener sponsored'; /* ลิงก์ affiliate → ระบุ sponsored */
|
||||
} else {
|
||||
node.setAttribute('title', p.brand || '');
|
||||
}
|
||||
frag.appendChild(node);
|
||||
});
|
||||
track.innerHTML = '';
|
||||
track.appendChild(frag);
|
||||
});
|
||||
}
|
||||
|
||||
function initMarquee() {
|
||||
var track = document.querySelector('.mu-marquee-track');
|
||||
if (!track || track.dataset.cloned) return;
|
||||
@@ -401,6 +446,6 @@
|
||||
}
|
||||
|
||||
initHomeSelectors();
|
||||
initMarquee();
|
||||
initSponsors().then(initMarquee); /* เติมไทล์จาก JSON ก่อน แล้วค่อย clone (ไม่งั้นไทล์ที่เพิ่มจะไม่ถูก clone) */
|
||||
initShare();
|
||||
})();
|
||||
@@ -392,6 +392,11 @@
|
||||
/* === Modern image polish === */
|
||||
.mu-logo-img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
|
||||
.mu-stop-hero-photo { width: 100%; height: 220px; object-fit: cover; border-radius: 16px; display: block; margin-bottom: 12px; box-shadow: 0 10px 24px rgba(63,43,94,.16); }
|
||||
/* รูปสำรอง (สถานียังไม่มีรูป) — เป็นไอคอนโปร่งใส จึงใช้ contain + พื้นอ่อน ไม่ให้ยืด/ตัด */
|
||||
.mu-stop-hero-photo.is-fallback {
|
||||
object-fit: contain; padding: 22px; box-sizing: border-box;
|
||||
background: #f7f4fd; box-shadow: none; border: 1px solid #e8e4f2;
|
||||
}
|
||||
.mu-nearby {
|
||||
background: #fff; border: 1px solid var(--mu-border); border-radius: 20px;
|
||||
padding: 18px; margin: 14px 0; box-shadow: 0 10px 24px rgba(63,43,94,.06);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
var DATA = '../resource/data/';
|
||||
var PHOTO_DIR = '../.image/stations/'; /* รูปสถานี: <station_id>.<jpg|jpeg|webp|png> (ไล่ลองนามสกุลให้) */
|
||||
var PHOTO_EXTS = ['jpg', 'jpeg', 'webp', 'png'];
|
||||
var PHOTO_FALLBACK = '../.image/stations/minibus-512x512.png'; /* รูปสำรองเมื่อสถานียังไม่มีรูป */
|
||||
|
||||
/* ประเภทป้าย → คีย์แปล + โทนสี */
|
||||
var TYPE_KEY = {
|
||||
@@ -89,6 +90,8 @@
|
||||
|
||||
/* ---------- รูปสถานี: .image/stations/<station_id>.jpg ----------
|
||||
เลือกตาม station_id ใน stations.json · ไฟล์หาย → ไม่แสดงช่องว่าง (hero ยืดเต็ม) */
|
||||
function bust(u) { return (window.ImgURL && ImgURL.of) ? ImgURL.of(u) : u; }
|
||||
|
||||
function findPhoto(station) {
|
||||
if (station.photo) return station.photo; /* ระบุพาธเองได้ใน stations.json (ทับค่าเริ่มต้น) */
|
||||
var n = station.__seq || 1; /* รูปเสริมของสถานีเดียวกัน: 2-2.jpg, 2-3.jpeg … */
|
||||
@@ -165,7 +168,12 @@
|
||||
img.hidden = true; /* ซ่อนไว้ก่อน — รอผลตรวจว่ามีไฟล์จริง */
|
||||
var cands = [].concat(photo || []).filter(Boolean); /* รองรับทั้งสตริงเดียวและรายการนามสกุล */
|
||||
(function tryNext(i) {
|
||||
if (i >= cands.length) return; /* ไม่มีไฟล์เลย → ไม่แสดงช่องว่าง */
|
||||
if (i >= cands.length) { /* ไม่มีรูปสถานี → ใช้รูปสำรอง ไม่ปล่อยช่องว่าง */
|
||||
img.classList.add('is-fallback');
|
||||
img.src = bust(PHOTO_FALLBACK);
|
||||
img.hidden = false;
|
||||
return;
|
||||
}
|
||||
var url = cands[i];
|
||||
fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) {
|
||||
|
||||
Reference in new issue
Block a user