Javascript – text to the second picture below and missing

Well, I am new to HTML / CSS / JS and create my own training project.
Well, I made this basic at the beginning and inserted a full screen of the game, the logo and a text below it
Then I placed another image in full screen mode underneath, but I want to place the text well centered in the middle or slightly above, but it seems like the text is coming down from the first image and in the second image, but it disappears, why ?

Starcraft II

LIVE THE PLAYING EXPERIENCE THAT HAS CHANGED THE STRATEGY GENDER IN REAL TIME. Conquer like Earth, Zerg or Proto

REAL-TIME STRATEGY GAME

CSS

  • {
    Padding: 0px;
    Border: 0px;
    Outline: 0px;
    }

Body {
Background: black URL (imagem2.jpg);
Background Size: Cover;

}

.LogoFund {

Position: middle;
}

Display: Inline block;
Position: relative;
}

Position: absolutely;
above: 0px;
right: 0px;
Font size: 25px;
Colour blue;
}

html – Simple vanilla JavaScript carousel with tabs and pause button

Currently I am coding and fully self-taught. Since I know that my code is far from perfect, I ask for advice and tips for improvement. Do not hesitate to submit comments on the topic – helpful advice and suggestions are very welcome.
It does not matter if the advice is for my HTML file, JavaScript syntax, or CSS knowledge. I really want to improve and every help is great!

Edit: I've uploaded a demo to my workspace, which you can visit at https://cedricjansen.com

Here's a picture to help you understand what I'm talking about:
MeadowJS in the Chrome browser

Let me try to explain my concept.
I created one div with the id = "meadow" Here you can specify an interval as an attribute as well as the width and height of the div.
All images are drawn later in this div #, so it acts as a container and wrapper.

Then I created one Tabulatorcontainer with the id = "Meadow Tabs" which contains all the tabs. Tabs are small dots that appear at the bottom of the main area, each referring to an image. The point with the currently displayed image is highlighted and marked with the class Active Reiter,

When the HTML file is loaded, all images are preloaded and then the first image (depending on which tab is active at startup) is displayed. Now you can either wait for the specified interval until the image changes by itself, or you can click on one of the tabs to instantly jump to a specific image.

The pause button can pause and continue the interval.

INDEX.HTML




    
    


    
    



MEADOW.JS

var tabs = ();
var fetchedImages = ();
var imageUrls = ();
var images = ();

var carouselIndex = ();
var meadow;

var pauseTab = document.getElementsByClassName('pause-tab')(0);
pauseTab.addEventListener("click", pausePlay);

const meadowDom = document.getElementById('meadow');
//Gets the interval time.
const interval = meadowDom.getAttribute('interval');
const banner = document.getElementsByClassName('banner')(0);

//Grabs the attributes from the html file for width and height
const width = meadowDom.getAttribute('m-width');
const height = meadowDom.getAttribute('m-height');

//Looks if the the attribute show is present;
const showTabs = document.getElementById("meadow-tabs").hasAttribute('show');

//If the attribute show is not present, hide the tabs
if(!showTabs)
{
    document.getElementById("meadow-tabs").style.display = "none";
}

//Set the custom height and width of the banner container, to which the images are drawn.
banner.style.height = height;
banner.style.width = width;


var loader = document.getElementById("meadow-load");


//Get all Tabs
var fetchedTabs = document.getElementById("meadow-tabs").querySelectorAll('.meadow-tab');

for( var i = 0; i < fetchedTabs.length; i++ )
{
    //Push all Image Links from the tabs to the ImageUrls array to preload them
    imageUrls.push(fetchedTabs(i).getAttribute('image'));
}
//Preloads the images
preload(imageUrls);
// Shows the first image of the active tab
initImage();



for( var i = 0; i < fetchedTabs.length; i++)
{

    fetchedTabs(i).addEventListener("click", toggleTab);
}

// Function used then pause button is clicked. Toggles between
// pausing and resuming the carousel.
function pausePlay()
{
    if(pauseTab.classList.contains('active'))
    {
        pauseTab.classList.remove('active');
        meadow = setInterval(play, interval);
    }
    else
    {
        pauseTab.classList.add('active');
        clearInterval(meadow);
    }
}

// Used when a certain tab is clicked. If the tab is not activated,
// activate it and deactive the current activated tab.
// Checks if the carousel is paused. If yes, keep it paused, if no
// continue from there with the given interval time.
function toggleTab()
{

    if( event.target.classList.contains('.active-tab'))
    {
        return;
    }
    var activeTab = document.getElementsByClassName('active-tab');
    console.log(activeTab);
    activeTab(0).classList.remove('active-tab');

    event.target.classList.add('active-tab');
    console.log("EVENT: " + event.target);
    changeImage(event.target);
    clearInterval(meadow);
    if(!pauseTab.classList.contains('active'))
    {
        meadow = setInterval(play, interval);   
    }

}

// Function which removes the active tab.
function removeActiveTab()
{
    var activeTab = document.getElementsByClassName('active-tab');
    activeTab(0).classList.remove('active-tab');
}

//Function to change the image.
function changeImage( tabToChangeTo )
{
    var imageToChangeTo = tabToChangeTo.getAttribute('image');
    banner.style.backgroundImage = "url('" + imageToChangeTo + "')" ;
}


//Used in the play function to continue to the next tab and change the image.
function changeInPlay( indexToChangeTo )
{
    var tab = document.querySelectorAll('(index="'+ indexToChangeTo + '")')(0);
    changeImage(tab);
    removeActiveTab();
    tab.classList.add('active-tab');
}

//Display the first image of the first active tab.
function initImage()
{
    var activeTab = document.getElementsByClassName('active-tab')(0);
    var activeImage = activeTab.getAttribute('image');
    banner.style.backgroundImage = "url('" + activeImage + "')" ;
}

// Used in setInterval to iterate over the tabs and show the different images.
function play()
{

    var activeTab = document.getElementsByClassName('active-tab')(0);
    var activeIndex = activeTab.getAttribute('index');

    var nextIndex;
    if( activeIndex == (fetchedTabs.length - 1))
    {
        nextIndex = 0;
    }
    else 
    {
        nextIndex = +activeIndex + 1;
    }
    changeInPlay(nextIndex);

}

function preload( urls ) {
    for (var i = 0; i < urls.length; i++) {
        //Preload the images from the passed urls and keep them in a reference
        // so that they aren't erased from storage.
        images(i) = new Image();
        images(i).src = urls(i);
    }
    //Hide the carousel loader after images are preloaded.
    loader.style.display = 'none';
}

//Set the initial interval for images to change.
meadow = setInterval(play, interval);

MEADOW.CSS

html
{
    width: 100%;
    height: 100%;
}

html body
{
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
}

.meadow.demo.banner
{
    width: 100%;
    height: 100%;

    min-height: 100px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    background-color: black; 

    position: relative;

    background-size: cover;
}

.meadow.demo.banner .meadow-loader
{
    position: absolute;
    width: 20px;
    height: 20px;

    border-radius: 10px;
    background-color:white;

    animation: meadow-pulse 2s infinite;
}

@keyframes meadow-pulse
{
    0%
    {
        opacity: 0;
    }
    50%
    {
        opacity: 0.8;
    }
    100%
    {
        opacity: 0;
    }
}

.meadow.demo.banner .pause-tab
{
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 20px;
    background-color: white;

    left: 10px;
    bottom: 10px;

    opacity: 0.5;
}

.meadow.demo.banner .pause-tab:hover
{
    cursor: pointer;
}

.meadow.demo.banner .pause-tab.active
{
    opacity: 1;
}

.meadow.demo.banner .tabs-bottom
{
    width: auto;
    min-width: 45px;
    max-width: 100px;

    position: absolute;

    min-height: 15px;
    height: 5%;

    display: flex;
    justify-content: center;
    align-items: center;

    bottom: 5px;

    background-color: rgba(152, 152, 152, 0.5);
    border-radius: 10px;
}

.meadow.demo.banner .tabs-bottom .meadow-tab
{
    min-width: 7px;
    min-height: 7px;
    border-radius: 5px;
    margin-left: 2px;
    margin-right: 2px;

    background-color: black;
}

.meadow.demo.banner .tabs-bottom .meadow-tab:hover
{
    cursor: pointer;
}

.meadow.demo.banner .tabs-bottom .meadow-tab.active-tab
{
    background-color: white;
}

.meadow.demo.cover
{
    width: 100%;
    height: 100%;
    background-color: black;
}

If anyone finds this post and wants to create their own carousel / image slider, you can use that code and recreate it to your liking.

I called it Meadow because I was sitting at a meadow, and then came up with the idea to build an Image Slider thing.

Thank you for your help!

Javascript – RayCasting with Mode7

I'm trying to connect the Mode7 algorithm to RayCasting. For mode7 I use a simple rotation matrix to implement the rotation. The result is a bit strange and I can not fix it. Do you know where the problem lies in aligning the algorithms? See the GIF below to understand:

Enter image description here

The code I use is:

function mode7() {
    let _x = 0;
    let _y = 0;
    let z = 0;
    let sin = Math.sin(degreeToRadians(data.player.angle));
    let cos = Math.cos(degreeToRadians(data.player.angle));
    for(let y = data.projection.halfHeight; y < data.projection.height; y++) {
        for(let x = 0; x < data.projection.width; x++) {
            _x = ((data.projection.width - x) * cos) - (x * sin);
            _y = ((data.projection.width - x) * sin) + (x * cos);

            _x /= z;
            _y /= z;

            if(_y < 0) _y *= -1;
            if(_x < 0) _x *= -1;

            _y *= 8.0;
            _x *= 8.0;

            _y %= data.floorTextures(0).height;
            _x %= data.floorTextures(0).width;

            screenContext.fillStyle = data.floorTextures(0).data(Math.floor(_x) + Math.floor(_y) * data.floorTextures(0).width);
            screenContext.fillRect(x, y, 1, 1);
        }   
        z += 1;
    }
}

Is there a way or a tutorial to teach you how to fix this? I tried to find it, but I did not find anyone about RayCasting with mode7.

Javascript – hash to record in URL

Hi

I wanted to add a hash to the URL when I click on a particular link. Because this hash is a coded URL, if you copy the link and open it in a new window, you can see the right image without losing the context.
How can I create a hash, specify a shortlink with a maximum number of characters and add at the end with:

window.location.hash = "sample page";

The sample page would be replaced by a hash that decrypts and accesses the correct information.

example

http://XXXX.com/image.jsp?query=test#hash

This in Javascript.

html – Detects the closing of javascript tabs

I am developing a website where I have to switch between different screens. Once the tab is closed on any screen, that user's session is about to be ended.

My problem is that using onbeforeunload and adding some conditions so that you do not leave the session while browsing the different screens of my website works. However, if I use the Chrome browser buttons back / next / refresh, I can do that as well Log out

How can I make sure that I leave the session only when I close the tab, not when I press Back / Next / Refresh?

That way I can control when to close the session:

Enter image description here

Javascript – TypeError: Undefined object is not JSON serializable

I tried to point out an overflow in several ways but could not fix the error.
Here is my code

HTML

{% expand "layout.html"%} {% block title%} sell share {% endblock%}

{% block main%}


{% if status == 0%}

Please choose a stock that you sell.

{% set tuples = session ("stockandbal")%}
{% elif status == 1%} Sold successfully! {% endif%} {% endblock%}

python

@app.route("/sell", methods=("GET", "POST"))
@login_required
def sell():
    username = session("user_id")
    status=0

    session("stockandbal")=dbexe(f"select history.symbol, history.comname, sum(history.sharenum) as totalnum from history join users on users.id=history.user_id where users.username='{username}' group by history.comname having SUM(history.sharenum)>0","selecall")

    if request.method == 'POST':

        symbol=request.form.get("symbol")
        shares=int(request.form.get("shares"))

        resultcom = lookup(symbol) 
        comname=resultcom("name")
        comprice=float(resultcom("price"))
        tAmt= -(comprice*shares)
        balance = int(dbexe(f"select cash from users where username='{username}'", "selec")(0))
        newbal = balance-tAmt

        user_id = int(dbexe(f"select id from users where username='{username}'", "selec")(0))


        dbexe(f"INSERT INTO history('user_id', 'type', 'date', 'symbol', 'comname', 'sharenum', 'sharePrice','transactionAmt', 'balatthetime') VALUES('{user_id}', 'SELL', datetime('now'), '{symbol}','{comname}', {-shares}, {comprice}, {tAmt}, {newbal})", "regi")

        dbexe(f"update users SET cash={newbal} where username='{username}'", "updat")

        status=1
        return render_template("sell.html", status=status)
    else:
        return render_template("sell.html", status=status)

def dbexe(sqlquery, str):
    db = sqlite3.connect("finance.db")
    cur = db.cursor()
    if str == "regi" or str == "updat":
        cur.execute(sqlquery)
        db.commit()
        db.close()
    elif str == "selec":
        rows = cur.execute(sqlquery)
        tupdata = rows.fetchone()
        db.close()
        return tupdata
    elif str == "selecall":
        rows = cur.execute(sqlquery)
        tupdata = rows.fetchall()
        db.close()
        return tupdata

I suppose that's the problem of Jinja used in J's part. when I log in to javascript, it seems that tuplex is object, but it seems undefined in js, as eorr says. Thank you for your opinion.

http – Does it need to be tested if there are security headers in response to the API in javascript code?

I've found in one of the client-side libraries that it checks to see if the answer contains all the following headers with appropriate values ​​(for security reasons):

'content-type', 'application/json'
'content-type', 'charset=utf-8'
'X-Content-Type-Options', 'nosniff'
'content-disposition', 'attachment'
'X-Frame-Options', 'DENY'

If a header does not exist, the library will throw an exception.

I can see no reason how this can improve security by checking client-side libraries.

Does anyone have any idea if this makes sense or does not make sense?

P.S. This is not about whether these headers should be set by the server.

P.P.S. I've found this out, because for some reason, even if the header is present, I can see in logs that sometimes this exception is thrown for them X-... Headlines. I do not really know why, but I suppose either remove proxies headers or some browsers will remove them for some reason in js do not return. I would be happy to hear why, when someone knows reason.

Javascript – Why do I get this error in the answer from Google reCAPTCHA V2?

It's my first time posting here and I'm not feeling well with things like the one I'm posting right now

I've been trying to solve this problem for 2 days so I can use help lol

This error "Please solve the captcha." is displayed even if the captcha is verified so that it will be displayed in both cases (verified / unverified).

Thank you in advance.

PHP part:


SQL part

function insertRewards($account_unique_id){
    global $config;

    $connect = odbc_connect('Driver={'.$config("db_driver").'};Server='.$config("db_server").';Database='.$config("db_database_player").';', $config('db_username') ,$config('db_password'));

    if(!$connect)
        return false;

    $query = odbc_exec($connect,"SELECT Top 1 (IID) FROM (Item) Where (IID) < 1 order by IID Desc");
    if(!$query)
        return false;

    $data = odbc_fetch_array($query);
    if($data && !empty($data) && isset($data("IID")))
        odbc_exec($connect,"INSERT INTO (Item) ((PID),(IID),(Index),(Prefix),(Info),(Num))VALUES ($account_unique_id,".($data("IID")+1).",".$config("Reward_Index").",0,".(16+($config("Reward_Bound") ? 128 : 0)).",".$config("Reward_Amount").")");

}

function checkCharacters($accountUID){
    global $config;

    $connect = odbc_connect('Driver={'.$config("db_driver").'};Server='.$config("db_server").';Database='.$config("db_database_player").';', $config('db_username') ,$config('db_password'));

    if(!$connect)
        return array("error" => "failed to connect to database players.");

    $query = odbc_exec($connect,"SELECT (Level) FROM (Player) WHERE (UID) = $accountUID ORDER BY (Level) DESC");
    if(!$query)
        return array("error" => "failed to find characters in this account id.");

    while($r = odbc_fetch_array($query)){
        if($r("Level")  >= $config("MinLvl_Require"))
        return array("success" => $accountUID);
    }
  return array("error" => "You should have one character at least higher than level : ".$config("MinLvl_Require")." to vote.");
}

function checkAccount($accountID){
    global $config;

    $connect = odbc_connect('Driver={'.$config("db_driver").'};Server='.$config("db_server").';Database='.$config("db_database_account").';', $config('db_username') ,$config('db_password'));

    if(!$connect)
        return array("error" => "failed to connect to database accounts.");

    $query = odbc_exec($connect,"SELECT TOP 1 (UID) FROM (Login) WHERE (ID) = '$accountID'");
    if(!$query)
        return array("error" => "this account id not exists.");

    $data = odbc_fetch_array($query);
    if(!$data || empty($data) || !isset($data("UID")))
        return array("error" => "this account id not exists.");

    if($config("MinLvl_Require") > 0)
          return checkCharacters($data("UID"));

  return array("success" => $data("UID"));
}

sending function

$ response = array ("error" => false, "success" => false, & # 39; redirect & # 39;;> false);

Function post_content ($ query) {
$ query_array = array (); foreach ($ query as $ key => $ key_value) $ query_array () = urlencode ($ key). & # 39; # = 39 ;. urlencode ($ key_value); return implode (& # 39; && #;; $ query_array);
}

global $ api;
$ opts = array (& # 39; http & # 39;;> array (& # 39; method & # 39; => & # 39; POST & # 39 ;, "header" => "Content Type: application / x-www- form-urlencoded  r  nAuthorization: ". base64_encode ($ API (" api_key ").": ". $ API (" secret_key ")."  R  n "," content "=> post_content ($ content)) ; return stream_context_create ($ opts);
}

Function submit () {
global $ api;

if (empty ($ captcha) || $ captcha == & # 39; ||! isset ($ captcha))
return array ("error" => "Please solve the captcha.");

if (empty ($ _ POST (& # 39; account & # 39;)) ||! ctype_alnum ($ _ POST (& # 39; account & # 39;)))
return array ("error" => "Invalid account ID.");

$ checkAccount = checkAccount ($ _ POST (& # 39; account & # 39;));

if (isset ($ checkAccount ("error")))
return array ("error" => $ checkAccount ("error"));

if (isset ($ checkAccount ("success"))) {
$ account_unique_id = (isset ($ _ SESSION (& kalalid & # 39;)))? $ _SESSION (# kal_id): $ checkAccount ("success");
$ result = json_decode (file_get_contents ($ API ("API_Domain"). & # 39; / api / generate / vote-rewards-token & # 39 ;, false, postParams (array (& # 39; callback & # 39; => $ API ("callback"), & # 39; account_unique_id & # 39; => $ account_unique_id))), true);
{
echo & # 39;

Please wait...

& # 39 ;; } if (! empty ($ result)) { if (isset ($ result ("response"))) { if (isset ($ result ("response") ("error"))) return array ("error" => $ result ("response") ("error")); elseif (isset ($ result ("response") ("success"))) Return Array ("redirect" => & # 39;& # 39); } } } } if ($ _SERVER ('REQUEST_METHOD') == 'POST' && isset ($ _ POST ('account')) { $ response = submit (); if (isset ($ response (& # 39; redirect & # 39;)) && $ response (& # 39; redirect & # 39;)) { echo $ response (& # 39; redirect & # 39;); to die; } } elseif (isset ($ _ GET (& # 39; return & # 39;)) { $ result = json_decode (file_get_contents ($ API ("API_Domain"). & # 39; / api / verify / vote-rewards-token & # 39 ;, false, postParams (array (& # 39; return_code & # 39; => $ _GET (? Return?))), True); if (! empty ($ result)) { if (isset ($ result ("response"))) { if (isset ($ result ("response") ("error"))) $ response (& # 39; error & # 39;) = $ result ("response") ("error"); elseif (isset ($ result ("response") ("success"))) { insertRewards ($ result ("response") ("account_unique_id")); $ response (& # 39; success & # 39;) = & # 39;Thank you, your vote has been recorded and server rank will be updated shortly.
You will receive your premiums credited to your account.

Your next vote in: & # 39 ;. $ result ("response") ("NextVote"). & # 39;

& # 39 ;; } } } } ?>

HTML part:


Voting rewards - <?php echo $config('serverName'); ?>
 







Sorry if the topic is way too long, but I'm desperate = DD