What is meant by "timeout" in toastr.options - toastr

I searched alot on Internet but I could not found the description of timeOut and extendedTimeOut in toastr.options
toastr.option = {
showDuration : its the time the toastr is visible.
timeOut : ?? (I need help here from you guys)
extendedTimeOut : ?? (I need help here from you guys)
}

How long the toast will display without user interaction
toastr.options.timeOut = 30;
How long the toast will display after a user hovers over it
toastr.options.extendedTimeOut = 60;
https://github.com/CodeSeven/toastr#timeouts

Related

Puppeteer: page.type() misses out first couple of characters of the string

I am facing an issue with Puppeteer's page.type() method. Sometimes it types a whole string perfectly but at times it just misses out the first couple of characters.
Suppose I have a string: I may not be there yet but I am closer than yesterday. It just types y not be there yet but I am closer than yesterday.
I have found an issue in github related to this but it has been closed. Although I have tried some of the solutions suggested there but it doesn't seem to work. I have also asked in the issue to be reopened but I guess it will take some time.
So thought of seeking a solution from SO. Here's the code:
const blog = {
postContent: [
{
text: "SSBtYXkgbm90IGJlIHRoZXJlIHlldCwgYnV0IEknbSBjbG9zZXIgdGhhbiB5ZXN0ZXJkYXk=",
status: "pending"
},
{
text: "RG9uJ3QgcXVpdGUuIFN1ZmZlciBub3cgYW5kIGxpdmUgdGhlIHJlc3Qgb2YgeW91ciBsaWZlIGFzIGEgY2hhbXBpb24u",
status: "pending"
},
{
text: "TGlmZSBpcyBub3QgYWJvdXQgd2lubmluZy4gSXQncyBhYm91dCBub3QgZ2l2aW5nIHVwIQ==",
status: "pending"
}
]
};
await page.waitForSelector('div[role="presentation"]' );
await page.focus('div[role="presentation"]');
// finding the index of the blog post which is pending
const pendingPostIndex = await blog.postContent.findIndex( item => item.status === "pending" );
// decoding post content
const textContent = `${Buffer.from(blog.postContent[pendingPostIndex].text, 'base64').toString()}`;
// this gets the full text without missing characters
console.log('text content of pending post: ', textContent);
// first couple characters are missing most of the time
await page.type('div[role="presentation"] span', textContent, {
delay: 100
});
I don't know what could be going wrong here. Is it because decoding takes a little bit of time and page.type() fires before the text is completely decoded? Or finding the post index takes time? How can I fix this?
A suggestion mentioned on the issue page you cited, and that has also worked for me is to be sure the input is zeroed out before typing:
await page.click('div[role="presentation"] span', {clickCount: 3});
await page.keyboard.press('Backspace');

Google Map Directions Service API 'Drag to change route' text change

I've successfully implemented google map direction service api : https://developers.google.com/maps/documentation/javascript/directions with 'draggble' option enabled. Is it possible to change the text label of Drag button (screenshot attached) on hovering the route ? At present it says: 'Drag to change route'. I need to modify it. I checked the documentation: https://developers.google.com/maps/documentation/javascript/reference, but couldn't find anything for this.
The current code is similar to: https://developers.google.com/maps/documentation/javascript/examples/directions-draggable
Please help me. Thanks in advance!
Update: I just got a down vote for: "There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.". The code is available in the provided url and I think there can be only one solution available using google map api. If there's any additional information needed, please add a comment.
Probably my answer will be downvoted, but maybe it will be useful for you. Let's say it's just an idea. So you may change the tooltip of the route after the direction has been changed.
directionsDisplay.addListener('directions_changed', function() {
directionsDisplay.gd.b.setTitle('This is your new tooltip for the route.');
});
But unfortunately at the time of the directions_changed event there are no markers yet, so somehow you should delay setting their title:
for (var i = 0; i < directionsDisplay.b.G.length; i++){
directionsDisplay.b.G[i].setTitle('Marker ' + i + ' tooltip');
}
UPDATE:
A more general code:
directionsDisplay.addListener('directions_changed', function() {
setRouteTitle(directionsDisplay, 'The new tooltip');
});
function setRouteTitle(dirsDispl, newTitle){
var ddObjKeys = Object.keys(dirsDispl);
for (var i = 0; i < ddObjKeys.length; i++){
var obj = dirsDispl[Object(ddObjKeys)[i]];
var ooObjKeys = Object.keys(obj);
for (var j = 0; j < ooObjKeys.length; j++){
var ooObj = obj[Object(ooObjKeys)[j]];
if ((ooObj) && (ooObj.hasOwnProperty('title')) && (ooObj.hasOwnProperty('shape')) && (ooObj.shape.type == 'circle')){
ooObj.setTitle(newTitle);
}
}
}
};
Hope this helps.

Change images on hover with AngularJS

Okay, so I need to change images on hover in my Angular app. However, due to some peculiarities of the site, it wasn't really feasible to change images on hover via css [without a ton of extra work], which would have been the best way, I realize.
So instead, I'm using ng-mouseenter and ng-mouseleave to change the images on hover.
landing.jade
img.share-button(src='images/btn_share.png', ng-click='dropdownShareIcons()')
img.share-icon-top(src='{{ shareIcons[0].orig }}', data-id='0', ng-mouseenter='colorizeIcons($event)', ng-mouseleave='decolorizeIcons($event)')
img.share-icon-top(src='{{ shareIcons[1].orig }}', data-id='1', ng-mouseenter='colorizeIcons($event)', ng-mouseleave='decolorizeIcons($event)')
img.share-icon-top(src='{{ shareIcons[2].orig }}', data-id='2', ng-mouseenter='colorizeIcons($event)', ng-mouseleave='decolorizeIcons($event)')
Then in the controller I have an object which contains the paths to the images, and the functions which switch images on hover.
landing.js
$scope.shareIcons = [
{orig: 'images/follow_weibo_grey.png', hover: 'images/follow_weibo_colored.png'},
{orig: 'images/follow_wechat_grey.png', hover: 'images/follow_wechat_colored.png'},
{orig: 'images/follow_youku_grey.png', hover: 'images/follow_youku_colored.png'},
]
$scope.colorizeIcons = function($event) {
$event.target.src = $scope.shareIcons[$event.target.dataset.id].hover;
}
$scope.decolorizeIcons = function($event) {
$event.target.src = $scope.shareIcons[$event.target.dataset.id].orig;
}
This all works fine and well on my local environment, but on the production server it is veeeerrrrry slow. Like, 2-3 seconds to switch the images.
So my question is - is there an easy way to fix this? Either something within angular or a workaround/hack. Doesnt really matter as long as image switch time is sped up a bit. Or is it going to continue to be slow as long as I'm switching images via JS like this? Ideally, I would like avoid rewriting this using CSS.
Thanks in advance.
Hey bro I had the same problem, and all I could think of doing was preloading the images. That helped alot. Add a small piece of js code which loads asynchronously at the beginning of your document. Like this for example:
var images = new Array()
function preload() {
for (i = 0; i < preload.arguments.length; i++) {
images[i] = new Image()
images[i].src = preload.arguments[i]
}
}
preload(
// for (i = 0; i < $scope.members.length; i ++){
// return members[i].source + ",";
// }
"http://ramiawar.co/pages/speakersPage/pages/team/assets/images/image1.1.jpg",
"http://ramiawar.co/pages/speakersPage/pages/team/assets/images/image2.1.jpg",
"http://ramiawar.co/pages/speakersPage/pages/team/assets/images/image3.1.jpg",
"http://ramiawar.co/pages/speakersPage/pages/team/assets/images/image4.1.jpg",
"http://ramiawar.co/pages/speakersPage/pages/team/assets/images/image5.1.jpg",
"http://ramiawar.co/pages/speakersPage/pages/team/assets/images/image6.1.jpg"
)
I would consider optimizing the PNG image sizes. There are batch optimization tools available online, here is a blog post comparing a few of them to get you started: http://www.sitepoint.com/image-compression-tools/ perhaps you can test optimize a couple of images to see if you notice a change?
GL!

Windows Phone speech recognition - words that are not in grammar

consider a grammar like this ; speech.Recognizer.Grammars.AddGrammarFromList("answer",new string[] { "Go.","no" });
When I say something else that are not in grammar, she says "sorry didnt catch" and then tries to start it again. Same goes for null input.
What I want is that it should only recognize the words in grammar and for everything else it should just pass the recognition. I don't want to see anything like "sorry didnt catch" and second time recognotion. Any idea ? thanks.
Edit : with try-catch I can avoid from second time recognotion if the word is unknown but now it's waiting too long on "sorry didnt catch" part.
try
{
SpeechRecognizerUI speech = new SpeechRecognizerUI();
speech.Settings.ReadoutEnabled = false;
speech.Settings.ShowConfirmation = false;
speech.Recognizer.Settings.InitialSilenceTimeout = System.TimeSpan.FromSeconds(0.8);
speech.Recognizer.Grammars.AddGrammarFromList("answer", new string[] { "Go.", "no" });
SpeechRecognitionUIResult result = await speech.RecognizeWithUIAsync();
if (result.RecognitionResult.Text == "Go.") { .... }
}
catch
{
..... }
In my opinion, you must build your own UI to avoid this. So you should use SpeechRecognizer and then you can handle the input as you want.
In my case I even created two SpeechRecognizer, on with own Wordlist, the other one with default dictionary. It works like a charm, but I couldn't get it to work with SpeechRecognizerUI.

RX threadding issues in WinRT

I have some simple code:
var timer = Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp();
//timer.Subscribe(x => timerTb.Text = x.Value.ToString());
timer.Subscribe(x => Debug.WriteLine(x.Value));
And a textbox on the view called timerTb. I am trying to get the commented out line to work without it shouting about marshalling issues.
From what i can find out i should be using timer.ObserveOnDispatcher().Subscribe(...
But i do not have access to this method, nor do i have access to the CoreDispatcherScheduler dispite referencing "System.Reactive.Linq;"
I am running RX 2.0.20304.0
Any ideas?
I managed to get it working.
Silly rookie mistake CoreDispatcherScheduler was in : System.Reactive.Windows.Threading
Once i referenced that i got ObserveOnDispatcher() and this worked:
var timer = Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1)).Timestamp();
timer.ObserveOnDispatcher().Subscribe(x => timerTb.Text = x.Value.ToString());
Put your timer on the UI thread:
Observable.Timer(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), CoreDispatcherScheduler.Instance)
.Timestamp();