Update and clean code

This commit is contained in:
schooltechx 2023-04-04 12:39:11 +07:00
parent 3edde43c25
commit 1c9b5877d6
29 changed files with 1179 additions and 838 deletions

View file

@ -4,8 +4,6 @@
</script>
<Header />
<div class="p-5 max-w-4xl place-content-center ">
<div>
<slot />
</div>
</div>
<slot />

View file

@ -0,0 +1,11 @@
import homeContent from "$lib/data/home.md?raw"
import { marked } from 'marked'
const detail = marked.parse(homeContent) //(await compile(homeContent))?.code;
import { getQualifyExams,getCompetitiveExams } from '$lib/data/info';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async () => {
const qualify_exams = await getQualifyExams(3);
const competitive_exams = await getCompetitiveExams(3);
return { detail , qualify_exams,competitive_exams };
};

View file

@ -1,12 +1,109 @@
<h1 class="text-4xl">กองสรรหาบุคคล (Recruitment Division)</h1>
<h2 class="text-2xl">ประกาศเกี่ยวกับการคัดเลือกบุคลากรกทม</h2>
<div>xxxx</div>
<div>xxxx</div>
<div>xxxx</div>
<div>xxxx</div>
<h2 class="text-2xl">ประกาศเกี่ยวกับการสอบแข่งขัน</h2>
<div>xxxx</div>
<div>xxxx</div>
<div>xxxx</div>
<div>xxxx</div>
version 0.2.0
<script lang="ts">
import type { PageData } from './$types';
export let data: PageData;
//import events from "$lib/data/activities_events.json"
const qualify_exams = data.qualify_exams;
const competitive_exams = data.competitive_exams;
const detail = data.detail;
import FullCalendar from '$lib/components/FullCalendar.svelte';
import daygridPlugin from '@fullcalendar/daygrid';
//import timegridPlugin from '@fullcalendar/timegrid';
import interactionPlugin from '@fullcalendar/interaction';
import type { EventClickArg } from '@fullcalendar/core';
let calendarRef;
function clickDate(info: { dateStr: string; }){
alert('a day has been clicked!'+info.dateStr);
}
function clickEvent(info:EventClickArg){
alert(
'Event: ' + info.event.title +
'\nID: ' + info.event.id +
'\nCoordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY +
'\nView: ' + info.view.type
);
// change the border color just for fun
info.el.style.borderColor = 'red';
}
let options = {
initialView: 'dayGridMonth',
plugins: [daygridPlugin,interactionPlugin],
locale: 'th',
headerToolbar: {
start: 'prev,next',
center: 'title'
},
contentHeight:"auto",
selectable: true,
buttonText: {
month: 'เดือน',
agendaDay: 'วัน',
agendaWeek: 'สัปดาห์',
today: 'วันนี้'
},
events:[
{ "id": "1","title": "ทำความสะอาด", "start": new Date() },
{ "id": "2","title": "กิจกรรมบางอย่าง", "start": "2023-03-28" },
{ "id": "3", "start": "2023-03-08T13:00:00", "end": "2023-03-10T12:00:00", "title": "ค่ายรักการอ่าน" }
],
dateClick: clickDate,
eventClick: clickEvent,
};
</script>
<h1 class="p-5 text-center text-orange-800">กองสรรหาบุคคล</h1>
<div class="w-full flex flex-col space-y-4 md:flex-row md:space-x-4 md:space-y-0" >
<div class="md:w-2/5 lg:w-2/5 px-3">
<FullCalendar bind:this={calendarRef} {options} />
</div>
<di class="md:w-3/5 lg:w-3/5 px-3">
{@html detail}
</di>
</div>
<div class="p-5">
<h2 class="text-2xl">ประกาศเกี่ยวกับการคัดเลือก</h2>
<table class="table table-compact w-full">
<thead>
<tr>
<th>วันที่</th>
<th>การสอบ</th>
<th>หน่วยงาน</th>
</tr>
</thead>
<tbody>
{#each qualify_exams as exam}
<tr>
<th><a href={'/qualify_exams/' + exam.id}>{exam.date}</a></th>
<td>{exam.detail}</td>
<td>{exam.institute}</td>
</tr>{/each}
</tbody>
</table>
</div>
<div class="p-5">
<h2 class="text-2xl">ประกาศเกี่ยวกับการสอบแข่งขัน</h2>
<table class="table table-compact w-full">
<thead>
<tr>
<th>วันที่</th>
<th>การสอบ</th>
</tr>
</thead>
<tbody>
{#each competitive_exams as exam}
<tr>
<th><a href={'/competitive_exams/' + exam.id}>{exam.date}</a></th>
<td>{exam.detail}</td>
</tr>{/each}
</tbody>
</table>
</div>
<div class="px-5">
<h2>Full Size Calendar</h2>
<FullCalendar bind:this={calendarRef} {options} />
</div>

View file

@ -1,11 +1,6 @@
import {getContact} from "$lib/data/info"
import type { PageServerLoad } from './$types'
/*
export const load: PageServerLoad = async () => {
return getContact()
}*/
export const load = (async () => {
return await getContact()
}) satisfies PageServerLoad
import { getAbout } from '$lib/data/info';
import type { PageServerLoad } from './$types';
export const load = (async () => {
const about = await getAbout();
return about;
}) satisfies PageServerLoad;

View file

@ -1,54 +1,20 @@
<script lang="ts">
import 'dayjs/locale/th.js';
import 'dayjs/locale/zh-cn.js';
import 'dayjs/locale/es.js';
import 'dayjs/locale/ar-dz.js';
// มันรองรับ พ.ศ. ใน dayjs แต่ใน velte-calendar ไม่ได้เอาไปใช้ ยังหาวิธีแก้หัวปฎิทินไม่ได้ยังเป็น พ.ศ.
import buddhistEra from 'dayjs/plugin/buddhistEra'
import dayjs from 'dayjs';
dayjs.extend(buddhistEra)
import { InlineCalendar, Swappable, themes } from 'svelte-calendar';
import { onDestroy } from 'svelte';
const locales = ['th','en', 'es', 'zh-cn', 'ar-dz'];
$: dayjs.locale(locale);
onDestroy(() => dayjs.locale('en'));
import Calendar2 from '$lib/components/Calendar2/Calendar.svelte';
import Calendar from '$lib/components/Calendar/Calendar.svelte';
const today = new Date
const locale = "th"
const buddhist = true //buddhist calendar + 543
let year = today.getFullYear()
let month = today.getMonth()
import ver from "$lib/ver.json"
import type { PageData } from './$types'
export let data: PageData;
</script>
<h1 class="text-4xl">เกี่ยวกับ {data.company_name}</h1>
<div>{data.description}</div>
<div class="p-5 max-w-4xl place-content-center ">
{@html data.detail}
</div>
<div>{data.contact.description}</div>
<div>{ver.version}</div>
<div>{ver.builddate}</div>
<h2 class="text-2xl">svelte-calendar</h2>
<p>3rd svelte-calendar ไม่รองรับ พ.ศ.</p>
<!-- note: Locale is not reactive -->
<Swappable value={{ locale }} vertical={false} >
<InlineCalendar theme={themes.light} />
</Swappable>
<h2 class="text-2xl">Custom Calendar1</h2>
<div>
Calendar ทำเองยังไม่รองรับการแสดง event ในวัน
</div>
<Calendar {year} {month} {locale} {buddhist}/>
<h2 class="text-2xl">Custom Calendar2</h2>
<div>
ทำเองรองรับการแสดง event และคลิ้กได้ ได้แต่ยังปรับโค้ดไม่เรียบร้อย
</div>
<Calendar2 {locale} {buddhist} />

View file

@ -0,0 +1,8 @@
import {getCompetitiveExams} from "$lib/data/info"
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async () => {
const exams = await getCompetitiveExams()
return {exams}
}

View file

@ -1,35 +1,28 @@
<script lang="ts">
import 'dayjs/locale/th.js';
import 'dayjs/locale/zh-cn.js';
import 'dayjs/locale/es.js';
import 'dayjs/locale/ar-dz.js';
// มันรองรับ พ.ศ. ใน dayjs แต่ใน velte-calendar ไม่ได้เอาไปใช้ ยังหาวิธีแก้หัวปฎิทินไม่ได้ยังเป็น พ.ศ.
import buddhistEra from 'dayjs/plugin/buddhistEra'
import dayjs from 'dayjs';
dayjs.extend(buddhistEra)
import { InlineCalendar, Swappable, themes } from 'svelte-calendar';
import { onDestroy } from 'svelte';
const locales = ['th','en', 'es', 'zh-cn', 'ar-dz'];
let format = 'DD/MM/BBBB'
let locale = 'th';
$: dayjs.locale(locale);
onDestroy(() => dayjs.locale('en'));
import type { PageData } from './$types'
export let data: PageData;
const exams = data.exams
</script>
<h1 class="text-4xl">การสอบแข่งขัน</h1>
<!-- note: Locale is not reactive -->
<Swappable value={{ locale }} vertical={false} >
<InlineCalendar theme={themes.light} {format} />
</Swappable>
<h1 class="p-5">การสอบแข่งขัน</h1>
<div class="button-group">
{#each locales as loc}
<button on:click={() => (locale = loc)} class:selected={locale === loc}>
{loc}
</button> |
{/each}
<div class="p-5">
<table class="table table-compact w-full">
<thead>
<tr>
<th>วันที่</th>
<th>การสอบ</th>
<th>หน่วยงาน</th>
</tr>
</thead>
<tbody>
{#each exams as exam}
<tr>
<th><a href={"/exams/"+exam.id}>{exam.date}</a></th>
<td>{exam.detail}</td>
<td>{exam.institute}</td>
{/each}
</tbody>
</table>
</div>

View file

@ -1,8 +1,8 @@
import {getExams} from "$lib/data/qualify-exam"
import {getQualifyExams} from "$lib/data/info"
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async () => {
const exams = await getExams()
const exams = await getQualifyExams()
return {exams}
}

View file

@ -4,10 +4,11 @@
const exams = data.exams
</script>
<h1 class="text-4xl">การสอบคัดเลือก</h1>
<h1 class="p-5">การสอบคัดเลือก</h1>
<h1 class="text-2xl">รายการสอบ</h1>
<div class="overflow-x-auto">
<div class="p-5">
<h2>รายการสอบ</h2>
<table class="table table-compact w-full">
<thead>
<tr>
@ -25,4 +26,4 @@
{/each}
</tbody>
</table>
</div>
</div>