How to use subscribe method in tracetest

Best JavaScript code snippet using tracetest

Subscriber.js

Source:Subscriber.js Github

copy

Full Screen

...25 }26 function consumeCallbackc(data) {27 console.debug("==>consumeCallbackc data : ==>" + JSON.stringify(data));28 checkConsumeData(data)29 notify.unsubscribe(subInfoa, unSubscribeCallbacka);30 }31 function connectCallbacka() {32 console.debug("==>connectCallbacka code==>");33 }34 function subscribeCallbacka(err) {35 console.debug("==>subscribeCallbacka code==>" +err.code);36 expect(err.code).assertEqual(0);37 }38 function unSubscribeCallbacka(err){39 console.debug("==>unSubscribeCallbacka code==>" +err.code);40 expect(err.code).assertEqual(0);41 }42 function disconnectCallbacka(){43 console.debug("==>disconnectCallbacka code==>");44 }45 //ActsSubscriber_test_020046 function connectCallbackb() {47 console.debug("==>connectCallbackb code==>");48 }49 function subscribeCallbackb(err) {50 console.debug("==>subscribeCallbackb code==>" +err.code);51 expect(err.code).assertEqual(0);52 }53 function subscribeCallbackc(err) {54 console.debug("==>subscribeCallbackc code==>" +err.code);55 expect(err.code).assertEqual(0);56 }57 function unSubscribeCallbackb(err){58 console.debug("==>unSubscribeCallbackb code==>" +err.code);59 expect(err.code).assertEqual(0);60 }61 function disconnectCallbackb(){62 console.debug("==>disconnectCallbackb code==>");63 }64 //ActsSubscriber_test_030065 function connectCallbackc() {66 console.debug("==>connectCallbackc code==>");67 }68 function connectCallbackd() {69 console.debug("==>connectCallbackd code==>");70 }71 function subscribeCallbackd(err) {72 console.debug("==>subscribeCallbackd code==>" +err.code);73 expect(err.code).assertEqual(0);74 }75 function subscribeCallbacke(err) {76 console.debug("==>subscribeCallbacke code==>" +err.code);77 expect(err.code).assertEqual(0);78 }79 function unSubscribeCallbackc(err){80 console.debug("==>unSubscribeCallbackc code==>" +err.code);81 expect(err.code).assertEqual(0);82 }83 function unSubscribeCallbackd(err){84 console.debug("==>unSubscribeCallbackd code==>" +err.code);85 expect(err.code).assertEqual(0);86 }87 function disconnectCallbackc(){88 console.debug("==>disconnectCallbackc code==>");89 }90 function disconnectCallbackd(){91 console.debug("==>disconnectCallbackd code==>");92 }93 //ActsSubscriber_test_050094 function connectCallbackf() {95 console.debug("==>connectCallbackf code==>");96 }97 function connectCallbackg() {98 console.debug("==>connectCallbackg code==>");99 }100 function subscribeCallbackg(err) {101 console.debug("==>subscribeCallbackg code==>" +err.code);102 expect(err.code).assertEqual(0);103 }104 function subscribeCallbackh(err) {105 console.debug("==>subscribeCallbackh code==>" +err.code);106 expect(err.code).assertEqual(0);107 }108 function subscribeCallbacki(err) {109 console.debug("==>subscribeCallbacki code==>" +err.code);110 expect(err.code).assertEqual(0);111 }112 function unSubscribeCallbackf(err){113 console.debug("==>unSubscribeCallbackf code==>" +err.code);114 expect(err.code).assertEqual(0);115 }116 function unSubscribeCallbackg(err){117 console.debug("==>unSubscribeCallbackg code==>" +err.code);118 expect(err.code).assertEqual(0);119 }120 function disconnectCallbackf(){121 console.debug("==>disconnectCallbackf code==>");122 }123 function disconnectCallbackg(){124 console.debug("==>disconnectCallbackg code==>");125 }126 //ActsSubscriber_test_0600127 var subInfob = {128 onConsume:consumeCallbacka,129 onConnect:connectCallbacki,130 onDisconnect:disconnectCallbacki,131 }132 function consumeCallbacka(data) {133 console.debug("==>consumeCallbacka data : ==>" + JSON.stringify(data));134 checkConsumeData(data)135 notify.unsubscribe(subInfob, unSubscribeCallbacki);136 }137 function connectCallbacki() {138 console.debug("==>connectCallbacki code==>");139 }140 function subscribeCallbackl(err) {141 console.debug("==>subscribeCallbackl code==>" +err.code);142 expect(err.code).assertEqual(0);143 }144 function unSubscribeCallbacki(err){145 console.debug("==>unSubscribeCallbacki code==>" +err.code);146 expect(err.code).assertEqual(0);147 }148 function disconnectCallbacki(){149 console.debug("==>disconnectCallbacki code==>");150 }151 //ActsSubscriber_test_0700152 var subInfoc ={153 onConsume:consumeCallbackb,154 onConnecte:connectCallbackj,155 onDisconnect:disconnectCallbackj,156 }157 function consumeCallbackb(data) {158 console.debug("==>consumeCallbackb data : ==>" + JSON.stringify(data));159 checkConsumeData(data)160 notify.unsubscribe(subInfoc, unSubscribeCallbackj);161 }162 function connectCallbackj() {163 console.debug("==>connectCallbackj code==>");164 }165 function unSubscribeCallbackj(err){166 console.debug("==>unSubscribeCallbackj code==>" +err.code);167 expect(err.code).assertEqual(0);168 }169 function disconnectCallbackj(){170 console.debug("==>disconnectCallbackj code==>");171 }172 //ActsSubscriber_test_0800173 var subInfod ={174 onConsume:consumeCallbackd,175 onConnect:connectCallbackm,176 onDisconnect:disconnectCallbackl,177 }178 function consumeCallbackd(data) {179 console.debug("==>consumeCallbackd data : ==>" + JSON.stringify(data));180 checkConsumeData(data)181 notify.unsubscribe(subInfod, unSubscribeCallbackl);182 }183 function connectCallbackm() {184 console.debug("==>connectCallbackm code==>");185 }186 function subscribeCallbackn(err) {187 console.debug("==>subscribeCallbackn code==>" +err.code);188 expect(err.code).assertEqual(0);189 }190 function unSubscribeCallbackl(err){191 console.debug("==>unSubscribeCallbackl code==>" +err.code);192 expect(err.code).assertEqual(0);193 }194 function disconnectCallbackl(){195 console.debug("==>disconnectCallbackl code==>");196 }197 //ActsSubscriber_test_0900198 var subInfoe ={199 onConsume:consumeCallbacke,200 onConnect:connectCallbackn,201 onDisconnect:disconnectCallbackm,202 }203 function consumeCallbacke(data) {204 console.debug("==>consumeCallbacke data : ==>" + JSON.stringify(data));205 checkConsumeData(data)206 notify.unsubscribe(subInfoe, unSubscribeCallbackm);207 }208 function connectCallbackn() {209 console.debug("==>connectCallbackn code==>");210 }211 function unSubscribeCallbackm(err){212 console.debug("==>unSubscribeCallbackm code==>" +err.code);213 expect(err.code).assertEqual(0);214 }215 function disconnectCallbackm(){216 console.debug("==>disconnectCallbackm code==>");217 }218 //ActsSubscriber_test_1400219 function connectCallbackl(){220 console.debug("==>connectCallbackl code==>");221 }222 function subscribeCallbacko(err){223 console.debug("==>subscribeCallbacko code==>" +err.code);224 expect(err.code).assertEqual(0);225 }226 function unSubscribeCallbackn(err){227 console.debug("==>unSubscribeCallbackn code==>" +err.code);228 expect(err.code).assertEqual(0);229 }230 function disconnectCallbackn(){231 console.debug("==>disconnectCallbackn code==>");232 }233 //ActsSubscriber_test_1500234 function connectCallbacko(){235 console.debug("==>connectCallbacko code==>");236 }237 function subscribeCallbackp(err){238 console.debug("==>subscribeCallbackp code==>" +err.code);239 expect(err.code).assertEqual(0);240 }241 function unSubscribeCallbacko(err){242 console.debug("==>unSubscribeCallbacko code==>" +err.code);243 expect(err.code).assertEqual(0);244 }245 function disconnectCallbacko(){246 console.debug("==>disconnectCallbacko code==>");247 }248 function checkConsumeData(data){249 expect(data.request.id).assertEqual(1);250 expect(data.request.content.contentType).assertEqual(0);251 expect(data.request.content.normal.title).assertEqual("test1_title");252 expect(data.request.content.normal.text).assertEqual("test1_text");253 expect(data.request.content.normal.additionalText).assertEqual("test1_additionalText");254 expect(data.request.slotType).assertEqual(65535);255 expect(data.request.isOngoing).assertEqual(true);256 expect(data.request.isUnremovable).assertEqual(false);257 expect(data.request.deliveryTime).assertEqual(1624950453);258 expect(data.request.tapDismissed).assertEqual(true);259 expect(data.request.autoDeletedTime).assertEqual(1625036817);260 expect(data.request.color).assertEqual(2);261 expect(data.request.colorEnabled).assertEqual(true);262 expect(data.request.isAlertOnce).assertEqual(true);263 expect(data.request.isStopwatch).assertEqual(true);264 expect(data.request.isCountDown).assertEqual(true);265 expect(data.request.progressValue).assertEqual(12);266 expect(data.request.progressMaxValue).assertEqual(100);267 expect(data.request.isIndeterminate).assertEqual(true);268 expect(data.request.statusBarText).assertEqual("statusBarText");269 expect(data.request.isFloatingIcon).assertEqual(true);270 expect(data.request.label).assertEqual("0100_1");271 expect(data.request.badgeIconStyle).assertEqual(1);272 expect(data.request.showDeliveryTime).assertEqual(true);273 }274275 /*276 * @tc.number: ActsSubscriber_test_0100277 * @tc.name: subscribe()278 * @tc.desc: verify the function of subscribe279 */280 it('ActsSubscriber_test_0100', 0, async function (done) {281 console.debug("==ActsSubscriber_test_0100==begin==>");282 await notify.subscribe(subInfoa, subscribeCallbacka);283 console.debug("==ActsSubscriber_test_0100==end==>");284 done();285 })286287 /*288 * @tc.number: ActsSubscriber_test_0200289 * @tc.name: subscribe()290 * @tc.desc: verify the function of subscribe291 */292 it('ActsSubscriber_test_0200', 0, async function (done) {293 console.debug("==ActsSubscriber_test_0200==begin==>");294 var subInfo ={295 onConnect:connectCallbackb,296 onDisconnect:disconnectCallbackb,297 }298 await notify.subscribe(subInfo,subscribeCallbackb);299 await notify.subscribe(subInfo,subscribeCallbackc);300 await notify.unsubscribe(subInfo, unSubscribeCallbackb);301 console.debug("==ActsSubscriber_test_0200==end==>");302 done();303 })304305 /*306 * @tc.number: ActsSubscriber_test_0300307 * @tc.name: subscribe()308 * @tc.desc: verify the function of subscribe309 */310 it('ActsSubscriber_test_0300', 0, async function (done) {311 console.debug("==ActsSubscriber_test_0300==begin==>");312313 var subInfo ={314 onConnect:connectCallbackc,315 onDisconnect:disconnectCallbackc,316 }317 var subInfo2 ={318 onConnect:connectCallbackd,319 onDisconnect:disconnectCallbackd,320 }321 await notify.subscribe(subInfo,subscribeCallbackd);322 await notify.subscribe(subInfo2,subscribeCallbacke);323 await notify.unsubscribe(subInfo, unSubscribeCallbackc);324 await notify.unsubscribe(subInfo2, unSubscribeCallbackd);325 console.debug("==ActsSubscriber_test_0300==end==>");326 done();327 })328 /*329 * @tc.number: ActsSubscriber_test_0400330 * @tc.name: subscribe()331 * @tc.desc: verify the function of subscribe332 */333 it('ActsSubscriber_test_0400', 0, async function (done) {334 console.debug("==ActsSubscriber_test_0500==begin==>");335336 var subInfo ={337 onConnect:connectCallbackf,338 onDisconnect:disconnectCallbackf,339 }340 var subInfo2 ={341 onConnect:connectCallbackg,342 onDisconnect:disconnectCallbackg,343 }344 await notify.subscribe(subInfo,subscribeCallbackg);345 await notify.subscribe(subInfo,subscribeCallbackh);346 await notify.subscribe(subInfo2,subscribeCallbacki);347348 await notify.unsubscribe(subInfo, unSubscribeCallbackf);349 await notify.unsubscribe(subInfo2, unSubscribeCallbackg);350 console.debug("==ActsSubscriber_test_0500==end==>");351 done();352 })353354 /*355 * @tc.number: ActsSubscriber_test_0500356 * @tc.name: subscribe()357 * @tc.desc: verify the function of subscribe358 */359 it('ActsSubscriber_test_0500', 0, async function (done) {360 console.debug("==ActsSubscriber_test_0500==begin==>");361 await notify.subscribe(subInfob, {bundleNames:["com.example.actsanspublishtest"]},subscribeCallbackl);362 console.debug("==ActsSubscriber_test_0500==end3==>");363 done();364 })365366 /*367 * @tc.number: ActsSubscriber_test_0700368 * @tc.name: subscribe()369 * @tc.desc: verify the function of subscribe370 */371 it('ActsSubscriber_test_0600', 0, async function (done) {372 console.debug("==ActsSubscriber_test_0600==begin==>");373 await notify.subscribe(subInfoc, {bundleNames:["com.example.actsanspublishtest"]}).then(374 console.log("ActsSubscriber_test_0600=======promise")375 );376 console.debug("==ActsSubscriber_test_0600==end==>");377 done();378 })379380 /*381 * @tc.number: ActsSubscriber_test_0700382 * @tc.name: subscribe()383 * @tc.desc: verify the function of subscribe384 */385 it('ActsSubscriber_test_0700', 0, async function (done) {386 console.debug("==ActsSubscriber_test_0700==begin==>");387 await notify.subscribe(subInfod, {bundleNames:["com.example.actsanspublishtest","com.example.actsanspublishtest"]},subscribeCallbackn);388 console.debug("==ActsSubscriber_test_0700==end==>");389 done();390 })391392 /*393 * @tc.number: ActsSubscriber_test_0800394 * @tc.name: subscribe()395 * @tc.desc: verify the function of subscribe396 */397 it('ActsSubscriber_test_0800', 0, async function (done) {398 console.debug("==ActsSubscriber_test_0900==begin==>");399 await notify.subscribe(subInfoe, {bundleNames:["com.example.actsanspublishtest","com.example.actsanspublishtest"]}).then(400 console.log("ActsSubscriber_test_0900=======promise")401 );402 console.debug("==ActsSubscriber_test_0900==end==>");403 done();404 })405 /*406 * @tc.number: ActsSubscriber_test_0900407 * @tc.name: subscribe()408 * @tc.desc: verify the function of subscribe409 */410 it('ActsSubscriber_test_0900', 0, async function (done) {411 console.debug("==ActsSubscriber_test_1000==begin==>");412 var promise = notify.subscribe(100,{bundleNames:["com.example.actsanspublishtest"]});413 expect(promise).assertEqual(undefined);414 console.debug("==ActsSubscriber_test_1000==end==>");415 done();416 })417 /*418 * @tc.number: ActsSubscriber_test_1000419 * @tc.name: subscribe()420 * @tc.desc: verify the function of subscribe421 */422 it('ActsSubscriber_test_1000', 0, async function (done) {423 console.debug("==ActsSubscriber_test_1000==begin==>");424 var subInfo = null425 var promise = await notify.subscribe(subInfo,{bundleNames:["com.example.actsanspublishtest"]});426 expect(promise).assertEqual(undefined);427 console.debug("==ActsSubscriber_test_1000==end==>");428 done();429 })430 /*431 * @tc.number: ActsSubscriber_test_1200432 * @tc.name: subscribe()433 * @tc.desc: verify the function of subscribe434 */435 it('ActsSubscriber_test_1100', 0, async function (done) {436 console.debug("==ActsSubscriber_test_1200==begin==>");437 var subInfo = "#$#%$%$^&%^%"438 var promise = notify.subscribe(subInfo,{bundleNames:["com.example.actsanspublishtest"]});439 expect(promise).assertEqual(undefined);440 console.debug("==ActsSubscriber_test_1200==end==>");441 done();442 })443 /*444 * @tc.number: ActsSubscriber_test_1200445 * @tc.name: subscribe()446 * @tc.desc: verify the function of subscribe447 */448 it('ActsSubscriber_test_1200', 0, async function (done) {449 console.debug("==ActsSubscriber_test_1200==begin==>");450 var subInfo = ""451 var promise = await notify.subscribe(subInfo,{bundleNames:["com.example.actsanspublishtest"]});452 expect(promise).assertEqual(undefined);453 console.debug("==ActsSubscriber_test_1200==end==>");454 done();455 })456 /*457 * @tc.number: ActsSubscriber_test_1300458 * @tc.name: subscribe()459 * @tc.desc: verify the function of subscribe460 */461 it('ActsSubscriber_test_1300', 0, async function (done) {462 console.debug("==ActsSubscriber_test_1300==begin==>");463 var subInfo ={464 onConnect:connectCallbackl,465 onDisconnect:disconnectCallbackn,466 }467 await notify.subscribe(subInfo,{bundleNames:["wrongBudleName"]},subscribeCallbacko);468 await notify.unsubscribe(subInfo, unSubscribeCallbackn);469 console.debug("==ActsSubscriber_test_1300==end==>");470 done();471 })472 /*473 * @tc.number: ActsSubscriber_test_1500474 * @tc.name: subscribe()475 * @tc.desc: verify the function of subscribe476 */477 it('ActsSubscriber_test_1400', 0, async function (done) {478 console.debug("==ActsSubscriber_test_1400==begin==>");479 var subInfo ={480 onConnect:connectCallbacko,481 onDisconnect:disconnectCallbacko,482 }483 await notify.subscribe(subInfo,{bundleNames:[]},subscribeCallbackp);484 await notify.unsubscribe(subInfo, unSubscribeCallbacko);485 console.debug("==ActsSubscriber_test_1400==end==>");486 done();487 })488}) ...

Full Screen

Full Screen

subscribeHandler.js

Source:subscribeHandler.js Github

copy

Full Screen

1/**2 * subscribehandler.js3 *4 * Register new subscribers and unsubscribers in the channel5 */6(function() {7 var subMessage = $.getSetIniDbString('subscribeHandler', 'subscribeMessage', '(name) just subscribed!'),8 primeSubMessage = $.getSetIniDbString('subscribeHandler', 'primeSubscribeMessage', '(name) just subscribed with Twitch Prime!'),9 reSubMessage = $.getSetIniDbString('subscribeHandler', 'reSubscribeMessage', '(name) just subscribed for (months) months in a row!'),10 giftSubMessage = $.getSetIniDbString('subscribeHandler', 'giftSubMessage', '(name) just gifted (recipient) a subscription!'),11 subWelcomeToggle = $.getSetIniDbBoolean('subscribeHandler', 'subscriberWelcomeToggle', true),12 primeSubWelcomeToggle = $.getSetIniDbBoolean('subscribeHandler', 'primeSubscriberWelcomeToggle', true),13 reSubWelcomeToggle = $.getSetIniDbBoolean('subscribeHandler', 'reSubscriberWelcomeToggle', true),14 giftSubWelcomeToggle = $.getSetIniDbBoolean('subscribeHandler', 'giftSubWelcomeToggle', true),15 subReward = $.getSetIniDbNumber('subscribeHandler', 'subscribeReward', 0),16 reSubReward = $.getSetIniDbNumber('subscribeHandler', 'reSubscribeReward', 0),17 giftSubReward = $.getSetIniDbNumber('subscribeHandler', 'giftSubReward', 0),18 customEmote = $.getSetIniDbString('subscribeHandler', 'resubEmote', ''),19 subPlan1000 = $.getSetIniDbString('subscribeHandler', 'subPlan1000', 'Tier 1'),20 subPlan2000 = $.getSetIniDbString('subscribeHandler', 'subPlan2000', 'Tier 2'),21 subPlan3000 = $.getSetIniDbString('subscribeHandler', 'subPlan3000', 'Tier 3'),22 announce = false,23 emotes = [],24 i;25 /*26 * @function updateSubscribeConfig27 */28 function updateSubscribeConfig() {29 subMessage = $.getIniDbString('subscribeHandler', 'subscribeMessage');30 primeSubMessage = $.getIniDbString('subscribeHandler', 'primeSubscribeMessage');31 reSubMessage = $.getIniDbString('subscribeHandler', 'reSubscribeMessage');32 giftSubMessage = $.getIniDbString('subscribeHandler', 'giftSubMessage');33 subWelcomeToggle = $.getIniDbBoolean('subscribeHandler', 'subscriberWelcomeToggle');34 primeSubWelcomeToggle = $.getIniDbBoolean('subscribeHandler', 'primeSubscriberWelcomeToggle');35 reSubWelcomeToggle = $.getIniDbBoolean('subscribeHandler', 'reSubscriberWelcomeToggle');36 giftSubWelcomeToggle = $.getIniDbBoolean('subscribeHandler', 'giftSubWelcomeToggle');37 subReward = $.getIniDbNumber('subscribeHandler', 'subscribeReward');38 reSubReward = $.getIniDbNumber('subscribeHandler', 'reSubscribeReward');39 giftSubReward = $.getIniDbNumber('subscribeHandler', 'giftSubReward');40 customEmote = $.getIniDbString('subscribeHandler', 'resubEmote');41 subPlan1000 = $.getIniDbString('subscribeHandler', 'subPlan1000');42 subPlan2000 = $.getIniDbString('subscribeHandler', 'subPlan2000');43 subPlan3000 = $.getIniDbString('subscribeHandler', 'subPlan3000');44 }45 /*46 * @function getPlanName47 */48 function getPlanName(plan) {49 if (plan.equals('1000')) {50 return subPlan1000;51 } else if (plan.equals('2000')) {52 return subPlan2000;53 } else if (plan.equals('3000')) {54 return subPlan3000;55 } else if (plan.equals('Prime')) {56 return 'Prime';57 }58 return 'Unknown Tier';59 }60 /*61 * @event twitchSubscriber62 */63 $.bind('twitchSubscriber', function(event) {64 var subscriber = event.getSubscriber(),65 message = subMessage;66 if (subWelcomeToggle === true && announce === true) {67 if (message.match(/\(name\)/g)) {68 message = $.replace(message, '(name)', subscriber);69 }70 if (message.match(/\(reward\)/g)) {71 message = $.replace(message, '(reward)', String(subReward));72 }73 if (message.match(/\(plan\)/g)) {74 message = $.replace(message, '(plan)', getPlanName(event.getPlan()));75 }76 $.say(message);77 $.addSubUsersList(subscriber);78 $.restoreSubscriberStatus(subscriber, true);79 $.writeToFile(subscriber + ' ', './addons/subscribeHandler/latestSub.txt', false);80 $.inidb.set('streamInfo', 'lastSub', subscriber);81 if (subReward > 0) {82 $.inidb.incr('points', subscriber, subReward);83 }84 }85 });86 /*87 * @event twitchPrimeSubscriber88 */89 $.bind('twitchPrimeSubscriber', function(event) {90 var subscriber = event.getSubscriber(),91 message = primeSubMessage;92 if (primeSubWelcomeToggle === true && announce === true) {93 if (message.match(/\(name\)/g)) {94 message = $.replace(message, '(name)', subscriber);95 }96 if (message.match(/\(reward\)/g)) {97 message = $.replace(message, '(reward)', String(subReward));98 }99 $.say(message);100 $.addSubUsersList(subscriber);101 $.restoreSubscriberStatus(subscriber, true);102 $.writeToFile(subscriber + ' ', './addons/subscribeHandler/latestSub.txt', false);103 $.inidb.set('streamInfo', 'lastSub', subscriber);104 if (subReward > 0) {105 $.inidb.incr('points', subscriber, subReward);106 }107 }108 });109 /*110 * @event twitchReSubscriber111 */112 $.bind('twitchReSubscriber', function(event) {113 var resubscriber = event.getReSubscriber(),114 months = event.getMonths(),115 message = reSubMessage,116 emotes = [];117 if (reSubWelcomeToggle === true && announce === true) {118 if (message.match(/\(name\)/g)) {119 message = $.replace(message, '(name)', resubscriber);120 }121 if (message.match(/\(months\)/g)) {122 message = $.replace(message, '(months)', months);123 }124 if (message.match(/\(reward\)/g)) {125 message = $.replace(message, '(reward)', String(reSubReward));126 }127 if (message.match(/\(plan\)/g)) {128 message = $.replace(message, '(plan)', getPlanName(event.getPlan()));129 }130 if (message.match(/\(customemote\)/)) {131 for (i = 0; i < months; i++, emotes.push(customEmote));132 message = $.replace(message, '(customemote)', emotes.join(' '));133 }134 $.say(message);135 $.addSubUsersList(resubscriber);136 $.restoreSubscriberStatus(resubscriber, true);137 $.writeToFile(resubscriber + ' ', './addons/subscribeHandler/latestResub.txt', false);138 $.writeToFile(resubscriber + ': ' + months + ' ', './addons/subscribeHandler/latestResub&Months.txt', false);139 $.inidb.set('streamInfo', 'lastReSub', resubscriber);140 if (reSubReward > 0) {141 $.inidb.incr('points', resubscriber, reSubReward);142 }143 }144 });145 /*146 * @event twitchSubscriptionGift147 */148 $.bind('twitchSubscriptionGift', function(event) {149 var gifter = event.getUsername(),150 recipient = event.getRecipient(),151 months = event.getMonths(),152 tier = event.getPlan(),153 message = giftSubMessage;154 if (giftSubWelcomeToggle === true && announce === true) {155 if (message.match(/\(name\)/g)) {156 message = $.replace(message, '(name)', gifter);157 }158 if (message.match(/\(recipient\)/g)) {159 message = $.replace(message, '(recipient)', recipient);160 }161 if (message.match(/\(months\)/g)) {162 message = $.replace(message, '(months)', months);163 }164 if (message.match(/\(reward\)/g)) {165 message = $.replace(message, '(reward)', String(subReward));166 }167 if (message.match(/\(plan\)/g)) {168 message = $.replace(message, '(plan)', getPlanName(event.getPlan()));169 }170 if (message.match(/\(customemote\)/)) {171 for (i = 0; i < months; i++, emotes.push(customEmote));172 message = $.replace(message, '(customemote)', emotes.join(' '));173 }174 $.say(message);175 $.addSubUsersList(recipient);176 $.restoreSubscriberStatus(recipient, true);177 $.writeToFile(recipient + ' ', './addons/subscribeHandler/latestSub.txt', false);178 $.inidb.set('streamInfo', 'lastSub', recipient);179 if (subReward > 0) {180 $.inidb.incr('points', recipient, subReward);181 }182 if (giftSubReward > 0) {183 $.inidb.incr('points', gifter, giftSubReward);184 }185 }186 });187 /*188 * @event command189 */190 $.bind('command', function(event) {191 var sender = event.getSender(),192 command = event.getCommand(),193 argsString = event.getArguments(),194 args = event.getArgs(),195 action = args[0],196 planId;197 /*198 * @commandpath subwelcometoggle - Enable or disable subscription alerts.199 */200 if (command.equalsIgnoreCase('subwelcometoggle')) {201 subWelcomeToggle = !subWelcomeToggle;202 $.setIniDbBoolean('subscribeHandler', 'subscriberWelcomeToggle', subWelcomeToggle);203 $.say($.whisperPrefix(sender) + (subWelcomeToggle ? $.lang.get('subscribehandler.new.sub.toggle.on') : $.lang.get('subscribehandler.new.sub.toggle.off')));204 }205 /*206 * @commandpath primesubwelcometoggle - Enable or disable Twitch Prime subscription alerts.207 */208 if (command.equalsIgnoreCase('primesubwelcometoggle')) {209 primeSubWelcomeToggle = !primeSubWelcomeToggle;210 $.setIniDbBoolean('subscribeHandler', 'primeSubscriberWelcomeToggle', primeSubWelcomeToggle);211 $.say($.whisperPrefix(sender) + (primeSubWelcomeToggle ? $.lang.get('subscribehandler.new.primesub.toggle.on') : $.lang.get('subscribehandler.new.primesub.toggle.off')));212 }213 /*214 * @commandpath resubwelcometoggle - Enable or disable resubsciption alerts.215 */216 if (command.equalsIgnoreCase('resubwelcometoggle')) {217 reSubWelcomeToggle = !reSubWelcomeToggle;218 $.setIniDbBoolean('subscribeHandler', 'reSubscriberWelcomeToggle', reSubWelcomeToggle);219 $.say($.whisperPrefix(sender) + (reSubWelcomeToggle ? $.lang.get('subscribehandler.resub.toggle.on') : $.lang.get('subscribehandler.resub.toggle.off')))220 }221 /*222 * @commandpath giftsubwelcometoggle - Enable or disable subgifting alerts.223 */224 if (command.equalsIgnoreCase('giftsubwelcometoggle')) {225 giftSubWelcomeToggle = !giftSubWelcomeToggle;226 $.setIniDbBoolean('subscribeHandler', 'giftSubWelcomeToggle', giftSubWelcomeToggle);227 $.say($.whisperPrefix(sender) + (giftSubWelcomeToggle ? $.lang.get('subscribehandler.giftsub.toggle.on') : $.lang.get('subscribehandler.giftsub.toggle.off')))228 }229 /*230 * @commandpath submessage [message] - Set a welcome message for new subscribers.231 */232 if (command.equalsIgnoreCase('submessage')) {233 if (action === undefined) {234 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.sub.msg.usage'));235 return;236 }237 subMessage = argsString;238 $.setIniDbString('subscribeHandler', 'subscribeMessage', subMessage);239 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.sub.msg.set'));240 }241 /*242 * @commandpath primesubmessage [message] - Set a welcome message for new Twitch Prime subscribers.243 */244 if (command.equalsIgnoreCase('primesubmessage')) {245 if (action === undefined) {246 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.primesub.msg.usage'));247 return;248 }249 primeSubMessage = argsString;250 $.setIniDbString('subscribeHandler', 'primeSubscribeMessage', primeSubMessage);251 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.primesub.msg.set'));252 }253 /*254 * @commandpath resubmessage [message] - Set a message for resubscribers.255 */256 if (command.equalsIgnoreCase('resubmessage')) {257 if (action === undefined) {258 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.resub.msg.usage'));259 return;260 }261 reSubMessage = argsString;262 $.setIniDbString('subscribeHandler', 'reSubscribeMessage', reSubMessage);263 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.resub.msg.set'));264 }265 /*266 * @commandpath giftsubmessage [message] - Set a message for resubscribers.267 */268 if (command.equalsIgnoreCase('giftsubmessage')) {269 if (action === undefined) {270 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.giftsub.msg.usage'));271 return;272 }273 giftSubMessage = argsString;274 $.setIniDbString('subscribeHandler', 'giftSubMessage', giftSubMessage);275 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.giftsub.msg.set'));276 }277 /**278 * @commandpath subscribereward [points] - Set an award for subscribers.279 */280 if (command.equalsIgnoreCase('subscribereward')) {281 if (isNaN(parseInt(action))) {282 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.sub.reward.usage'));283 return;284 }285 subReward = parseInt(action);286 $.setIniDbNumber('subscribeHandler', 'subscribeReward', subReward);287 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.sub.reward.set'));288 }289 /**290 * @commandpath resubscribereward [points] - Set an award for resubscribers.291 */292 if (command.equalsIgnoreCase('resubscribereward')) {293 if (isNaN(parseInt(action))) {294 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.resub.reward.usage'));295 return;296 }297 reSubReward = parseInt(action);298 $.setIniDbNumber('subscribeHandler', 'reSubscribeReward', reSubReward);299 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.resub.reward.set'));300 }301 /**302 * @commandpath giftsubreward [points] - Set an award for resubscribers.303 */304 if (command.equalsIgnoreCase('giftsubreward')) {305 if (isNaN(parseInt(action))) {306 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.giftsub.reward.usage'));307 return;308 }309 giftSubReward = parseInt(action);310 $.setIniDbNumber('subscribeHandler', 'giftSubReward', giftSubReward);311 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.giftsub.reward.set'));312 }313 /*314 * @commandpath resubemote [emote] - The (customemote) tag will be replace with that emote. The emote will be added the amount of months the user subscribed for.315 */316 if (command.equalsIgnoreCase('resubemote')) {317 if (action === undefined) {318 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.resubemote.usage'));319 return;320 }321 customEmote = action;322 $.setIniDbString('subscribeHandler', 'resubEmote', customEmote);323 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.resubemote.set'));324 }325 /*326 * @commandpath namesubplan [1|2|3] [name of plan] - Name a subscription plan, Twitch provides three tiers.327 */328 if (command.equalsIgnoreCase('namesubplan')) {329 if (action === undefined) {330 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.namesubplan.usage'));331 return;332 }333 if (!action.equals('1') && !action.equals('2') && !action.equals('3')) {334 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.namesubplan.usage'));335 return;336 }337 if (action.equals('1')) {338 planId = 'subPlan1000';339 } else if (action.equals('2')) {340 planId = 'subPlan2000';341 } else if (action.equals('3')) {342 planId = 'subPlan3000';343 }344 if (args[1] === undefined) {345 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.namesubplan.show', action, $.getIniDbString('subscribeHandler', planId)));346 return;347 }348 argsString = args.splice(1).join(' ');349 if (planId.equals('subPlan1000')) {350 subPlan1000 = argsString;351 } else if (planId.equals('subPlan2000')) {352 subPlan2000 = argsString;353 } else if (planId.equals('subPlan3000')) {354 subPlan3000 = argsString;355 }356 $.setIniDbString('subscribeHandler', planId, argsString);357 $.say($.whisperPrefix(sender) + $.lang.get('subscribehandler.namesubplan.set', action, argsString));358 return;359 }360 });361 /**362 * @event initReady363 */364 $.bind('initReady', function() {365 $.registerChatCommand('./handlers/subscribeHandler.js', 'subwelcometoggle', 1);366 $.registerChatCommand('./handlers/subscribeHandler.js', 'resubemote', 1);367 $.registerChatCommand('./handlers/subscribeHandler.js', 'primesubwelcometoggle', 1);368 $.registerChatCommand('./handlers/subscribeHandler.js', 'resubwelcometoggle', 1);369 $.registerChatCommand('./handlers/subscribeHandler.js', 'giftsubwelcometoggle', 1);370 $.registerChatCommand('./handlers/subscribeHandler.js', 'subscribereward', 1);371 $.registerChatCommand('./handlers/subscribeHandler.js', 'resubscribereward', 1);372 $.registerChatCommand('./handlers/subscribeHandler.js', 'giftsubreward', 1);373 $.registerChatCommand('./handlers/subscribeHandler.js', 'submessage', 1);374 $.registerChatCommand('./handlers/subscribeHandler.js', 'primesubmessage', 1);375 $.registerChatCommand('./handlers/subscribeHandler.js', 'resubmessage', 1);376 $.registerChatCommand('./handlers/subscribeHandler.js', 'giftsubmessage', 1);377 $.registerChatCommand('./handlers/subscribeHandler.js', 'namesubplan', 1);378 announce = true;379 });380 $.updateSubscribeConfig = updateSubscribeConfig;...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1(function (window) {2 if (!!window.JCCatalogProductSubscribe)3 {4 return;5 }6 var subscribeButton = function(params)7 {8 subscribeButton.superclass.constructor.apply(this, arguments);9 this.nameNode = BX.create('span', {10 props : { id : this.id },11 style: typeof(params.style) === 'object' ? params.style : {},12 text: params.text13 });14 this.buttonNode = BX.create('span', {15 attrs: { className: params.className },16 style: { marginBottom: '0', borderBottom: '0 none transparent' },17 children: [this.nameNode],18 events : this.contextEvents19 });20 if (BX.browser.IsIE())21 {22 this.buttonNode.setAttribute("hideFocus", "hidefocus");23 }24 };25 BX.extend(subscribeButton, BX.PopupWindowButton);26 window.JCCatalogProductSubscribe = function(params)27 {28 this.buttonId = params.buttonId;29 this.buttonClass = params.buttonClass;30 this.jsObject = params.jsObject;31 this.ajaxUrl = '/bitrix/components/bitrix/catalog.product.subscribe/ajax.php';32 this.alreadySubscribed = params.alreadySubscribed;33 this.urlListSubscriptions = params.urlListSubscriptions;34 this.listOldItemId = {};35 this.elemButtonSubscribe = null;36 this.elemPopupWin = null;37 this.defaultButtonClass = 'bx-catalog-subscribe-button';38 this._elemButtonSubscribeClickHandler = BX.delegate(this.subscribe, this);39 this._elemHiddenClickHandler = BX.delegate(this.checkSubscribe, this);40 BX.ready(BX.delegate(this.init,this));41 };42 window.JCCatalogProductSubscribe.prototype.init = function()43 {44 if (!!this.buttonId)45 {46 this.elemButtonSubscribe = BX(this.buttonId);47 this.elemHiddenSubscribe = BX(this.buttonId+'_hidden');48 }49 if (!!this.elemButtonSubscribe)50 {51 BX.bind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler);52 }53 if (!!this.elemHiddenSubscribe)54 {55 BX.bind(this.elemHiddenSubscribe, 'click', this._elemHiddenClickHandler);56 }57 this.setButton(this.alreadySubscribed);58 };59 window.JCCatalogProductSubscribe.prototype.checkSubscribe = function()60 {61 if(!this.elemHiddenSubscribe || !this.elemButtonSubscribe) return;62 if(this.listOldItemId.hasOwnProperty(this.elemButtonSubscribe.dataset.item))63 {64 this.setButton(true);65 }66 else67 {68 BX.ajax({69 method: 'POST',70 dataType: 'json',71 url: this.ajaxUrl,72 data: {73 sessid: BX.bitrix_sessid(),74 checkSubscribe: 'Y',75 itemId: this.elemButtonSubscribe.dataset.item76 },77 onsuccess: BX.delegate(function (result) {78 if(result.subscribe)79 {80 this.setButton(true);81 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true;82 }83 else84 {85 this.setButton(false);86 }87 }, this)88 });89 }90 };91 window.JCCatalogProductSubscribe.prototype.subscribe = function()92 {93 this.elemButtonSubscribe = BX.proxy_context;94 if(!this.elemButtonSubscribe) return false;95 BX.ajax({96 method: 'POST',97 dataType: 'json',98 url: this.ajaxUrl,99 data: {100 sessid: BX.bitrix_sessid(),101 subscribe: 'Y',102 itemId: this.elemButtonSubscribe.dataset.item,103 siteId: BX.message('SITE_ID')104 },105 onsuccess: BX.delegate(function (result) {106 if(result.success)107 {108 this.createSuccessPopup(result);109 this.setButton(true);110 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true;111 }112 else if(result.contactFormSubmit)113 {114 this.initPopupWindow();115 this.elemPopupWin.setTitleBar(BX.message('CPST_SUBSCRIBE_POPUP_TITLE'));116 var form = this.createContentForPopup(result);117 this.elemPopupWin.setContent(form);118 this.elemPopupWin.setButtons([119 new subscribeButton({120 text: BX.message('CPST_SUBSCRIBE_BUTTON_NAME'),121 className : 'btn btn-primary',122 events: {123 click : BX.delegate(function() {124 if(!this.validateContactField(result.contactTypeData))125 {126 return false;127 }128 BX.ajax.submitAjax(form, {129 method : 'POST',130 url: this.ajaxUrl,131 processData : true,132 onsuccess: BX.delegate(function (resultForm) {133 resultForm = BX.parseJSON(resultForm, {});134 if(resultForm.success)135 {136 this.createSuccessPopup(resultForm);137 this.setButton(true);138 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true;139 }140 else if(resultForm.error)141 {142 if(resultForm.hasOwnProperty('setButton'))143 {144 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true;145 this.setButton(true);146 }147 var errorMessage = resultForm.message;148 if(resultForm.hasOwnProperty('typeName'))149 {150 errorMessage = resultForm.message.replace('USER_CONTACT',151 resultForm.typeName);152 }153 BX('bx-catalog-subscribe-form-notify').style.color = 'red';154 BX('bx-catalog-subscribe-form-notify').innerHTML = errorMessage;155 }156 }, this)157 });158 }, this)159 }160 }),161 new subscribeButton({162 text : BX.message('CPST_SUBSCRIBE_BUTTON_CLOSE'),163 className : 'btn',164 events : {165 click : BX.delegate(function() {166 this.elemPopupWin.destroy();167 }, this)168 }169 })170 ]);171 this.elemPopupWin.show();172 }173 else if(result.error)174 {175 if(result.hasOwnProperty('setButton'))176 {177 this.listOldItemId[this.elemButtonSubscribe.dataset.item] = true;178 this.setButton(true);179 }180 this.showWindowWithAnswer({status: 'error', message: result.message});181 }182 }, this)183 });184 };185 window.JCCatalogProductSubscribe.prototype.validateContactField = function(contactTypeData)186 {187 var inputFields = BX.findChildren(BX('bx-catalog-subscribe-form'),188 {'tag': 'input', 'attribute': {id: 'userContact'}}, true);189 if(!inputFields.length || typeof contactTypeData !== 'object')190 {191 BX('bx-catalog-subscribe-form-notify').style.color = 'red';192 BX('bx-catalog-subscribe-form-notify').innerHTML = BX.message('CPST_SUBSCRIBE_VALIDATE_UNKNOW_ERROR');193 return false;194 }195 var contactTypeId, contactValue, useContact, errors = [], useContactErrors = [];196 for(var k = 0; k < inputFields.length; k++)197 {198 contactTypeId = inputFields[k].getAttribute('data-id');199 contactValue = inputFields[k].value;200 useContact = BX('bx-contact-use-'+contactTypeId);201 if(useContact && useContact.value == 'N')202 {203 useContactErrors.push(true);204 continue;205 }206 if(!contactValue.length)207 {208 errors.push(BX.message('CPST_SUBSCRIBE_VALIDATE_ERROR_EMPTY_FIELD').replace(209 '#FIELD#', contactTypeData[contactTypeId].contactLable));210 }211 }212 if(inputFields.length == useContactErrors.length)213 {214 BX('bx-catalog-subscribe-form-notify').style.color = 'red';215 BX('bx-catalog-subscribe-form-notify').innerHTML = BX.message('CPST_SUBSCRIBE_VALIDATE_ERROR');216 return false;217 }218 if(errors.length)219 {220 BX('bx-catalog-subscribe-form-notify').style.color = 'red';221 for(var i = 0; i < errors.length; i++)222 {223 BX('bx-catalog-subscribe-form-notify').innerHTML = errors[i];224 }225 return false;226 }227 return true;228 };229 window.JCCatalogProductSubscribe.prototype.reloadCaptcha = function()230 {231 BX.ajax.get(this.ajaxUrl+'?reloadCaptcha=Y', '', function(captchaCode) {232 BX('captcha_sid').value = captchaCode;233 BX('captcha_img').src = '/bitrix/tools/captcha.php?captcha_sid='+captchaCode+'';234 });235 };236 window.JCCatalogProductSubscribe.prototype.createContentForPopup = function(responseData)237 {238 if(!responseData.hasOwnProperty('contactTypeData'))239 {240 return null;241 }242 var contactTypeData = responseData.contactTypeData, contactCount = Object.keys(contactTypeData).length,243 styleInputForm = '', manyContact = 'N', content = document.createDocumentFragment();244 if(contactCount > 1)245 {246 manyContact = 'Y';247 styleInputForm = 'display:none;';248 content.appendChild(BX.create('p', {249 text: BX.message('CPST_SUBSCRIBE_MANY_CONTACT_NOTIFY')250 }));251 }252 content.appendChild(BX.create('p', {253 props: {id: 'bx-catalog-subscribe-form-notify'}254 }));255 for(var k in contactTypeData)256 {257 if(contactCount > 1)258 {259 content.appendChild(BX.create('div', {260 props: {261 className: 'bx-catalog-subscribe-form-container'262 },263 children: [264 BX.create('div', {265 props: {266 className: 'checkbox'267 },268 children: [269 BX.create('lable', {270 props: {271 className: 'bx-filter-param-label'272 },273 attrs: {274 onclick: this.jsObject+'.selectContactType('+k+', event);'275 },276 children: [277 BX.create('input', {278 props: {279 type: 'hidden',280 id: 'bx-contact-use-'+k,281 name: 'contact['+k+'][use]',282 value: 'N'283 }284 }),285 BX.create('input', {286 props: {287 id: 'bx-contact-checkbox-'+k,288 type: 'checkbox'289 }290 }),291 BX.create('span', {292 props: {293 className: 'bx-filter-param-text'294 },295 text: contactTypeData[k].contactLable296 })297 ]298 })299 ]300 })301 ]302 }));303 }304 content.appendChild(BX.create('div', {305 props: {306 id: 'bx-catalog-subscribe-form-container-'+k,307 className: 'bx-catalog-subscribe-form-container',308 style: styleInputForm309 },310 children: [311 BX.create('div', {312 props: {313 className: 'bx-catalog-subscribe-form-container-label'314 },315 text: BX.message('CPST_SUBSCRIBE_LABLE_CONTACT_INPUT').replace(316 '#CONTACT#', contactTypeData[k].contactLable)317 }),318 BX.create('div', {319 props: {320 className: 'bx-catalog-subscribe-form-container-input'321 },322 children: [323 BX.create('input', {324 props: {325 id: 'userContact',326 className: '',327 type: 'text',328 name: 'contact['+k+'][user]'329 },330 attrs: {'data-id': k}331 })332 ]333 })334 ]335 }));336 }337 if(responseData.hasOwnProperty('captchaCode'))338 {339 content.appendChild(BX.create('div', {340 props: {341 className: 'bx-catalog-subscribe-form-container'342 },343 children: [344 BX.create('span', {props: {className: 'bx-catalog-subscribe-form-star-required'}, text: '*'}),345 BX.message('CPST_ENTER_WORD_PICTURE'),346 BX.create('div', {347 props: {className: 'bx-captcha'},348 children: [349 BX.create('input', {350 props: {351 type: 'hidden',352 id: 'captcha_sid',353 name: 'captcha_sid',354 value: responseData.captchaCode355 }356 }),357 BX.create('img', {358 props: {359 id: 'captcha_img',360 src: '/bitrix/tools/captcha.php?captcha_sid='+responseData.captchaCode+''361 },362 attrs: {363 width: '180',364 height: '40',365 alt: 'captcha',366 onclick: this.jsObject+'.reloadCaptcha();'367 }368 })369 ]370 }),371 BX.create('div', {372 props: {className: 'bx-catalog-subscribe-form-container-input'},373 children: [374 BX.create('input', {375 props: {376 id: 'captcha_word',377 className: '',378 type: 'text',379 name: 'captcha_word'380 },381 attrs: {maxlength: '50'}382 })383 ]384 })385 ]386 }));387 }388 var form = BX.create('form', {389 props: {390 id: 'bx-catalog-subscribe-form'391 },392 children: [393 BX.create('input', {394 props: {395 type: 'hidden',396 name: 'manyContact',397 value: manyContact398 }399 }),400 BX.create('input', {401 props: {402 type: 'hidden',403 name: 'sessid',404 value: BX.bitrix_sessid()405 }406 }),407 BX.create('input', {408 props: {409 type: 'hidden',410 name: 'itemId',411 value: this.elemButtonSubscribe.dataset.item412 }413 }),414 BX.create('input', {415 props: {416 type: 'hidden',417 name: 'siteId',418 value: BX.message('SITE_ID')419 }420 }),421 BX.create('input', {422 props: {423 type: 'hidden',424 name: 'contactFormSubmit',425 value: 'Y'426 }427 })428 ]429 });430 form.appendChild(content);431 return form;432 };433 window.JCCatalogProductSubscribe.prototype.selectContactType = function(contactTypeId, event)434 {435 var contactInput = BX('bx-catalog-subscribe-form-container-'+contactTypeId), visibility = '',436 checkboxInput = BX('bx-contact-checkbox-'+contactTypeId);437 if(!contactInput)438 {439 return false;440 }441 if(checkboxInput != event.target)442 {443 if(checkboxInput.checked)444 {445 checkboxInput.checked = false;446 }447 else448 {449 checkboxInput.checked = true;450 }451 }452 if (contactInput.currentStyle)453 {454 visibility = contactInput.currentStyle.display;455 }456 else if (window.getComputedStyle)457 {458 var computedStyle = window.getComputedStyle(contactInput, null);459 visibility = computedStyle.getPropertyValue('display');460 }461 if(visibility === 'none')462 {463 BX('bx-contact-use-'+contactTypeId).value = 'Y';464 BX.style(contactInput, 'display', '');465 }466 else467 {468 BX('bx-contact-use-'+contactTypeId).value = 'N';469 BX.style(contactInput, 'display', 'none');470 }471 };472 window.JCCatalogProductSubscribe.prototype.createSuccessPopup = function(result)473 {474 this.initPopupWindow();475 this.elemPopupWin.setTitleBar(BX.message('CPST_SUBSCRIBE_POPUP_TITLE'));476 var content = BX.create('div', {477 props:{478 className: 'bx-catalog-popup-content'479 },480 children: [481 BX.create('p', {482 props: {483 className: 'bx-catalog-popup-message'484 },485 text: result.message486 })487 ]488 });489 this.elemPopupWin.setContent(content);490 this.elemPopupWin.setButtons([491 new subscribeButton({492 text : BX.message('CPST_SUBSCRIBE_BUTTON_CLOSE'),493 className : 'btn btn-primary',494 events : {495 click : BX.delegate(function() {496 this.elemPopupWin.destroy();497 }, this)498 }499 })500 ]);501 this.elemPopupWin.show();502 };503 window.JCCatalogProductSubscribe.prototype.initPopupWindow = function()504 {505 this.elemPopupWin = BX.PopupWindowManager.create('CatalogSubscribe_'+this.buttonId, null, {506 autoHide: false,507 offsetLeft: 0,508 offsetTop: 0,509 overlay : true,510 closeByEsc: true,511 titleBar: true,512 closeIcon: true,513 contentColor: 'white'514 });515 };516 window.JCCatalogProductSubscribe.prototype.setButton = function(statusSubscription)517 {518 this.alreadySubscribed = Boolean(statusSubscription);519 if(this.alreadySubscribed)520 {521 this.elemButtonSubscribe.className = this.buttonClass + ' ' + this.defaultButtonClass + ' disabled';522 this.elemButtonSubscribe.innerHTML = '<span>' + BX.message('CPST_TITLE_ALREADY_SUBSCRIBED') + '</span>';523 BX.unbind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler);524 }525 else526 {527 this.elemButtonSubscribe.className = this.buttonClass + ' ' + this.defaultButtonClass;528 this.elemButtonSubscribe.innerHTML = '<span>' + BX.message('CPST_SUBSCRIBE_BUTTON_NAME') + '</span>';529 BX.bind(this.elemButtonSubscribe, 'click', this._elemButtonSubscribeClickHandler);530 }531 };532 window.JCCatalogProductSubscribe.prototype.showWindowWithAnswer = function(answer)533 {534 answer = answer || {};535 if (!answer.message) {536 if (answer.status == 'success') {537 answer.message = BX.message('CPST_STATUS_SUCCESS');538 } else {539 answer.message = BX.message('CPST_STATUS_ERROR');540 }541 }542 var messageBox = BX.create('div', {543 props: {544 className: 'bx-catalog-subscribe-alert'545 },546 children: [547 BX.create('span', {548 props: {549 className: 'bx-catalog-subscribe-aligner'550 }551 }),552 BX.create('span', {553 props: {554 className: 'bx-catalog-subscribe-alert-text'555 },556 text: answer.message557 }),558 BX.create('div', {559 props: {560 className: 'bx-catalog-subscribe-alert-footer'561 }562 })563 ]564 });565 var currentPopup = BX.PopupWindowManager.getCurrentPopup();566 if(currentPopup) {567 currentPopup.destroy();568 }569 var idTimeout = setTimeout(function () {570 var w = BX.PopupWindowManager.getCurrentPopup();571 if (!w || w.uniquePopupId != 'bx-catalog-subscribe-status-action') {572 return;573 }574 w.close();575 w.destroy();576 }, 3500);577 var popupConfirm = BX.PopupWindowManager.create('bx-catalog-subscribe-status-action', null, {578 content: messageBox,579 onPopupClose: function () {580 this.destroy();581 clearTimeout(idTimeout);582 },583 autoHide: true,584 zIndex: 2000,585 className: 'bx-catalog-subscribe-alert-popup'586 });587 popupConfirm.show();588 BX('bx-catalog-subscribe-status-action').onmouseover = function (e) {589 clearTimeout(idTimeout);590 };591 BX('bx-catalog-subscribe-status-action').onmouseout = function (e) {592 idTimeout = setTimeout(function () {593 var w = BX.PopupWindowManager.getCurrentPopup();594 if (!w || w.uniquePopupId != 'bx-catalog-subscribe-status-action') {595 return;596 }597 w.close();598 w.destroy();599 }, 3500);600 };601 };...

Full Screen

Full Screen

showcase.js

Source:showcase.js Github

copy

Full Screen

...61}6263$(document).ready(function() {6465 $.subscribe('changeTextfield', function(event, data) {66 $('#result').html('Textfield '+data.id+' value is '+data.value);67 });6869 /*70 * Subscribe Topics for AJAX Link Event Example71 */72 $.subscribe('beforeLink', function(event, data) {73 alert('Before request ');74 $('#result').html('Loading ...');75 });76 $.subscribe('completeLink', function(event, data) {77 $('#result').append('<br/><br/><strong>Completed request ' + event.originalEvent.request.statusText + ' completed with ' + event.originalEvent.status + '.</strong><br/>Status: ' + event.originalEvent.request.status);78 });79 $.subscribe('errorStateLink', function(event, data) {80 $('#result').html('<br/><br/><strong>Error request ' + event.originalEvent.request.statusText + ' completed with ' + event.originalEvent.status + '.</strong><br/>Status: ' + event.originalEvent.request.status);81 });8283 /*84 * Subscribe Topics for AJAX Div Event Example85 */86 $.subscribe('beforeDiv', function(event, data) {87 alert('Before request ');88 });89 $.subscribe('completeDiv', function(event, data) {90 if (event.originalEvent.status == "success") {91 $('#resultnormal').append('<br/><br/><strong>Completed request ' + event.originalEvent.request.statusText + ' completed with ' + event.originalEvent.status + '.</strong><br/>Status: ' + event.originalEvent.request.status);92 }93 });94 $.subscribe('errorDiv', function(event, data) {95 $('#resulterror').html('<br/><br/><strong>Error request ' + event.originalEvent.request.statusText + ' completed with ' + event.originalEvent.status + '.</strong><br/>Status: ' + event.originalEvent.request.status);96 });9798 /*99 * Subscribe Topics for AJAX Form Event Example100 */101 $.subscribe('beforeForm', function(event, data) {102 var fData = event.originalEvent.formData;103 alert('About to submit: \n\n' + fData[0].value + ' to target ' + event.originalEvent.options.target + ' with timeout ' + event.originalEvent.options.timeout);104 var form = event.originalEvent.form[0];105 if (form.echo.value.length < 2) {106 alert('Please enter a value with min 2 characters');107 event.originalEvent.options.submit = false;108 }109 });110 $.subscribe('completeForm', function(event, data) {111 alert('status: ' + event.originalEvent.status + '\n\nresponseText: \n' + event.originalEvent.request.responseText + '\n\nThe output div should have already been updated with the responseText.');112 });113 $.subscribe('errorStateForm', function(event, data) {114 alert('status: ' + event.originalEvent.status + '\n\nrequest status: ' + event.originalEvent.request.status);115 });116117 /*118 * Subscribe Topics for AJAX Datepicker Examples119 */120 $.subscribe('onDpChangeMonthAndYear', function(event,data) {121 alert('Change month to : '+event.originalEvent.month+' and year to '+event.originalEvent.year);122 });123 $.subscribe('onDpClose', function(event,data) {124 alert('Selected Date : '+event.originalEvent.dateText);125 });126127 /*128 * Subscribe Topics for Dialog Event Example129 */130 $.subscribe('dialogopentopic', function(event, ui) {131 alert('run topic on dialog open');132 });133 $.subscribe('dialogclosetopic', function(event, ui) {134 alert('run topic on dialog close');135 });136 $.subscribe('dialogbeforeclosetopic', function(event, ui) {137 alert('run topic befor dialog close');138 });139140 /*141 * Subscribe Topics for Grid Loadonce Example142 */143 $.subscribe('showloadcolumns', function(event, data) {144 $.struts2_jquery.require("js/plugins/grid.setcolumns.js");145 $("#gridloadtable").jqGrid('setColumns', {});146 });147148 /*149 * Subscribe Topics for GridEdit Event Example150 */151 $.subscribe('rowselect', function(event, data) {152 $("#gridinfo").html('<p>Edit Mode for Row : ' + event.originalEvent.id + '</p>');153 });154 $.subscribe('oneditsuccess', function(event, data){155 var message = event.originalEvent.response.statusText;156 $("#gridinfo").html('<p>Status: ' + message + '</p>');157 });158 $.subscribe('rowadd', function(event, data) {159 $("#gridedittable").jqGrid('editGridRow', "new", {160 height : 280,161 reloadAfterSubmit : false162 });163 });164 $.subscribe('searchgrid', function(event, data) {165 $("#gridedittable").jqGrid('searchGrid', {166 sopt : [ 'cn', 'bw', 'eq', 'ne', 'lt', 'gt', 'ew' ]167 });168 });169 $.subscribe('showcolumns', function(event, data) {170 $.struts2_jquery.require("js/plugins/grid.setcolumns.js");171 $("#gridedittable").jqGrid('setColumns', {});172 });173174 /*175 * Subscribe Topics for Grid Multiselect Example176 */177 $.subscribe('getselectedids', function(event, data) {178 var s;179 s = $("#gridmultitable").jqGrid('getGridParam', 'selarrrow');180 alert('Selected Rows : ' + s);181 });182183 /*184 * Subscribe Topics for Progressbar Change Example185 */186 $.subscribe('progressbarchangetopic', function(event, data) {187 alert('value changed to : ' + $("#progressbarchange").progressbar('option', 'value'));188 });189 $.subscribe('progressbarclicktopic', function(event, data) {190 $("#progressbarchange").progressbar('value', parseInt((Math.random() * (90)), 10));191 });192193 /*194 * Subscribe Topics for Slider Range Example195 */196 $.subscribe('sliderStop', function(event, data) {197 alert('Slider stoped with value : ' + event.originalEvent.ui.value);198 });199 $.subscribe('sliderRangeStop', function(event, data) {200 alert('Slider stoped with values : ' + event.originalEvent.ui.values[0] + ' - ' + event.originalEvent.ui.values[1]);201 });202203 /*204 * Subscribe Topics for Remote Tabs Example205 */206 $.subscribe('tabchange', function(event, data) {207208 var tab = event.originalEvent.ui.index;209 $('#changepanel').html('Change to Tab <strong>' + tab + '.</strong>');210 $('#infopanel').html('');211 if (tab == 2) {212 $('#remotetabs').tabs('enable', 3);213 } else if (tab == 3) {214 $('#remotetabs').tabs('enable', 4);215 }216 });217 $.subscribe('tabcomplete', function(event, ui) {218 $('#infopanel').html('<strong>Completed request with Status ' + event.originalEvent.status + '.</strong><br/>Status: ' + event.originalEvent.request.status);219 });220221 /*222 * Remove Error Labels when Validation Forms are successfully223 */224 $.subscribe('removeErrors', function(event, data) {225 $('.errorLabel').html('').removeClass('errorLabel');226 $('#formerrors').html('');227 });228229 /*230 * Topic for Remote Link with JSON Result.231 */232 $.subscribe('handleJsonResult', function(event, data) {233 $('#result').html("<ul id='languagesList'></ul>");234 var list = $('#languagesList');235 $.each(event.originalEvent.data, function(index, value) {236 list.append('<li>' + value + '</li>\n');237 });238 });239240 /*241 * Hide the target after action is complete.242 */243 $.subscribe('hideTarget', function(event, data) {244 $('#'+event.originalEvent.targets).delay(2000).hide("blind", 2500);245 });246247 /*248 * Topic for Drag and Drop Example.249 */250 $.subscribe('ondrop', function(event,data) {251 $(data).addClass('ui-state-highlight').find('p').html($(event.originalEvent.ui.draggable).attr('id')+' dropped!');252 $(event.originalEvent.ui.draggable).find('p').html('I was dragged!');253 });254255 /*256 * Topic for Reload Div Examples.257 */258 var refreshDiv1 = 0;259 var refreshDiv2 = 0;260 var refreshDiv3 = 0;261 var refreshList = 0;262263 $.subscribe('refreshlist', function(event, data) {264 $.publish('reloadlist');265 });266 $.subscribe('refreshdiv', function(event, data) {267 $.publish('reloaddiv1');268 });269 $.subscribe('completediv1', function(event, data) {270 if (event.originalEvent.status == "success") {271 $('#counter1').html(++refreshDiv1);272 }273 });274 $.subscribe('completediv2', function(event, data) {275 if (event.originalEvent.status == "success") {276 $('#counter2').html(++refreshDiv2);277 setTimeout( function() {278 $.publish('reloaddiv2');279 }, 10000);280 }281 });282 $.subscribe('completediv3', function(event, data) {283 if (event.originalEvent.status == "success") {284 $('#counter4').html(++refreshDiv3);285 setTimeout( function() {286 $.publish('reloaddiv3');287 }, 15000);288 }289 });290 $.subscribe('completelist', function(event, data) {291 if (event.originalEvent.status == "success") {292 $('#counter3').html(++refreshList);293 }294 });295296 $.subscribe('autocompleteChange', function(event, data) {297 var ui = event.originalEvent.ui;298 if(ui.item) {299 var message = ui.item.value;300 if(ui.item.key) {301 message = '( '+ ui.item.key +' ) '+message;302 }303 $('#topics').html('<b>'+message+'</b>');304 }305 });306307 $.subscribe('autocompleteFocus', function(event, data) {308 var ui = event.originalEvent.ui;309 var message = ui.item.value;310 if(ui.item.key) {311 message = '( '+ ui.item.key +' ) '+message;312 }313 $('#topics').html('<u>'+message+'</u>');314 });315316 $.subscribe('autocompleteSelect', function(event, data) {317 var ui = event.originalEvent.ui;318 var message = ui.item.value;319 if(ui.item.key) {320 message = '( '+ ui.item.key +' ) '+message;321 }322 $('#topics').html('<i>'+message+'</i>');323 });324325 /*326 * Subscribe Topics for Chart Example327 */328 $.subscribe('chartHover', function(event, data) {329 $("#topicsHover").text(event.originalEvent.pos.x.toFixed(2)+','+event.originalEvent.pos.y.toFixed(2));330 });331 $.subscribe('chartClick', function(event, data) {332 var item = event.originalEvent.item;333 if (item) {334 $("#topicsClick").text("You clicked point " + item.dataIndex + " ("+item.datapoint[0]+","+item.datapoint[1]+") in " + item.series.label + ".");335 event.originalEvent.plot.highlight(item.series, item.datapoint);336 }337 });338339 /*340 * Subscribe Topics for Tree Example341 */342 $.subscribe('treeClicked', function(event, data) {343 var item = event.originalEvent.data.rslt.obj;344 alert('Clicked ID : ' + item.attr("id") + ' - Text ' + item.text());345 });346347 /*348 * Subscribe Topics for Reichtext Example349 */350 $.subscribe('focusRichtext', function(event, data) {351 $("#result").addClass('ui-state-active');352 $("#result").removeClass('ui-state-highlight');353 });354 $.subscribe('blurRichtext', function(event, data) {355 $("#result").removeClass('ui-state-active');356 $("#result").removeClass('ui-state-highlight');357 });358 $.subscribe('highlightRichtext', function(event, data) {359 $("#result").removeClass('ui-state-active');360 $("#result").addClass('ui-state-highlight');361 });362363 /*364 * Menu Highlight365 */366 $('div.ui-widget-header > ul > li').click(function() {367 $('div.ui-widget-header > ul > li').removeClass('ui-state-active');368 $(this).addClass('ui-state-active');369 }, function() {370 });371 $('div.ui-widget-header > ul > li').hover(function() {372 $(this).addClass('ui-state-hover'); ...

Full Screen

Full Screen

functions.js

Source:functions.js Github

copy

Full Screen

1const fetch = require('node-fetch')2const axios = require('axios')3const CFonts = require('cfonts')4const spin = require('spinnies')5const Crypto = require('crypto')6const wait = async (media) => new Promise(async (resolve, reject) => {7 const attachmentData = `data:image/jpeg;base64,${media.toString('base64')}`8 const response = await fetch("https://trace.moe/api/search",{method: "POST",body: JSON.stringify({ image: attachmentData }),headers: { "Content-Type": "application/json" }});9 if (!response.ok) reject(`Gambar tidak ditemukan!`);10 const result = await response.json()11 try {12 const { is_adult, title, title_chinese, title_romaji, title_english, episode, season, similarity, filename, at, tokenthumb, anilist_id } = result.docs[0]13 let belief = () => similarity < 0.89 ? "Saya memiliki keyakinan rendah dalam hal ini : " : ""14 let ecch = () => is_adult ? "Iya" : "Tidak"15 resolve({video: await getBuffer(`https://media.trace.moe/video/${anilist_id}/${encodeURIComponent(filename)}?t=${at}&token=${tokenthumb}`), teks: `${belief()}16~> Ecchi : *${ecch()}*17~> Judul Jepang : *${title}*18~> Ejaan Judul : *${title_romaji}*19~> Judul Inggris : *${title_english}*20~> Episode : *${episode}*21~> Season : *${season}*`});22 } catch (e) {23 console.log(e)24 reject(`Saya tidak tau ini anime apa`)25 }26})27const simih = async (text) => {28 try {29 const sami = await fetch(`https://simsumi.herokuapp.com/api?text=${text}`, {method: 'GET'})30 const res = await sami.json()31 return res.success32 } catch {33 return 'Simi ga tau apa yang anda ngomong, bahasa alien yah kak?'34 }35}36const h2k = (number) => {37 var SI_POSTFIXES = ["", " K", " M", " G", " T", " P", " E"]38 var tier = Math.log10(Math.abs(number)) / 3 | 039 if(tier == 0) return number40 var postfix = SI_POSTFIXES[tier]41 var scale = Math.pow(10, tier * 3)42 var scaled = number / scale43 var formatted = scaled.toFixed(1) + ''44 if (/\.0$/.test(formatted))45 formatted = formatted.substr(0, formatted.length - 2)46 return formatted + postfix47}48const getBuffer = async (url, options) => {49 try {50 options ? options : {}51 const res = await axios({52 method: "get",53 url,54 headers: {55 'DNT': 1,56 'Upgrade-Insecure-Request': 157 },58 ...options,59 responseType: 'arraybuffer'60 })61 return res.data62 } catch (e) {63 console.log(`Error : ${e}`)64 }65}66const randomBytes = (length) => {67 return Crypto.randomBytes(length)68}69const generateMessageID = () => {70 return randomBytes(10).toString('hex').toUpperCase()71}72const getGroupAdmins = (participants) => {73 admins = []74 for (let i of participants) {75 i.isAdmin ? admins.push(i.jid) : ''76 }77 return admins78}79const getRandom = (ext) => {80 return `${Math.floor(Math.random() * 10000)}${ext}`81}82var spinner = { 83 "interval": 120,84 "frames": [85 "",86 "S",87 "SU",88 "SUB",89 "SUBS",90 "SUBSC",91 "SUBSCR",92 "SUBSCRI",93 "SUBSCRIB",94 "SUBSCRIBE",95 "SUBSCRIBE Z",96 "SUBSCRIBE ZE",97 "SUBSCRIBE ZER",98 "SUBSCRIBE ZERO",99 "SUBSCRIBE ZERO YT",100 "SUBSCRIBE ZERO YT7.",101 "SUBSCRIBE ZERO YT7..",102 "SUBSCRIBE ZERO YT7...",103 "SUBSCRIBE ZERO YT7",104 "SUBSCRIBE ZERO YT7.",105 "SUBSCRIBE ZERO YT7..",106 "SUBSCRIBE ZERO YT7...",107 "SUBSCRIBE ZERO YT7..",108 "SUBSCRIBE ZERO YT7.",109 "SUBSCRIBE ZERO YT7",110 "SUBSCRIBE ZERO YT7.",111 "SUBSCRIBE ZERO YT7..",112 "SUBSCRIBE ZERO YT7...",113 "SUBSCRIBE ZERO YT7..",114 "SUBSCRIBE ZERO YT7.",115 "SUBSCRIBE ZERO YT7",116 "SUBSCRIBE ZERO YT7.",117 "SUBSCRIBE ZERO YT7..",118 "SUBSCRIBE ZERO YT7...",119 "SUBSCRIBE ZERO YT7..",120 "SUBSCRIBE ZERO YT7.",121 "SUBSCRIBE ZERO YT7",122 "SUBSCRIBE ZERO YT7.",123 "SUBSCRIBE ZERO YT7..",124 "SUBSCRIBE ZERO YT7...",125 "SUBSCRIBE ZERO YT7..",126 "SUBSCRIBE ZERO YT7.",127 "SUBSCRIBE ZERO YT7",128 "SUBSCRIBE ZERO YT7.",129 "SUBSCRIBE ZERO YT7..",130 "SUBSCRIBE ZERO YT7...",131 "SUBSCRIBE ZERO YT7..",132 "SUBSCRIBE ZERO YT7.",133 "SUBSCRIBE ZERO YT7",134 "SUBSCRIBE ZERO YT7.",135 "SUBSCRIBE ZERO YT7..",136 "SUBSCRIBE ZERO YT7...",137 "SUBSCRIBE ZERO YT7..",138 "SUBSCRIBE ZERO YT7.",139 "SUBSCRIBE ZERO YT7",140 "SUBSCRIBE ZERO YT7.",141 "SUBSCRIBE ZERO YT7..",142 "SUBSCRIBE ZERO YT7...",143 "SUBSCRIBE ZERO YT7..",144 "SUBSCRIBE ZERO YT7.",145 "SUBSCRIBE ZERO YT7",146 "SUBSCRIBE ZERO YT7.",147 "SUBSCRIBE ZERO YT7..",148 "SUBSCRIBE ZERO YT7...",149 "SUBSCRIBE ZERO YT7..",150 "SUBSCRIBE ZERO YT7.",151 "SUBSCRIBE ZERO YT7",152 "SUBSCRIBE ZERO YT7.",153 "SUBSCRIBE ZERO YT7..",154 "SUBSCRIBE ZERO YT7...",155 "SUBSCRIBE ZERO YT7..",156 "SUBSCRIBE ZERO YT7.",157 "SUBSCRIBE ZERO YT7",158 "SUBSCRIBE ZERO YT7.",159 "SUBSCRIBE ZERO YT7..",160 "SUBSCRIBE ZERO YT7...",161 "SUBSCRIBE ZERO YT7..",162 "SUBSCRIBE ZERO YT7.",163 "SUBSCRIBE ZERO YT7",164 "SUBSCRIBE ZERO YT7.",165 "SUBSCRIBE ZERO YT7..",166 "SUBSCRIBE ZERO YT7...",167 "SUBSCRIBE ZERO YT7..",168 "SUBSCRIBE ZERO YT7.",169 "SUBSCRIBE ZERO YT7",170 "SUBSCRIBE ZERO YT7.",171 "SUBSCRIBE ZERO YT7..",172 "SUBSCRIBE ZERO YT7...",173 "SUBSCRIBE ZERO YT7..",174 "SUBSCRIBE ZERO YT7.",175 "SUBSCRIBE ZERO YT7",176 "SUBSCRIBE ZERO YT7.",177 "SUBSCRIBE ZERO YT7..",178 "SUBSCRIBE ZERO YT7...",179 "SUBSCRIBE ZERO YT7..",180 "SUBSCRIBE ZERO YT7.",181 "SUBSCRIBE ZERO YT7",182 "SUBSCRIBE ZERO YT7.",183 "SUBSCRIBE ZERO YT7..",184 "SUBSCRIBE ZERO YT7...",185 "SUBSCRIBE ZERO YT7..",186 "SUBSCRIBE ZERO YT7.",187 "SUBSCRIBE ZERO YT7",188 "SUBSCRIBE ZERO YT7.",189 "SUBSCRIBE ZERO YT7..",190 "SUBSCRIBE ZERO YT7...",191 "SUBSCRIBE ZERO YT7..",192 "SUBSCRIBE ZERO YT7.",193 "SUBSCRIBE ZERO YT7",194 "SUBSCRIBE ZERO YT7.",195 "SUBSCRIBE ZERO YT7..",196 "SUBSCRIBE ZERO YT7...",197 "SUBSCRIBE ZERO YT7..",198 "SUBSCRIBE ZERO YT7.",199 "SUBSCRIBE ZERO YT7",200 "SUBSCRIBE ZERO YT7.",201 "SUBSCRIBE ZERO YT7..",202 "SUBSCRIBE ZERO YT7...",203 "SUBSCRIBE ZERO YT7..",204 "SUBSCRIBE ZERO YT7.",205 "SUBSCRIBE ZERO YT7",206 "SUBSCRIBE ZERO YT7.",207 "SUBSCRIBE ZERO YT7..",208 "SUBSCRIBE ZERO YT7...",209 "SUBSCRIBE ZERO YT7..",210 "SUBSCRIBE ZERO YT7.",211 "SUBSCRIBE ZERO YT7",212 "SUBSCRIBE ZERO YT7.",213 "SUBSCRIBE ZERO YT7..",214 "SUBSCRIBE ZERO YT7...",215 "SUBSCRIBE ZERO YT7..",216 "SUBSCRIBE ZERO YT7.",217 "SUBSCRIBE ZERO YT7",218 "SUBSCRIBE ZERO YT7.",219 "SUBSCRIBE ZERO YT7..",220 "SUBSCRIBE ZERO YT7...",221 "SUBSCRIBE ZERO YT7..",222 "SUBSCRIBE ZERO YT7.",223 "SUBSCRIBE ZERO YT7",224 "SUBSCRIBE ZERO YT7.",225 "SUBSCRIBE ZERO YT7..",226 "SUBSCRIBE ZERO YT7...",227 "SUBSCRIBE ZERO YT7..",228 "SUBSCRIBE ZERO YT7.",229 "SUBSCRIBE ZERO YT7",230 "SUBSCRIBE ZERO YT7.",231 "SUBSCRIBE ZERO YT7..",232 "SUBSCRIBE ZERO YT7...",233 "SUBSCRIBE ZERO YT7..",234 "SUBSCRIBE ZERO YT7.",235 "SUBSCRIBE ZERO YT7",236 "SUBSCRIBE ZERO YT7.",237 "SUBSCRIBE ZERO YT7..",238 "SUBSCRIBE ZERO YT7...",239 "SUBSCRIBE ZERO YT7..",240 "SUBSCRIBE ZERO YT7.",241 "SUBSCRIBE ZERO YT7",242 "SUBSCRIBE ZERO YT7.",243 "SUBSCRIBE ZERO YT7..",244 "SUBSCRIBE ZERO YT7...",245 "SUBSCRIBE ZERO YT7..",246 "SUBSCRIBE ZERO YT7.",247 "SUBSCRIBE ZERO YT7",248 "SUBSCRIBE ZERO YT7.",249 "SUBSCRIBE ZERO YT7..",250 "SUBSCRIBE ZERO YT7...",251 "SUBSCRIBE ZERO YT7..",252 "SUBSCRIBE ZERO YT7.",253 "SUBSCRIBE ZERO YT7",254 "SUBSCRIBE ZERO YT7.",255 "SUBSCRIBE ZERO YT7..",256 "SUBSCRIBE ZERO YT7...",257 "SUBSCRIBE ZERO YT7..",258 "SUBSCRIBE ZERO YT7.",259 "SUBSCRIBE ZERO YT7",260 "SUBSCRIBE ZERO YT",261 "SUBSCRIBE ZERO Y",262 "SUBSCRIBE ZERO",263 "SUBSCRIBE ZER ",264 "SUBSCRIBE ZE",265 "SUBSCRIBE Z",266 "SUBSCRIBE",267 "SUBSCRIB",268 "SUBSCRI",269 "SUBSCR",270 "SUBSC",271 "SUBS",272 "SUB",273 "SU",274 "S",275 ""276 ]}277let globalSpinner;278const getGlobalSpinner = (disableSpins = false) => {279 if(!globalSpinner) globalSpinner = new spin({ color: 'blue', succeedColor: 'green', spinner, disableSpins});280 return globalSpinner;281}282spins = getGlobalSpinner(false)283const start = (id, text) => {284 spins.add(id, {text: text})285 /*setTimeout(() => {286 spins.succeed('load-spin', {text: 'Suksess'})287 }, Number(wait) * 1000)*/288 }289const info = (id, text) => {290 spins.update(id, {text: text})291}292const success = (id, text) => {293 spins.succeed(id, {text: text})294 }295const close = (id, text) => {296 spins.fail(id, {text: text})297}298const banner = 299 CFonts.say('/system/data/data/com.teremux/files:\n[ROOT] STARTING BOT...\nBy: Zero YT7', {300 font: 'console',301 align: 'left',302 gradient: ['magenta', 'red']303})304CFonts.say('ZEROYT7', {305 font: 'block',306 align: 'center',307 color: 'blue'308})309CFonts.say(`WELCOME USER\nFOLLOW ALL SOSIAL MEDIA ME\nYOUTUBE : Zero YT7\nINSTAGRAM : @Zero_YT7\nTIKTOK : @_zeroyt7\nGITHUB : Zero-YT7`, {310 font: 'console',311 align: 'center',312 gradient: ['red', 'magenta']313})314 ...

Full Screen

Full Screen

commands.help.subscribe.test.js

Source:commands.help.subscribe.test.js Github

copy

Full Screen

1const chai = require('chai').use(require('chai-as-promised'));2const expect = chai.expect;3const assert = chai.assert;4const commands = require('../../components/commands');5const formats = ['plain', 'markdown'];6const messengers = ['twitter', 'telegram']7let commandChars = ['', '/'];8describe('Test Help commands: Subscribe help', function() {9 it('#dev Help command: subscribe', function() {10 let payload = {11 command: {12 name: 'help',13 params: 'subscribe'14 },15 user: { username: 'Adesuwa' }16 }17 let promises = Array.apply(null, {length: 2}).map((a, i) => {18 payload.format = formats[i];19 return commands(payload, messengers[i % 2])20 });21 return Promise.all(promises)22 .then(messages => {23 expect(messages).to.all.have.keys('text', 'replies');24 expect(messages[0].text).to.have.string('subscribe to all drops from creator CryptoKitties on Nifty Gateway.', 'subscription filters');25 expect(messages[1].text).to.have.string('*subscribe to all drops from creator CryptoKitties on Nifty Gateway*.', '*type subscription filters*');26 expect(messages).to.satisfy(arr => {27 return arr.every((message, i) => {28 expect(message.text).to.match(/^You can subscribe to certain creators, events \(drops, sales, listings, bids, offers\), platforms \(Nifty Gateway, SuperRare\.\.\.\)/);29 expect(message.text).to.have.string('\n\nCombine subscribe commands to create a subscription filter.\nFor example,\n', '\n\nUse the options below to find more information on subscription usecases.\n\nTo view your subscription filters, type');30 let c = commandChars[i];31 expect(message.replies).to.have.deep.members([32 {text: `${c}subscribe`},33 {text: `${c}help subscribe creators`},34 {text: `${c}help subscribe events`},35 {text: `${c}help subscribe platforms`},36 {text: `${c}help subscription filters`}37 ]);38 return true;39 });40 });41 });42 });43 it('Help command: subscribe platforms', function() {44 let payload = {45 command: {46 name: 'help',47 params: 'subscribe platforms'48 },49 user: { username: 'Adesuwa' }50 }51 let promises = Array.apply(null, {length: 2}).map((a, i) => {52 payload.format = formats[i % 2];53 let messenger = messengers[ i % 2]54 return commands(payload, messenger);55 });56 return Promise.all(promises)57 .then(messages => {58 expect(messages).to.all.have.keys('text', 'replies');59 expect(messages).to.satisfy(arr => {60 expect(messages[0].text).to.have.string(61 '!subscribe','!subscribe <platform>.', '!subscribe SuperRare.'62 );63 expect(messages[1].text).to.have.string( '*/subscribe*', '*/subscribe <platform>*', '*/subscribe SuperRare*');64 return arr.every((message, i) => {65 let c = commandChars[i];66 expect(message.replies).to.have.deep.members([67 {text: `${c}subscribe nifty`},68 {text: `${c}subscribe superrare`},69 {text: `${c}subscribe zora`},70 {text: `${c}subscribe foundation`},71 ]);72 expect(message.text).to.match(/You can choose to subscribe to alerts from only certain platforms.\nTo subscribe to all platforms, simply type \*?[\!\/]subscribe\*?\.\nTo subscribe to alerts from a particular platform, just type \*?[!\/]subscribe <platform>\*?.\nFor example, if you would like to receive updates from SuperRare, type \*?[!\/]subscribe SuperRare/);73 return true;74 });75 });76 });77 });78 it('Help command: subscribe events', function() {79 let payload = {80 command: {81 name: 'help',82 params: 'subscribe events'83 },84 format: 'plain',85 user: { username: 'Adesuwa' }86 }87 let promises = Array.apply(null, {length: 2}).map((a, i) => {88 payload.format = formats[i % 2];89 let messenger = messengers[ i % 2]90 return commands(payload, messenger);91 });92 return Promise.all(promises)93 .then(messages => {94 expect(messages).to.all.have.keys('text', 'replies');95 expect(messages).to.satisfy(arr => {96 return arr.every((message, i) => {97 let c = commandChars[i];98 expect(message.text).to.match(/You can subscribe to receive alerts whenever certain events occur.\nEvents you can subscribe to include\: Sales, Listings, Bids, Offers and Drops\/Releases\. To subscribe to one or more events, for example sales and drops, type [!\/]subscribe sales, drops\./);99 expect(message.replies).to.have.deep.members([100 {text: `${c}subscribe nifty`},101 {text: `${c}subscribe superrare`},102 {text: `${c}subscribe zora`},103 {text: `${c}subscribe foundation`},104 ]);105 return true;106 });107 });108 });109 });110 it('Help command: subscribe creators', function() {111 let payload = {112 command: {113 name: 'help',114 params: 'subscribe creators'115 },116 format: 'plain',117 user: { username: 'Adesuwa' }118 }119 let promises = Array.apply(null, {length: 2}).map((a, i) => {120 payload.format = formats[i % 2];121 let messenger = messengers[ i % 2]122 return commands(payload, messenger);123 });124 return Promise.all(promises)125 .then(messages => {126 expect(messages).to.all.have.keys('text', 'replies');127 expect(messages[0]).to.eql({128 text: 'You can choose to subscribe to one or more creators. To subscribe to a creator, type !subscribe to creator Xen Pluto\n. To subscribe to multiple creators, type !subscribe to creators Xen Pluto, Yen NotPluto.',129 replies: [130 {text: '!help subscribe'},131 {text: '!help subscription filters'},132 ]133 });134 expect(messages[1]).to.eql({135 text: 'You can choose to subscribe to one or more creators. To subscribe to a creator, type /subscribe to creator Xen Pluto\n. To subscribe to multiple creators, type /subscribe to creators Xen Pluto, Yen NotPluto.',136 replies: [137 {text: '/help subscribe'},138 {text: '/help subscription filters'},139 ]140 });141 });142 });...

Full Screen

Full Screen

variables.js

Source:variables.js Github

copy

Full Screen

1import { handleVariablesFor } from 'customizer-sync-helpers'2import {3 handleBackgroundOptionFor,4} from 'blocksy-customizer-sync'5handleVariablesFor({6 newsletter_subscribe_title_color: {7 selector: '.ct-newsletter-subscribe-block',8 variable: 'heading-color',9 type: 'color:default',10 responsive: true,11 },12 newsletter_subscribe_content: [13 {14 selector: '.ct-newsletter-subscribe-block',15 variable: 'color',16 type: 'color:default',17 },18 {19 selector: '.ct-newsletter-subscribe-block',20 variable: 'linkHoverColor',21 type: 'color:hover',22 },23 ],24 newsletter_subscribe_button: [25 {26 selector: '.ct-newsletter-subscribe-block',27 variable: 'buttonInitialColor',28 type: 'color:default',29 },30 {31 selector: '.ct-newsletter-subscribe-block',32 variable: 'buttonHoverColor',33 type: 'color:hover',34 },35 ],36 newsletter_subscribe_input_font_color: [37 {38 selector: '.ct-newsletter-subscribe-block',39 variable: 'form-text-initial-color',40 type: 'color:default',41 },42 {43 selector: '.ct-newsletter-subscribe-block',44 variable: 'form-text-focus-color',45 type: 'color:focus',46 },47 ],48 newsletter_subscribe_border_color: [49 {50 selector: '.ct-newsletter-subscribe-block',51 variable: 'form-field-border-initial-color',52 type: 'color:default',53 },54 {55 selector: '.ct-newsletter-subscribe-block',56 variable: 'form-field-border-focus-color',57 type: 'color:focus',58 },59 ],60 newsletter_subscribe_input_background: [61 {62 selector: '.ct-newsletter-subscribe-block',63 variable: 'form-field-initial-background',64 type: 'color:default',65 },66 {67 selector: '.ct-newsletter-subscribe-block',68 variable: 'form-field-focus-background',69 type: 'color:focus',70 },71 ],72 ...handleBackgroundOptionFor({73 id: 'newsletter_subscribe_container_background',74 selector: '.ct-newsletter-subscribe-block',75 responsive: true,76 }),77 newsletter_subscribe_container_border: {78 selector: '.ct-newsletter-subscribe-block',79 variable: 'newsletter-container-border',80 type: 'border',81 responsive: true,82 skip_none: true,83 },84 newsletter_subscribe_shadow: {85 selector: '.ct-newsletter-subscribe-block',86 type: 'box-shadow',87 variable: 'box-shadow',88 responsive: true,89 },90 newsletter_subscribe_container_spacing: {91 selector: '.ct-newsletter-subscribe-block',92 type: 'spacing',93 variable: 'padding',94 responsive: true95 },96 newsletter_subscribe_container_border_radius: {97 selector: '.ct-newsletter-subscribe-block',98 type: 'spacing',99 variable: 'border-radius',100 responsive: true101 },...

Full Screen

Full Screen

sync.js

Source:sync.js Github

copy

Full Screen

1import { checkAndReplace, responsiveClassesFor } from 'blocksy-customizer-sync'2import './variables'3wp.customize('newsletter_subscribe_subscribe_visibility', (val) =>4 val.bind((to) => {5 const block = document.querySelector('.ct-newsletter-subscribe-block')6 responsiveClassesFor('newsletter_subscribe_subscribe_visibility', block)7 })8)9if (10 document.body.classList.contains('single') ||11 document.body.classList.contains('page')12) {13 checkAndReplace({14 id: 'newsletter_subscribe_single_post_enabled',15 strategy: 'append',16 parent_selector: '.site-main article',17 selector: '.ct-newsletter-subscribe-block',18 fragment_id: 'blocksy-mailchimp-subscribe',19 watch: [20 'has_newsletter_subscribe_name',21 'newsletter_subscribe_button_text',22 'newsletter_subscribe_title',23 'newsletter_subscribe_text',24 'newsletter_subscribe_name_label',25 'newsletter_subscribe_mail_label',26 ],27 whenInserted: () => {28 if (29 !document.body.classList.contains('single') &&30 !document.body.classList.contains('page')31 ) {32 return33 }34 const block = document.querySelector(35 '.ct-newsletter-subscribe-block'36 )37 responsiveClassesFor(38 'newsletter_subscribe_subscribe_visibility',39 block40 )41 if (wp.customize('has_newsletter_subscribe_name')() !== 'yes') {42 block.querySelector('[data-fields]').dataset.fields = 143 block.querySelector('[name="FNAME"]').remove()44 } else {45 block.querySelector('[data-fields]').dataset.fields = 246 block47 .querySelector('[name="FNAME"]')48 .setAttribute(49 'placeholder',50 `${wp.customize('newsletter_subscribe_name_label')()}`51 )52 }53 block54 .querySelector('[name="EMAIL"]')55 .setAttribute(56 'placeholder',57 `${wp.customize('newsletter_subscribe_mail_label')()} *`58 )59 block.querySelector('button').innerHTML = wp.customize(60 'newsletter_subscribe_button_text'61 )()62 block.querySelector('h3').innerHTML = wp.customize(63 'newsletter_subscribe_title'64 )()65 block.querySelector(66 '.ct-newsletter-subscribe-description'67 ).innerHTML = wp.customize('newsletter_subscribe_text')()68 },69 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest');2tracetest.subscribe('test', function(data) {3 console.log(data);4});5var tracetest = require('tracetest');6tracetest.publish('test', 'Hello World');7var tracetest = require('tracetest');8tracetest.subscribe('test', function(data) {9 console.log(data);10});11tracetest.publish('test', 'Hello World');

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('./tracetest');2tracetest.subscribe('test', function(err, data) {3 console.log("data: " + data);4});5tracetest.subscribe('test2', function(err, data) {6 console.log("data: " + data);7});8var events = require('events');9var emitter = new events.EventEmitter();10exports.subscribe = function(name, callback) {11 emitter.on(name, callback);12}13exports.publish = function(name, data) {14 emitter.emit(name, null, data);15}

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetesting = require('./tracetesting.js');2tracetesting.subscribe('test', function(data) {3 console.log('data received: ' + data);4});5var tracetesting = require('./tracetesting.js');6tracetesting.publish('test', 'data to publish');7var tracetesting = require('./tracetesting.js');8tracetesting.unsubscribe('test');9var tracetesting = require('./tracetesting.js');10tracetesting.unsubscribeAll();11var events = require('events');12var eventEmitter = new events.EventEmitter();13var subscribe = function(channel, callback) {14 eventEmitter.on(channel, callback);15};16var publish = function(channel, data) {17 eventEmitter.emit(channel, data);18};19var unsubscribe = function(channel) {20 eventEmitter.removeAllListeners(channel);21};22var unsubscribeAll = function() {23 eventEmitter.removeAllListeners();24};25module.exports = {26};

Full Screen

Using AI Code Generation

copy

Full Screen

1traceTestTest.subscribe('test', function (data) {2consoT'ss, funcoiono(dal.) {3 lonsolo.log('g('tvnttggrd wi ata:'+ da);4});traceTest.subscribe('test3', function (data) {5ce.loTet('test2',daa6d);e to use publish method of tracetest7b'tesTs.subsrib('s3',(a){8 ool.log('tst3vntriggre wt dta: ' + data);9st2.jTplsh2HlloWorld2);10racTe.publish(3Hllo World311 console.log('test2 event triggered with data: ' + data);12});T13traceTest.subscribe('test3', functio na) {14 console.log('test event triggered with test3 'vent triggered with data: ' + data);15});16tratraceTest.publish('test2', 'Hello World2');17.publTsh('eubcbvewt3',ered witd (det rld318csovcs'gr'tts)3cevens trigg.sbd wcth dare: 'e+function (data) {19 ); console.log('test event triggered with data: ' + data);20});21cTs('ts','HellWorld');22T.('t2','HllWrld2');23T.pblih('t3','HllWrl3');24vartracTe= rqure('racest');25tacTes.('test',funci(daa){26onsol.log('vntriggd wdaa:'+daa);27});28acTe.e('tst2',funcin(da){29conol.log('et2trggd w '+);30});31tceTs.bcribe('ts3',funton(daa) {32 cosol.lg('st3iggw: ' +da);33});34ceTst.publish('t','HlloWord');

Full Screen

Using AI Code Generation

copy

Full Screen

1ar tracst=require('./tcst');2var tace=nwracst();3trae.susribe((da) {4onso.log(ta);5});6trac.mi('HelloWor!');7Your nibeett displayt(op'ionan):tion(data) {8 console.log('data received: ' + data);9});10var tracetesting = require('./tracetesting.js');11tracetesting.publish('test', 'data to publish');12var tracetesting = require('./tracetesting.js');13tracetesting.unsubscribe('test');14var tracetesting = require('./tracetesting.js');15tracetesting.unsubscribeAll();16var events = require('events');17var eventEmitter = new events.EventEmitter();18var subscribe = function(channel, callback) {19 eventEmitter.on(channel, callback);20};21var publish = function(channel, data) {22 eventEmitter.emit(channel, data);23};24var unsubscribe = function(channel) {25 eventEmitter.removeAllListeners(channel);26};27var unsubscribeAll = function() {28 eventEmitter.removeAllListeners();29};30module.exports = {31 subscribe: subscribe,s', 'tet 'test');

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('tracetest);2tracetest.subscribe('channel1');3racte.publish('channel1hello');4racte.subscribe(channel2'5tracetest.publish('channel2', 'hello');6tracetest.subscribe('channel3');7tracetest.publish('channel3', 'hello');8tracetest.subscribe('channel4');9tracetest.publish('channel4', 'hello');10tracetest.subscribe('channel5');11tracetest.publish('channel5', 'hello');12tracetest.subscribe('channel6');13tracetest.publish('channel6', 'hello');14tracetest.subscribe('channel7');15tracetest.publish('channel7', 'hello');16tracetest.subscribe('channel8');17tracetest.publish('channel8', 'hello');18tracetest.subscribe('channel9');19tracetest.publish('channel9', 'hello');20tracetest.subscribe('channel10');21tracetest.publish('channel10', 'hello');22tracetest.subscribe('channel11');23tracetest.publish('channel11', 'hello');24tracetest.subscribe('channel12');25tracetest.publish('channel12', 'hello');26tracetest.subscribe('channel13');27tracetest.publish('channel13', 'hello');28tracetest.subscribe('channel14');29tracetest.publish('channel14', 'hello');30tracetest.subscribe('channel15');31tracetest.publish('channel15', 'hello');32tracetest.subscribe('channel1633};

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('tracetest');2var traceObj = new trace();3traceObj.subscribe('test');4function trace() {5 this.subscribe = function (topic) {6 console.log('subscribed to ' + topic);7 }8}9module.exports = trace;

Full Screen

Using AI Code Generation

copy

Full Screen

1var tracetest = require('./tracetest');2tracetest.subscribe('test', function(err, data) {3 console.log("data: " + data);4});5tracetest.subscribe('test2', function(err, data) {6 console.log("data: " + data);7});8var events = require('events');9var emitter = new events.EventEmitter();10exports.subscribe = function(name, callback) {11 emitter.on(name, callback);12}13exports.publish = function(name, data) {14 emitter.emit(name, null, data);15}

Full Screen

Using AI Code Generation

copy

Full Screen

1var trace = require('tracetest');2var traceObj = new trace();3traceObj.subscribe('test');4function trace() {5 this.subscribe = function (topic) {6 console.log('subscribed to ' + topic);7 }8}9module.exports = trace;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tracetest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful