#StackBounty: #javascript #jquery #html #tooltip Tooltip showing hidden values in table format on hover

Bounty: 50

My site is set up in the following way:

4 user groups. Each user group can see different information. An example would be stock quantity for a store. So the user from London can’t see the stock availability for Manchester. This information is taken from the database for EACH item in stock. So if you have a list of 20 items, their individual values will be displayed.

I would like to do the following:

If I, or anyone I give permission to, hovers over the “In Stock” columm for their own store, a tooltip table must appear showing the current stock levels for the 3 other stores, for each individual product. So if I hover over item SKU-001, I will only see the stock availability for that item. I had an issue where it was displaying the whole list for each item.

I was thinking of this:

<table>
<tr>
<th>Store1></th>
<th>Store2></th>
<th>Store3></th>
<th>Store4></th>
</tr>
<?php foreach($this->products as $product) { ?>
<tr>
<td id="stock1" title="myFunction">Stock of Item 1st store</td> *If I hover/mouseover here, another table must appear showing only store name and values of "#stock2, #stock3 and #stock4* for the stock item I am hovering on.
<td id="stock2">Stock of Item 2nd store</td>
<td id="stock3">Stock of Item 3rd store</td>
<td id="stock4">Stock of Item 4th store</td>
</tr>
<?php } ?>
</table>

Here is some code I wrote:

function myFunction() {
var x = document.createElement("TABLE");
x.setAttribute("id", "table10");
document.body.appendChild(x);

var y = document.createElement("TR");
y.setAttribute("id", "myTr");
document.getElementById("myTable").appendChild(y);

var z = document.createElement("TD");
var t = document.getElementByID("riyadhbalance").value();
z.appendChild(t);
document.getElementById("myTr").appendChild(z);

However, for some reason this is not working. I have not found a way to include a tooltip. All the stock values are there for each individual item, so I just need to find a way to add the 3 values for the other stores and display them in a table format via a tooltip. That would be ideal.

So basically the tooltip should show the 3 values of the stores which are currently not on display, as the other 3 values are hidden. The user can only see their store’s stock levels. But I would like to include this for myself as it would make it easier to view stock levels across the board.


Get this bounty!!!

#StackBounty: #javascript #jquery #instagram #instagram-api #instafeedjs instafeed.js stopped working: The access_token provided is inv…

Bounty: 200

I am using instafeed.js like so:

var feed = new Instafeed({
        get: 'user',
        userId: 19191919191,
        limit: 9,
        accessToken: 'myaccesstokenhere',
        target: 'instagram',
        resolution: 'standard_resolution',
        after: function() {
            var el = document.getElementById('instagram');
            if (el.classList)
                el.classList.add('show');
            else
                el.className += ' ' + 'show';
        }
});

but I am getting this error:

The access_token provided is invalid.

I got the access_token by https://www.instagram.com/developer I registered my application and put the Client Secret as the accessToken and I got my userID from here https://smashballoon.com/instagram-feed/find-instagram-user-id/

but its still saying The access_token provided is invalid. what am I doing wrong?


Get this bounty!!!

#StackBounty: #javascript #jquery #html #spring-boot #thymeleaf app context lost when changing the location in Thymeleaf

Bounty: 50

I have this piece of code in a Thymeleaf template, but I lose the application context when I am redirected

 $('#selectAuthorizedDriverId').change(
   function() {
      var link = "/deviceDriver/updateauthorizeddriver/" + $(this).val();
      $(location).attr('href',link);
}); 

This piece of code redirect the browser to the link, but without the application context, so I got a 404.
To avoid this problem I normally use

var link = /*[[@{/deviceDriver/updateauthorizeddriver/}]]*/ + "";

and it works, but since here I’ve tried

var link = /*[[@/deviceDriver/updateauthorizeddriver/}]]*/ + $(this).val() "";

but it has not worked

The URL I see is

http://127.0.0.1:1234/deviceDriver/updateauthorizeddriver/

and the URL valid should be

http://127.0.0.1:1234/driversApp/deviceDriver/updateauthorizeddriver/


Get this bounty!!!

#StackBounty: #jquery #ios #mobile-safari How to programatically focus on a textfield on page load for mobile safari?

Bounty: 200

Background

I am developing a standalone web app for iPod Touch. One of my requirements is to focus on a textfield when a page loads so that a user can do a task continually (e.g. with a barcode reader).

Problem

The problem is that it does focus on the text field in question, but the keyboard does not go up. Is there a workaround for this? Or is this by design by Apple?

Sample Html

I’m unsure on how to put this into a code snippet, but this is where I’ve been experimenting on:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0.0">

    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="apple-touch-icon" href="https://cdn57.androidauthority.net/wp-content/uploads/2016/06/android-win-2-300x162.png">

    <title>TESTING</title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    https://code.jquery.com/jquery-3.2.1.min.js
    https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js

    
        // javascript goes here
    
</head>
<body>

    <section id="content">

        
Testing textfield focus
</div> </form> </div> </section> </body> </html>

I view this on Safari, then add it to the homescreen so that it would act as a standalone web app.

Attempts

I tried searching around for solutions, the first one(I lost the link) suggested to try timeouts like so:

$(function () {
    var firstResponder = $(".first-responder");
    setTimeout(function() {
        firstResponder.focus();

    }, 1000);

})

Another of the solutions I found suggested to set the selection range like so:

$(function () {
    var firstResponder = $(".first-responder");
    setTimeout(function() {
        firstResponder[0].setSelectionRange(0, 9999);

    }, 1000);

})

There was also a suggestion to bind it to a click like so:

$(function () {
    var firstResponder = $(".first-responder");
    firstResponder.on('click', function() {
        firstResponder.focus();
    });

    firstResponder.focus().click();
})

I also tried triggering a touchstart like so:

$(function () {
    var firstResponder = $(".first-responder");
    firstResponder.on('touchstart', function() {
        firstResponder.focus();
    });

    firstResponder.trigger('touchstart');
})

I also tried with a simple ajax call like so (don’t mind the success/error. All I wanted to do was focus after ajax call):

function doAjax() {
    var firstResponder = $(".first-responder");

    $.ajax({
        url: "#",
        method: "POST",
        dataType: "json",
        success: function(result) {
            firstResponder.focus();
        },
        error: function(request, error) {
            firstResponder.focus();         
        }
    });
}

I got kind of desperate so I tried setting some css too:

user-select: text;
-webkit-user-select: text;

These solutions worked on iOS 9.1 (except the css one) but all of them failed on iOS 11.1.1. I tried combining various solutions, setting timeouts, etc. but none seem to work. As I noted, it does focus because I can see that the textfield’s borders turn blue, signifying that it has focus. But I need to have the keyboard displayed too.

This behavior seems to be either a bug or a usability/security feature. If this is by design (i.e. a security feature), is there an official documentation by Apple that talks about this?

Addendum

If you think that the barcode reader might be the problem, this is not true. In the project I’m working on, the barcode reader replaces the native keyboard. In theory, even without the barcode, as long as I am able to bring up the keyboard on page load, I should be able to fulfill my requirement.

Continuous task is possible because the barcode reader can include an Enter key after the barcode it reads, thereby submitting the form the textfield is on. After the page reloads, if the textfield gets automatically focused, all the user needs to do is read another barcode. The page submits again, reloads, autofocuses, and the cycle can be repeated.


Get this bounty!!!

#StackBounty: #php #jquery #ajax #curl Send ajax request through CURL

Bounty: 50

An API request needs to be sent. For some reason, the server is blocking CURL request, but it approves an XHR ajax request. I could send an ajax request, but another problem arises – Mixed content my website is served over HTTPS but the request that needs to be sent is over HTTP so I cannot use ajax.

I am looking for a way to simulate ajax request through CURL, in some way, trick the server to believe that the CURL request is indeed an ajax request.

Here’s what I have tried.

This is my CURL request.

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64)');
curl_setopt($ch, CURLOPT_REFERER, 'server's url');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Accept:application/json, text/javascript, */*; q=0.01',
    'Accept-Encoding:gzip, deflate',
    'Accept-Language:en-US,en;q=0.9',
    'Connection:keep-alive',
    'Content-Type: application/json; charset=utf-8',
    'X-Requested-With: XMLHttpRequest',
    '__RequestVerificationToken: $token'
    ));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, base_path().'/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, base_path().'/cookies.txt');
$buffer = curl_exec($ch);
if(curl_error($ch))
{
    $buffer =   curl_error($ch);
}
curl_close($ch);

return $buffer;

This curl request is blocked

But, this ajax request goes through my localhost, but since my live website uses HTTPS I cannot really use it.

$.ajax({
    type: "get",
    xhrFields: { withCredentials:true },
    url: http://apiendpoint.com,
    success: function(data)
    {
      // console.log(data);
    }
})

Actually, the response received through CURL and ajax is different.


Get this bounty!!!

#StackBounty: #javascript #jquery #methods #swiper Swiper – methods won't work – mySwiper.slideTo is not a function

Bounty: 50

im using the swiper plugin, but can’t seem to get any methods to work.

my jQuery and swiper are added like this:

http://jquery-3.2.1.min.js
<script src="swiper.jquery.js" type="text/javascript">

at the bottom of my html.
my swiper is initialized like this in document ready:

mySwiper = new Swiper('.swiper-container', {
  direction: 'horizontal',
  nextButton: '.swiper-button-next',
  prevButton: '.swiper-button-prev',
  pagination: '.swiper-pagination',
  paginationType: 'fraction',
  grabCursor: true,
  keyboardControl: true,        
  onSlideChangeStart: function (){

    $('video').each(function() {  
        $(this)[0].pause();
    });

    $(".swiper-slide-active video").each(function() {  
        $(this)[0].play();
    });
        if ($(".swiper-slide-active").hasClass("layout4"))
        {
            video_visible = 1;
            $(".section").css("background-color", "black");
            $("body").css("color", "white");
            $(".swiper-button-prev").css("background-image", "url(img/leftArrowW.png)");
            $(".swiper-button-next").css("background-image", "url(img/rightArrowW.png)");
            $(".swiper-button-prev").css("opacity", "0.25");
            $(".swiper-button-next").css("opacity", "0.25");
            $(".headline").css("opacity", "0.25");
            $(".swiper-pagination").css("opacity", "0.25");
        }
        else {
            video_visible = 0;
            $(".section").css("background-color", "white");
            $("body").css("color", "black");
            $(".section .swiper-button-prev").css("background-image", "url(img/leftArrow.png)");
            $(".section .swiper-button-next").css("background-image", "url(img/rightArrow.png)");
            $(".swiper-button-prev").css("opacity", "1");
            $(".swiper-button-next").css("opacity", "1");
            $(".headline").css("opacity", "1");
            $(".swiper-pagination").css("opacity", "1");
        }
      if ($(".swiper-slide-active").hasClass("layout7"))
        {
            $(".layout7").css("background-color", "#e0e8eb");
        }

  },
  loop: true ,
});    

and the function i want to call is:

$('.section .down').waypoint(function(direction){
    if ($(".swiper-slide-active").hasClass("layout4")){
        if (direction == 'down') {
            if (!once_d){

                mySwiper.slideTo(1,100,false);

                $(".section").css("background-color", "white");
                $("body").css("color", "black");
                $(".swiper-button-prev").css("background-image", "url(img/leftArrow.png)");
                $(".swiper-button-next").css("background-image", "url(img/rightArrow.png)");
                $(".swiper-button-prev").css("opacity", "1");
                $(".swiper-button-next").css("opacity", "1");
                $(".headline").css("opacity", "1");
                $(".swiper-pagination").css("opacity", "1");
                $('video').each(function() {  
                $(this)[0].pause();
                });
                video_visible = 0;
                once_d = true;
            }
            else{
                return;
            }
        }
    }
}, { offset: "-25%" });

the error i get is:

Uncaught TypeError: mySwiper.slideTo is not a function
at Waypoint.$.waypoint.offset [as callback]

this happens , no matter what method i’m trying to execute.
i tried with

mySwiper.update();

aswell.

i’m suspecting the error might come from my swiper/jQuery files, but i also tried redownloading.

thanks in advance


Get this bounty!!!

#StackBounty: #javascript #jquery #html5-canvas #getimagedata #drawingcontext Javascript ImageData Drawing Is Scaling Incorrectly

Bounty: 50

The idea of the program is to have an image of a map and to overlay a black canvas on that map. Then the user will click on some part of the canvas and, similar to a spray paint tool, the pixels near the mouse will become transparent on the canvas. Thus, the map will be shown (like a fog of war type feature). When I click near the top left of the canvas the spray paint works sort of as intended but as I click further right and down the canvas the pixels that get turned transparent are way further right and down… Any idea what is wrong here? Here is the code:

// On document ready function.
$(document).ready(function() {
  canvas = document.getElementById("myImageDisplayerCanvas");
  drawingContext = canvas.getContext("2d");
  drawingContext.fillStyle = "#000000";
  drawingContext.fillRect(0, 0, 800, 554);
});

// Spray paint logic.
var _intervalId, // used to track the current interval ID
  _center, // the current center to spray
  density = 10,
  radius = 10,
  drawingCxt,
  leftClickPressed,
  drawingContext,
  canvas;

function getRandomOffset() {
  var randomAngle = Math.random() * 360;
  var randomRadius = Math.random() * radius;

  return {
    x: Math.cos(randomAngle) * randomRadius,
    y: Math.sin(randomAngle) * randomRadius
  };
}

this.startDrawing = function(position) {
  _center = position;
  leftClickPressed = true;
  // spray once every 10 milliseconds
  _intervalId = setInterval(this.spray, 10);
};

this.moveDrawing = function(position) {
  if (leftClickPressed) {
    clearInterval(_intervalId);
    _center = position;
    // spray once every 10 milliseconds
    _intervalId = setInterval(this.spray, 10);
  }
}

this.finishDrawing = function(position) {
  clearInterval(_intervalId);
  leftClickPressed = false;
};

this.spray = function() {
  var centerX = parseInt(_center.offsetX),
    centerY =
    parseInt(_center.offsetY),
    i;

  for (i = 0; i < density; i++) {
    var offset = getRandomOffset();
    var x = centerX + parseInt(offset.x) - 1,
      y = centerY +
      parseInt(offset.y) - 1;
    var dy = y * 800 * 4;
    var pos = dy + x * 4;
    var imageData = drawingContext.getImageData(0, 0, 800, 554);
    imageData.data[pos++] = 0;
    imageData.data[pos++] = 0;
    imageData.data[pos++] = 0;
    imageData.data[pos++] = 0;
    drawingContext.putImageData(imageData, 0, 0);
  }
};
https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js


Get this bounty!!!

#StackBounty: #jquery #datatables jQuery Datatables – pre filter specific table column based on url value

Bounty: 50

Using jQuery Datatables, is it possible to search a specific column only on page load based on url value?

for example if the url ends with live, then filter the table column Is live (which is index 4 in this sample?)

url = "website.com/circuits/live"
if ("url ends with live"){ 
    $('#circuit_list').DataTable({
        column index 4 filter "Live"
     })
}

here is the table sample

<table width="100%" class="table table-striped table-bordered table-hover dataTable no-footer dtr-inline" id="circuit_list" role="grid" style="width: 100%;">
<thead>     
    <tr>
        <th>&nbsp;</th>
        <th>Circuit</th>
        <th>Location</th>
        <th>Name</th>
        <th>Is Live</th>
        ...
    </tr>   
</thead>
<tbody>
    <tr>
        <td>EDIT</td>
        <td>DSL</td>
        <td>Liverpool</td>
        <td>Bills DSL</td>
        <td>Not Live</td>
        ...
    </tr>
        <tr>
        <td>EDIT</td>
        <td>DSL</td>
        <td>Manchester</td>
        <td>Bobs DSL</td>
        <td>Live</td>
        ...
    </tr>
    ...
</tbody>
</table>


$(document).ready(function() {
    $('#showroom_list').DataTable({
        "pageLength": 30,
        responsive: true
    });

});


Get this bounty!!!

#StackBounty: #javascript #jquery #html #css #google-chrome Chrome scrollbar disappears (not overflow-y)

Bounty: 50

The page (live-version) consists (roughly) of three parts:

  • Left sidebar
  • Centered content
  • Right sidebar

Right sidebar should be scrollable, so I’ve set overflow-y: scroll; right: -17px; to simply hide the scrollbar. Body, html have overflow-y: auto;. This way I don’t have to have two scrollbars (for page and for right sidebar).

ISSUE:
(only in CHROME, tested on version 62 and 63)

For some reason on different machines, chrome gives me two different styles for the scrollbar: Case 1 and Case 2.

So basically, for case 1 the the right sidebar scrollbar is “absolutely positioned” and page hides 17px of itself because of that, whilst for case 2 the scrollbar is “relatively positioned” and the page hides 17px that the scrollbar takes.

QUESTION

1) Why scrollbars are different on the same OS and browser version, but different machines ?

2) Is there any way to fix this without any plugins ? Taking into consideration Windows users have the case 2 and MacOS users either case 1 or 2 ?


Get this bounty!!!

#StackBounty: #custom-field #jquery #query #search #sort sort search results by custom fields using dropdown

Bounty: 100

On my search.php page, I have a “Sort By” dropdown that almost works exactly how I want it to —

<select class="dropdown-class" name="sort-posts" id="sortbox" onchange="document.location.href=location.href+this.options[this.selectedIndex].value;">
<option disabled>Sort by</option>
<option value="&orderby=date&order=dsc">Newest</option>
<option value="&orderby=date&order=asc">Oldest</option>
</select>



    
        document.getElementById('sortbox').value='orderby=date&order=dsc';

    
        document.getElementById('sortbox').value='orderby=date&order=asc';

    
        document.getElementById('sortbox').value='orderby=date&order=desc';

    


When Im on the search results page, the sort dropdown will sort the current results according to date by grabbing the url and appending to it then reloading the page with the results —

// Before
mydomain.com/?s=Search&property_city=new-york-city&beds=Any 

// After
mydomain.com/?s=Search&property_city=new-york-city&beds=Any&orderby=date&order=dsc

However, I am now trying to improve the code further by using it to sort based on numeric custom fields (high to low and low to high).

It seems all the info I can find on the subject have much more complicated ways of doing so. Is there anyway of doing this using the code I already started on?

UPDATE

I seem to be getting closer –

On my search.php page I have this before my loop —-

<select class="dropdown-class" name="sort-posts" id="sortbox" onchange="document.location.href=location.href+this.options[this.selectedIndex].value;">
<option disabled>Sort by</option>
<option value="&orderby=date&order=dsc">Newest</option>
<option value="&orderby=date&order=asc">Oldest</option>
<option value="&orderby=property_price&order=asc">Most Expensive</option>
<option value="&orderby=property_price&order=dsc">Least Expensive</option>
<option value="&orderby=property_area&order=dsc">Largest</option>
<option value="&orderby=property_area&order=asc">Smallest</option>
</select>



    
        document.getElementById('sortbox').value='orderby=date&order=dsc';

    
        document.getElementById('sortbox').value='orderby=date&order=asc';

    
        document.getElementById('sortbox').value='orderby=property_price&order=asc';

        
        document.getElementById('sortbox').value='orderby=property_price&order=dsc';

    
        document.getElementById('sortbox').value='orderby=property_area&order=asc';

        
        document.getElementById('sortbox').value='orderby=property_area&order=dsc';


    
        document.getElementById('sortbox').value='orderby=date&order=desc';

    


where it says “orderby=xxx” I just use my names for my custom fields.


Get this bounty!!!