javascript – How to display the menu in Angular with CSS Materialize?

I was doing a small project with Angular (v8.2.5) and Materialize (materialize-css v1.0.0), and I decided at some point to insert a drop-down menu in a header component. Following the documentation template, my HTML looked like this:

However, when typing, I don't know where the right place to call jQuery is from the example, and I did it:

import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';

/* trecho omitido */
export class HeaderComponent implements OnInit {

  /* trecho omitido */

  ngOnInit() {
    $(document).ready(() => {

However, typecript does not recognize the drop-down function ( and the system does not perform the corresponding action. What should I do?

javascript – Call function in (evade access security to cross-origin objects)

Is there any way to avoid the cross-origin security error that appears when an iframe (domain A) on a page (domain yes) try to access properties of

I want to call a function, that is. someFunc, which belongs to domain B, through an event in the iframe of domain A, in the context of domain B.


    This is a fake text.


This example generates the following error in Firefox:
SecurityError: Permission denied to access property "someFunc" on cross-origin object

javascript – Enable / Disable buttons using JS and / or PHP

I have a query from which I get an array with PHP and MYSQL, each row must have a button, these rows I show them in an html table, what I want to do is enable button by button, that is, that the user does not access all the buttons, I want it to go in order, one by one.

Thanks in advance.

How to protect the JavaScript object?

I am creating a website for a real estate agency. And, right now I am using some JavaScript objects as data. However, my concern is how I protect it once the website is active. Like, anyone can see this data. Also, using JavaScript objects is a good way to do it?

How do I use JavaScript to upload files to a server?

I would like to know your favorite library to upload files such as videos, images, documents to a server

Multer? Formidable?

javascript – Error registering in a php, mysql, ajax form

I am trying to make a registration form with php, mysql and ajax.

The error is that the user does not register me in the database, I give all the parameters with the corresponding variables however it does not register anything in the database

I am using PDO, it happens that sending the submit via the button skips error and I do not understand why, thanks in advance = D

I also use google recaptcha, I have deleted the secret key for security reasons.
I would appreciate any suggestions to improve the security of the form!

PHP code:


require '../../config.php'; // datos de la base de datos, database data

function isNull($data){
    if (strlen(trim($data)) < 1) {
        return true;
    } else {
        return false;

function verifyPassword($pass1, $pass2) {
    if (strcmp($pass1, $pass2) !== 0) {
        return false;
    } else {
        return true;

function isEmail($email) {
    if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return true;
    } else {
        return false;

function registerUser($username, $email, $password, $btc_wallet, $user_type){
    global $con;
    $stmt = $con->prepare("INSERT INTO usuarios (username, email, password, btc_wallet, user_type) VALUES(:username, :email, :password, :btc_wallet, :user_type)");
    $stmt->bindParam(':username', $username, PDO::PARAM_STR);
    $stmt->bindParam(':email', $email, PDO::PARAM_STR);
    $stmt->bindParam(':password', $password, PDO::PARAM_STR);
    $stmt->bindParam(':btc_wallet', $btc_wallet, PDO::PARAM_STR);
    $stmt->bindParam(':user_type', $user_type, PDO::PARAM_STR);

    if ($stmt->execute()) {
        return $con->insert_id;
    } else {
        return 0;

if (!empty($_POST)) {
    $giveBack = ();
    $user_type = 2;
    $secretKey = "google_secret_key";
    introducir el código aquí
    $username = $_POST('username');
    $btc_wallet = $_POST('wallet');
    $email = strtolower($_POST('email'));
    $clave = $_POST('password');
    $con_password = $_POST('con_password');
    $captcha = $_POST('grecaptcha');

    $search_user = $con->prepare("SELECT * FROM usuarios WHERE username='$username' LIMIT 1");
    $search_user->bindParam(':username', $username, PDO::PARAM_STR);

    //if (!captcha) $giveBack() = "Por favor, verifica el captcha";
    if (isNull($username) || isNull($btc_wallet) || isNull($email) || isNull($clave) || isNull($con_password)) $giveBack() = "Por favor, completa todos los campos.";
    if (!isEmail($email)) $giveBack() = "Email invalido";
    if (!verifyPassword($clave, $con_password)) $giveBack() = "Las contraseñas no coinciden";
    if ($search_user->rowCount() == 1) {
        # Usuario ya existe, proceder a enviar un mensaje
        $giveBack('usernameError') = "Este usuario ya existe";
        $giveBack('isLogin') = false;

    if (count($giveBack) == 0) {
        $response = file_get_contents("$secret&response=$captcha");
        $arr = json_decode($response, TRUE);

        if ($arr('success')) {
            # Creamos el hash para el password
            $password = password_hash($clave, PASSWORD_DEFAULT);

            $register = registerUser($username, $email, $password, $btc_wallet, $user_type);

            if ($register > 0) {
                # Recuperando el id
                $user_id = $con->lastInsertId();
                $_SESSION('user_id') = (int) $user_id;
                $giveBack('redirect') = '';
                $giveBack('isLogin') = true;
            } else {
                $giveBack() = 'Error al registrar';
        } else {
            $giveBack('errorToCheckCaptcha') = 'Error al comprobar el captcha';
} else {
    exit("Fuera de aquí");


Javascript code:

const url = 'http://localhost/faucet_st/api/user/signup/process-signup.php';

var username = document.getElementById("username").value;
var wallet = document.getElementById("btc_wallet").value;
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
var con_password = document.getElementById("con_password").value;

var data = {
    username: username,
    wallet: wallet,
    email: wallet,
    password: wallet,
    con_password: con_password,
    grecaptcha: grecaptcha.getResponse()

    type: 'POST',
    url: url,
    data: data,
    dataType: 'json',
.done((res) => {
.fail((e) => {
.always(() => {});


I would be grateful if you could help me with this problem, I have tried to solve it all day, but I did not find a solution, I will continue looking for the solution, but I appreciate any help from you.

javascript: the annotations in chart.js don't work

Guys, I have a chart.js project. I'm trying to add a line with annotations, but it doesn't show, could you help me?
the only option property that doesn't work is the annotations

follow the code:

//gera o chart

var name2 = ();
    var marks2 = ();
    for (var i in dados) {
    var ctx = document.getElementById("REABERTOS").getContext("2d");

    var gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);

    gradientStroke.addColorStop(1, 'rgba(66,134,121,0.15)');
    gradientStroke.addColorStop(0.4, 'rgba(66,134,121,0.0)'); //green colors
    gradientStroke.addColorStop(0, 'rgba(66,134,121,0)'); //green colors

    var data2 = {
      labels: name2,
      datasets: ({
        label: "Data",
        fill: true,
        backgroundColor: gradientStroke,
        borderColor: '#00d6b4',
        borderWidth: 2,
        borderDash: (),
        borderDashOffset: 0.0,
        pointBackgroundColor: '#00d6b4',
        pointBorderColor: 'rgba(255,255,255,0)',
        pointHoverBackgroundColor: '#00d6b4',
        pointBorderWidth: 20,
        pointHoverRadius: 4,
        pointHoverBorderWidth: 15,
        pointRadius: 4,

        data: marks2,

    var myChart = new Chart(ctx, {
      type: 'line',
      data: data2,
      options: gradientChartOptionsConfigurationWithTooltipGreen
//fim gera chart

//options fica separado com o codigo a baixo:
gradientChartOptionsConfigurationWithTooltipGreen = {
      maintainAspectRatio: false,
      legend: {
        display: false

      tooltips: {
        backgroundColor: '#f5f5f5',
        titleFontColor: '#333',
        bodyFontColor: '#666',
        bodySpacing: 4,
        xPadding: 12,
        mode: "nearest",
        intersect: 0,
        position: "nearest"
      responsive: true,
      scales: {
        yAxes: ({
          barPercentage: 1.6,
          gridLines: {
            drawBorder: false,
            color: 'rgba(29,140,248,0.0)',
            zeroLineColor: "transparent",
          ticks: {
            suggestedMin: 50,
            suggestedMax: 125,
            padding: 20,
            fontColor: "#9e9e9e"

        xAxes: ({
          barPercentage: 1.6,
          gridLines: {
            drawBorder: false,
            color: 'rgba(0,242,195,0.1)',
            zeroLineColor: "transparent",
          ticks: {
            padding: 20,
            fontColor: "#9e9e9e"
      }, annotation: {
        annotations: ({
            type: 'line',
            mode: 'horizontal',
            scaleID: 'y-axis-0',
            value: '26',
            borderColor: 'tomato',
            borderWidth: 1
        drawTime: "afterDraw" // (default)


javascript – Fade-in and Fade-in video transition

Good afternoon Guys, I have a small problem that is already making me bald …

I am trying to create a kind of carousel with the thumbs where it is possible to move from an image to a video with a fading effect, when placing the mouse over the image, it disappears and the video appears.

Could someone help me by setting an example for me?

To facilitate my description, all this can be seen on the Netflix website, where the cursor over the latest series / movies viewed is exactly the model I am trying to do.

I enclose Netflix screenshots with a mouseout and mouseover on the thumb:

Thumb Yu-Gi-Oh! normal in mouseout:
With mouseout

Thumb Yu-Gi-Oh! with mouseover:
With the mouseover

javascript: get the drupal7 field value in the viewer.js file (from pdf.js)

I created password protected pdf files. They are loaded into drupal7 and the password is saved in a pdf_password field in drupal.
I would like the pdf to open them with pdf.js without having to ask for the password. For this, I need to get the value of the pdf_password field password in the file libraries / pdf.js / web / viewer.js: instead of 123 to get the value of the pdf_password field password:

parameters.password = '123';

(pdf.js is the Mozilla pdf.js project)

javascript – How to get the email address of the users of the person or group field – using CSOM

To obtain the user's email address or username, you must use web.ensureUser() method and then get the email or login name as follows:


Reference: Retrieve the size and email of the person or group list field in SharePoint

Solution for you:

Then, for your case, you can use its function in this way:

function FunctionToReturnEmailAddress(employeeName) {
    var user = clientContext.get_web().ensureUser(employeeName);

            // successfully ensured user from user name
            var email = user.get_email();
            var login = user.get_loginName();
            var displayName = user.get_title();
            alert("User LoginName: " + login + "nUser Email: " + email + "nUser Display Name: " + displayName);
        },function(sender,args){ // on error