MediaWiki:Wikia.js

/* */ /* Loads the current source of the page "pagename" (as stored in the database) and inserts it at the cursor position */ function doPreload(pagename) { var loader = new ContentLoader; loader.callback = onPreloadArrival; loader.send('/index.php?title=' + pagename + '&action=raw&ctype=text/plain'); }

function insertAtCursor(myField, myValue) { //IE support if (document.selection) { myField.focus; sel = document.selection.createRange; sel.text = myValue; }   //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); }   else { myField.value += myValue; } }

function onPreloadArrival { if ($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length) { insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], this.text); tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); } else { insertAtCursor(document.getElementById('wpTextbox1'), this.text); tutloader('#wpTextbox1'); } } /* end preload code */

/* Template Preloads * Original by User:Grunny * Source - w:c:starwars:MediaWiki:Wikia.js * Altered to replace Wiki's template preloads by runescape wiki */ function customPreloadTemplates {

if (( mw.config.get('wgAction') !== 'edit' && mw.config.get('wgCanonicalSpecialPageName') !== 'CreatePage' ) || !$('div.module_content').length) { return; }

var preloadOptionsHtml = '', $preloadOptionsList, preloadBaseHtml = ' Standard preloads: ' +           ' Custom preload pagename: '

$('span.cke_buttons.cke_toolbar_templates').replaceWith(preloadBaseHtml);

$.get(mw.config.get('wgScript'), {       title: 'Template:Stdpreloads',        action: 'raw',        ctype: 'text/plain'    }, function (data) {        var lines = data.split('\n');        for (var i = 0; i < lines.length; i++) {            var value = ( lines[i].indexOf('-- ') === 0 ) ? lines[i].substring(3) : "";            preloadOptionsHtml += '' + lines[i] + ' ';        }        $preloadOptionsList = $(' ').attr('id', 'stdSummaries').html(preloadOptionsHtml).change(function  { var value = $(this).val; if (value !== '') { value = 'Template:' + value + '/preload'; value = value.replace(' ', '_'); $.get(mw.config.get('wgScript'), {title: value, action: 'raw', ctype: 'text/plain'}, function (data) {

if ($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length) { insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], data); tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); } else { insertAtCursor(document.getElementById('wpTextbox1'), data); tutloader('#wpTextbox1'); }               });            }        });

$('div#lf-preload').append($preloadOptionsList); });

$('#lf-preload-pagename-w').html(''); $('#lf-preload-button-w').html('');

}

$(customPreloadTemplates);

$(function {    if (window.CKEDITOR) {        CKEDITOR.on("instanceReady", function  { $(customPreloadTemplates); });   } });

function doCustomPreloadOasis { var value = $('#lf-preload-pagename-w > input').val; value = value.replace(' ', '_'); $.get(mw.config.get('wgScript'), {title: value, action: 'raw', ctype: 'text/plain'}, function (data) {

if ($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length) { insertAtCursor($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source')[0], data); tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); } else { insertAtCursor(document.getElementById('wpTextbox1'), data); tutloader('#wpTextbox1'); }   }); }

//link to converter in editor; thanks to UltimateSupreme with helping to put it for visual editors as well w:c:Thread:608344 $(function converter {   converticon = "  Convert  ";    $('.cke_button.RTEImageButton.cke_button_big').append(converticon);    if (window.CKEDITOR) {        CKEDITOR.on("instanceReady", function  { $(converter); });   } }); //formatbutton for List of Covered Songs $(function formatbutton {   formaticon = "  Format   ";    $('.cke_button.RTEImageButton.cke_button_big').append(formaticon);    if (window.CKEDITOR) {        CKEDITOR.on("instanceReady", function  { $(formatbutton); formatcaller; });   } else {        formatcaller;    } });

//Custom YT & TM player $(function loader {   if (document.querySelector('.ytsample') !== null) {        load(".ytsample", " ");   }    if (document.querySelector('.tmsample') !== null) {        load(".tmsample", " ");   } }); function load(sample, template1, template2) { $(sample).ready(function {        var id = document.querySelector(sample).title;        $(sample).append(template1 + id + template2);    }); } /* $(function ytloader { if (document.querySelector('.ytsample') !== null) { $('.ytsample').ready(function { var ytid = document.querySelector('.ytsample').title; var yttemplate1 = " "; $('.ytsample').append(yttemplate1 + ytid + yttemplate2); }); } }); $(function tmloader { if (document.querySelector('.tmsample') !== null) { $('.tmsample').ready(function { var tmid = document.querySelector('.tmsample').title; var tmtemplate1 = " "; $('.tmsample').append(tmtemplate1 + tmid + tmtemplate2); }); } }); */ //tutorial content var anch = function { $('.anchor').click(function {        $('.tutc').scrollTop($('.tutc').scrollTop - $('.tutnav').height + $('#' + this.getAttribute("name")).position.top);        if (this.getAttribute("name") == 'about') {            if ($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length) {                tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source');            } else {                tutloader('#wpTextbox1');            }        }    }) };

var text = ;

var tutloader = function (t) { var templates = ['{{infobox character', '{{playlist', '{{album', '{{album|type=collab', '{{song', '{{song chorus', '{{ytvideo', '{{utattemita tours', '{{anikora', '{{singer spotlight', '{{gallery']; var nav = [' ref resh cite refs ', ' sin ger ', ' song list ', ' CD ', ' Coll CD ', ' So ng ', ' Cho rus ', ' YT CB ', ' UT tour ', ' ani kora ', ' spot light ', ' gall ery tri via ', ' cite illus rep rint li nk '] var load = text[0]; var loadnav = nav[0]; for (var i = 0; i < templates.length; i++) { if ($(t).val.toLowerCase.indexOf(templates[i]) > -1) { //general, singer, playlist, album, collabalbum, song, songchorus, battle, tour, anikora, spotlight, gallery-trivia, illust-reprint-link load += text[i + 1]; loadnav += nav[i + 1]; }   }    load += text[12]; loadnav += nav[12] + " "; $('.tutnav').html(loadnav); $('.tutc').html(load); anch; };

$('#EditPage').ready(function {    if (window.location.href.indexOf("action=edit") > -1) {        var intervalID = setInterval(function  { if ($('#cke_21').length) { clearInterval(intervalID); $('.cke_button_ModeWysiwyg').css({'display': 'none'}); $('#cke_21').trigger('click'); $('#EditPageMainContainer').css({'width': 'calc(100% - (' + $('.tuttrigger').css('left') + ' + ' + $('.editpage-widemode-trigger').css('right') + '))'}); $('#cke_contents_wpTextbox1').css({'height': 'calc(' + $('#WikiaPage').height + ' - (' + $('#EditPageEditNotice').height + ' + ' + $('#EditPageToolbar').height + '))'}); }       }, 3000);        var closed = true;        $('#EditPage').append("   ");        $('#EditPageMain').prepend("    ");        $('#EditPageMainContainer').css({'width': 'calc(100% - (' + $('.tuttrigger').css('left') + ' + ' + $('.editpage-widemode-trigger').css('right') + '))'});        $('#cke_contents_wpTextbox1').css({'height': 'calc(' + $('#WikiaPage').height + ' - (' + $('#EditPageEditNotice').height + ' + ' + $('#EditPageToolbar').height + '))'});        $('.tutrail').css({'height': $('#EditPageMainContainer').height});        $('#EditPageMainContainer').css({'float': 'left'});        $('.tuttrigger').click(function  { if (closed) { $('.tuttrigger').css({'left': '300px'}); $('.tutrail').css({'display': 'block'});

closed = false } else { $('.tuttrigger').css({'left': '0'}); $('.tutrail').css({'display': 'none'}); closed = true; }           $('#EditPageMainContainer').css({'width': 'calc(100% - (' + $('.tuttrigger').css('left') + ' + ' + $('.editpage-widemode-trigger').css('right') + '))'}); $('.tutrail').css({'height': $('#EditPageMainContainer').height});

if ($('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source').length) { tutloader('#cke_wpTextbox1 #cke_contents_wpTextbox1 .cke_source'); } else { tutloader('#wpTextbox1'); }       });    }    ;    $('.editpage-widemode-trigger').click(function  { $('#EditPageMainContainer').css({'width': 'calc(100% - (' + $('.tuttrigger').css('left') + ' + ' + $('.editpage-widemode-trigger').css('right') + '))'}); $('.editpage-widemode-trigger').css({'top': '42px'}); });   $(window).resize(function  { $('#EditPageMainContainer').css({'width': 'calc(100% - (' + $('.tuttrigger').css('left') + ' + ' + $('.editpage-widemode-trigger').css('right') + '))'}); $('.tutrail').css({'height': $('#EditPageMainContainer').height}); }); });

$('#NewarticletextNS').ready(function {    if (window.location.href.indexOf("useFormat=1") > -1) {        var loc = [{            locations: ['.editpage-widemode-trigger', '.module.module_templates h3', '#EditPageIntro p'],            message: 'First, expand the right siderail and scroll to \"Templates\" OR click on one of the Layout options above.  Click here for next step.'        },            {                locations: ['#lf-preload #stdSummaries'],                message: 'Use the \"Templates\" section for adding page layouts and additional templates if needed.  The templates are neatly organized after types of templates (Article management, singer pages, song pages, group pages, and other pages).  Once you\'re ready, click here for next step.'            },            {                locations: ['.module.module_insert h3', '.cke_button.RTEImageButton.cke_button_big a:first-child', '.cke_button.RTEImageButton.cke_button_big a:nth-child(2)', '.cke_button.RTEImageButton.cke_button_big a:nth-child(3)'], message: 'Expand the \"Add features and media\" sections. Here you have nifty tools to make editing easier for yourself. Use \"Convert\" for converting images (.jpeg or .jpg) to .png, and \"Upload\" for uploading images. Use \"Format\" for the \"List of Covered Songs\" section. The formatter tool greatly helps with completing the \"List of Covered Songs\" section. Simply input the needed IDs (NND mylists, YT usernames, channel IDs, playlist IDs, TmBox IDs, SoundCloud IDs) and click \"Format\". Once the tool has finished formatting, you can copy paste the content into the editing tab. Click around to get used to the tools and then click here for next step.' },           {                locations: ['.tuttrigger', '.tutnav'], message: "Expand the right siderail to see the tutorial. The tutorial will display the relevant sections depending on the code in the editing box. If you don't see the relevant tutorial section, just click the \"refresh\" button.  If you're unfamiliar with the wiki markup in general, and it's your first time editing, read through the \"About this Tutorial\", \"General Notes\" and \"General Wiki Markup\" sections, to understand the basics of editing.  Also use the bubbles on top for navigation. \"cite refs\" = reference information sources; \"song\" = song pages; \"chorus\" = song chorus pages, \"singer\" singer pages, with an in dept tutorial about the \"List of Covered Songs\" or \"song list\", \"CD\"s, the \"gallery\" section, and the \"trivia\" section. \"collab CD\" explains additional fields for collaboration albums. \"cite illust\" = citing illustrators; \"reprint\" = guidelines to linking reprints, \"link\" = linking shortcuts,(to the Vocaloid wiki, the Touhou Wiki, pixiv, or special pages (Anikora</a>, Utattemita Tours</a>, Avatar Illustrators</a>, Collaboration CDs</a>)). Sections for special pages include \"YT CB\" for YT chorus battles</a>, \"UT tour\" for Utattemita Tours</a>, \"anikora\" for Anikora</a> pages, and \"spotlight\" for singer spotlight</a> pages. If you\'re ready to start, click here."           }];

var step = 0; $('#NewarticletextNS p').append(' '); $('.tutorialtooltip').css({'width': 'calc(100% - 20px)'}).css({'max-width': 'none'}).css({'margin': '0'}); $('.tutorialtooltip').html(loc[step].message); for (var i = 0; i < loc[step].locations.length; i++) { $(loc[step].locations[i]).addClass('activestep'); }       $('.tutorialtooltip').click(function  {            for (var i = 0; i < loc[step].locations.length; i++) {                $(loc[step].locations[i]).removeClass('activestep');            }            step++;            if (step == 4) {                $('.tutorialtooltip').remove            } else {                for (var i = 0; i < loc[step].locations.length; i++) {                    $(loc[step].locations[i]).addClass('activestep');                }                $('.tutorialtooltip').show;                $('.tutorialtooltip').html(loc[step].message);            }        }); } });

/* Other imports */ importArticles({   type: "script",    articles: [        "w:dev:AjaxRC/code.js",        "w:dev:Standard_Edit_Summary/code.js",    ] });

switch (mw.config.get('wgPageName')) { case 'Utaite_Wiki:Tutorial': $(document).ready(function {            var step = 0;            var info = [{                triggerlocation: '.WikiaMenuElement li a.createpage',                locations: ['.wikia-menu-button.contribute.secondary.combined'],                message: "Welcome to the Utaite Wiki editing tutorial! Learn editing and the syntax on our wiki at your own pace in an interactive way! This tutorial focuses on source code editing. If you\'re ready, go ahead and click the \"Contribute\" button above! For bug reports, please contact BLUEBIRD</a>"            },                {                    triggerlocation: 'button.button.normal.primary',                    locations: ['#CreatePageDialogFormatContainer', '#wpCreatePageDialogTitle'],                    message: "Input your preferred pagename, and select \"With Tutorial\" for tutorial hints. Once you\'re comfortable editing without hints, check the \"Without tutorial\" option. Once selected, click the \"Add a Page\" button."               }];            (function  {                $(info[step].triggerlocation).addClass("activestep");                for (var i = 0; i < info[step].locations.length; i++) {                    $(info[step].locations[i]).addClass("activestep");                }                ;                $(info[step].triggerlocation).addClass("activestep");                $(info[step].locations[0]).append(                    ' ' + info[step].message + ' '                )            });            $(info[step].triggerlocation).click(                function  {                    var intervalID = setInterval(function  {                        if ($('#CreatePageDialogFormatContainer').length) {                            clearInterval(intervalID);                            $('ul#CreatePageDialogChoices #CreatePageDialogFormatContainer label').html("With tutorial<img src='http://slot1.images.wikia.nocookie.net/__cb1480701179/common/extensions/wikia/CreatePage/images/thumbnail_format_video.png'>"); $('ul#CreatePageDialogChoices #CreatePageDialogBlankContainer label').html("Without tutorial<img src='http://slot1.images.wikia.nocookie.net/__cb1480701179/common/extensions/wikia/CreatePage/images/thumbnail_blank.png'>"); $('.tutorialtooltip').remove; for (var i = 0; i < info[step].locations.length; i++) { $(info[step].locations[i]).removeClass("activestep"); }                           ;                            $(info[step].triggerlocation).removeClass("activestep"); step++; $(info[step].triggerlocation).addClass("activestep"); for (var i = 0; i < info[step].locations.length; i++) { $(info[step].locations[i]).addClass("activestep"); }                           ;                            $(info[step].locations[0]).css({'width': 'calc(50% - 5px)'}); $(info[step].locations[0]).append(                               ' ' + info[step].message + ' '                            ); $('.tutorialtooltip').css({'margin': 0}).css({'position': 'relative'}).css({'max-width': 'none'}).css({'width': 'auto'}); }                   }, 3000);                }            );            $('#WikiaArticle #mw-content-text .t').show; var tmp = ""; for (var i = 0; i < text.length; i++) { tmp += text[i]; }           $('#WikiaArticle #mw-content-text .t').html(tmp); })       break; }

var formatcaller = function { $('#formatter').click(function {        if ($('#formatter').hasClass('formatteropen')) {            $('#formatter').removeClass('formatteropen');            $('#formatcontent').empty;            return;        }        $('#formatter').addClass('formatteropen');        $('#formatcontent').append(" <img src='http://slot1.images.wikia.nocookie.net/__cb1481713639/common/skins/oasis/images/icon_close.png'>  NND mylists  <input type='text' name='nnd' placeholder='7359936 25396393 31424334 13892546 26633779'>  BB userspace  <input type='text' name='bb' placeholder='11073'>  YT usernames  <input type='text' name='ytun' placeholder='splendiferousfantasy'>  YT channels  <input type='text' name='ytch' placeholder='UCMsNS10PzxzEayT7UHS4p6g'>  YT playlists  <input type='text' name='ytpl' placeholder='PLOA7lc-qUd88NjN4adz8Di8ZHT6jwIFrS PLOA7lc-qUd8_mcFeaVAKWKbg9FSy35SIV'>  TmBox ID  <input type='text' name='tm' placeholder='soraruru uni_mafumafu'>  SoundCloud ID  <input type='text' name='sc' placeholder='sumashu missingnumber'>  <input type='button' value='Format!'> "); format; });   function song(title, yt, nnd, tm, sc, bb, date) {        this.title = title;        this.yt = yt;        this.nnd = nnd;        this.tm = tm;        this.sc = sc;        this.bb = bb;        this.date = date;    };

var format = function { $('#formatwindow input[type=button]').click(function {            var nnd = [];            var ytun = [];            var ytch = [];            var ytpl = [];            var tm = [];            var sc = [];            var bb = [];            var list = [];            var listtm = [];            var listsc = [];

$.ajaxPrefilter(function (options) {               if (options.crossDomain && jQuery.support.cors && (options.url.includes("tmbox.net/user") || options.url.includes("space.bilibili.com"))) {                    console.log('prefilter attached');                    console.log(options.url);                    var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');                   options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;                    options.crossDomain = false;                }            }); if (!$('input[name=nnd]').val == '') { nnd = $('input[name=nnd]').val.split(" "); for (var i = 0; i < nnd.length; i++) { var url = "https://query.yahooapis.com/v1/public/yql?q=select%20title%2CpubDate%2Clink%20from%20rss%20where%20url%3D'http%3A%2F%2Fwww.nicovideo.jp%2Fmylist%2F" + nnd[i] + "%2Fvideo%3Frss%3D2.0'&diagnostics=true"; $.ajax({                       type: "GET",                        url: url,                        dataType: "xml",                        success: function (xml) {                            $(xml).find('item').each(function  { list.push(new song($(this).find('title').text, , $(this).find('link').text.split("/watch/")[1], , , , $(this).find('pubDate').text.split(' ')[3] + '.' + getmon($(this).find('pubDate').text.split(' ')[2]) + '.' + $(this).find('pubDate').text.split(' ')[1])) });                       }                    });                }            }            ;            if (!$('input[name=bb]').val == '') { bb = $('input[name=bb]').val.split(" "); var token = ""; for (var i = 0; i < bb.length; i++) { bbformat("http://space.bilibili.com/ajax/member/getSubmitVideos?mid=" + bb[i] + "&pagesize=9999&page=", 1, list); }           }            ;            if (!$('input[name=ytch]').val == '') { ytch = $('input[name=ytch]').val.split(" "); var token = ""; for (var i = 0; i < ytch.length; i++) { ytchformat(ytch[i], '', list); }           }            ;            if (!$('input[name=ytun]').val == '') { ytun = $('input[name=ytun]').val.split(" "); var token = ""; for (var i = 0; i < ytun.length; i++) { ytunformat(ytun[i], '', list); }           }            ;            if (!$('input[name=ytpl]').val == '') { ytpl = $('input[name=ytpl]').val.split(" "); var token = ""; for (var i = 0; i < ytpl.length; i++) { ytplformat(ytpl[i], '', list); }           }            ;            if (!$('input[name=tm]').val == '') { tm = $('input[name=tm]').val.split(" "); var u1 = "https://tmbox.net/user/" var u2 = "?page="; for (var i = 0; i < tm.length; i++) { tmformat(u1 + tm[i] + u2, 1, listtm); }           }            ;            if (!$('input[name=sc]').val == '') { sc = $('input[name=sc]').val.split(" "); var url = ""; for (var i = 0; i < sc.length; i++) { url = "http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/" + sc[i] + "/tracks&client_id=887b335a80f3e625454ebca548c53d96"; $.ajax({                       type: "GET",                        url: url,                        dataType: "json",                        success: function (json) {                            for (var j = 0; j < json.length; j++) {                                listsc.push(new song(json[j].title, , , , json[j].permalink_url, , json[j].created_at.split(' ')[0].replace('/', '.').replace('/', '.')));                            }                        }                    }); }           }            ;            //$(document).ajaxStop(function{}) $(document).ajaxStop(function {                list.sort(function (a, b) { if (a.title < b.title) return -1; if (a.title > b.title) return 1; return 0; });               list.sort(function (a, b) { if (a.date < b.date) return -1; if (a.date > b.date) return 1; return 0; });               for (var i = 0; i < list.length - 1; i++) {                    if ((list[i + 1].title == list[i].title) && (list[i + 1].date == list[i].date)) {                        if (list[i + 1].nnd != '') {                            list[i].nnd = list[i + 1].nnd;                        } else {                            list[i].yt = list[i + 1].yt;                        }                        list.splice(i + 1, 1);                        i--;                    }                }                var rmv = ['【歌ってみた】', 'を歌ってみた', '歌ってみた', '(english cover)', 'english cover', 'cover', 'english', 'vers.', 'ver.', 'vers', 'ver', 'french', 'german', 'chinese', 'spanish', 'rap', 'screamo', 'piano', 'tv size', 'tv-size', 'acapella', 'a capella', 'short', 'band', 'acoustic', 'arrange', 'parody', '替え歌ってみた', '替え歌', '--', '- -'];                var out = '==List of Covered Songs==\n{{Playlist|content = \n'; var ver = ''; for (var i = 0; i < list.length; i++) { ver = verformat(list[i].title); for (var j = 0; j < rmv.length; j++) { list[i].title = list[i].title.replace(new RegExp(' ' + rmv[j], "ig"), ""); list[i].title = list[i].title.replace(new RegExp('　' + rmv[j], "ig"), ""); list[i].title = list[i].title.replace(new RegExp(rmv[j], "ig"), ""); }                   if (list[i].yt !=  && list[i].nnd != ) { out = out.concat("# \"+ list[i.yt + " " + list[i].title + "]\" {{nnd|" + list[i].nnd + "}}" + ver + " (" + list[i].date + ")\n") }                   else if (list[i].yt !=  && list[i].nnd == ) { out = out.concat("# \"+ list[i.yt + " " + list[i].title + "]\"" + ver + " (" + list[i].date + ")\n") }                   else if (list[i].yt ==  && list[i].nnd != ) { out = out.concat("# \"" + list[i].title + "\" {{nnd|" + list[i].nnd + "}}" + ver + " (" + list[i].date + ")\n") }                   else if (list[i].bb !=  && list[i].nnd != ) { out = out.concat("# \"+ list[i.bb + " " + list[i].title + "]\" {{nnd|" + list[i].nnd + "}}" + ver + " (" + list[i].date + ")\n") }                   else { out = out.concat("# \"+ list[i.bb + " " + list[i].title + "]\"" + ver + " (" + list[i].date + ")\n") }               }                out = out.concat('}}\n'); var outtm = '===Songs on TmBox===\n{{Playlist|notice = tmbox|content = \n' for (var i = 0; i < listtm.length; i++) { ver = verformat(listtm[i].title); for (var j = 0; j < rmv.length; j++) { listtm[i].title = listtm[i].title.replace(new RegExp(' ' + rmv[j], "ig"), ""); listtm[i].title = listtm[i].title.replace(new RegExp('　' + rmv[j], "ig"), ""); listtm[i].title = listtm[i].title.replace(new RegExp(rmv[j], "ig"), ""); }                   outtm = outtm.concat("# \"+ listtm[i.tm + " " + listtm[i].title + "]\"" + ver + " (" + listtm[i].date + ")\n"); }               outtm = outtm.concat('}}\n'); if (listtm.length <= 0) { outtm = ''; }               var outsc = '===Songs on SoundCloud===\n{{Playlist|notice = soundcloud|content = \n' for (var i = 0; i < listsc.length; i++) { ver = verformat(listsc[i].title); for (var j = 0; j < rmv.length; j++) { listsc[i].title = listsc[i].title.replace(new RegExp(' ' + rmv[j], "ig"), ""); listsc[i].title = listsc[i].title.replace(new RegExp('　' + rmv[j], "ig"), ""); listsc[i].title = listsc[i].title.replace(new RegExp(rmv[j], "ig"), ""); }                   outsc = outsc.concat("# \"[" + listsc[i].sc + " " + listsc[i].title + "]\"" + ver + " (" + listsc[i].date + ")\n"); }               outsc = outsc.concat('}}\n'); if (listsc.length <= 0) { outsc = ''; }

$('#formatcontent').html(" <img src='http://slot1.images.wikia.nocookie.net/__cb1481713639/common/skins/oasis/images/icon_close.png'> " + out + outsc + outtm + " "); $('#formatwindow .close').click(function {                    $('#formatcontent').empty;                }); })       })    }    var verformat = function (title) { var tmp = ' -'; var t = ''; if (title.toLowerCase.indexOf('english') > -1 || title.indexOf('英語') > -1) { tmp += 'English '; }       if (title.toLowerCase.indexOf('french') > -1 || title.toLowerCase.indexOf('français') > -1) { tmp += 'French '; }       if (title.toLowerCase.indexOf('german') > -1 || title.toLowerCase.indexOf('deutsch') > -1) { tmp += 'German '; }       if (title.toLowerCase.indexOf('chinese') > -1 || title.indexOf('中文') > -1) { tmp += 'Chinese '; }       if (title.toLowerCase.indexOf('spanish') > -1 || title.toLowerCase.indexOf('español') > -1) { tmp += 'Spanish '; }       if (title.toLowerCase.indexOf('indonesia') > -1) { tmp += 'Indonesian '; }       if (title.toLowerCase.indexOf('rap') > -1) { tmp += 'Rap '; }       if (title.toLowerCase.indexOf('screamo') > -1) { tmp += 'Screamo '; }       if (title.toLowerCase.indexOf('piano') > -1 || title.indexOf('ピアノ') > -1) { tmp += 'Piano '; }       if (title.toLowerCase.indexOf('tv size') > -1 || title.toLowerCase.indexOf('tv-size') > -1) { tmp += 'TV size '; }       if (title.toLowerCase.indexOf('acapella') > -1 || title.toLowerCase.indexOf('a capella') > -1) { tmp += 'Acapella '; }       if (title.toLowerCase.indexOf('short') > -1) { tmp += 'Short '; }       if (title.toLowerCase.indexOf('band') > -1 || title.indexOf('バンド') > -1) { if (title.toLowerCase.indexOf('band edition') > -1) { t = ' -Band edition-'; } else { tmp += 'Band '; }       }        if (title.toLowerCase.indexOf('acoustic') > -1) { tmp += 'Acoustic '; }       if (title.toLowerCase.indexOf('arrange') > -1 || title.indexOf('アレンジ') > -1) { tmp += 'Arrange '; }       if (title.toLowerCase.indexOf('parody') > -1 || title.indexOf('替え歌') > -1) { tmp += 'Parody '; }       if (tmp == ' -') { return '' + t;       } return tmp + 'ver.-' + t   } var ytunformat = function (url, token, list) { var u = "https://www.googleapis.com/youtube/v3/channels?key=AIzaSyD5bC5qiEP-_25Llg2ciYNM9sW-WP6a6ck&part=id&forUsername=" + url; $.ajax({           type: "GET",            url: u,            dataType: "json",            success: function (json) {                u = "https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&maxResults=50&key=AIzaSyD5bC5qiEP-_25Llg2ciYNM9sW-WP6a6ck&channelId=" + json.items[0].id;                var turl;                if (token == '') {                    turl = u;                } else {                    turl = u + "&pageToken=" + token;                }                $.ajax({ type: "GET", url: turl, dataType: "json", success: function (json) { token = json.nextPageToken; for (var j = 0; j < json.items.length; j++) { if (json.items[j].id.videoId != null) { list.push(new song(json.items[j].snippet.title, json.items[j].id.videoId, , , , , json.items[j].snippet.publishedAt.split('T')[0].replace('-', '.').replace('-', '.'))); }                       }                        if (token != null) { ytunformat(url, token, list); }                   }                });            }        });    };    var ytchformat = function (url, token, list) { var u = "https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&maxResults=50&key=AIzaSyD5bC5qiEP-_25Llg2ciYNM9sW-WP6a6ck&channelId=" + url; var turl; if (token == '') { turl = u;       } else { turl = u + "&pageToken=" + token; }       $.ajax({            type: "GET",            url: turl,            dataType: "json",            success: function (json) {                token = json.nextPageToken;                for (var j = 0; j < json.items.length; j++) {                    if (json.items[j].id.videoId != null) {                        list.push(new song(json.items[j].snippet.title, json.items[j].id.videoId, , , , , json.items[j].snippet.publishedAt.split('T')[0].replace('-', '.').replace('-', '.')));                    }                }                if (token != null) {                    ytchformat(url, token, list);                }            }        }); };   var ytplformat = function (url, token, list) { var u = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=AIzaSyD5bC5qiEP-_25Llg2ciYNM9sW-WP6a6ck&playlistId=" + url; var turl; if (token == '') { turl = u;       } else { turl = u + "&pageToken=" + token; }       $.ajax({            type: "GET",            url: turl,            dataType: "json",            success: function (json) {                token = json.nextPageToken;                for (var j = 0; j < json.items.length; j++) {                    if (json.items[j].snippet.resourceId.videoId != null) {                        list.push(new song(json.items[j].snippet.title, json.items[j].snippet.resourceId.videoId, , , , , json.items[j].snippet.publishedAt.split('T')[0].replace('-', '.').replace('-', '.')));                    }                }                if (token != null) {                    ytplformat(url, token, list);                }            }        }); };

var bbformat = function (url, page, list) { var t = false; console.log(page); console.log('bbformat called with url:'+url+page); $.ajax({           dataType: 'json',            url: url + page,            crossDomain: true,            processData: false,            success: function (json) {                console.log('ajax successful');                var items = json.data.vlist;                for (var q = 0; q < items.length; q++) {                    var d = new Date(parseInt(items[q].created) * 1000)                    list.push(new song(items[q].title, , , , , "av" + items[q].aid, d.getFullYear + "." + ("0" + d.getMonth).slice(-2) + "." + ("0" + d.getDate).slice(-2)));                }                t = items.length == 9999;                if (t) {                    page++;                    bbformat(url, page, list);                }            }        }); };

var tmformat = function (url, page, listtm) { var t = false; $.ajax({           url: url + page,            crossDomain: true,            processData: false,            success: function (html) {                console.log(html);                html=html.split(" ")[0];                t = (html.indexOf(" ") > -1);                console.log(html.indexOf(" "));                html = html.split(" ")[0].replace(/(?:\r\n|\r|\n)/g, '');                var items = html.split("<div class=\"sound-box\">");                for (var q = 1; q < items.length; q++) {                    $.ajax({ indexValue: { title: items[q].split(" ")[1].split("</a>")[0], link: items[q].split(" ")[0] },                       url: 'https://tmbox.net' + items[q].split(" ")[0], success: function (h) { h = h.split("<i class='icon clock fitted'></i>")[1].split(" ")[0].trim.replace("/", ".").replace("/", "."); listtm.push(new song(this.indexValue.title, , , this.indexValue.link, , , h)); }                   })                }                if (t) {                    page++;                    tmformat(url, page, listtm);                }            }        }); };   var getmon = function (mon) { switch (mon) { case 'Jan': return '01'; break; case 'Feb': return '02'; break; case 'Mar': return '03'; break; case 'Apr': return '04'; break; case 'May': return '05'; break; case 'Jun': return '06'; break; case 'Jul': return '07'; break; case 'Aug': return '08'; break; case 'Sep': return '09'; break; case 'Oct': return '10'; break; case 'Nov': return '11'; break; case 'Dec': return '12'; break; }   } } /*  */