User:Dixtosa/sodeep.js

Hello, you have come here looking for the meaning of the word User:Dixtosa/sodeep.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Dixtosa/sodeep.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Dixtosa/sodeep.js in singular and plural. Everything you need to know about the word User:Dixtosa/sodeep.js you have here. The definition of the word User:Dixtosa/sodeep.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Dixtosa/sodeep.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
//TO-DO: see User:Dixtosa
// <nowiki>
// Closed for modification open for extension xD
deepCollection = ;


function deepCheckEnglishForCategories()
{
	var api = new mw.Api();
	var query = {
				'action': 'query',
				'titles': undefined,
				'redirects': 1,
				'prop': 'categories',
				'cllimit': 1000,
				'continue': ''
	};
	categoriesForTitles = ;
	var curPageCats = ;
	
	var defLinks = $(".defEditButton").parent().parent().find('a');
	query = defLinks.map(function() { return $(this).text();}).get().join('|') + "|" + mw.config.values.wgTitle;
	
	api.get(query).then(function(result)
	{
		for (var pageid in result.query.pages) {
			var title = result.query.pages.title;
			var cats = (result.query.pages.categories || ).map(function(val, ind){ return val.title;});
			categoriesForTitles = cats;
		}
		curPageCats = categoriesForTitles || ;		
	
		var catHtml = "";
		defLinks.each(function(){ 
			var langHeader = $(this).parentsUntil("#mw-content-text").last().prevUntil("h2").last().prev();
			var language = langHeader.find(".mw-headline").text();
			var langcode = (new LangMetadata()).cleanLangCode(language);
			var term = $(this).text();
			var cats = categoriesForTitles;
			
			for (var i = 0; i < cats.length; i++)
			{
				var value = cats.match(/Category:en:(.*)$/);
				if (value === null) continue;
				value = "Category:" + langcode + ":" + value;
				if (curPageCats.indexOf(value) >= 0) continue;
				catHtml += '</br> <input type="checkbox" value="' + value + '" checked data-lang = "' + language + '">' + value + " (" + this.outerHTML + ")";
			}
		});
		
		$("#sodeepjs").append("<div id = 'deep_suggestedcategories'>Suggested categories: </div>");
		$("#deep_suggestedcategories").append(catHtml);
	}, console.log);

	return function(wikitext)
	{
		var res = wikitext;
		var wikixml = WikiXml.parseWikitext(wikitext, {wrapCategory: true, wrapSplitter: true, wrapInterwikis: true});

		var checkedValues = $("#deep_suggestedcategories :checked");
		checkedValues.each(function() {
			var specificLang = wikixml.find("." + $(this).attr("data-lang"));
		
			var newWikitext = "]";
			newWikitext = "<category>" + newWikitext + "\n</category>";
			var node = specificLang.find("splitter, category, interwikis");
			if (node.length === 0)
			{
				specificLang.append(newWikitext);
			}
			else
				$(node.get(0)).before(newWikitext);
		});
		return WikiXml.toWikitext(wikixml);
	};
}
deepCollection.push(deepCheckEnglishForCategories);


var changeWikitextPlugin = ;
function deepSave(source)
{
	let summary = "edited by ]";
	$(source).text("Saving");
	
	new mw.Api()
	.edit(mw.config.values.wgPageName, function ( revision ) {
		let wikitext = revision.content;
		for (var i = 0; i < changeWikitextPlugin.length; i++)
		{
			wikitext = (changeWikitextPlugin)(wikitext);
		}
		return {text: wikitext, summary: summary};
	})
	.then( function () {
		mw.notify ( 'Saved! ');
	});
}
function goDeep()
{
	$("#firstHeading").before("<div id = 'sodeepjs'><button type='button'  onclick = 'deepSave(this)'>Save</button></div>");
	changeWikitextPlugin = deepCollection.map(function (plugin) { return plugin(); });
}

if (mw.config.values.wgNamespaceNumber === 0 && mw.config.values.wgAction == "view")
{
	mw.loader.using(, function () {
		$( () => {
			$ ("#ca-talk").after("<li> <span> <a onclick = 'return goDeep();'> Go deep </a> </span> </li>");
		});
	});
}

// </nowiki>