MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */ var kofiWidgetScript = document.createElement("script"); kofiWidgetScript.onload = function () { kofiWidgetOverlay.draw('awakeningwiki', { 'type': 'floating-chat', 'floating-chat.donateButton.text': 'Support Us', 'floating-chat.donateButton.background-color': '#323842', 'floating-chat.donateButton.text-color': '#fff' }); }; kofiWidgetScript.src = "https://storage.ko-fi.com/cdn/scripts/overlay-widget.js"; document.head.appendChild(kofiWidgetScript); if ( mw.config.get( 'wgPageName' ) === 'RandomCharacter' ) { function strftime(sFormat,date){if(typeof sFormat!=='string'){return ''}if(!(date instanceof Date)){date=new Date()}var nDay=date.getDay();var nDate=date.getDate();var nMonth=date.getMonth();var nYear=date.getFullYear();var nHour=date.getHours();var nTime=date.getTime();var aDays=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];var aMonths=['January','February','March','April','May','June','July','August','September','October','November','December'];var aDayCount=[0,31,59,90,120,151,181,212,243,273,304,334];var isLeapYear=function isLeapYear(){return nYear%4===0&&nYear%100!==0||nYear%400===0};var getThursday=function getThursday(){var target=new Date(date);target.setDate(nDate-(nDay+6)%7+3);return target};var zeroPad=function zeroPad(nNum,nPad){return(Math.pow(10,nPad)+nNum+'').slice(1)};return sFormat.replace(/%[a-z]+\b/gi,function(sMatch){var _Intl$DateTimeFormat$;return({'%a':aDays[nDay].slice(0,3),'%A':aDays[nDay],'%b':aMonths[nMonth].slice(0,3),'%B':aMonths[nMonth],'%c':date.toUTCString().replace(',',''),'%C':Math.floor(nYear/100),'%d':zeroPad(nDate,2),'%e':nDate,'%F':new Date(nTime-date.getTimezoneOffset()*60000).toISOString().slice(0,10),'%G':getThursday().getFullYear(),'%g':(getThursday().getFullYear()+'').slice(2),'%H':zeroPad(nHour,2),'%I':zeroPad((nHour+11)%12+1,2),'%j':zeroPad(aDayCount[nMonth]+nDate+(nMonth>1&&isLeapYear()?1:0),3),'%k':nHour,'%l':(nHour+11)%12+1,'%m':zeroPad(nMonth+1,2),'%n':nMonth+1,'%M':zeroPad(date.getMinutes(),2),'%p':nHour<12?'AM':'PM','%P':nHour<12?'am':'pm','%s':Math.round(nTime/1000),'%S':zeroPad(date.getSeconds(),2),'%u':nDay||7,'%V':function(){var target=getThursday();var n1stThu=target.valueOf();target.setMonth(0,1);var nJan1=target.getDay();if(nJan1!==4){target.setMonth(0,1+(4-nJan1+7)%7)}return zeroPad(1+Math.ceil((n1stThu-target)/604800000),2)}(),'%w':nDay,'%x':date.toLocaleDateString(),'%X':date.toLocaleTimeString(),'%y':(nYear+'').slice(2),'%Y':nYear,'%z':date.toTimeString().replace(/.+GMT([+-]\d+).+/,'$1'),'%Z':date.toTimeString().replace(/.+\((.+?)\)$/,'$1'),'%Zs':(_Intl$DateTimeFormat$=new Intl.DateTimeFormat('default',{timeZoneName:'short'}).formatToParts(date).find(function(oPart){return oPart.type==='timeZoneName'}))===null||_Intl$DateTimeFormat$===void 0?void 0:_Intl$DateTimeFormat$.value}[sMatch]||'')+''||sMatch})} function randomChoice(array) { return array[Math.floor(Math.random() * array.length)] } function download(data, filename, type) { var file = new Blob([data], {type: type}); if (window.navigator.msSaveOrOpenBlob) // IE10+ window.navigator.msSaveOrOpenBlob(file, filename); else { // Others var a = document.createElement("a"), url = URL.createObjectURL(file); a.href = url; a.download = filename; document.body.appendChild(a); a.click(); setTimeout(function() { document.body.removeChild(a); window.URL.revokeObjectURL(url); }, 0); } } function generateCharacter() { const appearanceOptions = {"BodyType":{"options":["1","2"],"type":2},"CC_Eyebrows":{"options":[false],"type":1},"CC_HairColor":{"options":[false],"type":1},"CC_Scalp":{"options":[false],"type":1},"CC_Stubble":{"options":[false],"type":1},"Head Morph Targets":{"options":[false],"type":1},"Character Type":{"options":["Player"],"type":2},"EyelashColor":{"options":["Black"],"type":2},"Hide All":{"options":[false],"type":1},"Hide Body":{"options":[false],"type":1},"Hide Bra":{"options":[false],"type":1},"Hide Cape":{"options":[false],"type":1},"Hide Facial Hair":{"options":[false],"type":1},"Hide Hair":{"options":[false],"type":1},"Hide Head":{"options":[false],"type":1},"Hide Hood":{"options":[false],"type":1},"Hide Mask":{"options":[false],"type":1},"Hide Nosetube":{"options":[false],"type":1},"Hide Skirt":{"options":[false],"type":1},"Feet":{"options":["Social_MaulaClothing_Footwear"],"type":2},"Top":{"options":["Social_MaulaClothing_Top"],"type":2},"Bottom":{"options":["Social_MaulaClothing_Bottom"],"type":2},"Hands":{"options":["Social_MaulaClothing_Gloves"],"type":2},"Helmet":{"options":["None"],"type":2},"Underwear":{"options":["UnderwearDefault"],"type":2},"Unique NPC":{"options":["Fenring Masked"],"type":2},"NPC Faction":{"options":["None"],"type":2},"NPC Archetype":{"options":["None"],"type":2},"SpiceEye":{"options":[0.0,1.0],"type":3},"Visibility Override Tags":{"options":["CC_VisibilityOverrides"],"type":2},"Head":{"options":["Head00"],"type":2},"FacialHair":{"options":["None","FacialHair01","FacialHair02","FacialHair04","FacialHair03","FacialHair09","FacialHair08","FacialHair07","FacialHair06","FacialHair05","FacialHair18","FacialHair17","FacialHair16","FacialHair14","FacialHair13","FacialHair12","FacialHair11","FacialHair10","FacialHair22","FacialHair21","FacialHair20","FacialHair19"],"type":2},"FacialHairColor":{"options":["Silver","Grey01","Grey02","Grey03","Black","LightBlonde01","LightBlonde02","LightBlonde03","MediumBlonde01","MediumBlonde02","MediumBlonde03","MediumBlonde04","DarkBlonde01","DarkBlonde02","DarkBlonde03","LightBrown01","LightBrown02","LightBrown03","MediumBrown01","MediumBrown02","MediumBrown03","MediumBrown04","DarkBrown01","DarkBrown02","DarkBrown03","StrawberryBlonde01","Ginger01","Ginger02","Ginger03","PhoenixRed","StrawberryRed01","Red01","Red02","Auburn01","Auburn02","Pink","Purple","Burgundy","Lilac01","Lilac02","PastelGreen","Green01","Green02","Blue01","Blue02"],"type":2},"BodyTattoo":{"options":["Tattoo_None","Tattoo1","Tattoo2","Tattoo3","Tattoo4","Tattoo5"],"type":2},"SkinTone":{"options":["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"],"type":2},"Hair":{"options":["None","Hair_Neut_F02","Hair_Neut_ALong01_01","Hair_Neut_ALong01_02","Hair_Neut_ALong01_03","Hair_Neut_AShort01_01","Hair_Neut_AShort01_02","Hair_Neut_AShort01_03","Hair_Neut_AShort01_04","Hair_Neut_BLong01_02","Hair_Neut_BLong01_03","Hair_Neut_BLong01_04","Hair_Neut_BLong01_05","Hair_Neut_BLong01_07","Hair_Neut_BShort01_01","Hair_Neut_BShort01_02","Hair_Neut_BShort01_03","Hair_Neut_BShort01_04","Hair_Neut_BShort01_05","Hair_Neut_BShort01_06","Hair_Neut_BShort01_07","Hair_Neut_BShort01_08","Hair_Neut_CLong01_01","Hair_Neut_E01_01","Hair_Neut_F01_01","Hair_Neut_DShort01_01","Hair_Neut_BShort01_09","Hair_Neut_BShort01_10"],"type":2},"EyelinerColor":{"options":["EyelinerBlack","EyelinerBrown","EyelinerPink","EyelinerBlue","EyelinerGreen","EyelinerRed","EyelinerWhite"],"type":2},"ScarMap":{"options":["Scar_None","Scar01","Scar02","Scar03","Scar04","Scar05","Scar06"],"type":2},"LipstickColor":{"options":["Lip_Red1","Lip_Red2","Lip_Red3","Lip_Red4","Lip_Red5","Lip_Purple1","Lip_Purple2","Lip_Purple3","Lip_Blue1","Lip_Blue2","Lip_BlueGrey1","Lip_BlueGrey2","Lip_Teal1","Lip_Teal2","Lip_Green1","Lip_Green2","Lip_Gold1","Lip_Gold2","Lip_Rose1","Lip_Orange1","Lip_Grey1","Lip_Grey2","Lip_Grey3","Lip_Black1","Lip_White1"],"type":2},"Eyeshadow":{"options":["Eyeshadow_None","Eyeshadow1","Eyeshadow2","Eyeshadow3","Eyeshadow4","Eyeshadow5","Eyeshadow6","Eyeshadow7","Eyeshadow8","Eyeshadow9","Eyeshadow10","Eyeshadow13","Eyeshadow11","Eyeshadow12","Eyeshadow14","Eyeshadow15","Eyeshadow16","Eyeshadow17"],"type":2},"Lipstick":{"options":["Lipstick_None","Lipstick1","Lipstick2","Lipstick3","Lipstick4","Lipstick5","Lipstick6","Lipstick7","Lipstick8","Lipstick9","Lipstick10","Lipstick11","Lipstick13","Lipstick14","Lipstick15","Lipstick16","Lipstick12"],"type":2},"EyeshadowColor":{"options":["EyeshadowColor01","EyeshadowColor02","EyeshadowColor03","EyeshadowColor04","EyeshadowColor05","EyeshadowColor06","EyeshadowColor07","EyeshadowColor08","EyeshadowColor09","EyeshadowColor10","EyeshadowColor11","EyeshadowColor12","EyeshadowColor13","EyeshadowColor14"],"type":2},"HairColor":{"options":["Silver","Grey01","Grey02","Grey03","Black","LightBlonde01","LightBlonde02","LightBlonde03","MediumBlonde01","MediumBlonde02","MediumBlonde03","MediumBlonde04","DarkBlonde01","DarkBlonde02","DarkBlonde03","LightBrown01","LightBrown02","LightBrown03","MediumBrown01","MediumBrown02","MediumBrown03","MediumBrown04","DarkBrown01","DarkBrown02","DarkBrown03","StrawberryBlonde01","Ginger01","Ginger02","Ginger03","PhoenixRed","StrawberryRed01","Red01","Red02","Auburn01","Auburn02","Pink","Purple","Burgundy","Lilac01","Lilac02","PastelGreen","Green01","Green02","Blue01","Blue02"],"type":2},"EyebrowType":{"options":["Brow_None","Brow1","Brow2","Brow3","Brow4","Brow5","Brow6","Brow7","Brow8","Brow9","Brow10","Brow11"],"type":2},"EyebrowColor":{"options":["Silver","Grey01","Grey02","Grey03","Black","LightBlonde01","LightBlonde02","LightBlonde03","MediumBlonde01","MediumBlonde02","MediumBlonde03","MediumBlonde04","DarkBlonde01","DarkBlonde02","DarkBlonde03","LightBrown01","LightBrown02","LightBrown03","MediumBrown01","MediumBrown02","MediumBrown03","MediumBrown04","DarkBrown01","DarkBrown02","DarkBrown03","StrawberryBlonde01","Ginger01","Ginger02","Ginger03","PhoenixRed","StrawberryRed01","Red01","Red02","Auburn01","Auburn02","Pink","Purple","Burgundy","Lilac01","Lilac02","PastelGreen","Green01","Green02","Blue01","Blue02"],"type":2},"EyeColor":{"options":["EyeColor1","EyeColor2","EyeColor3","EyeColor4","EyeColor5","EyeColor6","EyeColor7","EyeColor8","EyeColor9","EyeColor10","EyeColor11","EyeColor12","Blue","LightBlue","Ice","Yellow","Red","Black","White","Purple"],"type":2},"Tattoo Face":{"options":["Tattoo_None","Tattoo1","Tattoo2","Tattoo3","Tattoo4","Tattoo5","Tattoo6","Tattoo7","Tattoo8","Tattoo9","Tattoo10","Tattoo11","Tattoo12","Tattoo13","Tattoo14","Tattoo15","Tattoo16"],"type":2},"EyelinerOpacity":{"options":[0.0,1.0],"type":3},"EyeScleraTint":{"options":[0.0,1.0],"type":3},"ScarOpacity":{"options":[0.0,1.0],"type":3},"LipstickMetallic":{"options":[0.0,1.0],"type":3},"BlemishesAmount":{"options":[0.0,1.0],"type":3},"RednessAmount":{"options":[0.0,1.0],"type":3},"EyebagsAmount":{"options":[0.0,1.0],"type":3},"ChestSize":{"options":[0.0,1.0],"type":3},"EyeshadowOpacity":{"options":[0.0,1.0],"type":3},"TattooAge":{"options":[0.0,1.0],"type":3},"LipstickOpacity":{"options":[0.0,1.0],"type":3},"LipstickGlossyness":{"options":[0.0,1.0],"type":3},"AgeMorph":{"options":[0.0,1.0],"type":3},"FrecklesAmount":{"options":[0.0,1.0],"type":3},"VitiligoScale":{"options":[0.0,1.0],"type":3},"VitiligoOpacity":{"options":[0.0,1.0],"type":3},"CheekboneHght":{"options":[0.0,1.0],"type":3},"CheekboneDpth":{"options":[0.0,1.0],"type":3},"JawDepth":{"options":[0.0,1.0],"type":3},"ChinLength":{"options":[0.0,1.0],"type":3},"ChinWidth":{"options":[0.0,1.0],"type":3},"CheekFull":{"options":[0.0,1.0],"type":3},"JawWidth":{"options":[0.0,1.0],"type":3},"JawHeight":{"options":[0.0,1.0],"type":3},"EyeWidth":{"options":[0.0,1.0],"type":3},"EyeSize":{"options":[0.0,1.0],"type":3},"EyeSquint":{"options":[0.0,1.0],"type":3},"EyeAngle":{"options":[0.0,1.0],"type":3},"EyeHeight":{"options":[0.0,1.0],"type":3},"EyeDepth":{"options":[0.0,1.0],"type":3},"EyePupilSize":{"options":[0.0,1.0],"type":3},"EyeIrisSize":{"options":[0.0,1.0],"type":3},"BrowAngle":{"options":[0.0,1.0],"type":3},"BrowHeight":{"options":[0.0,1.0],"type":3},"BrowDepth":{"options":[0.0,1.0],"type":3},"NoseSize":{"options":[0.0,1.0],"type":3},"NoseHeight":{"options":[0.0,1.0],"type":3},"NoseTip":{"options":[0.0,1.0],"type":3},"NoseAngle":{"options":[0.0,1.0],"type":3},"NoseProjection":{"options":[0.0,1.0],"type":3},"NostrilHeight":{"options":[0.0,1.0],"type":3},"NostrilWidth":{"options":[0.0,1.0],"type":3},"NoseBridge":{"options":[0.0,1.0],"type":3},"NoseBridgeWidth":{"options":[0.0,1.0],"type":3},"MouthDepth":{"options":[0.0,1.0],"type":3},"MouthSize":{"options":[0.0,1.0],"type":3},"MouthWidth":{"options":[0.0,1.0],"type":3},"MouthHeight":{"options":[0.0,1.0],"type":3},"MouthAngle":{"options":[0.0,1.0],"type":3},"HeadType":{"options":["Head_Neut_01","Head_Neut_02","Head_Neut_03","Head_Neut_04","Head_Neut_05","Head_Neut_06","Head_Neut_07","Head_Neut_08","Head_Neut_09"],"type":2}}; const bodyParts = {"Height":{"body_part":true,"body_part_id":0,"options":[0.93,0.95,0.97,0.985,1.0,1.01,1.03,1.05,1.07],"type":3},"WaistWidth":{"body_part":true,"body_part_id":1,"options":[1],"type":3},"WaistDepth":{"body_part":true,"body_part_id":2,"options":[1],"type":3},"HipWidth":{"body_part":true,"body_part_id":3,"options":[1],"type":3},"HipDepth":{"body_part":true,"body_part_id":4,"options":[1],"type":3},"ArmThickness":{"body_part":true,"body_part_id":5,"options":[0.92,0.94,0.96,0.98,1.0,1.04,1.06,1.08,1.1],"type":3},"LegThickness":{"body_part":true,"body_part_id":6,"options":[0.92,0.94,0.96,0.98,1.0,1.04,1.06,1.08,1.1],"type":3},"NeckThickness":{"body_part":true,"body_part_id":7,"options":[1],"type":3},"NeckLength":{"body_part":true,"body_part_id":8,"options":[0.92,0.94,0.96,0.98,1.0,1.04,1.06,1.08,1.1],"type":3}}; const randomAppearance = []; Object.keys(appearanceOptions).sort().forEach(function(key) { const data = appearanceOptions[key]; randomAppearance.push({ "Name": key, "Type": data.type, "Value": randomChoice(data.options) }); }) const schema = { "Version": 10, "DialogueChoices": { "Homeworld": "Caladan", "Caste": "Na-Familia", "Mentor": "Mentat" }, "BodyPartValues": { "1": 1.0099999904632568, //randomChoice(bodyParts.Height.options), "2": 1, "3": 1, "4": 1, "5": 1, "6": 0.9399999976158142, //randomChoice(bodyParts.ArmThickness.options), "7": 0.9599999785423279, //randomChoice(bodyParts.LegThickness.options), "8": 1, "9": 0.9599999785423279// randomChoice(bodyParts.NeckLength.options) }, "CharacterAppearanceJson": JSON.stringify({ "Parameters": randomAppearance, "Version": 3}, null, 2), "CharacterClothedAppearanceJson": "", "CharacterState": 3, "VoiceSet": "1" }; return JSON.stringify(schema, null, 2); } function downloadRandomCharacter() { const timestamp = strftime("%y-%m-%d %H-%M-%S").replace(' ','_'); download(generateCharacter(), "SavedCharacter_" + timestamp + ".json", "application/json"); return true; } downloadRandomCharacter(); }