Show div at a specific time - timer

I need to show different divs on different exact times.
Example: 28/11/17 06:00, 08:35, 12:34, 15:21
The interval is not linear and changes daily.
I'd like to show the "08:35 div" until it's 08:35 and then switch to the "12:34 div".
How can I achieve that?

When using javascript you can try
new Date().toLocaleTimeString();
to get the current time. You can use an if-else statement to manipulate your divs.

Related

RangeSlider component does not work inside Filter's shortcut in Polaris Library

I am using the Polaris library by Shopify to build an app. I am using RangeSlider with dual thumb for the filter.
However, when I add it as a shortcut inside my Filters, the slider does not work, i.e., I am not able to drag the ends of the slider
Note - If you go to More Filters -> Money Spent, the slider works fine without any issues, and I am able to drag both ends.
I tried manipulating the callback, but it didn't help and also does not throw any errors while debugging.
Reproducible Code Link to CodeSandbox => check Money spend filter
The problem seems to be that you are saving the data the user enters into rangeValue, but the code you have to add the filters (Line 198) is looking at moneySpent instead. Since moneySpent is never set, the filter is never added.

Render part of page to file

How can I make InDesign render a region of a page, as it would be rendered when exporting the whole file?
I know I can render a PageItem using the exportFile function, but this will ignore any other PageItems sharing the same region.
My current solution is to make a new document the size of the region of interest, with a copy of each PageItem whose coordinates fall into that region. It’s very inelegant, and it seems it cannot be done without the user seeing windows meaningless to them come and go.
Another approach I can think of is to export the whole spread containing the region, then crop the resulting file using something like ImageMagick. But I’d still prefer to be able to render only the region I need, if possible.
You can open the InDesing document without showing its UI as well.
app.open(filepath, false);
and while closing the doc, simple use
doc.close(SaveOptions.NO);
You anyways don't need to save that doc on disk.
This will let you have the document open without showing its UI at all.
I did something like this recently. Here are my steps:
duplicate all spread items and group them
make a frame with a proper size/position
cut and paste the group into this frame
export the frame as PNG
If you need another region on this spread you don't need to repeat all the steps, you can change size and position of the frame and to export it again.
There is a limitation: master page items will be omitted.

How to click the buttons without element id

Im using protractor for e2e testing.I want to click the buttons
Is there any reason you're not using the Protractor API, but the driver directly? Selecting by ng-click might not be the best approach here as well (good practice seems to be selecting based on page structure, not mechanics), I would recommend you to investigate if you can't simply use by.buttonText:
element(by.buttonText('Place Order'));
EDIT: Looking at the way the selector is made, the above will not work - please note by.buttonText will only match:
button
input type="button"
input type="submit"
I'm keeping this for anyone who might need this in the future.
If that will not work, maybe you could at least select it by class, e.g. inside a parent? For example:
element(by.css('.btn-wrapper > .btn:nth-child(2)'));
Also, consider adding a separate class/id for the button, it might be useful later anyway.
Last remark, if you have a large page to test, consider using page objects instead of selecting same stuff in separate steps. This way, instead of writing the selector, you'll have a nice, maintainable object, that you can use like:
myPage.placeOrderButton().click();
Just something to consider.
Place order button:
$('[ng-if*="checkout"]').click();
Cancel button:
$('[ui-sref=​"main.store.featured"]').click();
This should work:
element(by.css('[ng-click="ctrl.placeOrder()"]')).click();
I think the simplest and the most readable approach here would be to locate the element by text:
element(by.xpath('//div[. = "Place Order"]'));
You may just need to add a wait for element to become visible:
var EC = protractor.ExpectedConditions,
placeOrder = element(by.xpath('//div[. = "Place Order"]'));
browser.wait(EC.visibilityOf(placeOrder), 5000);
placeOrder.click();
I don't know if this will help, but I found an article where someone was having issues clicking on a div. It seems a bit much for just clicking on a div but I figured the link could help you out
https://adventuresintesting.wordpress.com/tag/protractor-doesnt-click-div/

Implementing basic next/previous picture

I'm trying to convert the Adjuster example mentioned here: http://agiletoolkit.org/learn/understand/view/interactive
into a View that is able to show me the next/previous picture of a list of given images.
I guess the number in the example could be an index into an array of pictures.
I'm just not sure how to provide the list of pictures, when all the code is put in init() for the View, so no way to give it the picturelist before that...
Should I use memorize/recall for this list also to prevent it getting lost upon reload ?
is there another example that might help me?
I think you what you are doing can be much easier done with a classic JavaScript Lightbox script. You would supply it list of images and it would show one full-screen.
If not, you can use this:
https://gist.github.com/romaninsh/7217119
This will give you slides similar to the ones on http://agiletech.ie/
Be advised that this code is a little old.

Drupal: D7 rewriting values returned by views

I have a requirement to perform an indexed search across content which must include a couple of tags in the result. The tags must be a random selection. The platform is Drupal 7.12
I have created a view that manages the results of a SOLR search through the search_api. The view returns the required content and seems to work as intended. I have included a couple of Global: custom text fields as placeholders for the tag entries.
I am now looking for a solution to manage the requirement to randomise the tag values. The randomisation is not the issue, the issue is how to include the random values into the view result.
My current approach is to write a views_pre_render hook to intercept the placeholders which appear as fields ([nothing] and [nothing_1]). The test code looks like the following
function MODULE_views_pre_render( &$view )
{
$view_display = $view->display['default'];
$display_option = $view_display->display_options;
$fields = $display_option['fields'];
foreach( $view->result as $result )
{
$fields['nothing']['alter']['text'] = sprintf("test %d", rand(1,9));
}
}
I am currently not seeing any change in the placeholder when the view is rendered.
Any pointers to approach, alternate solutions etc would be gratefully received as this is consuming a lot of scarce time at the moment. Calling print_r( $view ) from within the hook dumps over 46M into a log file for a result set of 2 items.
There are two possible solutions for your task.
First approach is do everything on the template level. Define a template for the view field you want to randomize. In advanced settings of your display go to Theme: Information. Make sure that the proper theme is selected and find the template suggestions for your field. They are listed starting from most general to the most specific and you can choose whatever suits you better.
I guess the most specific template suggestion for your field would be something like this: views-view-field--[YOR VIEW NAME]--[YOUR DISPLAY NAME]--nothing.tpl.php. Create the file with that name in the theme templates directory and in this template you can render what ever you want.
By default this template has only one line:
print $output;
you can change this to:
print sprintf("test %d", rand(1,9));
or to anything else, whatsoever :)
Second approach is to go with Views PHP module. WIth this module you can add a custom PHP field in which you can do whatever you want. Even though the module hasn't been released it seems to work quite well for the most of the tasks and most certainly for such a simple task as randomizing numbers it will work out for sure.
I stumbled upon this while searching for another issue and thought I would contribute.
Instead of adding another module or modifying a template, just add a views "sort criteria" of "Global: Random".

Resources