/* START global js_head */
var lastE = "";
  var lastG = 0;
  var play_now = "Παίξτε τώρα!";
  var b = document.documentElement;
  var cefList = ["idcTesting", "idclauncher", "idcplaystv"];
  b.setAttribute("data-useragent", navigator.userAgent);
  b.setAttribute("data-platform", navigator.platform);
  b.className +=
    !!("ontouchstart" in window) || !!("onmsgesturechange" in window)
      ? " touch"
      : "";
  var fsAPIKey = "q1N40ieTqTkVqVnIyK7f8V15QgPx7swS";
  var fsProjectId = 5;
  
  function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(";");
    for (var i = 0; i < ca.length; i++) {
      var c = ca[i];
      while (c.charAt(0) == " ") {
        c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
        return c.substring(name.length, c.length);
      }
    }
    return "";
  }
  function loadSession(field) {
    if (getCookie(field) != null && getCookie(field) != "") {
      return getCookie(field);
    } else if (sessionStorage.getItem(field) != null) {
      return sessionStorage.getItem(field);
    } else if (localStorage.getItem(field) != null) {
      return localStorage.getItem(field);
    } else {
      return false;
    }
  }
  
  function saveUtm() {
    var vars = {};
    var parts = window.location.href.replace(
      /[?&]+([^=&]+)=([^&]*)/gi,
      function (m, key, value) {
        vars[key] = value;
      }
    );
    if (typeof vars.utm_source == "string")
      setCookie("utm_source", vars.utm_source, 1);
    if (typeof vars.utm_campaign == "string")
      setCookie("utm_campaign", vars.utm_campaign, 1);
    if (typeof vars.utm_medium == "string")
      setCookie("utm_medium", vars.utm_medium, 1);
    if (typeof vars.utm_term == "string")
      setCookie("utm_term", vars.utm_term, 1);
    if (typeof vars.utm_content == "string")
      setCookie("utm_content", vars.utm_content, 1);
    if (typeof vars.pixelTracking == "string")
      setCookie("pixelTracking", vars.pixelTracking, 1);
    if (typeof vars.pub == "string") setCookie("pub", vars.pub, 1);
    if (typeof vars.tid == "string") setCookie("tid", vars.tid, 1);
  }
  
  function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
    var expires = "expires=" + d.toUTCString();
    document.cookie =
      cname +
      "=" +
      cvalue +
      ";" +
      expires +
      "; domain=idcgames.com; path=/; SameSite=Strict; Secure";
  }
 /****************************************************************************************************************************/
  /*********************************************************  OTHERS  *********************************************************/
  /****************************************************************************************************************************/
  function addScript(src, clase) {
    var s = document.createElement("script");
    s.setAttribute("src", src);
    if (typeof clase == "string") {
      s.setAttribute("class", clase);
    }
    document.body.appendChild(s);
  }
  function addScriptJS(theJS) {
    var s = document.createElement("script");
    s.text = theJS;
    document.body.appendChild(s);
  }
  function changeNav(lang) {
    let href =
      $(`link[hreflang='${lang}']`).attr("href") ||
      `https://${lang}.idcgames.com`;
    window.location.href = href;
  }

  function getLanguageUrl() {
    return "idcgames.com/el";
  }

  function getTagsFromGameData(gamedata) {
    function find_duplicate_in_array(array) {
      const count = {};
      const result = [];

      array.forEach((item) => {
        if (count[item.id]) {
          count[item.id] += 1;
          return;
        }
        count[item.id] = 1;
      });

      for (let prop in count) {
        var item = {};
        item.id = prop;
        item.name = array.filter((aa) => aa.id == prop)[0].name;
        item.title = array.filter((aa) => aa.id == prop)[0].title;
        item.seo_url = array.filter((aa) => aa.id == prop)[0].seo_url;
        item.count = count[prop];

        result.push(item);
      }

      return result;
    }
    var tagBlocks = [],
      tagData = "";
    Object.keys(gamedata).forEach((key) => {
      gamedata[key].forEach((gData) => {
        Object.keys(gData.game_tags).forEach((key) => {
          tagBlocks.push(gData.game_tags[key]);
        });
      });
    });

    var tagData = find_duplicate_in_array(tagBlocks);
    tagData = getShuffledArr(tagData);

    return tagData;
  }

  function getShuffledArr(arr) {
    const newArr = arr.slice();
    for (let i = newArr.length - 1; i > 0; i--) {
      const rand = Math.floor(Math.random() * (i + 1));
      [newArr[i], newArr[rand]] = [newArr[rand], newArr[i]];
    }
    return newArr;
  }
/* END global js_head */
/* START nav-game-menu-default-v2 js_head */
var lastG = "1552" * 1;
  document.cookie = "lastG=" + lastG + ";domain=idcgames.com";
  var language = `el`;
  var msgError = `Σφάλμα κατά τη διαδικασία σύνδεσης. Παρακαλώ προσπαθήστε ξανά αργότερα.`;
  var msgBadLogin = `Λανθασμένος χρήστης / κωδικός πρόσβασης`;
  var msgUserExist = `Ο χρήστης υπάρχει`;
  var msgUserBad = `Λανθασμένη μορφή χρήστη: πρέπει να περιέχει τουλάχιστον 4-14 χαρακτήρες. Όλοι οι χαρακτήρες ισχύουν εκτός από <> \'\"`;
  var msgPassMatch = `Οι κωδικοί πρόσβασης δεν ταιριάζουν.`;
  var msgNoUser = `Εισάγετε ένα όνομα χρήστη`;
  var msgNoPass = `Eισάγετε εναν κωδικο`;
  var thankyou =
    "https://idcgames.com/el/dragonkin-the-banished/extra/σας-ευχαριστούμε";
/* END nav-game-menu-default-v2 js_head */
/* START post-news-normal-default js_head */
var post = {"id":10078,"game_seo":"dragonkin-the-banished","game_name":"Dragonkin: The Banished","id_idcgame":"1552","pubdate":"2025-02-19-13-40","pubdate_formatted":"19\/02\/2025 - 13:40","total_like":0,"total_dislike":0,"total_comment":0,"all_comments":[],"lang_comments":[],"author":"Mj\u00f6lnir","url":"https:\/\/idcgames.com\/default","title":"Dragonkin: The Banished DEMO is OUT!","body":"<p><img alt=\"\" src=\"https:\/\/cdn8.idcgames.com\/storage\/image\/1552\/demo\/default.jpg\" \/><\/p>\r\n\r\n<p>Time to <strong>hunt dragons<\/strong>!<\/p>\r\n\r\n<p>Try the <strong>free demo<\/strong> of <em>Dragonkin: The Banished<\/em> until <strong>March 3rd<\/strong> and get a taste of the action-packed adventure.<\/p>\r\n\r\n<p>The game officially launches in <strong>Steam Early Access on March 6th<\/strong>, with a <strong>console release<\/strong> planned after the Early Access phase.<\/p>\r\n\r\n<p>Sharpen your blades and prepare for battle! More information <a href=\"https:\/\/store.steampowered.com\/news\/app\/1863430\/view\/537719838344216596\"><strong>here<\/strong><\/a>.<\/p>\r\n\r\n<p><div class=\"embed-responsive embed-responsive-16by9\"><\/p>\r\n\r\n<p><iframe class=\"embed-responsive-item\" src=\"https:\/\/www.youtube.com\/embed\/KeZi5zsPdl4?si=_n7bIRDdif2FzD5R\"><\/iframe><\/p>\r\n\r\n<p><\/div><\/p>","kind":"Normal","start_at":"","end_at":""};
var typeContent = "n";
var request = {"ids": [{"game": "dragonkin-the-banished","id": typeContent +"_10078"}] };
var gameSeo = "dragonkin-the-banished";
var gamedata = [{"name":"Dragonkin: The Banished","seo":"dragonkin-the-banished","status":"not_in_idc","status_id":13,"short_description":"In a world dominated by dragons, choose one of the four hero classes, on your own or in multiplayer mode, and fight against monsters. Custom your abilities with the unique Ancestral Grid of skills, upgrade your city and share it with friends.","flag_windows":false,"flag_apple":false,"flag_linux":false,"game_tags":{"1":{"id":1,"name":"Action RPG","title":"\u0394\u03c1\u03ac\u03c3\u03b7 RPG ","seo_url":"\u03b4\u03c1\u03ac\u03c3\u03b7-rpg","active":true},"82":{"id":82,"name":"Dungeon Crawler","title":"Dungeon Crawler","seo_url":"dungeon-crawler","active":true},"87":{"id":87,"name":"Hack and Slash","title":"Hack \u03ba\u03b1\u03b9 \u03ba\u03ac\u03b8\u03b5\u03c4\u03bf","seo_url":"hack-\u03ba\u03b1\u03b9-\u03ba\u03ac\u03b8\u03b5\u03c4\u03bf","active":true},"140":{"id":140,"name":"Isometric","title":"\u03b9\u03c3\u03bf\u03bc\u03b5\u03c4\u03c1\u03b9\u03ba\u03ae","seo_url":"\u03b9\u03c3\u03bf\u03bc\u03b5\u03c4\u03c1\u03b9\u03ba\u03ae","active":true},"150":{"id":150,"name":"Top-Down","title":"\u0391\u03c0\u03cc \u03c0\u03ac\u03bd\u03c9 \u03c0\u03c1\u03bf\u03c2 \u03c4\u03b1 \u03ba\u03ac\u03c4\u03c9","seo_url":"\u03b1\u03c0\u03cc-\u03c0\u03ac\u03bd\u03c9-\u03c0\u03c1\u03bf\u03c2-\u03c4\u03b1-\u03ba\u03ac\u03c4\u03c9","active":true},"181":{"id":181,"name":"Fantasy","title":"\u03a6\u03b1\u03bd\u03c4\u03b1\u03c3\u03af\u03b1","seo_url":"\u03c6\u03b1\u03bd\u03c4\u03b1\u03c3\u03af\u03b1","active":true},"194":{"id":194,"name":"Loot","title":"\u039b\u03ac\u03c6\u03c5\u03c1\u03bf","seo_url":"\u03bb\u03ac\u03c6\u03c5\u03c1\u03bf","active":true},"305":{"id":305,"name":"Co-op","title":"\u039a\u03bf\u03c4\u03ad\u03c4\u03c3\u03b9","seo_url":"\u03ba\u03bf\u03c4\u03ad\u03c4\u03c3\u03b9","active":true},"310":{"id":310,"name":"Multiplayer","title":"multiplayer","seo_url":"multiplayer","active":true},"311":{"id":311,"name":"Online Co-Op","title":"\u03a3\u03c5\u03bd\u03b4\u03b5\u03b4\u03b5\u03bc\u03ad\u03bd\u03bf\u03b9 Co-Op","seo_url":"\u03c3\u03c5\u03bd\u03b4\u03b5\u03b4\u03b5\u03bc\u03ad\u03bd\u03bf\u03b9-co-op","active":true},"312":{"id":312,"name":"Singleplayer","title":"\u039c\u03bf\u03bd\u03bf\u03c2 \u03c0\u03b1\u03b9\u03c7\u03c4\u03b7\u03c2","seo_url":"\u03bc\u03bf\u03bd\u03bf\u03c2-\u03c0\u03b1\u03b9\u03c7\u03c4\u03b7\u03c2","active":true}},"game_cats":{"1":{"id":1,"name":null,"title":"\u0394\u03c1\u03ac\u03c3\u03b7\u03c2","seo_url":"\u03c0\u03b1\u03b9\u03c7\u03bd\u03af\u03b4\u03b9\u03b1-\u03b4\u03c1\u03ac\u03c3\u03b7\u03c2","active":true},"3":{"id":3,"name":null,"title":"\u03a0\u03b5\u03c1\u03b9\u03c0\u03ad\u03c4\u03b5\u03b9\u03b1","seo_url":"\u03c0\u03b1\u03b9\u03c7\u03bd\u03af\u03b4\u03b9\u03b1-\u03c0\u03b5\u03c1\u03b9\u03c0\u03ad\u03c4\u03b5\u03b9\u03b1\u03c2","active":true},"5":{"id":5,"name":null,"title":"RPG","seo_url":"\u03c0\u03b1\u03b9\u03c7\u03bd\u03af\u03b4\u03b9\u03b1-rpg","active":true},"13":{"id":13,"name":null,"title":"Indie","seo_url":"\u03c0\u03b1\u03b9\u03c7\u03bd\u03af\u03b4\u03b9\u03b1-indie","active":true}},"id_idcgame":"1552","meta_titles":"IDCGames - Dragonkin: The Banished - \u03a0\u03b1\u03b9\u03c7\u03bd\u03af\u03b4\u03b9\u03b1 PC","price":[],"offer":[],"offer_discount_percent":0,"free_2_play":"false","featured":"false","new_release":"false","price_shown":false,"demo_game":false,"redirect_url":"https:\/\/store.steampowered.com\/app\/1863430\/Dragonkin_The_Banished\/","image":{"logo":"https:\/\/cdn9.idcgames.com\/storage\/image\/1552\/game_logo\/default.png","logo_json":{"kind":"IMAGE","base":"dragonkin-the-banished-logo","format":"png","shared":false,"ratios":["1x1","1x2","1x3","1x5","2x1","2x3","3x1","3x2","3x4","4x1","4x3","4x5","5x1","5x2","5x3","5x4"],"resizes":["1-1","3-4","2-3","1-2","1-4","1-8"],"qualities":[0,300,72],"thumb":true},"logo_v2":"","logo_json_v2":"","banner":"https:\/\/cdn10.idcgames.com\/storage\/image\/1552\/game_banner\/default.jpg","banner_json":{"kind":"IMAGE","base":"dragonkin-the-banished-banner","format":"jpg","shared":false,"ratios":["1x1","1x2","1x3","1x5","2x1","2x3","3x1","3x2","3x4","4x1","4x3","4x5","5x1","5x2","5x3","5x4"],"resizes":["1-1","3-4","2-3","1-2","1-4","1-8"],"qualities":[0,300,72],"thumb":true},"background_foros":"https:\/\/cdn11.idcgames.com\/storage\/image\/1552\/background_foros\/default.jpg"},"video":{"url":"https:\/\/cdn12.idcgames.com\/storage\/video\/1552\/video_mp4\/default.mp4","lower_res":"https:\/\/cdn13.idcgames.com\/storage\/video\/1552\/video_mp4\/lower_res.mp4","json":{"kind":"VIDEO","base":"dragonkin-the-banished-landing","format":"mp4","shared":false,"thumb":true}}}][0];
/* END post-news-normal-default js_head */
/* START footer-default js_head */
let  game_review_requested = {};
  
  let classAndText = [
  {
    class: 'text-danger',
    text: 'Εξαιρετικά Αρνητικό',
    range: [0, 9]
  },
  {
    class: 'text-danger-',
    text: 'Πολύ Αρνητικό',
    range: [10, 19]
  },
  {
    class: 'text-danger--',
    text: 'Αρνητικό',
    range: [20, 39]
  },
  {
    class: 'text-warning',
    text: 'Ποικίλος',
    range: [40, 69]
  },
  {
    class: 'text-primary--',
    text: 'Θετικό',
    range: [70, 84]
  },
  {
    class: 'text-primary-',
    text: 'Πολύ Θετικό',
    range: [85, 94]
  },
  {
    class: 'text-primary',
    text: '',
    range: [95, 100]
  }
];

function findRangePercent(percent) {
  let finded = false, i = 0;
  while(!finded && i < classAndText.length) {
    if(percent >= classAndText[i].range[0] && percent <= classAndText[i].range[1]) finded = true;
    i++;
  }
  return classAndText[i - 1];
}

function getLangs(reviews) {
    return Object.keys(reviews);
}

function displayTotalReviewsTooltip(id_idcgame, popoverid, reviews) {
  var isPopover = true;
  let [positives, totalReviews] = getLangs(reviews).reduce((acc, el) => { acc[0] += reviews[el].filter(rev => rev.Vote == 1).length; acc[1] += reviews[el].length; return acc;}, [0, 0]);
  //change to const when all tooltips are popovers
  var tooltipObj = $(`#` + popoverid)

  if(!tooltipObj) {
    tooltipObj = $(`.custom-tooltip[id_idcgame=${id_idcgame}]`)
    isPopover = false;
    if(!tooltipObj) {
      return;
    }
  }

  if(totalReviews == 0) {
    $(tooltipObj).find(".text-review-positiveness").text("Καμία κριτική")
    $(tooltipObj).find(".text-review-count").text(``)
  }else{
    let percent = parseInt(positives/totalReviews*100);
    let classText = findRangePercent(percent)
  
    $(tooltipObj).find(".text-review-positiveness").text(classText.text)
    $(tooltipObj).find(".text-review-count").text(` (${totalReviews} reviews)`)
    // $(tooltipObj).find(".text-review-count").text(` (${totalReviews} reviews)`)
  }
  if (isPopover){
          var popover = $(tooltipObj).parent().data('bs.popover');
    //We need to call show in order to refresh the data in the popover when it is already visible.
    //If we don't call this code, the popover is not updated until it hides and it is shown again
          popover.show();
  }

  /*
  let totalReviewsHTML = String.format(
    templateTotalReviewsHTML,
    classText.class,
    classText.text,
    positives,
    totalReviews,
    percent,
    'h3'
  );
  document.getElementById('totalReviewsDisplay').innerHTML = totalReviewsHTML;
  let totalReviewsInfoHTML = String.format(
    templateTotalReviewsHTML,
    classText.class,
    classText.text,
    positives,
    totalReviews,
    percent,
    'span'
  );
  let idGameInfo = "infoReviewsGame";
  let qSelector = `span[__name__="content"]`;
  let containerInfo = document.getElementById(idGameInfo);
  let spanHTML = containerInfo.querySelector(qSelector);
  spanHTML.outerHTML = totalReviewsInfoHTML;
  containerInfo.classList.remove("d-none");*/
}

  function loadGameReview(id_idcgame, popoverid){
    if(!id_idcgame || game_review_requested.hasOwnProperty(id_idcgame)){
      return;
    }

    game_review_requested[id_idcgame] = 1;

    $.ajax({
      type:"GET",
      url:`/idcjson/comments/${id_idcgame}/CommentsCurrentYear.json`,
      dataType: 'text',
      async: true,
      success: function(e){
          try {
            var result = JSON.parse(e);
            jsonReviews = result;
            displayTotalReviewsTooltip(id_idcgame, popoverid, jsonReviews);
          }catch (e){
            displayTotalReviewsTooltip(id_idcgame, popoverid,{});
            return false;
          }
      },
      error: function(e){
        // $('#containerGraphs').addClass('d-none');
        displayTotalReviewsTooltip(id_idcgame, popoverid,{});
      }
    });
  }
/* END footer-default js_head */
