Skip to content

Commit

Permalink
Merge pull request #17 from William17/topic-filter
Browse files Browse the repository at this point in the history
topic filter
  • Loading branch information
William17 committed Oct 19, 2016
2 parents 730c518 + 9cc7477 commit c55cd44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions examples/yunba_javascript_demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
var topic = $('#topic_sub').val();
yunba.subscribe({'topic': topic }, function (success, msg) {
if (success) {
$('#topic_list').append('<b id="topic_id_' + topic + '">' + topic + '</b>');
$('#topic_list').append('<b data-topic="topic_id_' + topic + '">' + topic + '</b>');
} else {
alert(msg);
}
Expand All @@ -81,7 +81,7 @@
var topic = $('#topic_sub').val();
yunba.subscribe_presence({'topic': topic }, function (success, msg) {
if (success) {
$('#topic_list').append('<b id="topic_id_' + topic + '/p' + '">' + topic + '/p' + '</b>');
$('#topic_list').append('<b data-topic="topic_id_' + topic + '/p' + '">' + topic + '/p' + '</b>');
} else {
alert(msg);
}
Expand All @@ -98,7 +98,7 @@

yunba.unsubscribe({'topic': topic}, function (success, data) {
if (success) {
$('#topic_id_' + topic).remove();
$('#topic_list b').filter('[data-topic="' + 'topic_id_' + topic + '"]').remove();
} else {
alert(data);
}
Expand All @@ -115,7 +115,7 @@

yunba.unsubscribe_presence({'topic': topic}, function (success, data) {
if (success) {
$('#topic_id_' + topic + '/p').remove();
$('#topic_list b').filter('[data-topic="' + 'topic_id_' + topic + '/p' + '"]').remove();
} else {
alert(data);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/yunba_javascript_demo_customid.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
var topic = $('#topic_sub').val();
yunba.subscribe({'topic': topic }, function (success, msg) {
if (success) {
$('#topic_list').append('<b id="topic_id_' + topic + '">' + topic + '</b>');
$('#topic_list').append('<b data-topic="topic_id_' + topic + '">' + topic + '</b>');
} else {
alert(msg);
}
Expand All @@ -84,7 +84,7 @@
var topic = $('#topic_sub').val();
yunba.subscribe_presence({'topic': topic }, function (success, msg) {
if (success) {
$('#topic_list').append('<b id="topic_id_' + topic + '/p' + '">' + topic + '/p' + '</b>');
$('#topic_list').append('<b data-topic="topic_id_' + topic + '/p' + '">' + topic + '/p' + '</b>');
} else {
alert(msg);
}
Expand All @@ -101,7 +101,7 @@

yunba.unsubscribe({'topic': topic}, function (success, data) {
if (success) {
$('#topic_id_' + topic).remove();
$('#topic_list b').filter('[data-topic="' + 'topic_id_' + topic + '"]').remove();
} else {
alert(data);
}
Expand All @@ -118,7 +118,7 @@

yunba.unsubscribe_presence({'topic': topic}, function (success, data) {
if (success) {
$('#topic_id_' + topic + '/p').remove();
$('#topic_list b').filter('[data-topic="' + 'topic_id_' + topic + '/p' + '"]').remove();
} else {
alert(data);
}
Expand Down
2 changes: 1 addition & 1 deletion yunba-js-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ var __CookieUtil = {
Yunba.prototype._validate_topic = function (topic, callback) {
if (!topic) {
return __error(MSG_MISSING_CHANNEL) && callback(false, MSG_MISSING_CHANNEL);
} else if (topic.length > 50 || !/^([a-zA-Z0-9_]*)$/.test(topic)) {
} else if (topic.length > 50 || !/^([a-zA-Z0-9_\/#\+]*)$/.test(topic)) {
return __error(MSG_ERROR_CHANNEL) && callback(false, MSG_ERROR_CHANNEL);
}
return true;
Expand Down

0 comments on commit c55cd44

Please sign in to comment.