How to use collect method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

mydigitalstructure.util.financial-1.0.0.js

Source:mydigitalstructure.util.financial-1.0.0.js Github

copy

Full Screen

1/*2 {3 title: "Util; Financial",4 }5*/6/*!7 * ibCom Pty Ltd ATF ibCom Unit Trust & contributors8 * Licensed as Attribution-ShareAlike 4.0 International9 * http://creativecommons.org/licenses/by-sa/4.0/10 *11 * http://www.larryullman.com/2012/12/05/writing-the-javascript-code-for-handling-stripe-payments/12 * https://bootsnipp.com/snippets/featured/responsive-stripe-payment-form13 *14 * Example /paynow;15 <script src="/jscripts/jquery-1.8.3.min.js"></script>16 <script src="https://js.stripe.com/v3/"></script>17 <script src="/site/312/1blankspace.util.site.collect-1.0.0.js"></script>18 <p>Pay Now</p>19 <div id="ns1blankspaceUtilFinancialStripeContainer"></div>20 !!!!! TO BE CONVERTED TO MYDIGITALSRUCTURE NAMESPACE & FACTORY GENERATED CONTROLLERS21 //FLOW22 //Stripe: Elements;23 //1. Create a page with HTML container with data-ui="elements"24 //2. Get the Context; ie the invoice number, amount etc - via hash or direct passed if admin doing it25 //3. Get the stripe public key from financial account based on accountID set in the app options or passed26 //4. User enters card details 27 //5. Details tokenised by stripe28 //6. Tokenised details sent to Stripe with private key via site_collect_payment_stripe method29 //7. Response handled30 */31"use strict";32if (mydigitalstructure._util.financial == undefined) {mydigitalstructure._util.financial = {}}33if (mydigitalstructure._util.financial.collect === undefined) {mydigitalstructure._util.financial.collect = {}}34/*$(document).ready(function()35{ 36 mydigitalstructure._util.financial.collect.getContext()37});*/38mydigitalstructure._util.financial.collect =39{40 data: {_publicKey: undefined, _siteAccount: undefined, context: {currency: 'AUD'}},41 option: {autoReceipt: true},42 provider: {},43 getContext: function (param)44 { 45 var hashContexts = [];46 var context = {};47 if (window.location.hash != '')48 {49 hashContexts = window.location.hash.replace('#', '').split('|');50 }51 _.each(hashContexts, function (hashContext)52 {53 context[hashContext.split('=')[0]] = hashContext.split('=')[1]54 })55 mydigitalstructure._util.financial.collect.data.context =56 _.assign(context, mydigitalstructure._util.financial.collect.data.context);57 58 mydigitalstructure._util.financial.collect.init(context)59 },60 init: function (param)61 { 62 if (window.location.protocol == 'http:')63 {64 window.location.href = window.location.href.replace('http', 'https')65 }66 else67 {68 //Get stripe public key from _scope.69 mydigitalstructure._util.financial.collect.data.context = param;70 var collect = mydigitalstructure._util.financial.collect;71 collect.data.xhtmlContainer = $('#util-financial-collect-container-stripe');72 collect.data.xhtmlContainerSuccess = $('#util-financial-collect-container-stripe-success');73 collect.option.stripe = (collect.data.xhtmlContainer != undefined)74 if (collect.option.stripe && window.Stripe == undefined)75 {76 collect.option.stripe = false77 }78 if (collect.option.stripe)79 {80 if (collect.data._publicKey == undefined)81 {82 collect.data._publicKey = collect.data.context.publicKey;83 }84 if (collect.data._publicKey == undefined)85 {86 collect.data._publicKey = window.stripePublicKey;87 }88 if (collect.data._siteAccount == undefined)89 {90 collect.data._siteAccount = collect.data.context.account;91 }92 if (collect.data._siteAccount == undefined)93 {94 collect.data._siteAccount = window.siteAccount;95 }96 collect.option.elements = (collect.data.xhtmlContainer.attr('data-ui') == 'elements')97 collect.stripe.init(param);98 } 99 } 100 },101 error: function (error)102 {103 mydigitalstructure._util.financial.collect.data.xhtmlContainer.html(error)104 },105 stripe:106 {107 data: {},108 init: function (param, response)109 {110 var collect = mydigitalstructure._util.financial.collect;111 if (response == undefined)112 {113 if (collect.data._publicKey != undefined)114 {115 collect.stripe.init(param,116 {117 data: {rows: [{apikey: collect.data._publicKey}]},118 status: 'OK'119 }); 120 }121 else122 {123 mydigitalstructure.cloud.search(124 {125 object: 'site_funds_transfer_account',126 fields: ['apikey'],127 filters:128 [129 {130 field: 'id',131 value: collect.data._siteAccount132 }133 ],134 callback: mydigitalstructure._util.financial.collect.stripe.init,135 callbackParam: param136 });137 } 138 }139 else140 {141 if (response.status == 'OK')142 {143 if (response.data.rows.length > 0)144 {145 collect.data._publicKey = _.first(response.data.rows).apikey;146 collect.provider.stripe = Stripe(collect.data._publicKey);147 collect.stripe.render(param);148 }149 else150 {151 collect.error('Error: No public key set up.')152 }153 154 }155 else156 {157 collect.error('Error in getting key public key.')158 }159 } 160 },161 render: function (param)162 { 163 var collect = mydigitalstructure._util.financial.collect;164 if (collect.data.xhtmlContainer.html() == '')165 {166 console.log('STRIPE ERROR NO HTML');167 //DO FUNCTION TO CREATE STANDARD HTML AS PER .HTML FILE168 /*$.ajax(169 {170 type: 'GET',171 url: window.location.protocol + '//' + window.location.host + '/site/' + mydigitalstructureSiteId + '/1blankspace.util.site.collect-1.0.0.html',172 dataType: 'text',173 global: false,174 success: function(data)175 {176 if (data != '')177 {178 ns1blankspace.util.site.collect.data.xhtmlContainer.html(data);179 ns1blankspace.util.site.collect.stripe.render(param);180 } 181 },182 error: function(data)183 {184 ns1blankspace.util.site.collect.error('No payment collection template');185 }186 });*/187 }188 else189 { 190 collect.data.xhtmlContainerSuccess.hide();191 collect.data.xhtml = collect.data.xhtmlContainer.html();192 var amount = mydigitalstructure._util.param.get(param, 'amount', {default: ''}).value;193 collect.data.xhtml = collect.data.xhtml.replace(/\[\[Amount\]\]/g, amount);194 195 collect.data.xhtmlContainer.html(collect.data.xhtml);196 if (collect.option.elements)197 {198 collect.stripe.createCard(param);199 }200 else201 {202 collect.stripe.bind(param);203 }204 }205 },206 createCard: function (param)207 { 208 var collect = mydigitalstructure._util.financial.collect;209 collect.provider.elements = collect.provider.stripe.elements();210 collect.data.style =211 {212 base:213 {214 color: '#32325d',215 lineHeight: '18px',216 fontFamily: '"Helvetica Neue", Helvetica, sans-serif',217 fontSmoothing: 'antialiased',218 fontSize: '16px',219 '::placeholder':220 {221 color: '#aab7c4'222 }223 },224 invalid:225 {226 color: '#fa755a',227 iconColor: '#fa755a'228 }229 }230 collect.provider.card = collect.provider.elements.create('card',231 {style: collect.data.style});232 collect.provider.card.mount('#card-element');233 collect.stripe.bind(param);234 },235 bind: function (param)236 {237 //CHECK HTML IDS238 var collect = mydigitalstructure._util.financial.collect;239 $("#util-financial-collect-container").submit(function(event)240 {241 event.preventDefault();242 //CHECK ID243 if ($('#myds-financial-collect-collect-process').length == 0)244 {245 collect.stripe.getToken()246 } 247 });248 /* $("#myds-util-financial-collect-container").submit(function(event)249 {250 event.preventDefault();251 if ($('#myds-financial-collect-collect-process').length == 0)252 {253 mydigitalstructure._util.financial.collect.stripe.getToken();254 }255 });*/256 $('#util-financial-collect-collect-process').click(function(event)257 {258 var collect = mydigitalstructure._util.financial.collect;259 if (collect.option.elements)260 {261 collect.stripe.getToken();262 }263 else264 {265 collect.stripe.process();266 } 267 });268 if (collect.option.elements)269 {270 collect.provider.card.addEventListener('change', function(event)271 {272 if (event.error)273 {274 collect.data.error = true;275 $('#myds-util-financial-collect-card-errors').addClass('alert alert-danger');276 $('#myds-util-financial-collect-card-errors').html(event.error.message);277 }278 else279 {280 collect.data.error = false;281 $('#myds-util-financial-collect-card-errors').removeClass('alert alert-danger');282 $('#myds-util-financial-collect-card-errors').html('');283 }284 });285 } 286 },287 process: function (param)288 {289 //If not using Stripe Elements290 var collect = mydigitalstructure._util.financial.collect;291 if (param == undefined) {param = {}}292 param.error = false;293 param.errorMessages = [];294 param.number = $('.card-number').val();295 if (param.number == undefined) {param.number = $('.number').val()}296 param.cvc = $('.card-cvc').val();297 if (param.cvc == undefined) {param.cvc = $('.cvc').val()}298 param.exp_month = $('.card-expiry-month').val();299 if (param.exp_month == undefined) {param.exp_month = $('.expiry-month').val()}300 param.exp_year = $('.card-expiry-year').val();301 if (param.exp_year == undefined) {param.exp_year = $('.expiry-year').val()}302 if ((param.exp_year == undefined || param.exp_year == '')303 && (param.exp_month == undefined || param.exp_month == ''))304 {305 param.expiry = $('.expiry').val();306 if (param.expiry != undefined)307 {308 var aExpiry = param.expiry.split('/');309 if (aExpiry.length > 0)310 {311 param.exp_month = aExpiry[0];312 param.exp_year = aExpiry[1];313 } 314 }315 }316 if (!Stripe.card.validateCardNumber(param.number))317 {318 param.error = true;319 param.errorMessages.push('<div>The credit card number appears to be invalid.</div>');320 }321 if (!Stripe.card.validateCVC(param.cvc))322 {323 param.error = true;324 param.errorMessages.push('<div>The CVC number appears to be invalid.</div>');325 }326 if (!Stripe.card.validateExpiry(param.exp_month, param.exp_year))327 {328 param.error = true;329 param.errorMessages.push('<div>The expiration date appears to be invalid.</div>');330 }331 if (!param.error)332 {333 collect.provider.stripe.getToken()334 }335 else336 {337 collect.error(param.errorMessages.join(''));338 }339 }, 340 getToken: function (param)341 {342 var collect = mydigitalstructure._util.financial.collect;343 //CHECK ID344 $('#util-financial-collect-process').addClass('disabled').prop('disabled', true);345 collect.provider.stripe.createToken(collect.provider.card)346 .then(function(result)347 {348 if (result.error)349 {350 collect.stripe.error(result.error.message);351 }352 else353 {354 collect.stripe.processToken(result.token);355 }356 });357 },358 processToken: function (token)359 {360 var collect = mydigitalstructure._util.financial.collect;361 if (token != undefined)362 {363 var currency = collect.data.context.currency;364 if (currency == undefined) {currency = 'AUD'}365 var data =366 {367 token: token.id,368 currency: currency,369 amount: collect.data.context.amount,370 invoiceGUID: collect.data.context.invoiceGUID,371 description: collect.data.context.description,372 account: collect.data._siteAccount,373 site: window.mydigitalstructureSiteId374 }375 mydigitalstructure.cloud.invoke(376 {377 method: 'site_collect_payment_stripe',378 data: data,379 callback: mydigitalstructure._util.financial.collect.stripe.processTokenResponse,380 callbackParam: token381 });382 /* $.ajax(383 {384 type: 'POST',385 url: '/rpc/site/?method=SITE_COLLECT_PAYMENT_STRIPE',386 data: oData,387 dataType: 'json',388 success: function (data)389 {390 ns1blankspace.util.site.collect.stripe.processComplete(data);391 },392 error: function (data)393 {394 ns1blankspace.util.site.collect.stripe.error(data.responseJSON.error.errornotes)395 }396 });*/397 }398 else399 {400 collect.error('Bad token')401 } 402 },403 processTokenResponse: function (param, response)404 {405 var error = false;406 var collect = mydigitalstructure._util.financial.collect;407 if (error)408 {409 console.log('STRIPE ERROR');410 console.log(response);411 collect.error(data.responseJSON.error.errornotes);412 }413 else414 {415 collect.stripe.processComplete(response);416 }417 },418 processComplete: function (response)419 {420 var collect = mydigitalstructure._util.financial.collect;421 if (response.status == 'OK')422 {423 if (response.stripe_status == 'succeeded')424 {425 if (collect.option.autoReceipt)426 { 427 collect.stripe.autoReceipt({chargeToken: response.stripe_id})428 }429 else430 {431 collect.data.xhtmlContainer.hide();432 collect.data.xhtmlContainerSuccess.show();433 }434 }435 else436 {437 collect.stripe.error(response.stripe_outcome_sellermessage)438 }439 }440 else441 {442 collect.data.xhtmlContainer.html('<h3>There is something wrong with the set up of this page!')443 }444 },445 autoReceipt: function (param, response)446 {447 var collect = mydigitalstructure._util.financial.collect;448 if (response == undefined)449 {450 var data =451 {452 amount: collect.data.context.amount,453 guid: collect.data.context.invoiceGUID,454 description: param.chargeToken 455 }456 // site: window.mydigitalstructureSiteId457 mydigitalstructure.cloud.invoke(458 {459 method: 'site_auto_receipt',460 data: data,461 callback: mydigitalstructure._util.financial.collect.stripe.autoReceipt,462 callbackParam: param463 });464 /* $.ajax(465 {466 type: 'POST',467 url: '/rpc/site/?method=SITE_AUTO_RECEIPT',468 data: oData,469 dataType: 'json',470 success: function (data)471 {472 mydigitalstructure._util.financial.collect.stripe.autoReceipt(param, data);473 }474 });*/475 }476 else477 {478 if (response.status == 'ER')479 {480 collect.stripe.error(response.error.errornotes)481 }482 else483 {484 collect.data.xhtmlContainer.hide();485 collect.data.xhtmlContainerSuccess.show();486 }487 } 488 },489 error: function (message)490 {491 $('#card-errors').html(message).addClass('alert alert-danger');492 $('#site-collect-process').prop('disabled', false);493 return false;494 }495 496 }497}498mydigitalstructure._util.factory.financial = function (param)499{500 app.add(501 [502 {503 name: 'util-financial-collect-initialise',504 code: function (param)505 {506 mydigitalstructure._util.financial.collect.init(param);507 }508 }509 ]);...

Full Screen

Full Screen

collector.js

Source:collector.js Github

copy

Full Screen

...6 key1: 1,7 key2: 2,8 key3: 3,9 };10 const dc = collect(3)11 .done((err, result) => {12 test.error(err);13 test.strictSame(result, expectedResult);14 test.end();15 })16 .timeout(1000);17 dc('key1', null, 1);18 dc('key2', null, 2);19 dc('key3', null, 3);20});21metatests.test('data collector method', test => {22 const expectedResult = {23 key1: 1,24 key2: 2,25 key3: 3,26 };27 const dc = collect(3)28 .done((err, result) => {29 test.error(err);30 test.strictSame(result, expectedResult);31 test.end();32 })33 .timeout(1000);34 dc.collect('key1', null, 1);35 dc.collect('key2', null, 2);36 dc.collect('key3', null, 3);37});38metatests.test('data collector', test => {39 const expectedResult = {40 key1: 1,41 key2: 2,42 key3: 3,43 };44 const kc = collect(['key1', 'key2', 'key3'])45 .done((err, result) => {46 test.error(err);47 test.strictSame(result, expectedResult);48 test.end();49 })50 .timeout();51 kc.collect('key1', null, 1);52 kc.collect('key2', null, 2);53 kc.collect('key3', null, 3);54});55metatests.test('distinct data collector', test => {56 const expectedResult = {57 key1: 2,58 key2: 2,59 key3: 3,60 };61 const dc = collect(3)62 .distinct()63 .done((err, result) => {64 test.error(err);65 test.strictSame(result, expectedResult);66 test.end();67 });68 dc.pick('key1', 1);69 dc.pick('key1', 2);70 dc.pick('key2', 2);71 dc.pick('key3', 3);72});73metatests.test('distinct key collector', test => {74 const expectedResult = {75 key1: 2,76 key2: 2,77 key3: 3,78 };79 const kc = collect(['key1', 'key2', 'key3'])80 .distinct()81 .done((err, result) => {82 test.error(err);83 test.strictSame(result, expectedResult);84 test.end();85 });86 kc.pick('key1', 1);87 kc.pick('key1', 2);88 kc.pick('key2', 2);89 kc.pick('key3', 3);90});91metatests.test('data collector with repeated keys', test => {92 const dc = collect(3)93 .timeout(100)94 .done(err => {95 test.assert(err);96 test.end();97 });98 dc.collect('key1', null, 1);99 dc.collect('key1', null, 2);100 dc.collect('key2', null, 2);101});102metatests.test('key collector with repeated keys', test => {103 const kc = collect(['key1', 'key2', 'key3'])104 .timeout(100)105 .done(err => {106 test.assert(err);107 test.end();108 });109 kc.collect('key1', null, 1);110 kc.collect('key1', null, 2);111 kc.collect('key2', null, 2);112});113metatests.test('collect with error', test => {114 const testErr = new Error('Test error');115 const col = collect(1);116 col.done((err, res) => {117 test.strictSame(err, testErr);118 test.strictSame(res, {});119 test.end();120 });121 col.fail('someKey', testErr);122});123metatests.test('collect method calling after it is done', test => {124 const col = collect(1);125 col.done((err, res) => {126 test.error(err);127 test.strictSame(res, { someKey: 'someVal' });128 test.end();129 });130 col.pick('someKey', 'someVal');131 col.pick('someKey2', 'someVal2');132});133metatests.test('keys collector receives wrong key', test => {134 const col = collect(['rightKey']);135 col.done((err, res) => {136 test.error(err);137 test.strictSame(res, { wrongKey: 'someVal', rightKey: 'someVal' });138 test.end();139 });140 col.pick('wrongKey', 'someVal');141 col.pick('rightKey', 'someVal');142});143metatests.test('distinct keys collector receives wrong key', test => {144 const col = collect(['rightKey']).distinct();145 col.done(err => {146 test.assert(err);147 test.end();148 });149 col.pick('wrongKey', 'someVal');150 col.pick('rightKey', 'someVal');151});152metatests.test('collect with take', test => {153 const col = collect(1);154 col.done((err, res) => {155 test.error(err);156 test.strictSame(res, { someKey: 'someVal' });157 test.end();158 });159 const af = (x, callback) => callback(null, x);160 col.take('someKey', af, 'someVal');161});162metatests.test('collect generate callback', test => {163 const col = collect(1);164 col.done((err, res) => {165 test.error(err);166 test.strictSame(res, { someKey: 'someVal' });167 test.end();168 });169 const af = (x, callback) => callback(null, x);170 af('someVal', col.callback('someKey'));171});172metatests.test('collect generate callback shorthand', test => {173 const col = collect(1);174 col.done((err, res) => {175 test.error(err);176 test.strictSame(res, { someKey: 'someVal' });177 test.end();178 });179 const af = (x, callback) => callback(null, x);180 af('someVal', col('someKey'));181});182metatests.test('collect with timeout error', test => {183 const timeoutErr = new Error('Collector timeout');184 const col = collect(1)185 .done((err, res) => {186 test.strictSame(err, timeoutErr);187 test.strictSame(res, {});188 test.end();189 })190 .timeout(1);191 const af = (x, callback) => setTimeout(() => callback(null, x), 2);192 col.take('someKey', af, 'someVal');193});194metatests.test('collect with take calls bigger than expected', test => {195 const col = collect(1).done((err, res) => {196 test.error(err);197 test.strictSame(Object.keys(res).length, 1);198 test.end();199 });200 const af = (x, callback) => setTimeout(() => callback(null, x), 1);201 col.take('someKey', af, 'someVal');202 col.take('someKey2', af, 'someVal2');203});204metatests.test('cancel data collector', test => {205 const dc = collect(3).done(err => {206 test.assert(err);207 test.end();208 });209 dc.pick('key', 'value');210 dc.cancel();211});212metatests.test('cancel key collector', test => {213 const dc = collect(['uno', 'due']).done(err => {214 test.assert(err);215 test.end();216 });217 dc.pick('key', 'value');218 dc.cancel();219});220metatests.test('collect then success', test => {221 const col = collect(1).then(222 result => {223 test.assert(result);224 test.end();225 },226 err => {227 test.error(err);228 test.end();229 }230 );231 col.pick('Key', 'value');232});233metatests.test('collect then fail', test => {234 collect(5)235 .timeout(10)236 .then(237 result => {238 test.error(result);239 test.end();240 },241 err => {242 test.assert(err);243 test.end();244 }245 );...

Full Screen

Full Screen

video.js

Source:video.js Github

copy

Full Screen

...25 var collectData = {};26 collectData.id = $('#video_id').val().trim();27 collectData.action = 'play';28 collectData.time = player.getCurrentTime();29 collect(collectData);30 }31 });32 player.on("pause", function () {33 console.log('pause');34 var currentTime = player.getCurrentTime();35 // Collect pause action36 var collectData = {};37 collectData.id = $('#video_id').val().trim();38 collectData.action = 'pause';39 collectData.time = currentTime;40 collect(collectData);41 });42 player.on('ended', function () {43 question_dialog();44 var testBtn = $('#test_btn');45 var disableBtn = $(testBtn).find('.disable');46 $(disableBtn).hide();47 var enableBtn = $(testBtn).find('.enable');48 $(enableBtn).show();49 $(enableBtn).bind('click', question_dialog);50 // Collect ended action51 var collectData = {};52 collectData.id = $('#video_id').val().trim();53 collectData.action = 'end';54 collectData.time = player.getCurrentTime();55 collect(collectData);56 });57 // Collect open action58 var collectData = {};59 collectData.id = $('#video_id').val().trim();60 collectData.action = 'open';61 collect(collectData);62}63function question_dialog() {64 $('#question-confirm').dialog({65 resizable: false,66 height: "auto",67 width: "9.0625rem",68 modal: true,69 buttons: [{70 text: "马上开始",71 class: 'open',72 click: function () {73 var video_id = $('#video_id').val();74 console.log(video_id);75 window.location = '/video-cms/index.php?g=Video&m=Index&a=question&id=' + video_id;76 $(this).dialog("close");77 }78 }, {79 text: "稍后再说",80 class: 'close',81 click: function () {82 $(this).dialog("close");83 }84 }]85 });86}87// Just for test88//$('#test_btn').click(question_dialog);89// ### Control title slide down90$('#title_btn').on('click', function () {91 if($(this).hasClass('up')){92 $(this).removeClass('up');93 $(this).addClass('down');94 $('#title_desc').show('slow');95 } else if ($(this).hasClass('down')) {96 $(this).removeClass('down');97 $(this).addClass('up');98 $('#title_desc').hide('slow');99 }100});101//complete_info();102// ### Complete user info103//if($('#cu').val() === '1'){104function complete_info() {105 $('#complete_info').dialog({106 resizable: false,107 height: "auto",108 width: "9.0625rem",109 modal: true,110 buttons: [{111 text: "确定",112 class: 'ok',113 click: function () {114 if(!$('#agreement').is(':checked')){115 alert('请先阅读并同意我们的服务协议');116 return false;117 }118 var real_name = $('#real_name').val();119 var sex = $('#sex').val();120 var age = $('#age').val();121 var phone = $('#phone').val();122 if(real_name === ''){123 alert('请输入真实姓名');124 return false;125 }126 if(sex === ''){127 alert('请输入性别');128 return false;129 }130 if(age === ''){131 alert('请输入年龄');132 return false;133 }134 if(phone === ''){135 alert('请输入手机号码');136 return false;137 }138 if(!(/^1[3|4|5|8][0-9]{9}$/.test(phone))){139 alert('请输入正确手机号码');140 return false;141 }142 $.getJSON('/video-cms/index.php?g=Video&m=Index&a=complete_info&' + $('#complete-form').serialize(),function (data, status) {143 if(data !== undefined && data.code === 0){144 $('#cu').val('');145 }146 });147 $(this).dialog("close");148 }149 }]150 });151}152function collect(data){153 $.get('/video-cms/index.php?g=Video&m=Collect&a=video&' + $.param(data), function (data) {154 console.log(data);155 })...

Full Screen

Full Screen

router.js

Source:router.js Github

copy

Full Screen

1var app = angular.module('courseCollect', []);2app.config(function($provide, $stateProvider){3 $stateProvider.state("root.subjectSummary.courseCollect", {4 url : "/courseCollect",5 views : {6 "content@root.subjectSummary" : {7 templateUrl : "root/subjectSummary/courseCollect/_res/html/index.html",8 controller:"courseCollectCtrl"9 },"menu@root.subjectSummary" : {10 templateUrl : "root/subjectSummary/courseCollect/_res/html/menu.html",11 controller:"courseCollectMenuCtrl"12 }13 }14 }).state("root.subjectSummary.courseCollect.list[12]",{15 url:"/list[12]?id=&name=&page=",16 views:{17 "content@root.subjectSummary.courseCollect":{18 templateUrl : "root/subjectSummary/courseCollect/list/_res/html/index.html",19 controller:'courseCollectListCtrl'20 }21 }22 }).state("root.subjectSummary.courseCollect.add[12]",{23 url:"/add[12]",24 views:{25 "content@root.subjectSummary.courseCollect":{26 templateUrl : "root/subjectSummary/courseCollect/add/_res/html/index.html",27 controller:'courseCollectAddCtrl'28 }29 }30 }).state("root.subjectSummary.courseCollect.edit[12]",{31 url:"/edit[12]?id=&page=",32 views:{33 "content@root.subjectSummary.courseCollect":{34 templateUrl : "root/subjectSummary/courseCollect/edit/_res/html/index.html",35 controller:'courseCollectEditCtrl'36 }37 }38 }).state("root.subjectSummary.courseCollect.export[12]",{39 url:"/export[12]",40 views:{41 "content@root.subjectSummary.courseCollect":{42 templateUrl : "root/subjectSummary/courseCollect/export/_res/html/index.html",43 controller:'courseCollectExportCtrl'44 }45 }46 }).state("root.subjectSummary.courseCollect.subjectsSummary[12]",{47 url:"/subjectsSummary[12]",48 views:{49 "content@root.subjectSummary.courseCollect":{50 templateUrl : "root/subjectSummary/courseCollect/subjectsSummary/_res/html/index.html",51 controller:'subjectsSummaryCtrl'52 }53 }54 }).state("root.subjectSummary.courseCollect.areasSummary[12]",{55 url:"/areasSummary[12]",56 views:{57 "content@root.subjectSummary.courseCollect":{58 templateUrl : "root/subjectSummary/courseCollect/areasSummary/_res/html/index.html",59 controller:'areasSummaryCtrl'60 }61 }62 }).state("root.subjectSummary.courseCollect.teamSummary[12]",{63 url:"/teamSummary[12]",64 views:{65 "content@root.subjectSummary.courseCollect":{66 templateUrl : "root/subjectSummary/courseCollect/teamSummary/_res/html/index.html",67 controller:'teamSummaryCtrl'68 }69 }70 }).state("root.subjectSummary.courseCollect.projectSummary[12]",{71 url:"/projectSummary[12]",72 views:{73 "content@root.subjectSummary.courseCollect":{74 templateUrl : "root/subjectSummary/courseCollect/projectSummary/_res/html/index.html",75 controller:'projectNameSummaryCtrl'76 }77 }78 }).state("root.subjectSummary.courseCollect.contrast[12]",{79 url:"/contrast[12]",80 views:{81 "content@root.subjectSummary.courseCollect":{82 templateUrl : "root/subjectSummary/courseCollect/contrast/_res/html/index.html",83 controller:'courseCollectContrastCtrl'84 }85 }86 })...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1// pages/collectionGoods/index.js23import { getCollectUserList, getProductHot, collectDel} from '../../api/store.js';456const app=getApp();7Page({89 /**10 * 页面的初始数据11 */12 data: {13 parameter: {14 'navbar': '1',15 'return': '1',16 'title': '收藏商品',17 'color': false18 },19 host_product:[],20 loadTitle:'加载更多',21 loading:false,22 loadend:false,23 collectProductList:[],24 limit:8,25 page:1,26 },27 /**28 * 授权回调29 */30 onLoadFun:function(){31 this.get_user_collect_product();32 this.get_host_product();33 },34 /**35 * 生命周期函数--监听页面加载36 */37 onLoad: function (options) {3839 },40 /**41 * 获取收藏产品42 */43 get_user_collect_product:function(){44 var that=this;45 if (this.data.loading) return;46 if (this.data.loadend) return;47 that.setData({ loading: true, loadTitle:''});48 getCollectUserList({ page: that.data.page,limit: that.data.limit}).then(res=>{49 var collectProductList = res.data;50 var loadend = collectProductList.length < that.data.limit;51 console.log(collectProductList.length);52 that.data.collectProductList = app.SplitArray(collectProductList, that.data.collectProductList);53 that.setData({54 collectProductList: that.data.collectProductList,55 loadend: loadend,56 loadTitle: loadend ? '我也是有底线的' : '加载更多',57 page: that.data.page + 1,58 loading: false59 });60 }).catch(err=>{61 that.setData({ loading: false, loadTitle: "加载更多" })62 });63 },64 /**65 * 取消收藏66 */67 delCollection:function(e){68 var id = e.target.dataset.id, that = this, index = e.target.dataset.index;69 collectDel(id).then(res=>{70 return app.Tips({ title: '取消收藏成功', icon: 'success' }, function () {71 that.data.collectProductList.splice(index, 1);72 that.setData({ collectProductList: that.data.collectProductList });73 });74 });75 },76 /**77 * 获取我的推荐78 */79 get_host_product: function () {80 var that = this;81 getProductHot().then(res=>{82 that.setData({ host_product: res.data });83 });84 },85 /**86 * 页面上拉触底事件的处理函数87 */88 onReachBottom: function () {89 this.get_user_collect_product();90 } ...

Full Screen

Full Screen

collect_panels.js

Source:collect_panels.js Github

copy

Full Screen

1import sinon from 'sinon';2import * as collectIndexPatternsDep from '../collect_index_patterns';3import * as collectSearchSourcesDep from '../collect_search_sources';4import { collectPanels } from '../collect_panels';5import { expect } from 'chai';6describe('collectPanels(req, dashboard)', () => {7 let collectSearchSourcesStub;8 let collectIndexPatternsStub;9 let dashboard;10 const savedObjectsClient = { bulkGet: sinon.mock() };11 beforeEach(() => {12 dashboard = {13 attributes: {14 panelsJSON: JSON.stringify([15 { id: 'panel-01', type: 'search' },16 { id: 'panel-02', type: 'visualization' }17 ])18 }19 };20 savedObjectsClient.bulkGet.returns(Promise.resolve({21 saved_objects: [22 { id: 'panel-01' }, { id: 'panel-02' }23 ]24 }));25 collectIndexPatternsStub = sinon.stub(collectIndexPatternsDep, 'collectIndexPatterns');26 collectIndexPatternsStub.returns([{ id: 'logstash-*' }]);27 collectSearchSourcesStub = sinon.stub(collectSearchSourcesDep, 'collectSearchSources');28 collectSearchSourcesStub.returns([ { id: 'search-01' }]);29 });30 afterEach(() => {31 collectSearchSourcesStub.restore();32 collectIndexPatternsStub.restore();33 savedObjectsClient.bulkGet.reset();34 });35 it('should request each panel in the panelJSON', async () => {36 await collectPanels(savedObjectsClient, dashboard);37 expect(savedObjectsClient.bulkGet.calledOnce).to.equal(true);38 expect(savedObjectsClient.bulkGet.getCall(0).args[0]).to.eql([{39 id: 'panel-01',40 type: 'search'41 }, {42 id: 'panel-02',43 type: 'visualization'44 }]);45 });46 it('should call collectSearchSources()', async () => {47 await collectPanels(savedObjectsClient, dashboard);48 expect(collectSearchSourcesStub.calledOnce).to.equal(true);49 expect(collectSearchSourcesStub.args[0][1]).to.eql([50 { id: 'panel-01' },51 { id: 'panel-02' }52 ]);53 });54 it('should call collectIndexPatterns()', async () => {55 await collectPanels(savedObjectsClient, dashboard);56 expect(collectIndexPatternsStub.calledOnce).to.equal(true);57 expect(collectIndexPatternsStub.args[0][1]).to.eql([58 { id: 'panel-01' },59 { id: 'panel-02' }60 ]);61 });62 it('should return panels, index patterns, search sources, and dashboard', async () => {63 const results = await collectPanels(savedObjectsClient, dashboard);64 expect(results).to.eql([65 { id: 'panel-01' },66 { id: 'panel-02' },67 { id: 'logstash-*' },68 { id: 'search-01' },69 dashboard70 ]);71 });...

Full Screen

Full Screen

service.js

Source:service.js Github

copy

Full Screen

1var app = angular.module('collectServer',[]);2app.factory('collectSer',function ($http) {3 return {4 // collectOper : collectOper,5 collectDay : collectDay,6 collectWeek : collectWeek,7 collectMonth : collectMonth,8 collectPermission:collectPermission,9 collectTotal : collectTotal,10 getYear:getYear,11 biddingcollectfigure:biddingcollectfigure,12 findweek:findweek,13 };14 //获取年份15 function getYear(data){16 return $http.get('/biddinginfo/getYear',{17 params: data18 })19 }20 // //操作日志汇总21 // function collectOper(data){22 // return $http.post('/collectOper/Oper',data)23 // }24 //转正管理日汇总25 function collectDay(data){26 return $http.post('/collectDay/Day',data)27 }28 //转正管理周汇总29 function collectWeek(data){30 return $http.post('/collectWeek/Week',data)31 }32 //转正管理月汇总33 function collectMonth(data){34 return $http.post('/collectMonth/Month',data)35 }36 //转正管理累计汇总37 function collectTotal(data){38 return $http.post('/collectTotal/Total',data)39 }40 function collectPermission(data){41 return $http.get('/positPermission/permission/'+data);42 }43 function biddingcollectfigure(data){44 return $http.get('/biddingcollectfigure/dayCollect',{params: data})45 }46 function findweek(data){47 return $http.get('/biddingcollect/findweek',{params: data})48 }...

Full Screen

Full Screen

api.js

Source:api.js Github

copy

Full Screen

1'use strict';2// api 路径3var HOST = 'https://cnodejs.org/api/v1';4// get /topics 主题首页5var topics = HOST + '/topics';6//get /topic/:id 主题详情7var topic = HOST + '/topic';8// post /accesstoken 验证 accessToken 的正确性9var accesstoken = HOST + '/accesstoken';10// post /topic_collect/collect 收藏主题11var collect = HOST + '/topic_collect/collect';12// post /topic_collect/de_collect 取消主题13var de_collect = HOST + '/topic_collect/de_collect';14// post /reply/:reply_id/ups 为评论点赞15function reply (id) {16 return HOST + "/reply/"+ id +"/ups"17}18// get请求方法19function fetchGet(url, callback) {20 // return callback(null, top250)21 wx.request({22 url: url,23 header: { 'Content-Type': 'application/json' },24 success (res) {25 callback(null, res.data)26 },27 fail (e) {28 console.error(e)29 callback(e)30 }31 })32}33// post请求方法34function fetchPost(url, data, callback) {35 wx.request({36 method: 'POST',37 url: url,38 data: data,39 success (res) {40 callback(null, res.data)41 },42 fail (e) {43 console.error(e)44 callback(e)45 }46 })47}48module.exports = {49 // API50 topics: topics,51 topic: topic,52 accesstoken: accesstoken,53 collect: collect,54 de_collect: de_collect,55 reply: reply,56 // METHOD57 fetchGet: fetchGet,58 fetchPost: fetchPost...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var device = require('devicefarmer-stf-device');2deviceFarmer.collect(function(err, devices) {3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(devices);7 }8});9var device = require('devicefarmer-stf-device');10deviceFarmer.collect(function(err, devices) {11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log(devices);15 }16});17var device = require('devicefarmer-stf-device');18deviceFarmer.collect(function(err, devices) {19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log(devices);23 }24});25var device = require('devicefarmer-stf-device');26deviceFarmer.collect(function(err, devices) {27 if (err) {28 console.log('Error: ' + err);29 } else {30 console.log(devices);31 }32});33var device = require('devicefarmer-stf-device');34deviceFarmer.collect(function(err, devices) {35 if (err) {36 console.log('Error: ' + err);37 } else {38 console.log(devices);39 }40});41var device = require('devicefarmer-stf-device');42deviceFarmer.collect(function(err, devices) {43 if (err) {44 console.log('Error: ' + err);45 } else {46 console.log(devices);47 }48});

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 devicefarmer-stf 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