How to use bm method in wpt

Best JavaScript code snippet using wpt

Select.js

Source:Select.js Github

copy

Full Screen

1'use strict';2function Select(options) {3 if (!options) 4 return true;5 this.cloud = $(options.cloud);6 this.tags = options.tags;7 var self = this;8 // Make the tags9 $(this.tags).each(function(i, d) {10 self.addSelectHTML(d);11 });12 13 $('.bm-tag', this.cloud).each(function(i) {14 self.addSelectActions($(this)); // Add actions to the new tags15 self.addSelectValues($(this), self.tags[i].options || [{selected: self.tags[i].selected}]); // Add values to the new tags16 });17}18Select.prototype.addSelectActions = function(tag) {19 var self = this;20 $('.bm-title, .bm-drop', tag).off('click').click(function() {21 var target = $(this).hasClass('bm-drop') ? $(this) : $('.bm-drop', tag).first();22 var dropdown_type = $('.bm-dropdown', target).data('type');23 var input = $('.bm-input', tag);24 if (!target.hasClass('bm-open')) {25 self.closeDrop(tag);26 target.addClass('bm-open');27 $('.bm-dropdown', target).show();28 } else {29 self.closeDrop(tag);30 }31 if ($('.bm-item', target).length) {32 $('.bm-item', target).off('click').click(function() {33 var new_value = $(this).html();34 var new_query = $(this).data('query');35 $('span', target).data('query', new_query).html(new_value);36 target.removeClass('bm-more');37 tag.addClass('bm-active');38 if (dropdown_type == 'input') {39 target.removeClass('bm-inner');40 if (new_query == 'all') {41 input.hide();42 } else {43 target.addClass('bm-inner');44 input45 .show()46 .off('focus')47 .focus()48 .off('focus')49 .focus(function() {self.closeDrop(tag)});50 }51 }52 else if (dropdown_type == 'multi') {53 if (new_query != 'all' && !target.next().length) {54 var used_tags = $('.bm-drop', tag).length;55 var unused_tags = $('.bm-dropdown:first li:nth-child(1n+2)', tag).length;56 var drop_clone = $(target).clone();57 if (used_tags != unused_tags) {58 drop_clone.removeClass('bm-open').addClass('bm-more');59 drop_clone.find('.bm-dropdown').hide();60 drop_clone.find('span').html('More');61 target.addClass('bm-inner');62 $(target).after(drop_clone);63 self.addSelectActions(tag);64 } else {65 $('span', target).data('query', 'all').html('All');66 $('.bm-drop', tag).not(target).remove();67 $('.bm-dropdown li', tag).removeClass('bm-disabled');68 return true;69 }70 $('.bm-drop span', tag).each(function() {71 var query = $(this).data('query');72 $('.bm-dropdown', tag).find('[data-query="'+ query +'"]').addClass('bm-disabled');73 });74 } else if (new_query == 'all') {75 target.removeClass('bm-inner');76 $('.bm-drop', tag).not(target).remove();77 $('.bm-dropdown li', tag).removeClass('bm-disabled');78 } else {79 $('.bm-dropdown li', tag).removeClass('bm-disabled');80 $('.bm-drop span', tag).each(function() {81 var query = $(this).data('query');82 $('.bm-dropdown', tag).find('[data-query="'+ query +'"]').addClass('bm-disabled');83 });84 }85 }86 });87 } else {88 input.focus();89 }90 self.cloud.off('click').click(function(event) {91 $('html').one('click', function() {92 self.closeDrop(tag);93 });94 event.stopPropagation();95 });96 });97 $('.bm-close', tag).off('click').click(function() {98 var target = $(this).parent();99 var prev = target.prev();100 var next = target.next();101 var query = target.find('span').data('query');102 var dropdown_type = $('.bm-dropdown', target).data('type');103 target.parent().find('.bm-dropdown').find('[data-query="'+ query +'"]').removeClass('bm-disabled');104 if (dropdown_type == 'multi') {105 if (prev.hasClass('bm-title') && (next.hasClass('bm-more') || !next.length)) {106 next.remove();107 target.parent().removeClass('bm-active');108 target.removeClass('bm-inner').find('span').data('query', 'none').html('None');109 } else if (!target.parent().find('.bm-more').length) {110 var target_clone = target.clone();111 target_clone.removeClass('bm-inner').addClass('bm-more');112 target_clone.find('span').html('More');113 target.parent().find('.bm-drop:last').after(target_clone);114 target_clone.prev().addClass('bm-inner');115 target.remove();116 self.addSelectActions(tag);117 } else {118 target.remove();119 }120 } else if (dropdown_type == 'input') {121 next.hide();122 target.parent().removeClass('bm-active');123 target.removeClass('bm-inner').find('span').data('query', 'none').html('None');124 } else {125 next.remove();126 target.parent().removeClass('bm-active');127 target.removeClass('bm-inner').find('span').data('query', 'none').html('None');128 }129 });130 $('[contenteditable]', tag).off('keyup keydown input').on('keyup keydown input', function() {131 var target = $(this).parent();132 var str = $(this).html().replace(/<br\s*[\/]?>/gi, '');133 if (str.length > 0) {134 target.has('.bm-drop').length ? false : target.addClass('bm-active');135 $(this).removeClass('bm-empty');136 } else {137 target.has('.bm-drop').length ? false : target.removeClass('bm-active');138 $(this).empty().addClass('bm-empty');139 }140 });141}142Select.prototype.addSelectValues = function(tag, options) {143 if (options) {144 $.each(options, function(i, d) {145 if (d.selected) {146 if (d.query || d.title) {147 var trigger = $('.bm-drop', tag).last().trigger('click');148 var query = d.query || d.title.replace(/[^a-zA-Z]/g, '').toLowerCase();149 $('[data-query="'+ query +'"]', trigger).trigger('click');150 } else {151 tag.addClass('bm-active');152 }153 $('.bm-input', tag).removeClass('bm-empty').html(d.selected);154 }155 });156 }157 window.setTimeout(function() {158 $('.bm-input').blur();159 }, 0);160}161Select.prototype.closeDrop = function(tag) {162 $('.bm-drop', tag).removeClass('bm-open');163 $('.bm-dropdown', tag).hide();164}165Select.prototype.addSelectHTML = function(object) {166 var HTML = '<div class="bm-tag">'+167 '<div class="bm-title bm-cell">'+ object.title +'</div>';168 var type = object.type ? this[object.type]() : this.bmSingle();169 if (object.options) {170 HTML += '<div class="bm-drop bm-cell"><i class="bm-close"></i> <span data-query="none">None</span> <i class="bm-caret"></i><ul class="bm-dropdown" data-type="'+ type +'" style="display:none;">';171 $.each(object.options, function(i, d) {172 if (i == 0 && type == 'multi') {173 HTML += '<li class="bm-item" data-query="all">All</li>';174 }175 176 var query = d.query || d.title.replace(/[^a-zA-Z]/g, '').toLowerCase();177 HTML += '<li class="bm-item" data-query="'+ query +'">'+ d.title +'</li>';178 });179 HTML += '</ul></div>';180 }181 if (type == 'input') {182 HTML += '<div class="bm-input bm-empty bm-cell" placeholder="'+ (object.placeholder || 'Enter value...') +'"'+ (object.options ? 'style="display:none;"' : '') +'contenteditable></div>';183 }184 HTML += '</div>';185 $(this.cloud).append(HTML);186}187Select.prototype.addResultHTML = function(object) {188 var options = $.map(object.options || [{selected: object.selected}], function(d) {189 return {190 title: d.title,191 selected: d.selected || false192 }193 }).filter(function(e) {return e.selected != false});194 if (!options.length)195 return false;196 var HTML = '<div class="bm-tag bm-final">'+197 '<div class="bm-title bm-cell">'+ object.title +'</div>';198 if (this[object.type] == this.bmInput) {199 if (options[0].title)200 HTML += '<div class="bm-modifier bm-cell">'+ options[0].title +'</div>';201 HTML += '<div class="bm-values bm-cell">'+ (Number(options[0].selected) ? options[0].selected : '"'+ options[0].selected +'"') +'</div>';202 } else {203 HTML += '<div class="bm-values bm-cell">';204 $.each(options, function(i, d) {205 HTML += (i == 0 ? '' : ', ') + d.title;206 });207 HTML += '</div>';208 }209 HTML += '</div>';210 return HTML;211}212Select.prototype.call = function() {213 var self = this;214 var tags = self.tags;215 $('.bm-tag', this.cloud).each(function(i, d) {216 var title = $('.bm-title', d).html();217 var index = tags.map(function(e){return e.title}).indexOf(title);218 var selected = $.makeArray($('.bm-drop:not(.bm-more) span', d).map(function() {219 return $(this).data('query');220 }));221 if (tags[index].options) {222 $.each(tags[index].options, function(j, e) {223 var query = e.query || e.title.replace(/[^a-zA-Z]/g, '').toLowerCase();224 if (selected.indexOf(query) != -1 || selected[0] == 'all') {225 var input = $('.bm-input', d).html();226 tags[index].options[j].selected = input || true;227 } else {228 tags[index].options[j].selected = false;229 }230 });231 } else {232 var input = $('.bm-input', d).html();233 tags[index].selected = input || false234 }235 });236 return tags;237}238Select.prototype.reset = function() {239 $('.bm-active', this.cloud).each(function() {240 var d = $(this).removeClass('bm-active');241 242 $('.bm-drop', d).not(':first').remove();243 $('.bm-dropdown li', d).removeClass('bm-disabled');244 d.has('.bm-drop').length ? 245 $('.bm-input', d).hide() : 246 $('.bm-input', d).addClass('bm-empty').empty();247 $('.bm-drop:first', d).removeClass('bm-active bm-inner').find('span').data('query', 'none').html('None');248 });249}250Select.prototype.bmInput = function() {251 return 'input';252}253Select.prototype.bmMulti = function() {254 return 'multi';255}256Select.prototype.bmSingle = function() {257 return 'single';...

Full Screen

Full Screen

ajxp.js

Source:ajxp.js Github

copy

Full Screen

1/*2 * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>3 * This file is part of Pydio.4 *5 * Pydio is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * Pydio is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU Affero General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Pydio. If not, see <http://www.gnu.org/licenses/>.17 *18 * The latest code can be found at <http://pyd.io/>.19 */20var currentLink;21function parseLinks(){22 var bmlink1 = '<a id="ajxp_bm_link_dl1" title="Send to Pydio">\23 Download <img ajxp_image="true" src="'+window.ajxp_bm_target+'/plugins/gui.ajax/res/themes/umbra/images/actions/22/forward_22.png" align="absmiddle"><img align="absmiddle" ajxp_image="true" src="'+window.ajxp_bm_target+'/plugins/gui.ajax/res/themes/umbra/images/actions/32/hdd_external_unmount.png"></a>';24 jQuery('body').append('<link rel="stylesheet" type="text/css" href="'+ajxp_bm_target+'plugins/uploader.http/bookmarklet/ajxp.css"></link>');25 jQuery('body').append('<div id="ajxp_bm_main" style="display:none;" class="ajxp_bm_menu" ><div><a id="ajxp_bm_close" style="float:right;font-size:12px;cursor:pointer;border-left:1px solid #fff;padding-left: 10px;">X</a>Pydio direct download</div><div class="ajxp_bm_menu_legend">Click on any link or image to send the link directly to your Pydio account.</div><div style="display:none" id="ajxp_bm_frame_div"><iframe frameborder="0" id="ajxp_bm_iframe"></iframe></div></div><div style="position:absolute;" class="ajxp_bm_menu" id="ajxp_bm_link_menu">'+bmlink1+'<a id="ajxp_bm_link_dl2">Process link normally</a></div>').click(function(){jQuery('#ajxp_bm_link_menu').slideUp();}) ;26 jQuery('#ajxp_bm_main').css("background-color", "#ffffff").css("width", "400px").css("font-size","29px").css("line-height","auto");27 window.setTimeout(function(){28 jQuery('#ajxp_bm_main').css("top", ((jQuery(window).height() - jQuery('#ajxp_bm_main').outerHeight()) / 2) + jQuery(window).scrollTop() + "px");29 jQuery('#ajxp_bm_main').css("right", ((jQuery(window).width() - jQuery('#ajxp_bm_main').outerWidth()) / 2) + jQuery(window).scrollLeft() + "px");30 jQuery('#ajxp_bm_main').slideDown();31 }, 100);32 window.setTimeout(function(){33 var wTop = jQuery(window).scrollTop() + 5;34 jQuery("#ajxp_bm_main").animate({35 top:jQuery(window).scrollTop() + 5,36 right:5,37 width:250,38 fontSize:"16px",39 lineHeight:"20px",40 opacity:0.941 });42 jQuery(".ajxp_bm_menu_legend").slideUp();43 }, 2500);44 45 jQuery(window).bind('scroll', function(){46 jQuery('#ajxp_bm_main').css('top', jQuery(window).scrollTop() + 5);47 });48 //jQuery('#ajxp_bm_main').css('top', jQuery(window).scrollTop() + 5);49 jQuery('#ajxp_bm_link_dl1').click(triggerAjxpDL);50 jQuery('#ajxp_bm_link_dl2').click(triggerOriginalDL);51 var linkHandler = function(event){52 event.preventDefault();53 event.stopPropagation();54 currentLink = jQuery(this);55 var offset = currentLink.offset();56 var height = currentLink.height();57 var width = currentLink.width();58 var href = currentLink.attr("href") || currentLink.attr('src');59 var title = realHref(href);60 jQuery('#ajxp_bm_link_dl2').show();61 if(currentLink.attr("src")){62 if(!currentLink.parents('a').size()){63 jQuery('#ajxp_bm_link_dl2').hide();64 }65 }66 if(title.length > 38){67 title = title.substring(0,10)+'...'+title.substring(title.length-28);68 }69 jQuery("#ajxp_bm_link_menu a[ajxp_clone],#ajxp_bm_link_menu img[ajxp_clone]").remove();70 if(height > 45){71 jQuery("#ajxp_bm_link_menu").addClass("ajxp_bm_big").removeClass("ajxp_bm_small");72 if(jQuery("#ajxp_bm_link_menu").css('display') == 'none'){73 jQuery("#ajxp_bm_link_menu").css('top', offset.top-5).css('left',offset.left-5).css('height',height).css('width',width).slideDown();74 }else{75 jQuery("#ajxp_bm_link_menu").animate({top:offset.top-5,left:offset.left-5,height:height,width:width});76 }77 jQuery("#ajxp_bm_link_dl1").css("margin-top",(height/2)-30);78 }else{79 jQuery("#ajxp_bm_link_menu").removeClass("ajxp_bm_big").addClass("ajxp_bm_small");80 if(jQuery("#ajxp_bm_link_menu").css('display') == 'none'){81 jQuery("#ajxp_bm_link_menu").css('top', offset.top-5).css('left',offset.left-5).css('height','auto').css('width',Math.max(width,200)).slideDown();82 }else{83 jQuery("#ajxp_bm_link_menu").animate({top:offset.top-5,left:offset.left-5,width:Math.max(width,200)}).css('height','auto');84 }85 jQuery("#ajxp_bm_link_dl1").css("margin-top",5);86 jQuery("#ajxp_bm_link_dl1").before(jQuery(currentLink[0].cloneNode(true)).attr("ajxp_clone", "true"));87 }88 };89 var eachFuncAttacher = function(index){90 var link = jQuery(this); 91 var href = link.attr("href") || link.attr('src');92 if(link.attr('ajxp_image')) return;93 if(!href) return;94 link.bind('click', linkHandler).bind("mouseenter", function(){95 if(jQuery("#ajxp_bm_link_menu").css('display') == 'none') return;96 $(this).linkHandler();97 }) .attr('ajxp_bound', 'true');98 };99 jQuery('a,img').each(eachFuncAttacher);100 jQuery('#ajxp_bm_close').click(function(){101 jQuery('a,img').each(function(index){102 var link = jQuery(this);103 if(link.attr('ajxp_bound')){104 link.unbind('click', linkHandler); 105 }106 });107 jQuery('#ajxp_bm_main').remove();108 jQuery('#ajxp_bm_link_menu').remove();109 }); 110}111function triggerAjxpDL(){112 jQuery("#ajxp_bm_link_menu").slideUp();113 var href = currentLink.attr("href") || currentLink.attr('src');114 var params = [115 'gui=light',116 'dl_later='+encodeURIComponent(realHref(href)),117 'tmp_repository_id='+ajxp_bm_repository_id,118 'folder='+ajxp_bm_folder,119 'dl_now=true'//+(jQuery('#ajxp_dl_now')[0].checked ? "true":"false")120 ];121 jQuery('#ajxp_bm_iframe').attr("src", ajxp_bm_target+"?" + params.join("&"));122 jQuery('#ajxp_bm_frame_div').slideDown();123 var firstLoad = true;124 jQuery('#ajxp_bm_iframe')[0].onload = function(){125 if(firstLoad){126 firstLoad = false;127 }else{128 jQuery('#ajxp_bm_frame_div').slideUp();129 }130 };131 /*132 window.setTimeout(function(){133 jQuery('#ajxp_bm_frame_div').slideUp();134 }, 10000);135 */136}137function triggerOriginalDL(){138 jQuery("#ajxp_bm_link_menu").slideUp();139 var href = currentLink.attr("href");140 if(currentLink.attr("src")){141 href = currentLink.parents('a').first().attr("href");142 }143 document.location.href = href; 144}145function realHref(href){146 var path = jQuery("<div style=\"background-image:url('"+href+"');\"></div>").css("background-image");147 if (path.indexOf("url(" == 0)) { path = path.substring(4); }148 if (path.lastIndexOf(")") === path.length-1) { path = path.substring(0, path.length - 1); }149 if (path.indexOf("\"") === 0) { path = path.substring(1, path.length); }150 if (path.lastIndexOf("\"") === path.length-1) { path = path.substring(0, path.length - 1); } 151 return path;152}153if(!window.jQuery){154 var element=document.createElement('scr'+'ipt');155 element.setAttribute('src','https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js?t='+(new Date().getTime()));156 if(document.all){157 element.onreadystatechange = function(){158 if(element.readyState == 'loaded'){159 jQuery.noConflict();160 parseLinks();161 }162 };163 }else{164 element.onload = function(){165 jQuery.noConflict();166 parseLinks();167 };168 }169 document.body.appendChild(element);170}else{171 parseLinks();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest')('www.webpagetest.org');2var options = {3 lighthouseConfig: {4 settings: {5 },6 },7};8wpt.runTest(url, options, function (err, data) {9 if (err) return console.error(err);10 console.log('Test ID: %s', data.data.testId);11 console.log('User URL: %s', data.data.userUrl);12 console.log('Summary CSV: %s', data.data.summaryCSV);13 console.log('Detail CSV: %s', data.data.detailCSV);14});15var wpt = require('webpagetest')('www.webpagetest.org');16var options = {17 lighthouseConfig: {18 settings: {19 },20 },21};22wpt.runTest(url, options, function (err, data) {23 if (err) return console.error(err);24 console.log('Test ID: %s', data.data.testId);25 console.log('User URL: %s', data.data.userUrl);26 console.log('Summary CSV: %s', data.data.summaryCSV);27 console.log('Detail CSV: %s', data.data.detailCSV);28});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest')('www.webpagetest.org');2var options = {3 lighthouseConfig: {4 "settings": {5 }6 }7};8wpt.runTest(options, function (err, data) {9 if (err) {10 console.log('Error: ' + err);11 } else {12 console.log('Test status: ' + data.statusCode);13 console.log('Test ID: ' + data.data.testId);14 console.log('Test URL: ' + data.data.summary);15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var http = require('http');2var fs = require('fs');3var request = require('request');4var express = require('express');5var app = express();6var path = require('path');7var bodyParser = require('body-parser');8var urlencodedParser = bodyParser.urlencoded({ extended: false });9var formidable = require('formidable');10var util = require('util');11var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;12var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;13var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webpagetest = new wpt(options);5}, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12var wpt = require('webpagetest');13var options = {14};15var webpagetest = new wpt(options);16}, function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22});23{24 "data": {25 "data": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webPageTest = new wpt(options);5}, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPageTest for %s', data.data.testUrl);8 console.log('Test ID: %s', data.data.testId);9 webPageTest.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.error(err);11 console.log('Test completed for %s', data.data.testUrl);12 console.log('View your test results at %s', data.data.summary);13 });14});

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 wpt 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