mirror of
				https://github.com/monkeytypegame/monkeytype.git
				synced 2025-11-04 09:06:17 +08:00 
			
		
		
		
	added funbox filters
This commit is contained in:
		
							parent
							
								
									7ac5940cf5
								
							
						
					
					
						commit
						0414f5831e
					
				
					 4 changed files with 42 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -2108,7 +2108,8 @@ key {
 | 
			
		|||
      }
 | 
			
		||||
 | 
			
		||||
      &.languages,
 | 
			
		||||
      &.layouts {
 | 
			
		||||
      &.layouts,
 | 
			
		||||
      &.funbox {
 | 
			
		||||
        grid-template-columns: repeat(4, 1fr);
 | 
			
		||||
        grid-auto-flow: unset;
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1497,6 +1497,12 @@
 | 
			
		|||
              <div class="title">language</div>
 | 
			
		||||
              <div class="buttons languages">
 | 
			
		||||
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="buttonsAndTitle" style="grid-column:1/3;">
 | 
			
		||||
              <div class="title">funbox</div>
 | 
			
		||||
              <div class="buttons funbox">
 | 
			
		||||
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -428,6 +428,20 @@ Object.keys(words).forEach((language) => {
 | 
			
		|||
  }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$(".pageAccount .content .filterButtons .buttons.funbox").append(
 | 
			
		||||
  `<div class="button" filter="funbox_none">none</div>`
 | 
			
		||||
);
 | 
			
		||||
getFunboxList().then((funboxModes) => {
 | 
			
		||||
  funboxModes.forEach((funbox) => {
 | 
			
		||||
    $(".pageAccount .content .filterButtons .buttons.funbox").append(
 | 
			
		||||
      `<div class="button" filter="funbox_${funbox.name}">${funbox.name.replace(
 | 
			
		||||
        /_/g,
 | 
			
		||||
        " "
 | 
			
		||||
      )}</div>`
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
let activeFilters = ["all"];
 | 
			
		||||
 | 
			
		||||
$(document).ready((e) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -624,6 +638,7 @@ $(".pageAccount #currentConfigFilter").click((e) => {
 | 
			
		|||
    "timeFilter",
 | 
			
		||||
    "languages",
 | 
			
		||||
    "tags",
 | 
			
		||||
    "funbox",
 | 
			
		||||
  ];
 | 
			
		||||
  disableGroups.forEach((group) => {
 | 
			
		||||
    $.each(
 | 
			
		||||
| 
						 | 
				
			
			@ -655,6 +670,9 @@ $(".pageAccount #currentConfigFilter").click((e) => {
 | 
			
		|||
  config.resultFilters.push(`lang_${config.language}`);
 | 
			
		||||
  toggleFilterButton(`lang_${config.language}`);
 | 
			
		||||
 | 
			
		||||
  config.resultFilters.push(`funbox_${activeFunBox}`);
 | 
			
		||||
  toggleFilterButton(`funbox_${activeFunBox}`);
 | 
			
		||||
 | 
			
		||||
  let activeTags = [];
 | 
			
		||||
  try {
 | 
			
		||||
    dbSnapshot.tags.forEach((tag) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -723,8 +741,11 @@ function loadMoreLines() {
 | 
			
		|||
      icons += `<span aria-label="blind mode" data-balloon-pos="up"><i class="fas fa-fw fa-eye-slash"></i></span>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (result.theme === "nausea") {
 | 
			
		||||
      icons += `<span aria-label="nausea theme" data-balloon-pos="up"><i class="fas fa-skull-crossbones"></i></span>`;
 | 
			
		||||
    if (result.funbox !== "none" && result.funbox !== undefined) {
 | 
			
		||||
      icons += `<span aria-label="${result.funbox.replace(
 | 
			
		||||
        /_/g,
 | 
			
		||||
        " "
 | 
			
		||||
      )}" data-balloon-pos="up"><i class="fas fa-gamepad"></i></span>`;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let tagNames = "";
 | 
			
		||||
| 
						 | 
				
			
			@ -874,8 +895,14 @@ function refreshAccountPage() {
 | 
			
		|||
      }
 | 
			
		||||
      if (!activeFilters.includes(puncfilter)) return;
 | 
			
		||||
 | 
			
		||||
      //check if the user has any tags defined
 | 
			
		||||
      if (result.funbox === "none" || result.funbox === undefined) {
 | 
			
		||||
        if (!activeFilters.includes("funbox_none")) return;
 | 
			
		||||
      } else {
 | 
			
		||||
        if (!activeFilters.includes("funbox_" + result.funbox)) return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (dbSnapshot.tags.length > 0) {
 | 
			
		||||
        //check if the user has any tags defined
 | 
			
		||||
        //check if that result has any tags
 | 
			
		||||
        if (result.tags !== undefined && result.tags.length > 0) {
 | 
			
		||||
          let found = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -910,15 +937,6 @@ function refreshAccountPage() {
 | 
			
		|||
 | 
			
		||||
      if (datehide) return;
 | 
			
		||||
 | 
			
		||||
      // if(
 | 
			
		||||
      //   (!activeFilters.includes("date_all")) &&
 | 
			
		||||
      //   (activeFilters.includes("date_day") && timeSinceTest > 86400) &&
 | 
			
		||||
      //   (activeFilters.includes("date_week") && timeSinceTest > 604800) &&
 | 
			
		||||
      //   (activeFilters.includes("date_month") && timeSinceTest > 18144000)
 | 
			
		||||
      //   ){
 | 
			
		||||
      //   return;
 | 
			
		||||
      // }
 | 
			
		||||
 | 
			
		||||
      filteredResults.push(result);
 | 
			
		||||
 | 
			
		||||
      //filters done
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2625,7 +2625,10 @@ function updateTestModesNotice() {
 | 
			
		|||
 | 
			
		||||
  if (activeFunBox !== "none") {
 | 
			
		||||
    $(".pageTest #testModesNotice").append(
 | 
			
		||||
      `<div><i class="fas fa-gamepad"></i>${activeFunBox}</div>`
 | 
			
		||||
      `<div><i class="fas fa-gamepad"></i>${activeFunBox.replace(
 | 
			
		||||
        /_/g,
 | 
			
		||||
        " "
 | 
			
		||||
      )}</div>`
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue