{"id":1441,"date":"2025-11-03T18:07:11","date_gmt":"2025-11-03T18:07:11","guid":{"rendered":"https:\/\/forestgreen-goose-685196.hostingersite.com\/?page_id=1441"},"modified":"2025-12-29T12:05:51","modified_gmt":"2025-12-29T12:05:51","slug":"deka-lisi-blocks","status":"publish","type":"page","link":"https:\/\/dekadevelopment.ge\/en\/deka-lisi-blocks\/","title":{"rendered":"Deka Lisi &#8211; Choose Block"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1441\" class=\"elementor elementor-1441\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-f19c453 e-flex e-con-boxed e-con e-parent\" data-id=\"f19c453\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-8851f9f e-con-full visual_selection e-flex e-con e-child\" data-id=\"8851f9f\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-c3c2de0 elementor-widget elementor-widget-html\" data-id=\"c3c2de0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t\t<script>\n\/**\n * ImageMapPro API Script - URL Redirection with Language Logic\n * \n * This script uses ImageMapPro's API to handle clicks on polygons in the \"lisiallfloors\" \n * image map and redirect users to appropriate block\/floor URLs with language support.\n * \n * Polygon naming convention:\n *   - Letters (a, b, c) = Building blocks (1, 2, 3)\n *   - Numbers (1, 2, 3...) = Floor numbers\n *   - Examples: a1, a2, b8, c3\n * \n * URL Structure:\n *   Georgian: https:\/\/dekadevelopment.ge\/deka-lisi-blocks\/[block]-block\/#floor-[floor]\n *   English:  https:\/\/dekadevelopment.ge\/en\/deka-lisi-blocks\/[block]-block\/#floor-[floor]\n *\/\n\n(function() {\n  'use strict';\n\n  \/\/ Configuration\n  const CONFIG = {\n    imageMapName: 'lisiallfloors',        \/\/ Image map name from ImageMapPro editor\n    artboardId: 'allblocks',              \/\/ Artboard ID\n    baseUrl: 'https:\/\/forestgreen-goose-685196.hostingersite.com',\n    basePath: '\/deka-lisi-blocks',\n    enPath: '\/en\/deka-lisi-blocks',\n    blockMap: {                           \/\/ Letter to block name mapping\n      'a': 'a',\n      'b': 'b',\n      'c': 'c'\n      \/\/ Add more blocks as needed (d, e, f, etc.)\n    }\n  };\n\n  \/**\n   * Detect the current language from the URL\n   * @returns {string} 'en' for English, 'ge' for Georgian (default)\n   *\/\n  function detectLanguage() {\n    const path = window.location.pathname;\n    \/\/ Check if '\/en\/' is in the URL path\n    return path.includes('\/en\/') ? 'en' : 'ge';\n  }\n\n  \/**\n   * Parse polygon name to extract block and floor\n   * @param {string} polygonName - Name of the polygon (e.g., \"a1\", \"b8\", \"c3\")\n   * @returns {object|null} Object with { block: string, floor: number } or null if invalid\n   * \n   * Examples:\n   *   \"a1\" -> { block: 'a', floor: 1 }\n   *   \"b8\" -> { block: 'b', floor: 8 }\n   *   \"c15\" -> { block: 'c', floor: 15 }\n   *\/\n  function parsePolygonName(polygonName) {\n    if (!polygonName || typeof polygonName !== 'string') {\n      return null;\n    }\n\n    \/\/ Match pattern: letter(s) followed by number(s)\n    const match = polygonName.match(\/^([a-z]+)(\\d+)$\/i);\n    \n    if (!match) {\n      console.warn(`Invalid polygon name format: ${polygonName}`);\n      return null;\n    }\n\n    const block = match[1].toLowerCase();\n    const floor = parseInt(match[2], 10);\n\n    \/\/ Validate block exists in our configuration\n    if (!CONFIG.blockMap[block]) {\n      console.warn(`Unknown block: ${block}`);\n      return null;\n    }\n\n    \/\/ Validate floor is a positive number\n    if (isNaN(floor) || floor <= 0) {\n      console.warn(`Invalid floor number: ${floor}`);\n      return null;\n    }\n\n    return { block, floor };\n  }\n\n  \/**\n   * Generate redirect URL based on block, floor, and language\n   * @param {string} block - Block letter (a, b, c, etc.)\n   * @param {number} floor - Floor number\n   * @param {string} language - Language code ('en' or 'ge')\n   * @returns {string} Complete redirect URL\n   * \n   * Examples:\n   *   (a, 1, 'ge') -> https:\/\/dekadevelopment.ge\/deka-lisi-blocks\/a-block\/#floor-1\n   *   (b, 8, 'en') -> https:\/\/dekadevelopment.ge\/en\/deka-lisi-blocks\/b-block\/#floor-8\n   *\/\n  function generateRedirectUrl(block, floor, language) {\n    const basePath = language === 'en' ? CONFIG.enPath : CONFIG.basePath;\n    const blockName = `${block}-block`;\n    const fragment = `floor-${floor}`;\n    \n    return `${CONFIG.baseUrl}${basePath}\/${blockName}\/#${fragment}`;\n  }\n\n  \/**\n   * Handle polygon click event\n   * Redirects to the appropriate URL based on polygon name and current language\n   * \n   * This function is called via ImageMapPro's 'objectClick' hook\n   * when any polygon\/object in the image map is clicked\n   *\/\n  function handlePolygonClick(polygonName) {\n    \/\/ Parse the polygon name\n    const parsed = parsePolygonName(polygonName);\n    \n    if (!parsed) {\n      console.error(`Failed to parse polygon name: ${polygonName}`);\n      return;\n    }\n\n    \/\/ Detect current language\n    const language = detectLanguage();\n\n    \/\/ Generate the redirect URL\n    const redirectUrl = generateRedirectUrl(parsed.block, parsed.floor, language);\n\n    \/\/ Log for debugging\n    console.log({\n      polygonClicked: polygonName,\n      parsed: parsed,\n      currentLanguage: language,\n      redirectingTo: redirectUrl\n    });\n\n    \/\/ Perform the redirect\n    window.location.href = redirectUrl;\n  }\n\n  \/**\n   * Initialize the ImageMapPro API listener\n   * Subscribe to the 'objectClick' event on the image map\n   * \n   * The ImageMapPro.subscribe() method listens for all events on the image map.\n   * When an object is clicked, we receive an 'objectClick' action with the object's name.\n   *\/\n  function initializeImageMapListener() {\n    try {\n      \/\/ Check if ImageMapPro is available\n      if (typeof ImageMapPro === 'undefined') {\n        console.error('ImageMapPro API is not loaded. Make sure the image map is properly embedded.');\n        return;\n      }\n\n      \/\/ Subscribe to ImageMapPro events\n      ImageMapPro.subscribe((action) => {\n        \/\/ Only handle clicks on objects in our specific image map\n        if (action.type === 'objectClick' && action.payload.map === CONFIG.imageMapName) {\n          const objectName = action.payload.object;\n          console.log(`Polygon clicked: ${objectName}`);\n          \n          \/\/ Handle the click and redirect\n          handlePolygonClick(objectName);\n        }\n      });\n\n      console.log(`ImageMapPro listener initialized for image map: ${CONFIG.imageMapName}`);\n\n    } catch (error) {\n      console.error('Error initializing ImageMapPro listener:', error);\n    }\n  }\n\n  \/**\n   * Wait for ImageMapPro to be loaded and then initialize\n   * The script tag that loads ImageMapPro might load after this script runs,\n   * so we need to wait for it to be available\n   *\/\n  function waitForImageMapPro() {\n    const maxAttempts = 50; \/\/ Try for up to 5 seconds (50 * 100ms)\n    let attempts = 0;\n\n    const checkAndInit = setInterval(() => {\n      attempts++;\n\n      if (typeof ImageMapPro !== 'undefined') {\n        clearInterval(checkAndInit);\n        initializeImageMapListener();\n      } else if (attempts >= maxAttempts) {\n        clearInterval(checkAndInit);\n        console.error('ImageMapPro did not load within the expected time. Check your image map setup.');\n      }\n    }, 100);\n  }\n\n  \/**\n   * Start the initialization when the DOM is ready\n   * This ensures the image map HTML is already in the DOM\n   *\/\n  if (document.readyState === 'loading') {\n    document.addEventListener('DOMContentLoaded', waitForImageMapPro);\n  } else {\n    \/\/ DOM is already loaded\n    waitForImageMapPro();\n  }\n\n})();\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-656ffca elementor-absolute elementor-widget elementor-widget-heading\" data-id=\"656ffca\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;_position&quot;:&quot;absolute&quot;}\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">\u10d0\u10d8\u10e0\u10e9\u10d8\u10d4 \u10d1\u10da\u10dd\u10d9\u10d8<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1c83659 elementor-widget elementor-widget-shortcode\" data-id=\"1c83659\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><div><div id=\"image-map-pro-da37b857-71df-41b2-9581-4bf526fa5f9c\"><\/div><\/div><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Choose Block<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-1441","page","type-page","status-publish","hentry"],"acf":[],"_hostinger_reach_plugin_has_subscription_block":false,"_hostinger_reach_plugin_is_elementor":false,"_links":{"self":[{"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/pages\/1441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/comments?post=1441"}],"version-history":[{"count":91,"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/pages\/1441\/revisions"}],"predecessor-version":[{"id":6913,"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/pages\/1441\/revisions\/6913"}],"wp:attachment":[{"href":"https:\/\/dekadevelopment.ge\/en\/wp-json\/wp\/v2\/media?parent=1441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}