MediaWiki:MyStory.js

require([   'jquery',    'mw',    'wikia.window' ], function($, mw, window) {    // Double-loading prevention    if ($('#MyStory').exists || window.myStoryLoaded) return;    window.myStoryLoaded = true;

// Load dependencies importArticle({       type: 'style',        articles: [            'u:dev:MediaWiki:FandomIcons.css',            'u:dev:MediaWiki:MyStory.css'        ]    });

$.ajax({       url: 'https://dev.fandom.com/api.php',        data: {            action: 'query',            meta: 'allmessages',            ammessages: 'Custom-Testimonials',            format: 'json'        },        dataType: 'jsonp',        success: function(data) {            var myStory = JSON.parse(data.query.allmessages[0]["*"]); console.log(myStory);            var _keys = Object.keys(myStory);            window.myStoryUser = _keys[Math.floor(Math.random * _keys.length)];            window.myStoryMessage = myStory[myStoryUser];

$.getJSON('/api/v1/User/Details/avatar?ids=' + myStoryUser.replace(/ /g, '%20')).then(function(data) {               window.myStoryAvatar = data.items[0].avatar;

// do the roar $(' ', {                   'class': 'rail-module',                    id: 'mystory',                    css: {                        border: '1px solid rgba(58,58,58,0.75)',                        boxShadow: '5px 5px 5px 0 rgba(0,0,0,0.75)',                        padding: '5px'                    }                }).append(                    $(' ', { text: 'My Fandom Story' }).prepend( $(' ', {                           'class': 'fandom-icons',                            text: '💙',                            css: {                                fontSize: 'larger',                                color: 'rgba(58,58,58,0.75)',                                marginRight: '7px',                                verticalAlign: 'text-bottom'                            }                        }) )               ).append(                    $(' ', { 'class': 'wds-avatar', title: window.myStoryUser, css: { verticalAlign: 'top', 'float': 'left', marginRight: '10px' }                   }).prepend( $(' ', {                           src: window.myStoryAvatar.replace('100', '50'),                            alt: myStoryUser,                            'class': 'wds-avatar__image',                            css: {                                border: '2px solid #1a1a1a',                            }                        }) )               ).append(                    $(' ', { css: { fontSize: '14px' }                   }).append( $('', {                           href: '/wiki/User:' + myStoryUser,                            text: myStoryUser.replace(/_/g, ' ')                        }) ).append(': ' + myStoryMessage).append( $(' ', {                           css: {                                textAlign: 'center',                                marginTop: '10px',                                paddingTop: '10px',                                borderTop: '1px solid rgba(58,58,58,0.75)'                            }                        }).append(                            $('', { href: 'http://bit.ly/fandom-signin', html: 'Create an account to start your experience today!' })                       )                    )                ).prependTo('#WikiaRail'); });       }    }); });