object oriented – OOP in Javascript with classes

I am learning OOP in Javascript and I have done two small projecs which i have uploaded onto Github. I would really appreciate it if someone checks out my code and sees if it is adequate enough. The links are below.

https://github.com/bobaram/flash-OOp-project
https://github.com/bobaram/course-form-OOP-project-

1.Flash-OOP-project

const showBtn = document.getElementById("show-btn");
const questionCard = document.querySelector(".question-card");
const closeBtn = document.querySelector(".close-btn");
const form = document.getElementById("question-form");
const feedback = document.querySelector(".feedback");
const questionInput = document.getElementById("question-input");
const answerInput = document.getElementById("answer-input");
const questionList = document.getElementById("questions-list");

class Card {
  constructor(question, answer) {
    this.question = question;
    this.answer = answer;
  }

  createCard() {
    const html = ` 
      <div class="col-md-4">
      <div class="card card-body flashcard my-3">
     <h4 class="text-capitalize">${questionInput.value}</h4>
     <a href="#" class="text-capitalize my-3 show-answer">show/hide answer</a>
     <h5 class="answer mb-3">${answerInput.value}</h5>
     <div class="flashcard-btn d-flex justify-content-between">
      <a href="#" id="edit-flashcard" class=" btn my-1 edit-flashcard text-uppercase" data-id="">edit</a>
      <a href="#" id="delete-flashcard" class=" btn my-1 delete-flashcard text-uppercase">delete</a>
     </div>`;
    questionList.insertAdjacentHTML("afterbegin", html);
    form.reset();
  }
}

class App {
  constructor() {
    showBtn.addEventListener("click", this.showButton.bind(this));
    closeBtn.addEventListener("click", this.closeButton.bind(this));
    form.addEventListener("click", this.checkpressed.bind(this));
  }
  showButton(e) {
    e.preventDefault();
    questionCard.classList.add("showItem");
  }

  closeButton() {
    questionCard.classList.remove("showItem");
  }
  checkpressed(e) {
    e.preventDefault();
    const newCard = new Card(questionInput.value, answerInput.value);
    let clicked = e.target;
    if (clicked.classList.contains("submitBtn")) {
      if (newCard.question.length == 0 || newCard.answer.length == 0) {
        feedback.classList.add("showItem", "alert-danger");
        feedback.textContent = "cannot add empty values";
        setTimeout(function () {
          feedback.classList.remove("alert-danger", "showItem");
        }, 3000);
      } else if (!newCard.question.length == 0 && !newCard.answer.length == 0) {
        newCard.createCard();
      }
    }
    if (questionList.innerHTML.length > 0) {
      questionList.addEventListener("click", function (e) {
        e.preventDefault();
        if (e.target.classList.contains("show-answer")) {
          e.target.nextElementSibling.classList.toggle("showItem");
        } else if (e.target.classList.contains("edit-flashcard")) {
          questionInput.value =
            e.target.parentElement.parentElement.firstElementChild.textContent;
          answerInput.value =
            e.target.parentElement.parentElement.firstElementChild.nextElementSibling.nextElementSibling.textContent;
          e.target.parentElement.parentElement.parentElement.remove();
        } else if (e.target.classList.contains("delete-flashcard")) {
          e.target.parentElement.parentElement.parentElement.remove();
        }
      });
    }
  }
}
const newApp = new App();

2.Course-form-OOP

const nameInput = document.querySelector("#name");
const courseInput = document.querySelector("#course");
const authorInput = document.querySelector("#author");
const customerList = document.querySelector(".customer-list");
const form = document.querySelector("#customer-form");

class Card {
  constructor(name, course, author) {
    this.name = name;
    this.course = course;
    this.author = author;
  }

  checkInputFields() {
    if (
      !this.author.length == 0 ||
      !this.name.length == 0 ||
      !this.name.length == 0
    ) {
      this.createCard();
    } else {
      return;
    }
  }

  createCard() {
    this.random = Math.trunc(Math.random() * 5 + 1);
    this.html = `
          <div class="col-11 mx-auto col-md-6 col-lg-4 my-3">
        
          <div class="card text-left">
          <img src="./img/cust-${this.random}.jpg" class="card-img-top" alt="">
          <div class="card-body">
           <!-- customer name -->
           <h6 class="text-capitalize "><span class="badge badge-warning mr-2">name :</span><span id="customer-name">${this.name}</span></h6>
           <!-- end of customer name -->
           <!-- customer name -->
           <h6 class="text-capitalize my-3"><span class="badge badge-success mr-2">course :</span><span id="customer-course">
             ${this.course}
            </span></h6>
           <!-- end of customer name -->
           <!-- customer name -->
           <h6 class="text-capitalize"><span class="badge badge-danger mr-2">author :</span><span id="course-author">${this.author}</span></h6>
           <!-- end of customer name -->
          </div>
         </div>
         </div>`;
    customerList.insertAdjacentHTML("afterbegin", this.html);

    form.reset();
  }
}

class App {
  constructor() {
    form.addEventListener("click", this.checkPressed.bind(this));
  }
  checkPressed(e) {
    e.preventDefault();
    this.newCard = new Card(
      nameInput.value,
      courseInput.value,
      authorInput.value
    );
    if (
      e.target.classList.contains("submitBtn") &&
      this.newCard.checkInputFields()
    ) {
      this.newCard.checkInputFields();
    } else {
      delete this.newCard;
    }
    console.log(this.newCard);
  }
}

const run = new App();

How would the classes of regular, context-free, decidable, and Turing-recognizable languages relate to each other

I’m a bit confused as to how they relate to each other. I think I understand them individually but not sure how they would relate.

google sheets – If I set the school to “School A” then only School A’s classes should be visible

I have created a progress tracker for the Academy Trust I work in. The trust at the moment consist of 4 schools. Students move between the schools as the progress and between classes during the year depending on their abilities and needs. when a student move his/her tracking data needs to move to the correct class because teachers does not want to search.

My idea is to just change the class and then the students whole data row should move automatically to the correct class on another sheet.

The first thing I need to do is to be able to select the class from a drop down list but the list must be linked to the school. So if I set the school to “School A” then only School A’s classes should be visible. The same for school B,C and D.

The Script I tried is below.
It is not working and due to the fact that I do not know anything about Scripts I do not know how to fix this problem. I got the Script from Youtube and tried to edit it to fit my workbook.

function onEdit(){
  var tabLists = "lists";
  var tabValidation = "w1";
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("lists")

  var activeCell = ss.getActiveCell();

  if(activeCell.getColumn() == 1 && ActiveCell.getRow() > 1 && ss.getSheetName() == tabValidation){
    activeCell.offset(0,1).clearContent().clearDataValidations()

    var Sites = datass.getRange(1,6,datass.getLastColumn()).getvalue();

    var makeIndex = makes(0).indexOf(activeCell.getValue()) +1;
    if(makeindex != 0){

        var validationRange = datass.getRange(3, makeIndex, datass.getLastRow());
        var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
        activeCell.offset(0, 1).setDataValidation(validationRule);



    }
  }
    } 

magento2 – Magento 2: Pass data between classes

I’m trying to pass the data between 2 classes. One of them called via ObjectManager.
Here’s the schema and short explanation.
ParseFormstackForm class called from the frontend form (Block) with regular construct() method. ParseFormstackForm calls API of 3rd party service, receive data which is used in the form and also needed to be saved (field mapping) and to be reused later in another class. Form renders in the frontend. The user fills it in and clicks submit. Controller Save calls DataTransmitter class (via ObjectManager) to pass the data for another service. And at that moment I need to use saved mapping. However, the registry is empty at that moment.
What could be the issue?

enter image description here

C#, design classes to be scalable

I’m creating an inventory management system, in which the program needs to handle a lot of different equipment, with the possibility for the product owner to increase the selection, without having to change the code.
Some of the products that might need to be included in the application is:

  • Transistors
  • Wires
  • Drones
  • RaspberryPie
  • Chargers
  • 360 degree camera

So far the only solution I’ve been able to come up with is:
enter image description here

But right off the bat I see a lot of problems, mainly what if product owner wants to add a 360 degree camera? He would need to physically edit the codebase in order to create that item, also the serial number property repeats itself, which I don’t think is optimal.

My first thoughts was just having an Item model, that included all the properties. But that seems like a waste of attributes?
My second thought was using the strategy pattern, but I have a hard time picturing how I can apply it to this diagram.

My question is, how do I make this scalable?

Taking Away Advanced Classes in the name of Equity? | Forum Promotion

IMO, they are dumbing down our society. Some people are good at math & should be able to take advance courses. If they are stuck in beginner classes, they won’t live up to their full potential, be bored, not challenged.
I always tell people I believe in Equal not More rights. This is not equality but rather the less advanced students have MORE rights.
These same kids won’t learn hard work. Getting stars for participating is making them, what’s a good term, crybabies? The real world doesn’t work that way.

 

object oriented – Base class with different logic for sub classes

Currently I have two different (A,B) classes which basically share common logic but also one of them (let’s say class A) have special additional logic. Class A pretty much contains B’s logic. I want to unite them into one base class.I thought about doing one base class which will contain all the logic, and have two sub classes which will define a flag whether or not should we execute the special logic I mentioned and then I can check this in the base class.
I guess I can also have a base class containing B’s logic (the more specific one) and then extend it to another sub class which will implement the special logic. Wanted to hear pros and cons or any other ideas that might come up. Thanks !

theming – Remove CSS classes when not logged-in

theming – Remove CSS classes when not logged-in – Drupal Answers

javascript – Css className has low specifity than css classes from material-ui v5

When using IconButton from @material-ui/core for example in my react app, I applied a className classes.myCloseButtonstyle, turns out it has low specificity compared to css classes .css-1743419-MuiButtonBase-root-MuiIconButton-root (see screenshot below).

extra material-ui classes

When I checked the doc here https://next.material-ui.com/components/dialogs/#customized-dialogs
the order is different than what I got in above screenshot. the classes.myCloseButtonstyle has higher specificity than this .css-1uaxfgw-MuiButtonBase-root-MuiIconButton-root classes

what could possibly wrong in my react material ui setup, tho? I need to make the classes.myCloseButtonstyle win the specificity

icon button from official material-ui v5

magento2 – Magento is not generating factory classes

I am trying to create custom table in a plugin and trying to write model classes for it. Custom database tables is successfully generated. However I am struggling to let magento auto generate model factory classes.

When bin/magento setup:di:compile command is executed only Interceptor.php file is generated and not Factory class.

Model interface

<?php
namespace CompanyOrderListenerApiData;

interface CustomOrderModelInterface {

    const ID           = 'id';
    const ORDERID      = 'orderId';
    const PROCESSED    = 'processed';

    //Getter & Setter interface definitions
}

Model class

<?php
namespace CompanyOrderListenerModel;

use CompanyOrderListenerApiDataCustomOrderModelInterface;
use MagentoFrameworkModelAbstractModel;
use MagentoFrameworkDataObjectIdentityInterface;

/**
 * Undocumented class
 */
class CustomOrderModel extends MagentoFrameworkModelAbstractModel implements CustomOrderModelInterface , IdentityInterface {
    const CACHE_TAG = 'orderlistener_custom_order_model';

    /**
     * Model cache tag for clear cache in after save and after delete
     *
     * @var string
     */
    protected $_cacheTag = self::CACHE_TAG;

    /**
     * Prefix of model events names
     *
     * @var string
     */
    protected $_eventPrefix = 'custom_order_model';

    /**
     * Initialize resource model
     *
     * @return void
     */
    protected function _construct()
    {
        $this->_init('CompanyOrderListenerModelResourceModelCustomOrderModel');
    }

    //Getters and Setters
}

Resource Model class

<?php
namespace CompanyOrderListenerModelResourceModel;

class CustomOrderModel extends MagentoFrameworkModelResourceModelDbAbstractDb {
    
    /**
     * Initialize resource model
     *
     * @return void
     */
    //custom_order is custom table and id is primary key 
    protected function _construct()
    {
        $this->_init("custom_order","id");
    }

    public function __construct(MagentoFrameworkModelResourceModelDbContext $context)
    {
        parent::__construct($context);
    }
}

Collection class

<?php
namespace CompanyOrderListenerModelResourceModelCustomOrderModel;

class Collection extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection {

    public function __construct() {
        $this->_init('CompanyOrderListenerModelCustomOrderModel',
        'CompanyOrderListenerModelResourceModelCustomOrderModel');
    }
}

Most of the guides and magento documents suggest to create these files and use auto generated factory class to persist/access data to/from custom database tables in plugin. However factory class are not auto generated with both bin/magento setup:di:compile and bin/magento setup:upgrade commands.

Does some definitions needs to be done in di.xml for this to work?

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123