Is it possible to convert the text.json file into a jQuery animation?

Looking to extract information from text.json and integrate it with my jquery.animation().

My goal is similar to the one demonstrated here. Instead of using "data" attributes like in that example, I want to parse the text based on the "ID" property as a key value for each button to display text within middleBubble. The only difference between my version and the example is that my bubble toggles, so the text should be displayed after the animation.

I'm struggling to translate this into code to incorporate it into my jquery.animation(); this concept is new to me. Can someone assist me in coding this so I can comprehend how it functions?

This is the HTML for my animation:

<section class='circle-animation'>
        <div class="container-fluid">
          <div class="row">
            <div class="hidden-xs hidden-sm">
              <div class="col-sm-6 col-sm-offset-3 col-sm-pull-1">
                <div id="middlepapir" class="jumbotron">
                  <div class="row">

                    <img id="placeholder" class="papir img-responsive" src="img/circle/11.png" alt="">
                    <div class="row">
                      <div id="all" class="move1 col-sm-4 col-xs-4 col-md-push-4"> 
                          <a href="#"><img class="position1 round" src="img/circle/off/home-all-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="cover" class="move2 col-sm-4 col-xs-4 col-md-push-1">
                          <a href="#"><img class="position2 round" src="img/circle/off/home-cover-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="design" class="move3 col-sm-4 col-xs-4 col-md-push-7">
                          <a href="#"><img class="position3 round" src="img/circle/off/home-design-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="diy" class="move4 col-sm-4 col-xs-4">
                          <a href="#"><img class="position4 round" src="img/circle/off/home-diy-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="marketing" class="move5 col-sm-4 col-xs-4 col-md-push-8">
                          <a href="#"><img class="position5 round" src="img/circle/off/home-marketing-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="other" class="move6 col-sm-4 col-xs-4 col-md-push-1">
                          <a href="#"><img class="position6 round" src="img/circle/off/home-other-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="special" class="move7 col-sm-4 col-xs-4 col-md-push-4">
                          <a href="#"><img class="position7 round" src="img/circle/off/home-special-icon-off.png"></a>
                      </div>
                    </div>
                    <div class="row">
                      <div id="vip" class="move8 col-sm-4 col-xs-4 col-md-push-7">
                          <a href="#"><img class="position8 round" src="img/circle/off/home-vip-icon-off.png"></a>
                      </div>
                    </div>
                  </div>
                </div>   
              </div>  
            </div>  
          </div>    
        </div>
      </section>

This is the CSS for the animation:

/**
 *
 * Position icons into circle (SO)
 * 
 */

/* -------Up------ */ 

.move1 {

}

.move2 {
  margin-top: -80px;
}

.move3 {
  margin-top: -140px;
}
/* --------------- */


/* ------Middle---- */

.move5 {
   margin-top: -140px;
}


/* ---------------- */


/* ------Down------ */

.move7 {
  margin-top: -80px;
}

.move8 {
  margin-top: -195px;
}

/* --------------- */

.round {
  width: 140px;
  height: 140px;
}

.jumbotron {
  display: inline-block;
  width: 700px;
  height: 600px;
}

.jumbotron img.img-responsive {
  width: 450px;
  position: absolute;
  margin-top: 120px;
  margin-left: 60px;
}

Jquery:

// jQuery script for are Circle div whit Scroll Reveal Script

$(document).ready(function(){
    /*==========================================
    SCROLL REVEL SCRIPTS
    =====================================================*/
    window.scrollReveal = new scrollReveal();
    /*==========================================
    WRITE  YOUR  SCRIPTS BELOW
    =====================================================*/
    $('.round').click(function(){
       $('.papir').animate({
        width: ['toggle', 'swing'],
        height: ['toggle', 'swing'],
       }); 
    });    

});

The text available in text.json that I aim to include in my html:

var a = {
    "all":{
        "id":"all",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "cover": {
        "id":"cover",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "diy": {
        "id":"diy",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "marketing": {
        "id": "marketing",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "other": {
        "id": "other",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "special": {
        "id": "special",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "vip": {
        "id": "vip",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "design": {
        "id": "design",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }
}

Answer №1

Give this a try:

var a = {
    "all":{
        "id":"all",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "cover": {
        "id":"cover",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "diy": {
        "id":"diy",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "marketing": {
        "id": "marketing",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "other": {
        "id": "other",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "special": {
        "id": "special",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "vip": {
        "id": "vip",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }, "design": {
        "id": "design",
        "data": {
            "datatext": "Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
        }
    }
}


    $('div[class^="move"]').on('mouseover',function(){
        var id = $(this).attr('id');
        alert(a[id].data.datatext)
        $('.main-view').text(a[id].data.datatext);//.main-view is the text body where you display it

    })

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using LocalStorage in Greasemonkey

I am currently working on developing a Greasemonkey script, but I am encountering difficulties with implementing local storage within it. The method I found to work with local storage in Greasemonkey involves creating another instance of JavaScript using t ...

Any tips on how to retrieve the data from an AJAX request using vanilla JavaScript?

After successfully implementing my first AJAX call last week, I am now faced with a new challenge. This time, I need to not only change something onSuccess but also access the returned data. <script type="text/javascript"> function showMessage(j ...

Is it possible to replicate the functionality of "npm run x" without including a "scripts" entry?

If you want to run a node command within the "context" of your installed node_modules, one way to do it is by adding an entry in the scripts field of your package.json. For example: ... "scripts": { "test": "mocha --recursive test/**/*.js --compiler ...

Javascript error specific to Internet Explorer. Can't retrieve the value of the property 'childNodes'

After removing the header information from the XML file, the issue was resolved. Internet Explorer did not handle it well but Firefox and Chrome worked fine. An error occurred when trying to sort nodes in IE: SCRIPT5007: Unable to get value of the proper ...

Perform Function Again

Recently, I came across some code for a tesseract ocr from Google that seemed to be functioning well. However, I encountered an issue where it would work fine the first time I input a URL, but on the second run, it wouldn't work without a manual page ...

Experiencing difficulty serializing the database in Django and receiving an error message stating "Error: Unable to serialize database"?

Encountering an issue while attempting to dump data to a JSON fixture in Django 1.2.1 on my live server. The live server is running MySQL Server version 5.0.77 and I imported a significant amount of data to my tables using the phpMyAdmin interface. Everyth ...

having difficulty applying a border to the popup modal

Currently, I am utilizing a Popup modal component provided by the reactjs-popup library. export default () => ( <Popup trigger={<button className="button"> Guide </button>} modal nested > {(close: any) =&g ...

Creating a Dynamic Clear Button for a Text Area in Angular

Working on my Angular application, I have implemented a form with a textarea element. My goal is to incorporate a clear button inside the textarea element that should: Appear only when the textarea is focused Disappear when the textarea is out of focus ( ...

Analyzing the path of the cursor

Looking to enhance my tracking capabilities by monitoring mouse movements. I have the ability to capture XY coordinates, but understand that they may vary depending on browser size. Are there any other parameters recommended for accurate results? P.S: Be ...

Encountering difficulty inserting ajax response into a specific div element

What could be the issue? I've included the getElementById and I am receiving a response, as confirmed by Firebug. The response is correct, but for some reason it's not populating my div area. <script> $(document).ready(function () { $( ...

Retrieve the current URL upon page load

I'm currently attempting to parse the URL in document.ready() so I can retrieve the id of the current page and dynamically populate it with content from an AJAX call. However, I've encountered an issue where 'document.URL' seems to refe ...

Having trouble with the Jquery Slider script?

I recently integrated a slider from into my website, following the installation instructions. However, I seem to be facing some conflicts with another script that controls animated div movements on the same page. Upon loading the page, all elements of th ...

How can I troubleshoot email validation issues in Vue.js?

<button type="submit" class="register-button" :class="(isDisabled) ? '' : 'selected'" :disabled='isDisabled' v-on:click=" isFirstScreen ...

Another option to replace the file_get_contents function

I am attempting to retrieve JSON data from the following URL: . When using the file_get_contents() function, I encountered the following error message: Error Message: require(): https:// wrapper is disabled in the server configuration by allow_url_fope ...

Repurposing React key usage

section, I am curious to know if it is standard practice to reuse a React key from one component to another. For instance, in the Row component, the key obtained from the Column component is reused for mapping the children of Row. const Table = props =& ...

Tips for syncing a database with information stored in identical div elements:

I am attempting to use Ajax for updating the database without the standard submission process, allowing the page to be refreshed solely to update the results (entries). Initially, there exists a table with pre-existing data which has been saved in the lin ...

Is there a way to restrict form choices depending on the previous entry, while also keeping all fields, including file selections, filled out upon submission?

Currently, I have a form set up as follows: <form name="estimate" action="live_preview.php" method="post"enctype="multipart/form-data"> <label for="file">Upload File 1:</label> <input type="file" name="file" id="file"/> ...

Parsing JSON Data in Python

I am currently working with a json document called as_stats.json. Here is an example of what the contents may look like: {"failed":5, "received": {"192.168.5.2": 40, "192.168.5.45": 84, "127.0.0.1": 145}} Below is a snippet of my python code that parses ...

Error Encountered: The TypeError indicates that the function e.indexOf is not recognized, while also displaying a 404 error

I recently started learning Django and followed a tutorial on Udemy (TweetMe). In the process of setting up rest_framework to load serialized data as JSON, I encountered the following errors: TypeError: e.indexOf is not a function in jquery-3.3.1.min.js ...

The CORS problem arises only in production when using NextJS/ReactJS with Vercel, where the request is being blocked due to the absence of the 'Access-Control-Allow-Origin' header

I've encountered a CORS error while trying to call an API endpoint from a function. Strangely, the error only occurs in production on Vercel; everything works fine on localhost. The CORS error message: Access to fetch at 'https://myurl.com/api/p ...