/* Scoreboard Module by Burey requires the following scripts/links in HTML head: requires your own firebase account see https://code.sololearn.com/Wb3UALD0atIG/ for tutorial if changing options, DO NOT REMOVE EXISTING options, just leave the {} brackets empty default options: var options={ // customize the following: // syntax is like css, but make sure: // key and value are both strings! "scoreboardWidth":"auto", //recommended "scoreboardHeight":"400", // recommended "submitDialogWidth":"auto", //recommended "submitDialogHeight":"auto", // recommended burey:{ // Scoreboard Module By Burey text "font-family":"Times New Roman", "font-style":"italic", "text-shadow": "5px 2px 4px grey", "color": "#9910ff", "background-color":"white", "border-radius": "25px" }, dialogTitle:{ // dialogs title bar "font-family":"Times New Roman", "background":"black", "color":"#9910ff" }, scoreboardContainer:{ // scoreboard container dialog "background-color":"black" }, tableHeader:{ // # Name Score Time "font-family":"Times New Roman", "color": "#9910ff" }, scorePosition:{ // # "font-family":"Times New Roman", "color": "#9910ff" }, scoreName:{ // name of user "font-family":"Times New Roman", "color": "#9910ff", "word-wrap": "break-word", "max-width":"110px" }, scoreValue:{ // score value "font-family":"Times New Roman", "font-size": "15px", "color": "#9910ff" }, scoreTime:{ // time + date "font-family":"Times New Roman", "font-size":"12px", "color": "#9910ff" }, newScoreContainer:{ // submit new score dialog "background-color":"black" }, scoreYourScoreLabel:{ // 'Your Score:' text in new score dialog "font-family":"Times New Roman", "color": "#9910ff" }, scoreValueLabel:{ // score value in new score dialog "font-family":"Times New Roman", "color": "#9910ff", "margin-right":"25px" }, scoreErrorLabel:{ // error label in new score dialog "font-family":"Times New Roman", "color": "red" }, scoreboardButtons:{ // scoreboard dialog buttons "font-family":"Times New Roman", "text-shadow": "5px 2px 4px grey", "background":"black", "color": "#9910ff", "display":"none" // remove button }, newScoreButtons:{ // new score dialog buttons "font-family":"Times New Roman", "text-shadow": "5px 2px 4px grey", "background":"black", "color": "#9910ff" }, loaderOptions:{ // scoreboard loading animation "border-bottom": "16px solid #888", "border-top": "16px solid #888", "border-right": "16px solid #9910ff", "border-left": "16px solid #9910ff", "margin-left": "auto", "margin-right": "auto" } } usage example: var scoreboard = new Scoreboard(options); scoreboard.showScoreBoard(); // opens the scoreboard scoreboard.submitNewScoreDialog(scoreValue); // open score submit dialog (allow entry of name) */ ///////// CODE STARTS HERE ///////// var markdown = { // taken from Michael Ermishin's Markdown module htmlEntitiesMap: { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', ' ': ' ' }, specToEntities: function(text) { var pattern = new RegExp('[' + Object.keys(this.htmlEntitiesMap).join('') + ']', 'g'); //return text.replace(pattern, k => this.htmlEntitiesMap[k]); return text.replace(pattern, function (m) { return markdown.htmlEntitiesMap[m]; }); } }; var optionsMap = { // mapping of option name to actual element burey:"#by_burey", dialogTitle:".ui-dialog-titlebar", scoreboardContainer:"#container_scoreboard", tableHeader:"#tbl_header", scorePosition:".score_pos", scoreName:".score_name", scoreValue:".score_value", scoreTime:".score_time", newScoreContainer:"#container_submit_score_dialog", scoreYourScoreLabel:"#lbl_your_score", scoreValueLabel:"#lbl_best_score_submit", scoreErrorLabel:"#lbl_best_score_name_error", scoreboardButtons:".buttons_scoreboard", newScoreButtons:".buttons_new_score", dialogButtonPanels:".ui-dialog-buttonpane", sortDropDownList:"#container_sort", loaderOptions:"#loader" }; var defaultOptions = { // customize the following: // syntax is like css, but make sure: // key and value are both strings inside each option! "scoreboardWidth":"90%", //recommended "scoreboardHeight":"400", // recommended "submitDialogWidth":"auto", //recommended "submitDialogHeight":"auto", // recommended burey:{ // Scoreboard Module By Burey text "font-family":"Times New Roman", "font-style":"italic", "text-shadow": "5px 2px 4px grey", "color": "green", "background-color":"white", "border-radius": "25px" }, dialogTitle:{ // dialogs title bar "background":"black", "color":"white" }, scoreboardContainer:{ // scoreboard container dialog "background-color":"#97B5F5" }, tableHeader:{ // # Name Score Time "font-family":"Times New Roman", "color": "black" }, scorePosition:{ // # "font-family":"Times New Roman", "color": "blue" }, scoreName:{ // name of user "font-family":"'Press Start 2P', Times New Roman", "font-size":"10px", "color": "red", "word-wrap": "break-word", "max-width":"110px" }, scoreValue:{ // score value "font-family":"Times New Roman", "font-size": "15px", "color": "green" }, scoreTime:{ // time + date "font-family":"Times New Roman", "font-size":"12px", "color": "yellow" }, newScoreContainer:{ // submit new score dialog "background-color":"#97B5F5" }, scoreYourScoreLabel:{ // 'Your Score:' text in new score dialog "font-family":"Times New Roman", "color": "green" }, scoreValueLabel:{ // score value in new score dialog "font-family":"Times New Roman", "color": "blue", "margin-right":"25px" }, scoreErrorLabel:{ // error label in new score dialog "font-family":"Times New Roman", "color": "red" }, scoreboardButtons:{ // scoreboard dialog buttons "font-family":"Times New Roman", "text-shadow": "5px 2px 4px grey", "background":"red", "color": "white" }, dialogButtonPanels:{ "font-family":"Times New Roman", "text-shadow": "5px 2px 4px grey", "background":"#97B5F5", "color": "red" }, sortDropDownList:{ "font-family":"'Press Start 2P', Times New Roman", "font-size":"20px" }, newScoreButtons:{ // new score dialog buttons "font-family":"Times New Roman", "text-shadow": "5px 2px 4px grey", "background":"black", "color": "white" }, loaderOptions:{ // scoreboard loading animation "border-bottom": "25px solid #888", "border-top": "25px solid #888", "border-right": "25px solid green", "border-left": "25px solid green", "width": "80px", "height": "80px", "margin-left": "auto", "margin-right": "auto", "margin-top": "20px" } } function initializeDefaultCSS(){ // adds default CSS to the scoreboard dialog var KeyFrame = { // add spin keyframe rule to page init: function(){ if(!KeyFrame.check){ //set the style and append to head var css = $('').appendTo('head'); //make sure you don't carriage return the css inline statement, or else it'll be error as ILLEGAL //so u don't keep appending style to head KeyFrame.check = true; } } }; KeyFrame.init(); loaderOptions={ // default loader options // set loader colors, size, placement and animation "border-bottom": "16px solid #888", "border-top": "16px solid #888", "border-right": "16px solid #66ccff", "border-left": "16px solid #66ccff", "border-radius": "70%", "width": "50px", "height": "50px", "animation": "spin 1s linear infinite" }; // apply the default loader options $('#loader').css(loaderOptions); scoreboardDialogOptions={ // default scoreboard dialog options // makes the "Scoreboard Module By Burey" text static (unscrollable) "position": "absolute", "left": "10px", "top": "0", "z-index": "10", "width": "90%", "padding": "0.5e" }; // apply the default scoreboard dialog options $('#by_burey').css(scoreboardDialogOptions); // add margin to the scoreboard display area $('#scoreboard').css({"margin-top":"1.5em"}); } function Scoreboard(options){ var _score = 0; // private score variable var _sortMethod = 'score'; // set initial sort method to 'score' var _previousSortMethod = 'score'; // set previous sort method to 'score' (first load) var SCORES_TO_LOAD = 100; // might need to add to a different div, depends on the code, it must be on topmost layer! // add div container for the scoreboard dialog $("body").children().last().prepend("
# | Name | Score | Time |
---|