Reload vue-owl-carousel after dynamic data update

Initialized a vue-owl-carousel using dynamic data

<script>

import carousel from 'vue-owl-carousel'

export default {
    components: { carousel },
}
<carousel :items="1">
    <img v-for="(img, index) in images" :src="img" :key="index">
  </carousel>


 data: function() {
    return {
      images: [
        "https://placeimg.com/200/200/any?1",
        "https://placeimg.com/200/200/any?2",
        "https://placeimg.com/200/200/any?3",
        "https://placeimg.com/200/200/any?4"
      ]
    };
  }

Removed one of images from the images array

How to update the owl carousel with new images array?

Vuejs method ajax call other method on component

how to call another method inside jquery ajax?

methods : {
    calert(type,msg="",error=""){
        console.log("call me");
    },
    getData(){
        $.ajax({
            type: "GET",
            success: function(data){
                // error calert not found
                calert(true,"","asd");
            },
            error: function (error) {
                // also error calert not found
                this.calert(false,"",error);
            },
            complete: function(){
            },
            url: "/test",
        });
    },
}

i have try to using this.calert but it doesn’t work, still error

Want to “ay” at the end of word

This code reverses the string and I want to add “ay” at the end of the word.

var string = prompt(“Enter string:”);
var strLen = string.length;

  for(var i = strLen-1; i >= 0; i--){
     document.writeln(string[i]);
 } 

fail to embed tableau worksheet into vue compoenent?

I am trying to embed tableau worksheets into my webpage,
I’m using laravel and VueJs, however in the backend I managed to sign in successfully into tableau through Laravel, but when trying to show worksheet it returns tableau refused to connect,

my code looks like this:

first included JavaScript API in app.

<script src="https://my_server_name/javascripts/api/tableau-2.8.0.min.js.min.js"></script>

and installed vue-tableau using

npm i vue-tableau

Tableau vue component:

<template>
  <Tableau 
    ref="tableau" 
    :url="url" /// https://my_server_name/#/site/site_name/views/workbook_name/view_name 
    height="1000" 
    width="1000"
  />
</template>
<script>

export default {
  name: "TableauWorkbookShow",
  props: {
    url: {
      type: String, 
      required: true,
    },
  },
};
</script>

what am I missing here ?

Custom Attributes values Javascript

The innline style Attributes has values such as style = "color: green; background: red;". If I want to dynamically change only the background I change with the javascript Attribute style, I do it with: element.style.background = "blue".

How to create a “custum Attributes” so that the values within an attribute change dynamically.

For example:
myAttributes = "car: mercedes; truck: volvo;" so that I change only car values dynamically as style changes, as an element.myAttributes.car = "ferrari" or with setAttributes ("myAttributes", car = "ferrari" ). Is there a possibility to do this, or some similar alternative, some idea?

Is there a way to selectively pick CSV Data in Javascript

I am new to Javascript and want to find a way read from a CSV File selectively (using a given range).

For example, something like CSVRead(row3,col5, toRow10, toCol15).

I found d3.csv which just reads the CSV and there are no arguments to do this. Also saw PapaParse – which from what i can tell doesn’t have this functionality either.

The goal is to product charts using selective areas from ONE CSV file, rather than create multiple CSV Data files.

3Js Raycasting + OrbitControls + Camera Rotation on a Globe

I would like for the user to be able to hover over the little spheres inside the countries to receive information.

Using a raycaster seems to be the first step here, but it does not trigger upon mouse move. Also, it is not pointing where the mouse is. I believe this has something to do with the camera being rotated.

This is less important because I think I can figure it out, but it’s a bug in the code snippet below so I’m mentioning it:

I also would like for my globe to be rotating constantly, unless the user is controlling it with OrbitControls. Right now, when I try to use OrbitControls (dragging the mouse), the globe just zooms in and out- why is that? Does this have to do with the camera being updated constantly in d3.timer()?

I think this is the part of the code that’s most important.

d3.timer( function ( t ) {
        theta += 0.1;

        camera.position.x = 100 * Math.sin( THREE.MathUtils.degToRad( theta ) );
        camera.position.y = 100 * Math.sin( THREE.MathUtils.degToRad( theta ) );
        //camera.position.z = 100 * Math.cos( THREE.MathUtils.degToRad( theta ) );
        camera.lookAt( scene.position );
        camera.updateMatrixWorld();

        controls.update();
        raycaster.setFromCamera( pointer, camera );
        const intersects = raycaster.intersectObjects( earthPivot.children, false );

        if ( intersects.length > 0 ) {

                if ( INTERSECTED != intersects[ 0 ].object ) {

                    console.log(intersects[0].object.name)
                    INTERSECTED = intersects[ 0 ].object;

                }

            } else {

                INTERSECTED = null;

            }

            renderer.render( scene, camera );
    } );

Please take a look at this snippet.

<div id='container'> </div>
<script src="https://d3js.org/d3.v6.js"></script>
<script src="https://unpkg.com/topojson-client@3"></script>
<script src="https://unpkg.com/d3-array@1"></script>
<script src="https://unpkg.com/d3-collection@1"></script>
<script src="https://unpkg.com/d3-dispatch@1"></script>
<script src="https://unpkg.com/d3-request@1"></script>
<script src="https://unpkg.com/d3-timer@1"></script>
<script type='module'>
import * as THREE from "https://unpkg.com/[email protected]/build/three.module.js";
import { OrbitControls } from "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js";

var width = 650;
var height = 650;
var radius = 168,
    scene = new THREE.Scene(),
    camera = new THREE.PerspectiveCamera( 100, width / height, 1, 1000 ),
    renderer = new THREE.WebGLRenderer( { alpha: true } ),
    container = document.getElementById( 'container' ),
    controls,
    raycaster;

const pointer = new THREE.Vector2();
let INTERSECTED;
raycaster = new THREE.Raycaster();
container.addEventListener( 'mousemove', pointerMove );
let theta = 0;

scene.background = new THREE.Color( "rgb(20,20,20)" );

camera.position.set( 0, 0, 300 );
camera.lookAt( 0, 0, 0 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( width, height );
container.appendChild( renderer.domElement );

let earthPivot = new THREE.Group();

d3.json( "https://raw.githubusercontent.com/alessiogmonti/alessiogmonti.github.io/master/Pages/Index/dataFranceModified.json", function ( error, topology ) {

    if ( error ) throw error;
  
  /// NO NEED TO LOOK AT ////////////////////////////////////////////
    var countries = [];
    var cones = [];
    for ( var i = 0; i < topology.objects.countries.geometries.length; i ++ ) {

        var rgb = [];
        var newcolor;
        for ( var j = 0; j < 3; j ++ ) {
            rgb.push( Math.floor( Math.random() * 255 ) );
            newcolor = 'rgb(' + rgb.join( ',' ) + ')';
        }

        var mesh = wireframe( topojson.mesh( topology, topology.objects.countries.geometries[ i ] ), new THREE.LineBasicMaterial( { color: newcolor, linewidth: 5 } ) );
        countries.push( mesh );
        scene.add( mesh );

        mesh.geometry.computeBoundingBox();
        var center = new THREE.Vector3();
        mesh.geometry.boundingBox.getCenter( center );

        mesh.add( earthPivot );
        let height = 1;
        const geometry = new THREE.SphereGeometry( height, 50, 36 );
        const material = new THREE.MeshBasicMaterial( { color: newcolor } );
        const cone = new THREE.Mesh( geometry, material );
        cone.position.copy( center );
        cone.position.setLength( radius + height );
        cone.name = topology.objects.countries.geometries[ i ].properties[ 'name' ];
        cones.push( cone );
        earthPivot.add( cone );

  /// NO NEED TO LOOK AT //////////////////////////////////////////////////////////////
    }


    controls = new OrbitControls( camera, renderer.domElement );

    const helper = new THREE.CameraHelper( camera );
    scene.add( helper );

    const axesHelper = new THREE.AxesHelper( 50 );
    scene.add( axesHelper );

    d3.timer( function ( t ) {
        theta += 0.1;

        camera.position.x = 100 * Math.sin( THREE.MathUtils.degToRad( theta ) );
        camera.position.y = 100 * Math.sin( THREE.MathUtils.degToRad( theta ) );
        //camera.position.z = 100 * Math.cos( THREE.MathUtils.degToRad( theta ) );
        camera.lookAt( scene.position );
        camera.updateMatrixWorld();

        controls.update();

    // this code was to look at the interaction between pointer and camera
        // const material = new THREE.LineBasicMaterial( { color: 0x0000ff } );
        // const geometry = new THREE.BufferGeometry().setFromPoints( [pointer,camera.position] );
        // const line = new THREE.Line( geometry, material );
        // scene.add(line)

        raycaster.setFromCamera( pointer, camera );
        const intersects = raycaster.intersectObjects( earthPivot.children, false );

        if ( intersects.length > 0 ) {

                if ( INTERSECTED != intersects[ 0 ].object ) {

                    console.log(intersects[0].object.name)
                    INTERSECTED = intersects[ 0 ].object;

                }

            } else {

                INTERSECTED = null;

            }

            renderer.render( scene, camera );
    } );
} );

// Converts a point [longitude, latitude] in degrees to a THREE.Vector3.
function vertex( point ) {

    var lambda = point[ 0 ] * Math.PI / 180,
        phi = point[ 1 ] * Math.PI / 180,
        cosPhi = Math.cos( phi );
    return new THREE.Vector3(
        radius * cosPhi * Math.cos( lambda ),
        radius * cosPhi * Math.sin( lambda ),
        radius * Math.sin( phi )
    );

}

function pointerMove( event ){

    pointer.x = ( event.clientX / width ) * 2 - 1;
    pointer.y = - ( event.clientY / height ) * 2 + 1;

}

// Converts a GeoJSON MultiLineString in spherical coordinates to a THREE.LineSegments.
function wireframe( multilinestring, material ) {

    var geometry = new THREE.BufferGeometry();
    var pointsArray = new Array();
    multilinestring.coordinates.forEach( function ( line ) {

        d3.pairs( line.map( vertex ), function ( a, b ) {

            pointsArray.push( a, b );

        } );

    } );
    geometry.setFromPoints( pointsArray );
    return new THREE.LineSegments( geometry, material );

}
</script>

Multiple File Upload VueJS

I am new to VueJS and I was trying to upload multiple pictures. The form looks like this. I am using Vue from CDN on a blade file. The problem is when I click delete, it is not the one clicked which is removed, but the last one. I have noticed that the one clicked is actually removed from the data, but the form doesn’t update like that. Any help is appreciated. My code looks like this:

Vue.createApp({
    data() {
        return {
            images: []
        }
    },
    methods: {
        addField(images){
            images.push({});
        },
        removeField(index, images){
            images.splice(index, 1);
        }
    }
}).mount('#picture')

<input id="picture" type="file"
 class="form-control-file{{ $errors->has('picture') ? ' is-invalid' : '' }}"
 name="picture[]" accept="image/*" required>
                                    
 @if ($errors->has('picture'))
 <span class="invalid-feedback" role="alert">
     <strong>{{ $errors->first('picture') }}</strong>
 </span>
 @endif

Typeahead not working in my laravel blade page

I want to search a client by his name from DB.
I have the following controller function(note: I saved them with “nume” instead of “name”)

namespace AppHttpControllers;
use AppModelsPlati;
use AppModelsClients;
use IlluminateHttpRequest;
use IlluminateSupportFacadesDB;
use Datatables;
use IlluminateHttpRedirectResponse;
use SymfonyComponentHttpFoundationResponse;

public function autocomplete(Request $request)
        {
            $data = Clients::select("nume")
                ->where("nume","LIKE","%{$request->get('query')}%")
                ->get();
   
        return response()->json($data);

}

This function outputs this:enter image description here

This is each’s client’s name.

In my blade page I have the following:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <title></title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
  <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.min.js" ></script>
 <style>
    .container{
    padding: 10%;
    text-align: center;
   } 
 </style>
</head>
<body>
 
<div class="container mt-3">
    <h1 class="mb-3">Laravel 8 Autocomplete Search using Bootstrap Typeahead JS - LaraTutorials</h1>   
    <input id="search" class="typeahead form-control" type="text">
</div>
 
<script type="text/javascript">
    var path = "{{ url('autocomplete') }}";
    $('#search').typeahead({
        return $.get(route, {
                    query: query
                }, function ($data) {
                    return process($data);
                });
        }
    });
</script>
   
</body>
</html>

But when I type it doesn’t show me anything.
Does anyone know why?

Variable is initialized again after the input value changes in angular

I have a shared component with some input values and one declared variable. The input values of the component change in between and whenever the input value changes, showItems is declared again and it’s value is false.
I tried to use behavior subject, but it doesn’t solve my problem. Is there any better workaround for this one?

Code:

export class Component{
    @Input() input1: boolean;
    @Input() input2: string[];

    showItems: boolean;

    constructor() {}

    toggleItems() {
        this.showItems= !this.showItems;
    }
}

Jquery – add class to the specific child element

Hello Stackoverflow friends… I am trying to solve a problem…

I have 4 link blocks which are having the class “faq-tab_link” and they have a child element of the image having the class of “careers-faq-icon” and the image have a combo class of “is__hide”

what I am trying to achieve is when I click on any of the link block the image element which is having the combo class of is__hide should be removed to that particular link block only..so that the image will appear on the clicked link block.. and which clicked on the second link the image should appear on the second link and all other images of other links should be hidden…

can anybody help me with that please?

input type=”number” addClass on increase removeClass on decrease

In an online game, students are asked “How many 12-year-olds already have (…)” and have to choose how many of 25 people’s icons (4%) they color in. This is actually kind of a range input, but I thought it could be done easily with an input type=”number” too.

I’ve already got it working to some extent. Arrow up or mouse up adds the necessary class, but the remove class doesn’t work yet. When I enter a number, the people’s icon with that number gets the class, but all icons with a lower id should also get the class.

You can find the live example here. The code I’m using:

HTML:

<svg id="manneke1" class="manneke" (…) /></svg>
(…)
<svg id="manneke25" class="manneke" /></svg>
<input type="number" id="inputMannekes" class="form-control text-center" name="inputMannekes" value="0" min="0" max="25"/>

CSS:

.manneke {
  fill:none;
  stroke:#004f75;
  stroke-linecap:round;
  stroke-linejoin:round;
  stroke-width:11.49px;
}

.gevuld {
  fill:#f5c1bc;
  stroke: #e66557;
}

Javascript:

$("#inputMannekes").change(function () {
    if (this.getAttribute('value') === this.value) {
        $(this).data('lastvalue', this.value);
        console.log(this.value);
    } else {
        if (this.value > $(this).data('lastvalue')) {
            $("#manneke"+$(this).val()).addClass("gevuld");
        } else {
            $("#manneke"+$(this).val()).removeClass("gevuld");
        }
    }
}).change();

What is causing this TypeError

Uncaught TypeError: Failed to resolve module specifier “events”. Relative references must start with either “/”, “./”, or “../”. index.html:1

what is causing this error?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script defer type="module"src="./index.js"></script>
</head>
<body>

    <form class="add">
        <Label for="Fornavn">Fornavn:</Label>
        <input type="Text" name="Fornavn" required>
        <Label for="Etternavn">Etternavn:</Label>
        <input type="Text" name="Etternavn" required>
        <Label for="Forkort">Partiforkortelse:</Label>
        <input type="Text" name="Forkort" required>

        <button>Legg til politiker</button>

    </form>
    
</body>
</html>

First time writing on here so im sorry if its not clear enough, if you need more information ill do my best to give you it.

Chatbot in Dialogflow

I am trying to implement a chatbot in dialogflow CX, and I have never done it before.
I want to customise the buttons that appear in the chat and a couple more things as the background.
I already know that I have to use javascript files and the code for that is here. The thing is… how do implement that in the dialogflow CX? Thank you

What is the shorthand syntax for callback functions generating a new interface instance?

Given the following TypeScript example to construct a new object with default values

interface MyInterface {
  foo: boolean;
};

const generateMyInterfaceWithDefaults: () => MyInterface = () => { foo: false };

The syntax seems to be invalid because the function needs to have a nested return statement like so

const generateMyInterfaceWithDefaults = () => { return { foo: false }; }; // returns function that returns a new interface of MyInterface

I’m wondering if my first approach can be fixed because primitve objects seem to work fine

const generateFalsy = () => false; // returns boolean

So do I have to use the return statement for non primitive types or is it possible to have something like ( … pseudo code … )

const generateMyInterfaceWithDefaults = () => MyInterface.of({ foo: false }); // fixes the first approach