Butun axtardiqlarinizi tapmaq ucun buraya: DAXIL OLUN
  Mp4 Mp3 Axtar Yukle
  Video Axtar Yukle
  Shekil Axtar Yukle
  Informasiya Melumat Axtar
  Hazir Inshalar Toplusu
  AZERI CHAT + Tanishliq
  1-11 Sinif Derslikler Yukle
  Saglamliq Tibbi Melumat
  Whatsapp Plus Yukle(Yeni)

  • Ana səhifə
  • Təsadüfi
  • Yaxınlıqdakılar
  • Daxil ol
  • Nizamlamalar
İndi ianə et Əgər Vikipediya sizin üçün faydalıdırsa, bu gün ianə edin.

MediaViki:Gadget-sns-arxiv.js

  • İnterfeys
  • Müzakirə
  • Mənbəyə bax
Etdiyiniz dəyişikliklərin yayımlanandan sonra effekt verməsi üçün brauzerinizin keşini təmizləməyə ehtiyacınız ola bilər. Bunun üçün Chrome, Firefox, Edge, yaxud Safari istifadəçisisinizsə, klaviaturanızın Shift düyməsini sıxaraq brauzerin ⟳ səhifə yeniləmək düyməsini klik edə bilərsiniz.
"use strict";

mw.loader.using(['mediawiki.util', 'mediawiki.api', '@wikimedia/codex', 'vue'], function(require) {
	const { createMwApp, ref, onMounted, watch } = require('vue');
	const { CdxDialog, CdxButton } = require('@wikimedia/codex');
	const api = new mw.Api();

	const page = mw.config.get('wgPageName');
	if (page !== "Vikipediya:Silinməyə_namizəd_səhifələr") return;
	if (mw.config.get('skin') === 'minerva') return;

	const headings = document.querySelectorAll('.mw-heading');

	headings.forEach((heading) => {
		const editSection = heading.querySelector('.mw-editsection');
		if (!editSection) return;

		const aTag = editSection.querySelector('a');
		const editLinkHref = aTag ? aTag.getAttribute('href') : null;
		const match = editLinkHref && editLinkHref.match(/title=([^&]+)/);
		const matchedTitle = match && match[1] ? decodeURIComponent(match[1]).replace(/_/g, ' ') : null;
		if (!matchedTitle) return;

		const sectionPage = matchedTitle;

		api.get({
			action: 'parse',
			prop: 'wikitext',
			page: sectionPage,
			formatversion: 2
		}).then(res => {
			const wikitext = res.parse.wikitext;
			if (!wikitext.includes('{{qapalı')) return;

			let container;
			if (mw.config.get('skin') === 'minerva') {
				container = document.createElement('div');
				container.className = 'arxivleshdir-wrapper';
				heading.after(container);
			} else {
				container = document.createElement('span');
				container.className = 'mw-editsection';
				editSection.after(container);
			}

			const app = createMwApp({
				components: { CdxDialog, CdxButton },
				setup() {
					const dialogOpen = ref(false);
					const progressing = ref(false);
					const countdown = ref(5);
					const redirectInterval = ref(null);
					const archivePage = ref('');
					const loadingArchive = ref(true);

					const sectionName = sectionPage.replace('Vikipediya:Silinməyə namizəd səhifələr/', '');
					const monthNames = ['Yanvar', 'Fevral', 'Mart', 'Aprel', 'May', 'İyun', 'İyul', 'Avqust', 'Sentyabr', 'Oktyabr', 'Noyabr', 'Dekabr'];

					onMounted(async () => {
						try {
							const creationRes = await api.get({
								action: 'query',
								titles: sectionPage,
								prop: 'revisions',
								rvlimit: 1,
								rvdir: 'newer',
								rvprop: 'timestamp',
								formatversion: 2
							});
							const pageData = creationRes.query.pages[0];
							if (pageData && pageData.revisions && pageData.revisions.length > 0) {
								const created = new Date(pageData.revisions[0].timestamp);
								const year = created.getUTCFullYear();
								const month = monthNames[created.getUTCMonth()];
								archivePage.value = `Vikipediya:Silinməyə namizəd səhifələr/Arxiv/${year} ${month}`;
							}
						} catch (e) {
							console.error('Creation date fetch failed:', e);
							mw.notify('Səhifənin yaradılma tarixi tapılmadı.', { type: 'error' });
						}
						loadingArchive.value = false;
					});

					watch(dialogOpen, function(newVal) {
						if (!newVal && redirectInterval.value) {
							clearInterval(redirectInterval.value);
							redirectInterval.value = null;
							countdown.value = 5;
						}
					});

					async function archiveDiscussion() {
						if (!archivePage.value) {
							mw.notify('Arxiv səhifəsi müəyyən edilə bilmədi.', { type: 'error' });
							return;
						}

						progressing.value = true;

						try {
							const mainRes = await api.get({
								action: 'query',
								titles: page,
								prop: 'revisions',
								rvprop: 'content',
								formatversion: 2
							});
							let mainContent = mainRes.query.pages[0].revisions[0].content;
							const lineToRemove = `{{Vikipediya:Silinməyə namizəd səhifələr/${sectionName}}}`;
							mainContent = mainContent.split('\n').filter(function(l) {
								return l.trim() !== lineToRemove;
							}).join('\n');

							await api.postWithEditToken({
								action: 'edit',
								title: page,
								text: mainContent,
								summary: `[[${sectionPage}]] müzakirəsi [[${archivePage.value}|arxivə]] köçürüldü`,
								format: 'json'
							});

							let archiveContent = '';
							let isNew = false;
							try {
								const archRes = await api.get({
									action: 'query',
									titles: archivePage.value,
									prop: 'revisions',
									rvprop: 'content',
									formatversion: 2
								});
								const pageObj = archRes.query.pages[0];
								if (pageObj.missing) {
									archiveContent = '{{Arxiv}}\n';
									isNew = true;
								} else {
									archiveContent = pageObj.revisions[0].content;
								}
							} catch (e) {
								console.error('Archive page fetch failed:', e);
							}

							archiveContent += `\n{{Vikipediya:Silinməyə namizəd səhifələr/${sectionName}}}`;

							await api.postWithEditToken({
								action: 'edit',
								title: archivePage.value,
								text: archiveContent,
								summary: `[[${sectionPage}]] müzakirəsi arxivə əlavə olundu`,
								createonly: isNew,
								format: 'json'
							});

							redirectInterval.value = setInterval(function() {
								countdown.value--;
								if (countdown.value <= 0) {
									clearInterval(redirectInterval.value);
									redirectInterval.value = null;
									location.href = mw.util.getUrl(archivePage.value) + '#' + encodeURIComponent(sectionName);
								}
							}, 1000);
						} catch (err) {
							console.error(err);
							mw.notify('Arxivləşdirmə zamanı xəta baş verdi.', { type: 'error' });
						}
					}

					return {
						dialogOpen,
						progressing,
						archiveDiscussion,
						countdown,
						sectionName,
						archivePage,
						loadingArchive
					};
				},
				template: `
					<span class="mw-editsection-bracket">[</span>
					<a href="#" @click.prevent="dialogOpen = true">arxivləşdir</a>
					<span class="mw-editsection-bracket">]</span>

					<cdx-dialog
						v-model:open="dialogOpen"
						title="Müzakirənin arxivləşdirilməsi"
						use-close-button
					>
						<template #default>
							<p v-if="!loadingArchive">
								<code>{{ sectionName }}</code> səhifəsinin müzakirəsi
								<a :href="'/wiki/' + archivePage.replace(/ /g, '_')">{{ archivePage }}</a> səhifəsində arxivləşdiriləcəkdir. Davam etmək üçün klikləyin.
							</p>
							<p v-else>
								Arxiv səhifəsi müəyyən edilir...
							</p>

							<div v-if="progressing && countdown === 5" class="cdx-progress-indicator">
								<div class="cdx-progress-indicator__indicator">
									<progress class="cdx-progress-indicator__indicator__progress"></progress>
								</div>
								<div class="cdx-label cdx-progress-indicator__label">
									<label class="cdx-label__label">
										<span class="cdx-label__label__text">Müzakirə arxivləşdirilir…</span>
									</label>
								</div>
							</div>

							<p v-if="progressing && countdown < 5 && countdown > 0" style="margin-top: 1em;">
								Müzakirə arxivləşdirildi! {{ countdown }} saniyə sonra arxiv səhifəsinə yönləndiriləcəksiniz.
							</p>
						</template>
						<template #footer>
							<cdx-button @click="archiveDiscussion" :disabled="progressing || loadingArchive">Davam et</cdx-button>
						</template>
					</cdx-dialog>
				`
			});

			app.mount(container);
		});
	});
});
Mənbə — "https://az.wikipedia.org/w/index.php?title=MediaViki:Gadget-sns-arxiv.js&oldid=8257180"
Informasiya Melumat Axtar