javascript – script or command to close the program that runs the web page in js, php, or any other way?

I'm creating a new program that runs in PHP and opens every HTML, PHP and js file as a browser. The problem is that I want to know if there is any way to close the program with js, php or any other way I want the program to be fun in fullscreen mode and the users click it with a click of a button close the HTML file.

Javascript – How can I use vuex-map fields in a single JS file?

For a variety of reasons, I can not use either the ES6 module import or the VUE-CLI compiler for a project I'm working on. Therefore, I use both Vue and Vuex via CDN tags on a static HTML web page.

Vue and Vuex are working fine, but I'm having a problem trying to get Vuex map boxes to work with Vuex.

I tried to copy the functions from the module, i. H. To insert it directly into my JS script:

function arrayToObject(fields = ()) { ... }
function normalizeNamspace(fn) { ... }
function getField(state) { ... }
function updateField(state, { path, value }) { ... }
const mapFields = normalizeNamespace((namespace, fields, getterType, mutationType) => { ... }
const mapMultiRowFields = normalizeNamespace((namespace, paths, getterType, mutationType,) => { ... }
const createHelpers = ({ getterType, mutationType }) => ({ ... }

Then for my shop:

const store = new Vuex.Store({
strict: true,
state: {
    data: {}
},
getters: {
    getField
},
mutations: {
    updateField
}
})

And my component:

computed: {
...mapFields((
'data.item1',
'data.item2',
'data.item3',
'data.item4'
))
}

Unfortunately, I only get one mistake

(Vue warn): Failed to generate render function:
ReferenceError: Invalid left-hand side in assignment in
with(this){return _c( ... and here's the entirety of my Vue app object notation ... )

Is that repairable?

Javascript – Axios get network errors

I'm taking part in a Reaction Course for native speakers, but since Genymotion was not running on my computer, I had to improvise and download BlueStacks to debug the projects. The problem is that my program always issues a network error when inquiring from the internet. I use the axes.

The complete error is as follows:

I searched everywhere I could, but I did not find anything to solve this problem.

edit: had forgotten to set the code

main.js:

import React, { Component } from 'react';
import api from '../services/api';

import { View, Text } from 'react-native';

export default class Main extends Component {
    static navigationOptions = {
        title: 'JSHunt'
    };

    componentDidMount() {
        this.loadProducts();
    }

    loadProducts = async () => {
        const response = await api.get('/products');

        //const { docs } = response.data;

        //console.log(docs);
    };

    render() {
        return (
            
                Página Main
            
        );
    }
}

api.js

import axios from 'axios';

const api = axios.create({
  baseUrl: 'https://rocketseat-node.herokuapp.com/api'
});

export default api;

Javascript – Use the Dropbox API to retrieve the latest file from the Github Pages site

I am currently trying to use the Dropbox API in a Github Web site to retrieve the most recent file in Dropbox and use its title to change the CSS background color. However, I can not figure out how to write the js to use the Dropbox API. I have the access token that I replaced in the code I specified with Insert_Access_Token_Here. The following is a test that should print my files in the console, but not. Can anyone tell me from scratch how to use the Dropbox API to at least get the name of the latest file? Many thanks


The error message I keep getting in the console is

net :: ERR_ABORTED 404

javascript error: Unable to contact & # 39; formGroup & # 39; bind, since there is no known property of & # 39; form & # 39; is

I'm creating an app in IONIC V 4

In the form using FormBuilder, I added the tag (formGroup). Two errors have occurred:

  

Error message vs code

and the other:

Enter image description here

The component (register.page.ts) looks like this:


    import { User } from './../../../models/user';
    import { Component, OnInit, Input } from '@angular/core';
    import { ModalController, NavController } from '@ionic/angular';
    import { LoginPage } from '../login/login.page';
    import { AuthService } from 'src/app/services/auth.service';
    import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
    import { AlertService } from 'src/app/services/alert.service';

    @Component({
      selector: 'app-register',
      templateUrl: './register.page.html',
      styleUrls: ('./register.page.scss'),
    })
    export class RegisterPage implements OnInit {
      formRegister: FormGroup;

      constructor(
        private modalController: ModalController,
        private authService: AuthService,
        private navCtrl: NavController,
        private alertService: AlertService,
        private formBuilder: FormBuilder
      ) {  }

      ngOnInit(): void {
       this.formRegister = this.formBuilder.group({
          username: ('', (Validators.required, Validators.minLength(4))),
          email: ('', (Validators.required, Validators.email)),
          password: ('', (Validators.required, Validators.pattern('(?=.*(a-z))(?=.*(A-Z)).{6,}')))
        });
      }

      register() {
        this.authService.register(this.formRegister.value)
        .subscribe(data => {
            this.authService.login(this.formRegister.value)
            .subscribe((res) => { console.log(res); },
              error => {
                console.log(error);
              },
              () => {
                this.dismissRegister();
                this.navCtrl.navigateRoot('/dashboard');
              }
            );
            // tslint:disable-next-line:no-string-literal
            this.alertService.presentToast(data('message'));
          },
          error => {
            console.log(error);
          },
          () => { console.log('ok'); }
        );
      }

      }

The module (register.module.ts) looks like this:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { RegisterPage } from './register.page';
import { Routes, RouterModule } from '@angular/router';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';

const routes: Routes = (
  {
    path: '',
    component: RegisterPage
  }
);

@NgModule({
  imports: (
    IonicModule,
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forChild(routes)
  ),
  declarations: (RegisterPage)
})
export class RegisterPageModule {}


The app.module.ts looks like this:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

import { HttpClientModule } from '@angular/common/http';
import { NativeStorage } from '@ionic-native/native-storage/ngx';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';

@NgModule({
  declarations: (
    AppComponent
  ),
  entryComponents: ( ),
  imports: (
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
  ),
  exports: (ReactiveFormsModule),
  providers: (
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
    NativeStorage
  ),
  bootstrap: (AppComponent)
})
export class AppModule {}

What am I doing wrong?

Thanks in advance.

Javascript Tree Class – Code checking stack exchange

I got caught in the trap of implementing my own data structure. I'm mainly looking for advice on how to make this code more idiomatic, but also about features that may be missing in this class or that are not required. I also want to think about how idiomatic the traverse function is and if there is a better way to implement it.

function Node(value = 0, children = ()) {
    this.value = value;
    this.children = children;
    this.parent = undefined;
}

Node.from = function(node) {
    let that = Object.assign(new Node(), node);
    that.parent = undefined;
    that.children = node.children.map(n => (Node.from(n), n.parent = that));
    return that;
};

Node.prototype.add = function(...children) {
    for (child of children) {
        child.parent = this;
        this.children.push(child);
    }
};

Node.Traversal = {
    BreadthFirst: 1,
    DepthFirst: 2
};

Node.prototype.traverse = function(callback, mode = Node.Traversal.BreadthFirst) {
    if (mode == Node.Traversal.BreadthFirst) {
        let nodes = (this);
        while (nodes.length > 0) {
            const current = nodes.shift();
            callback(current);
            nodes = nodes.concat(current.children);
        }
    } else if (mode == Node.Traversal.DepthFirst) {
        callback(this);
        this.children.forEach(n => n.traverse(callback, false));
    }
    return this;
};

Node.prototype.reduce = function(callback, initial, mode) {
    let acc = initial;
    this.traverse(n => acc = callback(acc, n), mode);
    return acc;
};

Node.prototype.every = function(callback) {
    return this.reduce((a, n) => a && callback(n), true);
};

Node.prototype.some = function(callback) {
    return this.reduce((a, n) => a || callback(n), false);
};

Node.prototype.find = function(callback, mode) {
    return this.reduce((a, n) => a || (callback(n)? n: false), false, mode);
};

Node.prototype.includes = function(value) {
    return this.some(n => n.value === value);
};

Javascript – Error in the JQery form

I'm installing an admin template in Laravel that has a data submission wizard. The detail is that simply clicking on the form does not send the data. I do not understand javascript very well. I hope someone can guide me when I need something or it is wrong

The form works, but does not send anything to the database. First define the path:

Route::resource('empresas', 'EmpresasController');

Then create the form in which each input contains the "name" to be sent for the controller to receive. It has already been shipped with the template and customize it to my requirements:


                                                @csrf
                                                
                                                
{{ __('forms.Account_Details') }}
{{ __('forms.Indication_RS') }}
{{ __('forms.Indication_NC') }}
{!! Form::select('sector',$sectors,null,('class' => 'form-control', 'name' => 'sector','placeholder' => 'Selecciona', 'width' => '100')) !!} {{ __('forms.Indication_Sector') }}
{{ __('forms.Indication_CS') }}
3
{{ __('forms.Indication_Rfc') }}
{{ __('forms.Indication_Tel') }}
{{ __('forms.Indication_Email') }}
{{ __('forms.Title_Ubic') }}
{!! Form::select('country',$countries,null,('id'=>'country', 'class' => 'form-control kt-select2', 'name' => 'pais','placeholder' => 'Selecciona', 'width' => '100')) !!}
{!! Form::select('state',('placeholder'=>'Selecciona'),null,('id'=>'state', 'name' => 'estado', 'class'=>'form-control kt-select2')) !!}
{!! Form::select('town',('placeholder'=>'Selecciona'),null,('id'=>'town', 'name' => 'ciudad', 'class' => 'form-control kt-select2')) !!}
{!! Form::select('colony',('placeholder'=>'Selecciona'),null,('id'=>'colony', 'name' => 'colonia', 'class' => 'form-control kt-select2')) !!}
{{ __('forms.Indication_Direcc') }}
{!! Form::text('postalcode', null, ('id'=>'postalcode','value'=>'', 'name' => 'codigopostal', 'class' => 'form-control', 'disabled' => 'disabled')) !!}
{{ __('forms.Indication_Post') }}
{{ __('forms.Indication_Phone') }}
Previous
Submit
Next Step

Then the EmpresasController Controller looks like this:

middleware('auth');
    }
    /**
     * Display a listing of the resource.
     *
     * @return IlluminateHttpResponse
     */
    public function index()
    {
       //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return IlluminateHttpResponse
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  IlluminateHttpRequest  $request
     * @return IlluminateHttpResponse
     */
    public function store(Request $request)
    {
        $request->validate((
            'nombreempresa'=>'required',
            'nombrecomercial'=>'required',
            'idfiscal'=>'required|max:13',
            'tel' => 'required|numeric',
            'calleynumero'=>'required',
            'colonia'=>'required',
            'ciudad'=>'required',
            'estado'=>'required',
            'codigopostal'=>'required',
            'pais'=>'required',
            'sector'=>'required',
            'serial'=>'required',
        ));

        $empresa = new Empresa((
            'nombreempresa' => $request->get('nombreempresa'),
            'nombrecomercial' => $request->get('nombrecomercial'),
            'idfiscal' => $request->get('idfiscal'),
            'adminid' => auth()->id(),
            'tel' => $request->get('tel'),
            'calleynumero' => $request->get('calleynumero'),
            'colonia' => $request->get('colonia'),
            'ciudad' => $request->get('ciudad'),
            'estado' => $request->get('estado'),
            'codigopostal' => $request->get('codigopostal'),
            'pais' => $request->get('pais'),
            'email' => $request->get('email'),
            'acceso' => '1',
            'sector' => $request->get('sector'),
            'tipo' => '1',
            'sitioweb' => $request->get('sitioweb'),
            'serial' => 'XEVB-TBMN-KHKL-YB2JI89J',
            'wizard' => '1'
        ));
        $empresa->save();
        return redirect('/dashboard')->with('success', 'Gracias hemos recibido tu informacion!');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return IlluminateHttpResponse
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return IlluminateHttpResponse
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  int  $id
     * @return IlluminateHttpResponse
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return IlluminateHttpResponse
     */
    public function destroy($id)
    {
        //
    }
}

And that's the model:

And finally, this is the javascript code that gives the form the appearance and why they have an id with each input:

"use strict";

// Class definition
var KTWizard2 = function () {
    // Base elements
    var wizardEl;
    var formEl;
    var validator;
    var wizard;

    // Private functions
    var initWizard = function () {
        // Initialize form wizard
        wizard = new KTWizard('kt_wizard_v2', {
            startStep: 1,
        });

        // Validation before going to next page
        wizard.on('beforeNext', function(wizardObj) {
            if (validator.form() !== true) {
                wizardObj.stop();  // don't go to the next step
            }
        })

        // Change event
        wizard.on('change', function(wizard) {
            KTUtil.scrollTop();
        });
    }

    var initValidation = function() {
        validator = formEl.validate({
            // Validate only visible fields
            ignore: ":hidden",

            // Validation rules
            rules: {
                //= Step 1
                fname: {
                    required: true
                },
                lname: {
                    required: true
                },
                phone: {
                    required: true
                },
                emaul: {
                    required: true,
                    email: true
                },

                //= Step 2
                address1: {
                    required: true
                },
                postcode: {
                    required: true
                },
                city: {
                    required: true
                },
                state: {
                    required: true
                },
                country: {
                    required: true
                },

                //= Step 3
                delivery: {
                    required: true
                },
                packaging: {
                    required: true
                },
                preferreddelivery: {
                    required: true
                },

                //= Step 4
                locaddress1: {
                    required: true
                },
                locpostcode: {
                    required: true
                },
                loccity: {
                    required: true
                },
                locstate: {
                    required: true
                },
                loccountry: {
                    required: true
                },

                //= Step 5
                ccname: {
                    required: true
                },
                ccnumber: {
                    required: true,
                    creditcard: true
                },
                ccmonth: {
                    required: true
                },
                ccyear: {
                    required: true
                },
                cccvv: {
                    required: true,
                    minlength: 2,
                    maxlength: 3
                },
            },

            // Display error
            invalidHandler: function(event, validator) {
                KTUtil.scrollTop();

                swal.fire({
                    "title": "",
                    "text": "There are some errors in your submission. Please correct them.",
                    "type": "error",
                    "confirmButtonClass": "btn btn-secondary"
                });
            },

            // Submit valid form
            submitHandler: function (form) {

            }
        });
    }

    var initSubmit = function() {
        var btn = formEl.find('(data-ktwizard-type="action-submit")');

        btn.on('click', function(e) {
            e.preventDefault();

            if (validator.form()) {
                // See: srcjsframeworkbaseapp.js
                KTApp.progress(btn);
                //KTApp.block(formEl);

                // See: http://malsup.com/jquery/form/#ajaxSubmit
                formEl.ajaxSubmit({
                    success: function() {
                        KTApp.unprogress(btn);
                        //KTApp.unblock(formEl);

                        swal.fire({
                            "title": "",
                            "text": "The application has been successfully submitted!",
                            "type": "success",
                            "confirmButtonClass": "btn btn-secondary"
                        });
                    }
                });
            }
        });
    }

    return {
        // public functions
        init: function() {
            wizardEl = KTUtil.get('kt_wizard_v2');
            formEl = $('#kt_form');

            initWizard();
            initValidation();
            initSubmit();
        }
    };
}();

jQuery(document).ready(function() {
    KTWizard2.init();
});

I hope you can help me determine if something is missing or wrong. Note that changing the post method displays the message that the form has been sent. However, it is not registered in the database, and I'm not sure if a form is being sent using get.