Auto-updating store opened / store closed being displayed - javascript

new to this site. I have searched and searched and kept getting referred back to this previous post - How to determine the image that is displayed during business hours/days?
The previous poster was trying to accomplish the exact thing I am trying to do. I tried the code that was shown in jsfiddle, but I think there is something missing somewhere (in the css?). In fact, in jsfiddle, it shows "store is" and "store is closed" at the same time in the result window. I just can't seem to get it to work no matter what I do.
If they are in fact correct, can someone show me exactly what I need to do / where I need to put these? I just want a small image to be shown if the store is open or closed based on local time.
Any ideas from anyone with some patience would be appreciated. I'd even settle for a configurable widget at this point if anyone knows of one.
Thanks!

The fiddle works fine..
it is just that the open image is not available anymore ..
Check this fiddle (different photos that are available..) and an extra css rule that sets both open/closed divs to be hidden by default.. (so you do not see the flashing..)

Related

WebExtension: collect infos on all iframes of current page

I’m writing a WebExtension that identify fields using a given criterion in a web page.
The content script which is loaded with every page and iframe does its job well identifying and highlighting those fields.
Now I want to count the total number of said fields in a page as the user sees it, that is, including its iframes, and display this number over the browserAction icon (as adblock displays a count over its action icon).
My plan was to use setBadgeText in the action script to clear the current counter, then issue a tabs.sendMessage({req:"countFields"}), and then let every content script respond to that message by getting the current value of the badgeText and increase it with the number of fields it found on its part of the page.
Well, that does not work well. I’m getting erratic values when a page contains iFrames. I guess this is a synchronization problem, when content scripts from different parts of the page try to get the badge value and update it.
I’ve also tried navigating through window.frames from a top level content script ("all_frames":false), but that won’t work either, since cross script errors can prevent me from descending all iFrames (using the online version of tinyMce for example)
Well, at this point, I’m asking for help and advice on how to solve my problem.
Any clue or pointer would be very much welcome !
I found the answer to that problem !
Since I believe knowing where to find for answers to a specific kind of problems (here, WebExtension development) is part of the answer, I give the link to that answer on the right place instead of just repeating here what was given me there.
https://discourse.mozilla.org/t/collect-infos-on-all-iframes-of-current-page-solved/30453

Why are my JQuery Modal boxes not in there default position?

Until recently any modal box I displayed was dead center in the page. Which I assume is the default and is what I wanted.
Recently some change I made someplace in my code is causing the modal to open on the left bottom of the page, just poking up above the bottom of the screen.
I've explored all the code I've changed in the past weeks and can't find it. I also had updated the 'jquery.modal.min.css' file to the current version v0.9.1 so replaced that with the previous version. But that didn't fix it either.
I'm the first to admit I do not understand how to use the 'Web Inspector' effectively. If this is how I can track down the issue please be specific on its use.
well, you need to provide a fiddle so we can see any example of your code. That been said:
do you use GIT( you might be able to version back ALL files that might have been touched, keep in mind any new changes are gone).
are you the only Developer working on this? is there another developer, who could have added something locally with a !important? May be someone forgot to open or close a bracket, in your css/html/structure
my 2 cents

Images not showing up on first time

Hellow everyone,
I'm having a problem on the site where my images' widths are not being calculated properly (they're not showing either on first load as well) inside jCarouselLite plugin.
I wonder if this has something to do with the fact that they're loaded from the CDN and don't have a proper content-type set (or something similar). (Example apartment)
If you check the List of apartments, you can go inside each one by clicking on the name or on the picture. It's INSIDE that pictures do not show up for me in any browser I've tried. If, however, I refresh the page, they show up fine.
Can anyone suggest what may be happening here?

jQuery Mobile + knockout.js performance problems and problems with a function

First of all, my english skills fell apart during the last years so I hope I can explain my problems exactly.
Im trying to write a garbage calendar app with an alarm, notification and so on if it might be ready some time.
At first you have to choose the right address of your city and due to that I know in which district the user is living and with that information I know when his garbage is being collected.
Right now I have two problems and I really can't fix them.
The first one is when I chose my address I'm coming to the address site where the address is shown and I have two buttons. The first one is: "Wrong address?" and the second one is "show me the dates for this district".
When I'm clicking the second option with the dates I'm calling my function doSomething3(sorry for those names) but if I'm coming to the page where the dates should be shown there is nothing shown on this page.
I figured out when im setting the variable viewModel.bezirksnr in the javascript file and for example navigate from the homescreen to the dates of districts with opening the same function its actualy workin so i guess my function isn't completly wrong.
The second observation I made is when I'm setting the variable, then pushing the button in the homescreen for showing me the dates (is working ofc) and then I'm setting an address and then push the button from my address site to show me the dates then something like this appears:
Every single date of the first attempt(with the variable set before starting the app) is followed by all of the dates of the new chosen district.
The second problem is the performance problems. When I selected an address and maybe I miss clicked and want to select another its not working. The app is so laggy and doesn't react anymore.
Due to this and cause of the pic I uploaded I guess maybe I'm not clearing the arrays in a right way but I tried for example the removeAll() for observable arrays but there was no effect.
Here is my index.html including all those pages:
http://pastebin.com/Zci009cn
And here is my javascript file:
http://pastebin.com/PwBdkBa0
I put them into pastebin for not creating a massive wall of text ;)
I hopefully could explain everything in an understanding way and it would be awesome if anyone can help me! if you have any questions, feel free to ask

Strange javascript/jquery issue

Hopefully someone can help me here.
I have a page that displays a list of users in a modal popup. This page can be accessed in two ways, one way you choose Unapproved users and it will open the page, the other way you choose user accounts which will open a popup asking if you have any search criteria such as name, once you have finished there you search and it brings up the page of users.
I have a button on the form to clear any filters. When i run it on the Unapproved users page, it clears the box fine, however if i do it on the form from the other way the code will not empty the textbox and when i try an alert it shows no data. Where as the alert works on the Unapproved route!
Here is the jquery that i am using:
clear: function () {
//reset filters//
$('.usersFilterList li').remove();
$('.userFilterSelect option').show();
$('#UserFilter_SearchTermIncluded').attr('value', ''); // This line doesn't seem to work properly
alert($('#UserFilter_SearchTermIncluded').attr('value'));
//hide filter options
MSG.showNHide('', '#usersFilterBox');
//reset modal control buttons
$('#usersButSaveFilter,#usersButClearFilter').hide();
$('#usersButFilter').fadeIn();
usersFilter.refresh(0);
}
Can anyone see if i am doing anything stupid? As i say, it is exactly the same form called from the same MVC action just with the other popup in between.
Apologies if this is confusing, I cannot post anymore code i am afraid. I can assure you that the ID of the textbox is correct though.
Any advice here would be much appreciated as I have been staring at it for hours now...
Cheers,
Gareth
If i right click the second option and run in new tab and run that first pop up as a full page the code will then work! So the problem appears to be that there are two popups.
SOLVED
I found a work around of my own, thanks for all your help.
I simply assigned a class and searched for any items with that class and cleared it like so:
$('.jq-clearme').val('');
I will close this when i can. I am not allowed yet due to my rep being too low.
To change the value of an element (or to retrieve it), accessing the attribute is the wrong way to go - it's not synchronized in both directions. What you want is the property. While also exposed through .prop('value'[, newvalue]) the correct way to get/set it with jQuery is .val([newvalue]).
To clear the element's value use the following:
$('#UserFilter_SearchTermIncluded').val('');
To retrieve/show it, use
alert($('#UserFilter_SearchTermIncluded').val());
You should use val() to get/set the value of the input.
Use without a parameter to get the value:
$('#UserFilter_SearchTermIncluded').val();
And with a paramater set the value, in this case set it to nothing:
$('#UserFilter_SearchTermIncluded').val('');
Is there an ajax call involved which might be loading the Javascript you posted twice and hence when called the second time (after the ajax call) it finds a conflict?
As mentioned by others best to use .val('') to set a value and .val() to get the value. Check in firebug if there are any Javascript errors.
I found a work around of my own, thanks for all your help.
I simply assigned a class and searched for any items with that class and cleared it like so:
$('.jq-clearme').val('');
I will close this when i can. I am not allowed yet due to my rep being too low.

Categories

Resources