MediaWiki:Gadget-ResearchNotes-datatable.js: Difference between revisions

From Toolkit.Socialnetwork.Health
Created page with "if( $('#research-notes').length ) { $('#research-notes').DataTable({ dom: '<"top"lf>rt<"bottom"ip><"clear">', columns: [ { "title": "Page" }, { "title": "File" }, { "title": "URL" }, { "title": "Topic" }, { "title": "Note" }, { "title": "User" }, { "title": "Date" } ], columnDefs: [ { type: 'date', targets: [ 6 ] } ], aaSorting: [ [ 1, "desc" ] ], pageLength: 100, lengthMenu: [ [50, 100, 250, -1], ['50..."
 
No edit summary
Line 1: Line 1:
if( $('#research-notes').length ) {
/**
$('#research-notes').DataTable({
* Datatables definitions
dom: '<"top"lf>rt<"bottom"ip><"clear">',
* @example <>
    columns: [
*/
    { "title": "Page" },
if( $('link[href$="datatables.min.css"]').length ){
{ "title": "File" },
    // do nothing
{ "title": "URL" },
} else {
{ "title": "Topic" },
    $('<link/>', {
{ "title": "Note" },
        rel: 'stylesheet',
{ "title": "User" },
        type: 'text/css',
{ "title": "Date" }
        href: 'https://cdn.datatables.net/v/dt/dt-2.0.8/b-3.0.2/cr-2.0.3/date-1.5.2/fc-5.0.1/fh-4.0.1/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.3/sb-1.7.1/sp-2.3.1/sl-2.0.3/sr-1.4.1/datatables.min.css'
],
    }).appendTo('head');
columnDefs: [
}
{
 
type: 'date',
$.ajaxSetup({ cache: true });
targets: [ 6 ]
 
$.when(
    mw.loader.getScript( 'https://cdn.datatables.net/v/dt/dt-2.0.8/b-3.0.2/cr-2.0.3/date-1.5.2/fc-5.0.1/fh-4.0.1/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.3/sb-1.7.1/sp-2.3.1/sl-2.0.3/sr-1.4.1/datatables.min.js' )
)
.then(
function () {
if( $('#research-notes').length ) {
$('#research-notes').DataTable({
dom: '<"top"lf>rt<"bottom"ip><"clear">',
    columns: [
    { "title": "Page" },
{ "title": "File" },
{ "title": "URL" },
{ "title": "Topic" },
{ "title": "Note" },
{ "title": "User" },
{ "title": "Date" }
],
columnDefs: [
{
type: 'date',
targets: [ 6 ]
}
],
aaSorting: [
[ 1, "desc" ]
],
pageLength: 100,
lengthMenu: [
[50, 100, 250, -1],
['50 per page', '100 per page', '250 per page', 'Show all']
],
    language: {
    searchPlaceholder: 'Search in notes',
searchBuilder: {
    title: ''
},
lengthMenu: '_MENU_',
},
initComplete: function () {
}
}
],
});
aaSorting: [
[ 1, "desc" ]
],
pageLength: 100,
lengthMenu: [
[50, 100, 250, -1],
['50 per page', '100 per page', '250 per page', 'Show all']
],
    language: {
    searchPlaceholder: 'Search in notes',
searchBuilder: {
    title: ''
},
lengthMenu: '_MENU_',
},
initComplete: function () {
}
}
});
});
}

Revision as of 01:40, 14 July 2024

/**
 * Datatables definitions
 * @example <>
 */
if( $('link[href$="datatables.min.css"]').length ){
    // do nothing
} else {
    $('<link/>', {
        rel: 'stylesheet',
        type: 'text/css',
        href: 'https://cdn.datatables.net/v/dt/dt-2.0.8/b-3.0.2/cr-2.0.3/date-1.5.2/fc-5.0.1/fh-4.0.1/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.3/sb-1.7.1/sp-2.3.1/sl-2.0.3/sr-1.4.1/datatables.min.css'
    }).appendTo('head');
}

$.ajaxSetup({ cache: true });

$.when(
    mw.loader.getScript( 'https://cdn.datatables.net/v/dt/dt-2.0.8/b-3.0.2/cr-2.0.3/date-1.5.2/fc-5.0.1/fh-4.0.1/r-3.0.2/rg-1.5.0/rr-1.5.0/sc-2.4.3/sb-1.7.1/sp-2.3.1/sl-2.0.3/sr-1.4.1/datatables.min.js' )
)
.then(
	function () {
		if( $('#research-notes').length ) {
			$('#research-notes').DataTable({
				dom: '<"top"lf>rt<"bottom"ip><"clear">',
    			columns: [
    				{ "title": "Page" },
					{ "title": "File" },
					{ "title": "URL" },
					{ "title": "Topic" },
					{ "title": "Note" },
					{ "title": "User" },
					{ "title": "Date" }
				],
				columnDefs: [
					{
						type: 'date',
						targets: [ 6 ]
					}
				],
				aaSorting: [
					[ 1, "desc" ]
				],
				pageLength: 100,
				lengthMenu: [
					[50, 100, 250, -1],
					['50 per page', '100 per page', '250 per page', 'Show all']
				],
    			language: {
    				searchPlaceholder: 'Search in notes',
					searchBuilder: {
    				title: ''
				},
				lengthMenu: '_MENU_',
			},
			initComplete: function () {
			}
		});
	}
});