x x x
x
Only portrait mode is currently supported - please rotate your device.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

HTML
<script>
// show right block based on groups 
let judge_username = getQueryVariableFromUrl("user") 
let is_viewing_judge = judge_username !== "notfound" ? true : false; 
var judge_group_mapping = {"mssba-round1-judges" : "#round1", "mssba-screening-judges",: "#screening"};  // mapping of group name with container css selector 
const DEADLINE_FIELD = "customfield_10677";
var is_any_valid_judge = false;

const getConfig = async () => { 
   let res = await jQuery.ajax({
   url: "/rest/scriptrunner/latest/custom/getApplicationConfig?project=SEA",
   type: "get",
   dataType: 'json',
   headers: {
     "X-Atlassian-Token": "nocheck",
     "Content-type": "application/json",
   },
   async: true
    }).then(res => res);
   return res; 
}

const getGroups = async (username) => { 
	console.log("yooooooo")
   let res = await jQuery.ajax({
   url: "/rest/api/user/memberof?username=" + encodeURIComponent(username),
   type: "get",
   dataType: 'json',
   headers: {
     "X-Atlassian-Token": "nocheck",
     "Content-type": "application/json",
   },
   async: true
    }).then(res => res);
   res = res.results;
	console.log("ressss", res)
   let group_arr = []; 
   for (var i = 0; i < res.length; i++) {
    group_arr.push(res[i].name)
   }
   return group_arr; 
}

  const getJudgeInfo = async (username) => { 
    let res = await jQuery.ajax({
    url: "/rest/api/user?username=" + username,
    type: "get",
    dataType: 'json',
    headers: {
      "X-Atlassian-Token": "nocheck",
      "Content-type": "application/json",
    },
    async: true
      }).then(res => res);
    return res; 
  }

if(!is_viewing_judge){

/* 
// TEMP COMMENTED
getConfig().then(deadline_obj => {
  var right_now = new Date(deadline_obj["date"]);
	round_deadline_obj = {"screening" : "Sept 30 2022 23:59:59 PST"}
  if(deadline_obj.issues.length){
   round_deadline_obj = JSON.parse(deadline_obj.issues[0].fields[DEADLINE_FIELD]);
  }
  getGroups(AJS.params.remoteUser).then(curr_judge_groups => {
    for(var group in judge_group_mapping) {
      var deadline = new Date(round_deadline_obj[group])
      var is_deadline_passed = right_now > deadline; 
      if(curr_judge_groups.includes(group) && !is_deadline_passed){
        $(judge_group_mapping[group]).show(); 
        is_any_valid_judge = true;
      } else if (curr_judge_groups.includes(group) && is_deadline_passed) {
        $(judge_group_mapping[group] + "deadlinepassed").show(); 

      }
    }
  })
}); 
*/  
  getGroups(AJS.params.remoteUser).then(curr_judge_groups => {
	console.log("Yo", curr_judge_groups)
    for(var group in judge_group_mapping) {
		console.log("curr_judge_groups", curr_judge_groups)
		console.log("group", group)

      if(curr_judge_groups.includes(group)){
        $(judge_group_mapping[group]).show(); 
        is_any_valid_judge = true;
      } else if (curr_judge_groups.includes(group) && is_deadline_passed) {
        $(judge_group_mapping[group] + "deadlinepassed").show(); 

      }
	  if(curr_judge_groups.includes("morganstanley-icvideo-judges") && !curr_judge_groups.includes("confluence-administrators") && !curr_judge_groups.includes("morganstanley-admins")){
	 	$("head").append(`<style>
				li#rw_category_key_add {
    				display: none !important;
				}

 				li#rw_category_key_map {
     				display: none !important;
 				}

 				li#rw_category_key_msset {
     				display: none !important;
 				}
			</style>`);
	  }
     }
  });


    getJudgeInfo(AJS.params.remoteUser).then(judge => {
	  $("#user_name").text("Hi " +judge.displayName + "!");
    })

}
</script>
<script type="text/javascript" src="https://gsvlabs-confluence-files.s3.us-west-2.amazonaws.com/js/MS+SBA/Judging/showJudgeDashboard.js"> </script>

...