Jump to content

User:Crispyshill/test.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Crispyshill (talk | contribs) at 00:01, 20 January 2023. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Adds a link to the applications UI at the top of the page 
$('#p-personal > .vector-menu-content > .vector-menu-content-list').prepend('<li style="cursor: pointer; user-select: none;" id="sh-citation-button-container"></li>');
$("#sh-citation-button-container").append('<p id="sh-citation-button" >citationFixer</p>');

let portletOpen = false;
let jsonData;
// title is the location of the json which holds the recorded cites with their corresponding access levels
let title = "User:Crispyshill/citationtable.json";
// This JQuery function grabs the JSON object from the file
$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title='+title, function(data){
			    $('#bodyContent').append('<p>Supported Sites:</p>');
			    // Adds to the end of each page each of the url's of the supported cites FOR TESTING ONLY, REMOVE FOR FINAL VERSION
	data.forEach(x=>{
		    $('#bodyContent').append('<p>'+JSON.stringify(x.url)+'</p>');

	})
	// Saves the json object for further use
	jsonData = data;
});


// Controlls functionality when the UI button is pressed
$("#sh-citation-button").click(()=>{
if(portletOpen){
	$(".sh-portlet").remove();
	portletOpen = false;
}
else{
portletOpen = true;
// working on portlet funcitonality
$('#sh-citation-button-container').append('<div style="position: relative; top: 5%; border-style: solid; background: blue;" class="sh-portlet">Hello World</div>');
$('.sh-portlet').append('<button>Enter new source</button>');
}

});