Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. Take a look at these 3 classes:

     var EventDragging = /** @class */ (function (_super) {
            __extends(EventDragging, _super);//it seems this code sets the obj prototype
            function EventDragging(settings) {
                var _this = _super.call(this, settings) || this;
                //some props here
                _this.handlePointerDown = function (ev) {
                  
                };
                var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
                hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
    
                return _this;
            }
           
            return EventDragging;
        }(Interaction));
    
     var Emitter = /** @class */ (function () {
            function Emitter() {
                this.handlers = {};
                this.thisContext = null;
                 }
             Emitter.prototype.on = function (type, handler) {
                addToHash(this.handlers, type, handler);
            };
            Emitter.prototype.trigger = function (type) {//η select callback μαλλον πυροδοτειται απο εδω
                var args = [];
                for (var _i = 1; _i < arguments.length; _i++) {
                    args[_i - 1] = arguments[_i];
                }
             
                var attachedHandlers = this.handlers[type] || [];
                var optionHandler = this.options && this.options[type];
                var handlers = [].concat(optionHandler || [], attachedHandlers);
                for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
                    var handler = handlers_1[_a];
                    handler.apply(this.thisContext, args);//handler called here
                }
            };
         
            return Emitter;
        }());
    
     var HitDragging = /** @class */ (function () {
            function HitDragging(dragging, droppableStore) {
                var _this = this;
                this.handlePointerDown = function (ev) {
                _this.emitter.trigger('pointerdown', ev);//goes to  pointerdown method of EvenDragging Class
                };
               }
           };
            return HitDragging;
        }());

    Inside the EventDragging class a new Instance of HitDragging class is created....and a listener attached(on)...this patter is event/emitter patter from Node.js and since this is not node a polyfill is made-look at the on method inside the emitter class.

    The code for triggering the handlePointerDown method inside the EventDragging class is found inside the HitDragging class..in the trigger method call(also taken from the emitter class)

    The codebase I study has various instances of The HitDragging class-in the above example you see one of them

    Each time a different instance is accesed-the value of this references(depending on some factors) a different instance of the Htdragging class.

    Despite searching extensively I have not found the code responsible for this reference change.-furthermore there is nowhere a bind method or arrow function to set the reference accordingly.

    Keep in must that this code is an emulation of event emiiter patter(pub/sub) found in node.

    Node has native functions for the above(on/trigger method).

    Any idea as to where I shoud direct my search...a clue maybe.

  2. On top of my PHP scripts I have session checking code:

     

    if (!isset($_SESSION['regular_user'])) { 
    
         if ((isset($_COOKIE['cookiename']))) {// check for existense of persistent cookie (the user ticked the remember me option) 
            
        } else {
    
            header("Location: ../Frontend/login.php"); 
    
        }
    }

    I am using also Facebook Social Login(JS SDK)...and on every page I must check also if the user is connected to my App.

    Than means JS code-Facebook API request and ajax request to create sessions.

    Js cannot be placed on top of the page before PHP session code.

    What are my alternatives? 

    The only solution I have found so far is to put the ajax request/FB api call inside a PHP script that is required in the page

    that contains the above code...along w the HTML of course.

    What do you think?

  3. On 11/13/2021 at 8:40 AM, Ingolme said:

    Unfortunately, I don't fully understand it because I never put the time into researching it. It wasn't worth the trouble for me.

    It does seem kind of redundant to have to call setObjectPrototype() and then later manually assign the prototype. Perhaps you could try to search on Google for a clear explanation on how this technique works and why.

    Yes it seems redundant...but as you imply there is no point investigating further...since modern JS provides native inheritance functionality.

    And with the above our discussion is cncluded..thanks.

  4. I think yours answer explains things very good...there is one last point that I would like to be clarified cause it creates confusion to me.

    So inheritance in old JS is achieved with these 2 steps...

    If there is sth I do not understand is why to use setObjectPrototype in th first place...after testing the code it seems clear that the "bulk" of the work is done from the second part..(dymmy constructor etc).

    I just want some last comments on this...THX.

  5. well...object.setPrototypeof seems to work only w objects...but.

    I do not know if you are familiar with the extends pollyfill(it simulates class inheritance)....ES6 made it native https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends

    One post about _extends pollyfill is here https://stackoverflow.com/questions/45954157/understanding-the-extends-function-generated-by-typescript 

    Go where it says about Note 2.

    By reading it you will reach the conclusion that setPrototypeof accepts constructor functions as arguments which does not make sense...since as you said and according to mdn accepts only objects.

    WHat do you think?

     

  6. I am trying to use objectSetPrototype. here is the code w  2 classes

    var A = /** @class */ (function () {
        function A() {
        this.name='6';
        }
        A.prototype.test=function()
        {
        return 'john';
        };
        return A;
    }());
    
    var B = /** @class */ (function (_super) {
        function B() {
            return _super !== null && _super.apply(this, arguments) || this;
    
        }
        B.prototype.othertest=function(){return 'Anna'};
        
        return B;
    }(A));
    
    Object.setPrototypeOf(B,A);
    
    var testInheritance=new B();
    console.log(testInheritance.test());

    nonetheless testInheritance.test() does not print in the console "john" as it should...no inheritance taking place.

    I get the following mesaage in the console:

    Uncaught TypeError: testInheritance.test is not a function

    Furthermore:It is interesrting to see what B.prototype prints in the console

    https://1drv.ms/u/s!AjCBrCpLQye-ihUHb_9Ta5FLkDXp?e=FiIsAn

    Take a look at the red arrow it points to the [[prototype]] and confirms that f A() was set as prototype...nonetheless as already said inheritance is not taking place

    Cannot call test() which is a method f A-after instantiating B of course.

     

  7. take a look at this query...it has a series of AND clasues..pay attention to the 3rd commented..it sums up what I want to do.

    SELECT lastname,city FROM users
    INNER JOIN business_users
     ON business_users.user_ID=users.user_ID 
    WHERE   users.active=1  
    AND business_users.sched_entered =1 
    AND business_users.services_entered=1
    --and  business.users.staff_entered=1 only if business.users.sraff_enfaged_in_appt=1
     AND lastname LIKE  'p%';

    I want to ask as prerequisite business.users.staff_entered ONLY if business.users.sraff_enfaged_in_appt column is true.

    How I would go about achieving that?

  8. 1 hour ago, dsonesuk said:

    The user can enter whatever, But! what is shown that matches, for selection is predefined 

    Ok...I will put it this way in case I was not specific.

    The user might put whatever value he/she likes...even values not matching any value from the menu....and he leaves the value there in the input with no selection 

    making....that is undesirable but in the case of autocomplete scenarios we are examining probable..entering a custom value and NOT choosing from the menu.

    Unless I miss sth in the above logic.

     

    In case I confused you sorry...what I am trying to say is that I must find a way to enforce selection..that is the key here.

  9. 16 hours ago, dsonesuk said:

    What about a datalist or select dropdown of keywords that will sublist using datalist to the keyword selected.

    well...datalist seems to have some browser incosistencies plus the fact that it has the same drawback search like functionality....the user can enter whatever value he likes.

    The nice thing about select is that the user can only choose from predefined options but that bad thing is that it is not the best solution when a menu has many choices...in my case about 70. 

  10. there is one slight problem though with this "search like" feature.

    The user can enter an invalid value...a value not included in the medical specialties....whereas with a dropdown menu(select tag) he//she can only enter predefined(valid) values.

     

    Any workaround to the above problem?

  11. 25 minutes ago, niche said:

    php or an ajax call for the auto complete.

    I'd do a preselect by sub cat, if poss,  to knock that number down.

    65 too big a number based on experience.  Triggers people to walk away. I try to limit choice to 5 +/- 2 (span of control). 

    some clarifications....

    You said ajax call for the auto complete...kind like a search feature?...keyword is sent w ajax then query echo the results back.

    When you say to limit the choice....I suppose you mean what is actually seen by the user....the specialties are 65+ one way or the other.

    The results appearing(the specialties) must reflect the keyword...and when typing a keyword the user will see only the specialties starting from that keyword....which is less than 10. I do not see a problem with that.

    From the moment he starts typing the keyword in reality he/she never sees 65 options.

    I hope it is more clear now...what do you think?

     

  12. My user is a doctor who must choose what medical specialty he/she is..that said choose from 65+ options.

    So I must use a drop menu here(select tag).

    Q1:Do you think I sould use an autocomplete feature?

    Q2:Using an autocomplete feature or not...what do you think is the best implementation for the above scenario?

    Putting it more simple...how to go about implementing a dropdown list with about 65+ options.

    I have seen various implementation in the web but confused about which to choose about my use case.

     

    Thanks.

  13. I have a container with list items:

        <fieldset id="column_contai">
            <ul>
                <li>maria</li>
                <li>anthi</li>
                <li>Nikos</li>
               <li>maria</li>
                <li>anthi</li>
                <li>Nikos</li>
                 <li>maria</li>
                <li>anthi</li>
                <li>Nikos</li>
               <li>maria</li>
                <li>anthi</li>
                <li>Nikos</li>
            </ul>
                </fieldset>

    I want the height to be auto adjusted depending on the content and when it reaches a threshold(PX for example)...hide the rest and display a scrollbar.

    I know that the last one is a metter of overflow but I do not kbow how to achieve the first feature.

  14. I have a table that stores the hours of the week a business(hair salon for example) is open monday 11:00 to 18:00 tuesday etx so on so on

    CREATE TABLE `store_open` (
      `id` int NOT NULL AUTO_INCREMENT,
      `b_user_ID` mediumint unsigned DEFAULT NULL,
      `open_time` time DEFAULT NULL,
      `close_time` time DEFAULT NULL,
      `open_time_b` time DEFAULT NULL,
      `close_time_b` time DEFAULT NULL,
      `day` tinyint DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `b_user_ID` (`b_user_ID`),
      KEY `day_idx` (`day`),
      CONSTRAINT `day` FOREIGN KEY (`day`) REFERENCES `weekdays` (`dayID`)
    ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8

    the day foreign key refrences this table here..which holds the days of the week,

    CREATE TABLE `weekdays` (
      `dayID` tinyint NOT NULL AUTO_INCREMENT,
      `days` varchar(45) DEFAULT NULL,
      PRIMARY KEY (`dayID`)
    ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8

    QUESTION...

    I must also store the days where the business will be closed...do you think a separate table for that is needed?

    Which I assume this table will have a foreing key referencing the weekdays table....

    OR you think is better to add another column  to the store_open table(probably a boolean-closed or no closed)

    In that last scenario the days that the business will be closed the values of open_time,close_time(see the store open table create statement) will be set to null.

  15. On 4/15/2021 at 1:38 AM, Ingolme said:

    That should work, but it could be made more efficient if you store the column values in a variable declared outside of the loop. Is there a reason you replaced in_array() with array_search()?

    in_array does not search in multi-dimentional arrays...I did found some code to do it though but I avoided after all cause was more complex than the code above.

     

    Sorry for the late response.

  16. thanks for the answer,,,I just want your opinion in this code below since I wrote it BEFORE you answer.

    thanks again

       $i=0;
                               while($i<count($_POST['services'])){
                               if(array_search($_POST['services'][$i], array_column($serviceslist, "serviceID"))===false)
                                       {
                                         echo json_encode('nosuchservice');
                                         return;
                                       }
                                      $i++;  
                                    }

     

  17. I have 2 arrays

    $_POST['services'][0]);///this is '31'....but it can contain more than one value
    $serviceslist);...this is a multidimentional array array(1) { [0]=> array(2) { ["service"]=> string(7) "haircut" ["serviceID"]=> int(31) } }

    I tried the following code....but it does not work and the reason being it assumes that $servicelist is one-dimentional array.

     if (is_array($_POST["services"]))
               {
    
                  $i=0;
                while($i<count($_POST['services']))
                    { 
                        if ((in_array($_POST['services'][$i],$serviceslist))==false)
                                {
                         $error='nosuchservice';
                        echo json_encode($error);
                        return;
                    }
                    $i++;
                    }
    //            
                return;
               }

    how can I search in $secviselist for the values contained in $_POST['services'];

    The above code shoud output true since I do not use the strict paramaeter...31 exists in both.

    What adjustments I have to make?

  18. I have a JS datetime object such as this.

    start =Wed Mar 31 2021 09:00:00 GMT+0300 (Eastern European Summer Time)

    And I am using the localedatestring and localetimestring to format it.

     

     var startsend=info.start.toLocaleDateString() + 'T' + info.start.toLocaleTimeString('el-GR', { hour12: false });

    I do not undestand why console longing the above will produce a portion of the result date in a hyperlink format...

     

    stringdteHyperlink.png.b3bced6164ab82f97cfa2891c4af99fb.png

     

     

  19. now...when error callback of ajax request fires I just display a message to the user....but how am I going to be notified for the reason the request failed...I mean me the dev.

    Of course I have not intention showing technial details to the end user..the aim is that such info(must somehow reach me)..any suggestions?

×
×
  • Create New...