cabl

a cat girl

kinda a girl that posts and stuff its knida cool
+18 but not nsfw | 21


Personal site (has links there)
cabl.rodeo/
sheezy.art
sheezy.art/cabl
mastodon (yiff.life)
yiff.life/@cabl

cabl
@cabl

javascrypt is making me so mad


cabl
@cabl

It took me like 2 hours to figure out the best way to open and use the contents of a json file.

I got the like fetch thing working but then i couldent like call the function to show the stuffon the page from in the html file for some reason. I understand that im using a language that i have not used before n stuff but wherever i looked for help nothing explained more than the base like "get data from file" thing or whatever


cabl
@cabl

this is the fuckin thing i ended up with


`
import journal from '/Files/Journal/journal.json' assert {type: 'json'} ;
import Game from '/Files/Journal/GameDev.json' assert {type: 'json'} ;
import Site from '/Files/Journal/SiteUpdate.json' assert {type: 'json'} ;

function setupJournal(wichone){
var a
var data
//console.log(wichone)

switch (wichone){
    case 1: // if loading the journal page
        //console.log("journl");
        data = Object.assign({},journal);
        a = "Jtop";
        break;
    case 2: // if loading the game updates pate
        //console.log("game");
        data = Object.assign({},Game);
        a = "Gtop";
        break;
    case 3: // if loading the site updatePage
        //console.log("Site");
        data = Object.assign({},Site);
        a = "Stop";
        break;

}

//console.log(data)

// for normal journal page

var chunk1 = "<div class=\"jEntry\"> <div class=\"jESide\">"
// adding the date here
var chunk2 = "</div><div class = \"jText\">"
// adding the actual entry here
var chunk3 = "</div></div>"
// getting the position of the thing
const thing = document.getElementById(a);
//console.log(thing)

var up1 =     "<div class = \"entry\"> <!-- entry --> \n <div class = \"line\" style=\"padding: 3px;\">" 
// insert date here
var up2 = "</div><p class=\"entry\"> <!-- the actual text of the thing-->"
// add actual content here
var up3 = "</p></div>"


// for ever y entry in the data thing it gets the thing
for(let i = 0; i < Object.keys(data).length ;i++){
//for(var i = Object.keys(data).length - 1; i >= 0 ;i-=1){

    //making shure everything works
    //console.log(data[String(i)]["date"]);
    //console.log(data[String(i)]["entry"]);
    // getting the actual data 
    var date = data[String(i)]["date"];
    var entry = data[String(i)]["entry"];
    // building the chunk of html
    var html
    // if its the journal page
    if (wichone == 1){
        html = chunk1 + date + chunk2 + entry + chunk3;
    }
    // if one of the list type pages
    else{
        html = up1 + date+ up2 + entry + up3
    }
    // Checking if there exists a thing that you can append to
    if (thing != null){
        // appending the html to the page
        thing.insertAdjacentHTML("afterend", html);
    }
}

}

setupJournal(1)
setupJournal(2)
setupJournal(3)`

This is all part of 1 file idk y the embed thing does that lol


You must log in to comment.

in reply to @cabl's post: