How to use Y.Notify.Message? - javascript

I have a problem with http://yuilibrary.com/gallery/show/notify
Unfortunately I'm using the older version of YUI (3.4.0) so it's even harder to search for the solutions. I can't change it so I have to stick to it :(
I have read documentation page a couple of times, but I still can't figure out how to use flag. It says it's a part of configuration of Y.Notify.Message, but how do I access it? There is no example on the site except a very simple way of using Y.Notify constructor.
I was trying something like that:
notification.add({
message : 'Some message',
flag : 'some_flag',
timeout : 1000,
});
Unfortunately it does nothing ...
Any help will be appreciated, because I'm leaning to some 3rd-party library more and more... Still I would rather use something that is part of the framework I use.
The funniest part is I have checked the source code on the github:
https://github.com/yui/yui3-gallery/blob/master/src/gallery-notify/js/notify.js
...and I don't see any flag there :(
However have I found one here:
https://github.com/yui/yui3-gallery/blob/master/src/gallery-notify/js/notify.js~
What is the current version? Anyone?
I also checked the github repository for https://github.com/apipkin/xarno/blob/master/src/gallery-xarno-notify/js/notify.js which should be the most recent version of the code and it also has no flag.
Thanks a million!

It's a bug. You should contact the author.
A workaround to add a class for skinning would be to create the message as a widget first, add your class and then pass it to Y.Notify:
var message = new Y.Notify.Message({
message: 'Some message',
timeout: 1000
});
message.get('boundingBox').addClass('my-skin-class');
notification.add(message);
Another option would be to add it as an object to the notification widget and then retrieve it using item(index):
notification.add({
message: 'Some message',
timeout: 1000
});
notification.item(notification.size() - 1).get('boundingBox').addClass('my-skin-class');

Related

Hubot nesting commands

I want to create a tree-style question and answer bot with hubot doing support services and I haven't been able to figure out how. I wanted Hubot to ask a question upon someone entering the room (with robot.enter) though that doesn't work with Rocket.Chat, I've found a workaround. But if I want to ask a question and wait for a user to reply to save their reply and ask them another question, how would I go about doing this?
I tried nesting even a res.send and it wouldn't allow me, giving me an index error on CoffeeScript
If you want something prebuilt, there are a couple framework scripts that provide this capability:
https://github.com/lmarkus/hubot-conversation
https://www.npmjs.com/package/hubot-dynamic-conversation
hubot-conversation is a little more JavaScripty (and ironically, a little more dynamic), whereas hubot-dynamic-conversation centers around you building a JSON model of the conversation flow.
If you don't like either of those options, you can always implement your own flow using a mixture of robot.listen to dynamically match messages and the brain to track state.
Example (that I haven't actually tested, but should give the right idea):
module.exports = (robot) ->
robot.respond /hello$/, (res) ->
res.reply 'Why hello there! How are you today?'
# Record that we are mid-conversation
convs = robot.brain.get('conversations')
convs = convs.push(message.user.name)
robot.brain.set('conversations', convs)
robot.listen(
# If we are mid-conversation, respond to whatever they say next
(message) -> message.user.name in robot.brain.get('conversations')
(response) ->
response.reply 'I hope you have a great rest of the day!'
# Record that we are done conversing
convs = robot.brain.get('conversations')
convs = convs.splice(convs.indexOf(message.user.name), 1)
robot.brain.set('conversations', convs)
)
According to https://github.com/github/hubot/blob/master/docs/scripting.md
You can just use:
robot.enter (res) ->
res.send res.random enterReplies
don't know whether still have solution on this, since TS mention robot.enter in rocketchat does not work.

Google People API request

Hi currently using people API by google, But i am having some errors on request "api.client.people.people.connections.list" on API.
The picture below will show the error, The first picture is the console error. and the other one is the code error it shows that the list is cannot read property of undefined. The code is in below.
var request = gapi.client.people.people.connections.list({
'resourceName': 'people/me',
'requestMask.includeField': ['person.phoneNumbers', 'person.names','person.emailAddresses'],
'sortOrder' : 'FIRST_NAME_ASCENDING',
'pageSize': 500,
});
I ran into this too, their tutorial here has the same problem https://developers.google.com/people/quickstart/js.
Now you have to do gapi.client.people.people.me.connections.list
And list doesn't take a resourceName param anymore, you can see that here https://developers.google.com/people/api/rest/v1/people.connections/list.
It would be nice if they would update their tutorial...
This works today.
gapi.client.people.people.connections.list({
The accepted answer was posted in 2017 so the API has probably changed somehow, but I copied the code for the above function and the call works for me. You can find the full source at: https://developers.google.com/people/quickstart/js

I can't cancel a notification using the cordova local notification plugin

I have the following code to add a notification:
$cordovaLocalNotification.add({
id:"my-notification",
repeat:"daily",
date:time,
message:"a message"
});
But for some reason, when I run the code to cancel it:
cordova.plugin.notification.local.cancel("my-notification");
The notification isn't cleared. Nothing I do seems to clear the notification.
The local notification plugin requires that the IDs are Integers.
If they aren't, the plugin will silently use 0 as the id for the notification.
I'm not sure if this has changed recently because I feel like I've used string ids in the past.
If anyone knows of a plugin for mapping strings to integer ids, I would find that useful!
Why don't you use a simple javascript object?
var notificationMap = {"my-notitifcation-1":1, "my-not-2":2, "my-not-x":3}
then get the id using:
notificationMap["my-notitifcation-1]

Facebook Graph API - Tagged Places in version 2.0

I used the Graph API with javascript to fetch all of my data contained locations in v1.0.
( I used FB.api("/v1.0/me/locations", function (response) { ... }); )
I know that the updated version is 2.2 and the "locations" node is replaced by "tagged_places" node in v2.0 and above.
I also use the Graph API Explorer to test my results.
I try this, GET: /v2.2/me?fields=tagged_places
and the results are exactly what I want.
However, in my js code, I try: FB.api("/v2.2/me?fields=tagged_places", function (response) { ... });
and there is NO any results!
Besides,
I set version: 'v2.2' in Parse.FacebookUtils.init();
I also ask the permissions :user_tagged_places,user_photos,user_status,user_friends,user_about_me,user_birthday,read_stream in Parse.FacebookUtils.logIn();
I need almost all of the data of my checkins(a.k.a locations in v1.0/tagged_places in v2.0) to add into my database.
I try to fetch /me/photos, but the results are not satisfied. So I still need to use maybe this: FB.api("/v2.2/me?fields=tagged_places", function (response) { ... });
So... can anyone help me? please....
I went through permissions in groups testing them out and I figured out what the problem was.
You need to have the permission of the item you were tagged in.
So in my case I was tagged in photos, so I needed user_photos permission to gain access to user_tagged_places. It actually creates quite an issue because you need to know how a user was tagged to retrieve their tagged_places.
If a user was tagged at a place in a post you need a different permission than if they were tagged in a photo.

Meteor Accounts.createUser throws internal server error?

I have been using Meteor for two weeks, I am trying to add functionality to send an email once the user account has been created. I have looked at several tutorials on the Accounts.onCreateUser() function. Here is the code below.
if(Meteor.isClient{
....some code here.....
Accounts.createUser({
..... Insert some options ......
}, function(error){
..... some More code here ......
});
}
if(Meteor.isServer){
Accounts.onCreate(function(options, user){
...... Do the required .......
});
}
It seems like it is according to the several tutorials that I have been using.
I have tested out the code and but the onCreate for the account is always returning 'Internal server error' and I can't find out a cause for it. Is this the way that I am supposed the Accounts.onCreate() callback for the form?
Also is there a debugging functionality if so I can further track the code down?
Thanks
Your code says onCreate instead of onCreateUser. Maybe that's a typo? Also make sure it is returning a user document. You can always add a console.log to test if the function is being called with the right parameters.

Categories

Resources