How to use pull method in wpt

Best JavaScript code snippet using wpt

PullRequest.py

Source:PullRequest.py Github

copy

Full Screen

...26class PullRequest(Framework.TestCase):27 def setUp(self):28 Framework.TestCase.setUp(self)29 self.repo = self.g.get_user().get_repo("PyGithub")30 self.pull = self.repo.get_pull(31)31 def testAttributes(self):32 self.assertEqual(self.pull.additions, 511)33 self.assertEqual(self.pull.assignee.login, "jacquev6")34 self.assertEqual(self.pull.base.label, "jacquev6:topic/RewriteWithGeneratedCode")35 self.assertEqual(self.pull.base.sha, "ed866fc43833802ab553e5ff8581c81bb00dd433")36 self.assertEqual(self.pull.base.user.login, "jacquev6")37 self.assertEqual(self.pull.base.ref, "topic/RewriteWithGeneratedCode")38 self.assertEqual(self.pull.base.repo.full_name, "jacquev6/PyGithub")39 self.assertEqual(self.pull.body, "Body edited by PyGithub")40 self.assertEqual(self.pull.changed_files, 45)41 self.assertEqual(self.pull.closed_at, datetime.datetime(2012, 5, 27, 10, 29, 7))42 self.assertEqual(self.pull.comments, 1)43 self.assertEqual(self.pull.commits, 3)44 self.assertEqual(self.pull.created_at, datetime.datetime(2012, 5, 27, 9, 25, 36))45 self.assertEqual(self.pull.deletions, 384)46 self.assertEqual(self.pull.diff_url, "https://github.com/jacquev6/PyGithub/pull/31.diff")47 self.assertEqual(self.pull.head.label, "BeaverSoftware:master")48 self.assertEqual(self.pull.html_url, "https://github.com/jacquev6/PyGithub/pull/31")49 self.assertEqual(self.pull.id, 1436215)50 self.assertEqual(self.pull.issue_url, "https://github.com/jacquev6/PyGithub/issues/31")51 self.assertFalse(self.pull.mergeable)52 self.assertTrue(self.pull.merged)53 self.assertEqual(self.pull.merged_at, datetime.datetime(2012, 5, 27, 10, 29, 7))54 self.assertEqual(self.pull.merged_by.login, "jacquev6")55 self.assertEqual(self.pull.number, 31)56 self.assertEqual(self.pull.patch_url, "https://github.com/jacquev6/PyGithub/pull/31.patch")57 self.assertEqual(self.pull.review_comments, 1)58 self.assertEqual(self.pull.state, "closed")59 self.assertEqual(self.pull.title, "Title edited by PyGithub")60 self.assertEqual(self.pull.updated_at, datetime.datetime(2012, 11, 3, 8, 19, 40))61 self.assertEqual(self.pull.url, "https://api.github.com/repos/jacquev6/PyGithub/pulls/31")62 self.assertEqual(self.pull.user.login, "jacquev6")63 def testCreateComment(self):64 commit = self.repo.get_commit("8a4f306d4b223682dd19410d4a9150636ebe4206")65 comment = self.pull.create_comment("Comment created by PyGithub", commit, "src/github/Issue.py", 5)66 self.assertEqual(comment.id, 886298)67 def testGetComments(self):68 self.assertListKeyEqual(self.pull.get_comments(), lambda c: c.id, [886298])69 def testCreateIssueComment(self):70 comment = self.pull.create_issue_comment("Issue comment created by PyGithub")71 self.assertEqual(comment.id, 8387331)72 def testGetIssueComments(self):73 self.assertListKeyEqual(self.pull.get_issue_comments(), lambda c: c.id, [8387331])74 def testGetIssueComment(self):75 comment = self.pull.get_issue_comment(8387331)76 self.assertEqual(comment.body, "Issue comment created by PyGithub")77 def testEditWithoutArguments(self):78 self.pull.edit()79 def testEditWithAllArguments(self):80 self.pull.edit("Title edited by PyGithub", "Body edited by PyGithub", "open")81 self.assertEqual(self.pull.title, "Title edited by PyGithub")82 self.assertEqual(self.pull.body, "Body edited by PyGithub")83 self.assertEqual(self.pull.state, "open")84 def testGetCommits(self):85 self.assertListKeyEqual(self.pull.get_commits(), lambda c: c.sha, ["4aadfff21cdd2d2566b0e4bd7309c233b5f4ae23", "93dcae5cf207de376c91d0599226e7c7563e1d16", "8a4f306d4b223682dd19410d4a9150636ebe4206"])86 def testGetFiles(self):87 self.assertListKeyEqual(self.pull.get_files(), lambda f: f.filename, ["codegen/templates/GithubObject.py", "src/github/AuthenticatedUser.py", "src/github/Authorization.py", "src/github/Branch.py", "src/github/Commit.py", "src/github/CommitComment.py", "src/github/CommitFile.py", "src/github/CommitStats.py", "src/github/Download.py", "src/github/Event.py", "src/github/Gist.py", "src/github/GistComment.py", "src/github/GistHistoryState.py", "src/github/GitAuthor.py", "src/github/GitBlob.py", "src/github/GitCommit.py", "src/github/GitObject.py", "src/github/GitRef.py", "src/github/GitTag.py", "src/github/GitTree.py", "src/github/GitTreeElement.py", "src/github/Hook.py", "src/github/Issue.py", "src/github/IssueComment.py", "src/github/IssueEvent.py", "src/github/Label.py", "src/github/Milestone.py", "src/github/NamedUser.py", "src/github/Organization.py", "src/github/Permissions.py", "src/github/Plan.py", "src/github/PullRequest.py", "src/github/PullRequestComment.py", "src/github/PullRequestFile.py", "src/github/Repository.py", "src/github/RepositoryKey.py", "src/github/Tag.py", "src/github/Team.py", "src/github/UserKey.py", "test/Issue.py", "test/IssueEvent.py", "test/ReplayData/Issue.testAddAndRemoveLabels.txt", "test/ReplayData/Issue.testDeleteAndSetLabels.txt", "test/ReplayData/Issue.testGetLabels.txt", "test/ReplayData/IssueEvent.setUp.txt"])88 def testMerge(self):89 self.assertFalse(self.pull.is_merged())90 status = self.pull.merge()91 self.assertEqual(status.sha, "688208b1a5a074871d0e9376119556897439697d")92 self.assertTrue(status.merged)93 self.assertEqual(status.message, "Pull Request successfully merged")94 self.assertTrue(self.pull.is_merged())95 def testMergeWithCommitMessage(self):...

Full Screen

Full Screen

dth.py

Source:dth.py Github

copy

Full Screen

1import time2from machine import enable_irq, disable_irq, Pin3class DTHResult:4 'DHT sensor result returned by DHT.read() method'5 ERR_NO_ERROR = 06 ERR_MISSING_DATA = 17 ERR_CRC = 28 error_code = ERR_NO_ERROR9 temperature = -110 humidity = -111 def __init__(self, error_code, temperature, humidity):12 self.error_code = error_code13 self.temperature = temperature14 self.humidity = humidity15 def is_valid(self):16 return self.error_code == DTHResult.ERR_NO_ERROR17class DTH:18 'DHT sensor (dht11, dht21,dht22) reader class for Pycom'19 #__pin = Pin('P3', mode=Pin.OPEN_DRAIN)20 __dhttype = 021 def __init__(self, pin, sensor=0):22 self.__pin = pin23 self.__dhttype = sensor24 self.__pin(1)25 time.sleep(1.0)26 def read(self):27 #time.sleep(1)28 # send initial high29 #self.__send_and_sleep(1, 0.025)30 # pull down to low31 self.__send_and_sleep(0, 0.019)32 # collect data into an array33 data = self.__collect_input()34 #print(data)35 # parse lengths of all data pull up periods36 pull_up_lengths = self.__parse_data_pull_up_lengths(data)37 # if bit count mismatch, return error (4 byte data + 1 byte checksum)38 #print(pull_up_lengths)39 #print(len(pull_up_lengths))40 if len(pull_up_lengths) != 40:41 return DTHResult(DTHResult.ERR_MISSING_DATA, 0, 0)42 # calculate bits from lengths of the pull up periods43 bits = self.__calculate_bits(pull_up_lengths)44 # we have the bits, calculate bytes45 the_bytes = self.__bits_to_bytes(bits)46 #print(the_bytes)47 # calculate checksum and check48 checksum = self.__calculate_checksum(the_bytes)49 if the_bytes[4] != checksum:50 return DTHResult(DTHResult.ERR_CRC, 0, 0)51 # ok, we have valid data, return it52 [int_rh, dec_rh, int_t, dec_t, csum] = the_bytes53 if self.__dhttype==0: #dht1154 rh = int_rh #dht11 20% ~ 90%55 t = int_t #dht11 0..50°C56 else: #dht21,dht2257 rh = ((int_rh * 256) + dec_rh)/1058 t = (((int_t & 0x7F) * 256) + dec_t)/1059 if (int_t & 0x80) > 0:60 t *= -161 return DTHResult(DTHResult.ERR_NO_ERROR, t, rh)62 def __send_and_sleep(self, output, mysleep):63 self.__pin(output)64 time.sleep(mysleep)65 def __collect_input(self):66 # collect the data while unchanged found67 unchanged_count = 068 # this is used to determine where is the end of the data69 max_unchanged_count = 10070 last = -171 data = []72 m = bytearray(800) # needs long sample size to grab all the bits from the DHT73 irqf = disable_irq()74 self.__pin(1)75 for i in range(len(m)):76 m[i] = self.__pin() ## sample input and store value77 enable_irq(irqf)78 for i in range(len(m)):79 current = m[i]80 data.append(current)81 if last != current:82 unchanged_count = 083 last = current84 else:85 unchanged_count += 186 if unchanged_count > max_unchanged_count:87 break88 #print(data)89 return data90 def __parse_data_pull_up_lengths(self, data):91 STATE_INIT_PULL_DOWN = 192 STATE_INIT_PULL_UP = 293 STATE_DATA_FIRST_PULL_DOWN = 394 STATE_DATA_PULL_UP = 495 STATE_DATA_PULL_DOWN = 596 state = STATE_INIT_PULL_UP97 lengths = [] # will contain the lengths of data pull up periods98 current_length = 0 # will contain the length of the previous period99 for i in range(len(data)):100 current = data[i]101 current_length += 1102 if state == STATE_INIT_PULL_DOWN:103 if current == 0:104 # ok, we got the initial pull down105 state = STATE_INIT_PULL_UP106 continue107 else:108 continue109 if state == STATE_INIT_PULL_UP:110 if current == 1:111 # ok, we got the initial pull up112 state = STATE_DATA_FIRST_PULL_DOWN113 continue114 else:115 continue116 if state == STATE_DATA_FIRST_PULL_DOWN:117 if current == 0:118 # we have the initial pull down, the next will be the data pull up119 state = STATE_DATA_PULL_UP120 continue121 else:122 continue123 if state == STATE_DATA_PULL_UP:124 if current == 1:125 # data pulled up, the length of this pull up will determine whether it is 0 or 1126 current_length = 0127 state = STATE_DATA_PULL_DOWN128 continue129 else:130 continue131 if state == STATE_DATA_PULL_DOWN:132 if current == 0:133 # pulled down, we store the length of the previous pull up period134 lengths.append(current_length)135 state = STATE_DATA_PULL_UP136 continue137 else:138 continue139 return lengths140 def __calculate_bits(self, pull_up_lengths):141 # find shortest and longest period142 shortest_pull_up = 1000143 longest_pull_up = 0144 for i in range(0, len(pull_up_lengths)):145 length = pull_up_lengths[i]146 if length < shortest_pull_up:147 shortest_pull_up = length148 if length > longest_pull_up:149 longest_pull_up = length150 # use the halfway to determine whether the period it is long or short151 halfway = shortest_pull_up + (longest_pull_up - shortest_pull_up) / 2152 bits = []153 for i in range(0, len(pull_up_lengths)):154 bit = False155 if pull_up_lengths[i] > halfway:156 bit = True157 bits.append(bit)158 return bits159 def __bits_to_bytes(self, bits):160 the_bytes = []161 byte = 0162 for i in range(0, len(bits)):163 byte = byte << 1164 if (bits[i]):165 byte = byte | 1166 else:167 byte = byte | 0168 if ((i + 1) % 8 == 0):169 the_bytes.append(byte)170 byte = 0171 #print(the_bytes)172 return the_bytes173 def __calculate_checksum(self, the_bytes):...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1import time2import RPi3class DHT11Result:4 'DHT11 sensor result returned by DHT11.read() method'5 ERR_NO_ERROR = 06 ERR_MISSING_DATA = 17 ERR_CRC = 28 error_code = ERR_NO_ERROR9 temperature = -110 humidity = -111 def __init__(self, error_code, temperature, humidity):12 self.error_code = error_code13 self.temperature = temperature14 self.humidity = humidity15 def is_valid(self):16 return self.error_code == DHT11Result.ERR_NO_ERROR17class DHT11:18 'DHT11 sensor reader class for Raspberry'19 __pin = 020 def __init__(self, pin):21 self.__pin = pin22 def read(self):23 RPi.GPIO.setup(self.__pin, RPi.GPIO.OUT)24 # send initial high25 self.__send_and_sleep(RPi.GPIO.HIGH, 0.05)26 # pull down to low27 self.__send_and_sleep(RPi.GPIO.LOW, 0.02)28 # change to input using pull up29 RPi.GPIO.setup(self.__pin, RPi.GPIO.IN, RPi.GPIO.PUD_UP)30 # collect data into an array31 data = self.__collect_input()32 # parse lengths of all data pull up periods33 pull_up_lengths = self.__parse_data_pull_up_lengths(data)34 # if bit count mismatch, return error (4 byte data + 1 byte checksum)35 if len(pull_up_lengths) != 40:36 return DHT11Result(DHT11Result.ERR_MISSING_DATA, 0, 0)37 # calculate bits from lengths of the pull up periods38 bits = self.__calculate_bits(pull_up_lengths)39 # we have the bits, calculate bytes40 the_bytes = self.__bits_to_bytes(bits)41 # calculate checksum and check42 checksum = self.__calculate_checksum(the_bytes)43 if the_bytes[4] != checksum:44 return DHT11Result(DHT11Result.ERR_CRC, 0, 0)45 # ok, we have valid data46 # The meaning of the return sensor values47 # the_bytes[0]: humidity int48 # the_bytes[1]: humidity decimal49 # the_bytes[2]: temperature int50 # the_bytes[3]: temperature decimal51 temperature = the_bytes[2] + float(the_bytes[3]) / 1052 humidity = the_bytes[0] + float(the_bytes[1]) / 1053 return DHT11Result(DHT11Result.ERR_NO_ERROR, temperature, humidity)54 def __send_and_sleep(self, output, sleep):55 RPi.GPIO.output(self.__pin, output)56 time.sleep(sleep)57 def __collect_input(self):58 # collect the data while unchanged found59 unchanged_count = 060 # this is used to determine where is the end of the data61 max_unchanged_count = 10062 last = -163 data = []64 while True:65 current = RPi.GPIO.input(self.__pin)66 data.append(current)67 if last != current:68 unchanged_count = 069 last = current70 else:71 unchanged_count += 172 if unchanged_count > max_unchanged_count:73 break74 return data75 def __parse_data_pull_up_lengths(self, data):76 STATE_INIT_PULL_DOWN = 177 STATE_INIT_PULL_UP = 278 STATE_DATA_FIRST_PULL_DOWN = 379 STATE_DATA_PULL_UP = 480 STATE_DATA_PULL_DOWN = 581 state = STATE_INIT_PULL_DOWN82 lengths = [] # will contain the lengths of data pull up periods83 current_length = 0 # will contain the length of the previous period84 for i in range(len(data)):85 current = data[i]86 current_length += 187 if state == STATE_INIT_PULL_DOWN:88 if current == RPi.GPIO.LOW:89 # ok, we got the initial pull down90 state = STATE_INIT_PULL_UP91 continue92 else:93 continue94 if state == STATE_INIT_PULL_UP:95 if current == RPi.GPIO.HIGH:96 # ok, we got the initial pull up97 state = STATE_DATA_FIRST_PULL_DOWN98 continue99 else:100 continue101 if state == STATE_DATA_FIRST_PULL_DOWN:102 if current == RPi.GPIO.LOW:103 # we have the initial pull down, the next will be the data pull up104 state = STATE_DATA_PULL_UP105 continue106 else:107 continue108 if state == STATE_DATA_PULL_UP:109 if current == RPi.GPIO.HIGH:110 # data pulled up, the length of this pull up will determine whether it is 0 or 1111 current_length = 0112 state = STATE_DATA_PULL_DOWN113 continue114 else:115 continue116 if state == STATE_DATA_PULL_DOWN:117 if current == RPi.GPIO.LOW:118 # pulled down, we store the length of the previous pull up period119 lengths.append(current_length)120 state = STATE_DATA_PULL_UP121 continue122 else:123 continue124 return lengths125 def __calculate_bits(self, pull_up_lengths):126 # find shortest and longest period127 shortest_pull_up = 1000128 longest_pull_up = 0129 for i in range(0, len(pull_up_lengths)):130 length = pull_up_lengths[i]131 if length < shortest_pull_up:132 shortest_pull_up = length133 if length > longest_pull_up:134 longest_pull_up = length135 # use the halfway to determine whether the period it is long or short136 halfway = shortest_pull_up + (longest_pull_up - shortest_pull_up) / 2137 bits = []138 for i in range(0, len(pull_up_lengths)):139 bit = False140 if pull_up_lengths[i] > halfway:141 bit = True142 bits.append(bit)143 return bits144 def __bits_to_bytes(self, bits):145 the_bytes = []146 byte = 0147 for i in range(0, len(bits)):148 byte = byte << 1149 if (bits[i]):150 byte = byte | 1151 else:152 byte = byte | 0153 if ((i + 1) % 8 == 0):154 the_bytes.append(byte)155 byte = 0156 return the_bytes157 def __calculate_checksum(self, the_bytes):...

Full Screen

Full Screen

pullToRefresh.js

Source:pullToRefresh.js Github

copy

Full Screen

1/*!2 * pull to refresh v2.03 *author:wallace4 *2015-7-225 */6var refresher = {7 info: {8 "pullDownLable": "Pull down to refresh...",9 "pullingDownLable": "Release to refresh...",10 "pullUpLable": "上滑加载更多...",11 "pullingUpLable": "Release to load more...",12 "loadingLable": "Loading..."13 },14 init: function(parameter) {15 var wrapper = document.getElementById(parameter.id);16 var div = document.createElement("div");17 div.className = "scroller";18 wrapper.appendChild(div);19 var scroller = wrapper.querySelector(".scroller");20 var list = wrapper.querySelector("#" + parameter.id + " ul");21 scroller.insertBefore(list, scroller.childNodes[0]);22 var pullDown = document.createElement("div");23 pullDown.className = "pullDown";24 var loader = document.createElement("div");25 loader.className = "loader";26 for (var i = 0; i < 4; i++) {27 var span = document.createElement("span");28 loader.appendChild(span);29 }30 pullDown.appendChild(loader);31 var pullDownLabel = document.createElement("div");32 pullDownLabel.className = "pullDownLabel";33 pullDown.appendChild(pullDownLabel);34 scroller.insertBefore(pullDown, scroller.childNodes[0]);35 var pullUp = document.createElement("div");36 pullUp.className = "pullUp";37 var loader = document.createElement("div");38 loader.className = "loader";39 for (var i = 0; i < 4; i++) {40 var span = document.createElement("span");41 loader.appendChild(span);42 }43 pullUp.appendChild(loader);44 var pullUpLabel = document.createElement("div");45 pullUpLabel.className = "pullUpLabel";46 var content = document.createTextNode(refresher.info.pullUpLable);47 pullUpLabel.appendChild(content);48 pullUp.appendChild(pullUpLabel);49 scroller.appendChild(pullUp);50 var pullDownEl = wrapper.querySelector(".pullDown");51 var pullDownOffset = pullDownEl.offsetHeight;52 var pullUpEl = wrapper.querySelector(".pullUp");53 var pullUpOffset = pullUpEl.offsetHeight;54 this.scrollIt(parameter, pullDownEl, pullDownOffset, pullUpEl, pullUpOffset);55 },56 scrollIt: function(parameter, pullDownEl, pullDownOffset, pullUpEl, pullUpOffset) {57 eval(parameter.id + "= new iScroll(parameter.id, {useTransition: true,vScrollbar: false,topOffset: pullDownOffset,onRefresh: function () {refresher.onRelease(pullDownEl,pullUpEl);},onScrollMove: function () {refresher.onScrolling(this,pullDownEl,pullUpEl,pullUpOffset);},onScrollEnd: function () {refresher.onPulling(pullDownEl,parameter.pullDownAction,pullUpEl,parameter.pullUpAction);},})");58 pullDownEl.querySelector('.pullDownLabel').innerHTML = refresher.info.pullDownLable;59 document.addEventListener('touchmove', function(e) {60 e.preventDefault();61 }, false);62 },63 onScrolling: function(e, pullDownEl, pullUpEl, pullUpOffset) {64 if (e.y > -(pullUpOffset)) {65 pullDownEl.id = '';66 pullDownEl.querySelector('.pullDownLabel').innerHTML = refresher.info.pullDownLable;67 e.minScrollY = -pullUpOffset;68 }69 if (e.y > 0) {70 pullDownEl.classList.add("flip");71 pullDownEl.querySelector('.pullDownLabel').innerHTML = refresher.info.pullingDownLable;72 e.minScrollY = 0;73 }74 if (e.scrollerH < e.wrapperH && e.y < (e.minScrollY - pullUpOffset) || e.scrollerH > e.wrapperH && e.y < (e.maxScrollY - pullUpOffset)) {75 pullUpEl.style.display = "block";76 pullUpEl.classList.add("flip");77 pullUpEl.querySelector('.pullUpLabel').innerHTML = refresher.info.pullingUpLable;78 }79 if (e.scrollerH < e.wrapperH && e.y > (e.minScrollY - pullUpOffset) && pullUpEl.id.match('flip') || e.scrollerH > e.wrapperH && e.y > (e.maxScrollY - pullUpOffset) && pullUpEl.id.match('flip')) {80 pullDownEl.classList.remove("flip");81 pullUpEl.querySelector('.pullUpLabel').innerHTML = refresher.info.pullUpLable;82 }83 },84 onRelease: function(pullDownEl, pullUpEl) {85 if (pullDownEl.className.match('loading')) {86 pullDownEl.classList.toggle("loading");87 pullDownEl.querySelector('.pullDownLabel').innerHTML = refresher.info.pullDownLable;88 pullDownEl.querySelector('.loader').style.display = "none"89 pullDownEl.style.lineHeight = pullDownEl.offsetHeight + "px";90 }91 if (pullUpEl.className.match('loading')) {92 pullUpEl.classList.toggle("loading");93 pullUpEl.querySelector('.pullUpLabel').innerHTML = refresher.info.pullUpLable;94 pullUpEl.querySelector('.loader').style.display = "none"95 pullUpEl.style.lineHeight = pullUpEl.offsetHeight + "px";96 }97 },98 onPulling: function(pullDownEl, pullDownAction, pullUpEl, pullUpAction) {99 if (pullDownEl.className.match('flip') /*&&!pullUpEl.className.match('loading')*/ ) {100 pullDownEl.classList.add("loading");101 pullDownEl.classList.remove("flip");102 pullDownEl.querySelector('.pullDownLabel').innerHTML = refresher.info.loadingLable;103 pullDownEl.querySelector('.loader').style.display = "block"104 pullDownEl.style.lineHeight = "20px";105 if (pullDownAction) pullDownAction();106 }107 if (pullUpEl.className.match('flip') /*&&!pullDownEl.className.match('loading')*/ ) {108 pullUpEl.classList.add("loading");109 pullUpEl.classList.remove("flip");110 pullUpEl.querySelector('.pullUpLabel').innerHTML = refresher.info.loadingLable;111 pullUpEl.querySelector('.loader').style.display = "block"112 pullUpEl.style.lineHeight = "20px";113 if (pullUpAction) pullUpAction();114 }115 } ...

Full Screen

Full Screen

index-scroll.js

Source:index-scroll.js Github

copy

Full Screen

1var myScroll,2pullDownEl, pullDownOffset,3pullUpEl, pullUpOffset,4generatedCount = 0;5function pullDownAction (str,thelist,myScroll) {6 setTimeout(function () { // <-- Simulate network congestion, remove setTimeout from production!7 var el, li, i;8 el = document.getElementById(thelist);9 for (i=0; i<4; i++) {10 li = document.createElement('li');11 li.innerHTML=str;12 el.insertBefore(li, el.childNodes[0]);13 }14 15 myScroll.refresh(); // Remember to refresh when contents are loaded (ie: on ajax completion)16 }, 1000); // <-- Simulate network congestion, remove setTimeout from production!17}18function pullUpAction (str,thelist,myScroll) {19 setTimeout(function () { // <-- Simulate network congestion, remove setTimeout from production!20 var el, li, i;21 el = document.getElementById(thelist);22 23 for (i=0; i<4; i++) {24 li = document.createElement('li');25 li.innerHTML=str;26 el.appendChild(li, el.childNodes[0]);27 }28 29 myScroll.refresh(); // Remember to refresh when contents are loaded (ie: on ajax completion)30 }, 1000); // <-- Simulate network congestion, remove setTimeout from production!31}32function loaded(wrapper) {33 setTimeout(function () { document.getElementById(wrapper).style.left = '0'; }, 800);34}35loaded.prototype.makeScroll = function (str,wrapper,thelist,pullUp,pullDown){36 var pullDownEl = document.getElementById(pullDown);37 var pullUpEl = document.getElementById(pullUp); 38 var pullDownOffset =pullDownEl.offsetHeight;39 var pullUpOffset = pullUpEl.offsetHeight;40 this.wrapper=wrapper;41 var scroll = new iScroll(this.wrapper, {42 useTransition: true,43 topOffset: pullDownOffset,44 onRefresh: function () {45 if (pullDownEl.className.match('loading')) {46 pullDownEl.className = '';47 pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';48 } else if (pullUpEl.className.match('loading')) {49 pullUpEl.className = '';50 pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';51 }52 },53 onScrollMove: function () {54 if (this.y > 5 && !pullDownEl.className.match('flip')) {55 pullDownEl.className = 'flip';56 pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';57 this.minScrollY = 0;58 } else if (this.y < 5 && pullDownEl.className.match('flip')) {59 pullDownEl.className = '';60 pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';61 this.minScrollY = -pullDownOffset;62 } else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {63 pullUpEl.className = 'flip';64 pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Release to refresh...';65 this.maxScrollY = this.maxScrollY;66 } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {67 pullUpEl.className = '';68 pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Pull up to load more...';69 this.maxScrollY = pullUpOffset;70 }71 },72 onScrollEnd: function () {73 if (pullDownEl.className.match('flip')) {74 pullDownEl.className = 'loading';75 pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...'; 76 pullDownAction(str,thelist,scroll); // Execute custom function (ajax call?)77 } else if (pullUpEl.className.match('flip')) {78 pullUpEl.className = 'loading';79 pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Loading...'; 80 pullUpAction(str,thelist,scroll); // Execute custom function (ajax call?)81 }82 }83 });84return scroll;85}...

Full Screen

Full Screen

common.js

Source:common.js Github

copy

Full Screen

1/**2 * @ignore3 * @file common.js4 * @author fanyy5 * @time 15-4-286 */78define(function(require) {9 var tpl = require('./common.tpl');10 var etpl = require('etpl');11 var FastClick = require('m/common/fastclick');1213 function init() {14 etpl.compile(tpl);1516 //解决 click 的延迟, 还可以防止 穿透(跨页面穿透除外)17 FastClick.attach(document.body);18 }1920 /**21 * 滚动事件22 * 23 */24 function myScrollEvents(myScroll, pullUpAction, pullDownAction) {25 var pullDownEl = document.getElementById('pullDown');26 var pullDownOffset = pullDownEl.offsetHeight;27 var pullUpEl = document.getElementById('pullUp');28 var pullUpOffset = pullUpEl.offsetHeight;29 myScroll.on('scroll', function() {30 if (this.y > 5 && !pullDownEl.className.match('flip')) {31 pullDownEl.className = 'flip';32 pullDownEl.querySelector('.pullDownLabel').innerHTML = '释放后加载最新';33 this.minScrollY = 0;34 } else if (this.y < 5 && pullDownEl.className.match('flip')) {35 pullDownEl.className = '';36 pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉加载更多';37 this.minScrollY = -pullDownOffset;38 } else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {39 pullUpEl.className = 'flip';40 pullUpEl.querySelector('.pullUpLabel').innerHTML = '释放后加载最新';41 this.maxScrollY = this.maxScrollY;42 } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {43 pullUpEl.className = '';44 pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多';45 this.maxScrollY = pullUpOffset;46 }47 });48 myScroll.on('scrollEnd', function() {49 if (pullDownEl.className.match('flip')) {50 pullDownEl.className = 'loading';51 pullDownEl.querySelector('.pullDownLabel').innerHTML = '正在努力加载中...';52 pullDownAction(); // Execute custom function (ajax call?)53 } else if (pullUpEl.className.match('flip')) {54 pullUpEl.className = 'loading';55 pullUpEl.querySelector('.pullUpLabel').innerHTML = '正在努力加载中...';56 pullUpAction(); // Execute custom function (ajax call?)57 }58 });59 myScroll.on('refresh', function() {60 if (pullDownEl.className.match('loading')) {61 pullDownEl.className = '';62 pullDownEl.querySelector('.pullDownLabel').innerHTML = "下拉加载更多";63 } else if (pullUpEl.className.match('loading')) {64 pullUpEl.className = '';65 pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多';66 }67 });68 }6970 return {71 init: init,72 myScrollEvents: myScrollEvents73 }; ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test submitted. Poll for results at %s/jsonResult.php?test=%s', test.serverUrl, data.data.testId);5 test.pullResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log('Test completed. Results: %j', data);8 });9});10var wpt = require('webpagetest');11var test = wpt('www.webpagetest.org');12 if (err) return console.error(err);13 console.log('Test submitted. Poll for results at %s/jsonResult.php?test=%s', test.serverUrl, data.data.testId);14 test.pullResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log('Test completed. Results: %j', data);17 });18});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wiki.getPull(function(err, data) {3 if (err) {4 console.log(err);5 }6 console.log(data);7});8var wptools = require('wptools');9wiki.getPull(function(err, data) {10 if (err) {11 console.log(err);12 }13 console.log(data);14});15var wptools = require('wptools');16wiki.getPull(function(err, data) {17 if (err) {18 console.log(err);19 }20 console.log(data);21});22var wptools = require('wptools');23wiki.getPull(function(err, data) {24 if (err) {25 console.log(err);26 }27 console.log(data);28});29var wptools = require('wptools');30wiki.getPull(function(err, data) {31 if (err) {32 console.log(err);33 }34 console.log(data);35});36var wptools = require('wptools');37wiki.getPull(function(err, data) {38 if (err) {39 console.log(err);40 }41 console.log(data);42});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const request = require('request');5const async = require('async');6const csv = require('csvtojson');7const csvFilePath = path.join(__dirname, 'data.csv');8const csvData = [];9const csvData1 = [];10const csvData2 = [];11const csvData3 = [];12const csvData4 = [];13const csvData5 = [];14const csvData6 = [];15const csvData7 = [];16const csvData8 = [];17const csvData9 = [];18const csvData10 = [];19const csvData11 = [];20const csvData12 = [];21const csvData13 = [];22const csvData14 = [];23const csvData15 = [];24const csvData16 = [];25const csvData17 = [];26const csvData18 = [];27const csvData19 = [];28const csvData20 = [];29const csvData21 = [];30const csvData22 = [];31const csvData23 = [];32const csvData24 = [];33const csvData25 = [];34const csvData26 = [];35const csvData27 = [];36const csvData28 = [];37const csvData29 = [];38const csvData30 = [];39const csvData31 = [];40const csvData32 = [];41const csvData33 = [];42const csvData34 = [];43const csvData35 = [];44const csvData36 = [];45const csvData37 = [];46const csvData38 = [];47const csvData39 = [];48const csvData40 = [];49const csvData41 = [];50const csvData42 = [];51const csvData43 = [];52const csvData44 = [];53const csvData45 = [];54const csvData46 = [];55const csvData47 = [];56const csvData48 = [];57const csvData49 = [];58const csvData50 = [];59const csvData51 = [];60const csvData52 = [];61const csvData53 = [];62const csvData54 = [];63const csvData55 = [];64const csvData56 = [];65const csvData57 = [];66const csvData58 = [];67const csvData59 = [];68const csvData60 = [];69const csvData61 = [];70const csvData62 = [];71const csvData63 = [];72const csvData64 = [];73const csvData65 = [];74const csvData66 = [];75const csvData67 = [];76const csvData68 = [];77const csvData69 = [];78const csvData70 = [];79const csvData71 = [];

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const request = require('request');5const async = require('async');6const csv = require('csvtojson');7const csvFilePath = path.join(__dirname, 'data.csv');8const csvData = [];9const csvData1 = [];10const csvData2 = [];11const csvData3 = [];12const csvData4 = [];13const csvData5 = [];14const csvData6 = [];15const csvData7 = [];16const csvData8 = [];17const csvData9 = [];18const csvData10 = [];19const csvData11 = [];20const csvData12 = [];21const csvData13 = [];22const csvData14 = [];23const csvData15 = [];24const csvData16 = [];25const csvData17 = [];26const csvData18 = [];27const csvData19 = [];28const csvData20 = [];29const csvData21 = [];30const csvData22 = [];31const csvData23 = [];32const csvData24 = [];33const csvData25 = [];34const csvData26 = [];35const csvData27 = [];36const csvData28 = [];37const csvData29 = [];38const csvData30 = [];39const csvData31 = [];40const csvData32 = [];41const csvData33 = [];42const csvData34 = [];43const csvData35 = [];44const csvData36 = [];45const csvData37 = [];46const csvData38 = [];47const csvData39 = [];48const csvData40 = [];49const csvData41 = [];50const csvData42 = [];51const csvData43 = [];52const csvData44 = [];53const csvData45 = [];54const csvData46 = [];55const csvData47 = [];'https);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var page = wptools.page('Barack_Obama');4page.get(function(err, resp) {5 fs.writeFile('test.json', JSON.stringify(resp, null, 2), function(err) {6 if (err) {7 console.log('error');8 } else {9 console.log('success');10 }11 })12}13const csvData48 = [];14const csvData49 = [];15const csvData50 = [];16const csvData51 = [];17const csvData52 = [];18const csvData53 = [];19const csvData54 = [];20const csvData55 = [];21const csvData56 = [];22const csvData57 = [];23const csvData58 = [];24const csvData59 = [];25const csvData60 = [];26const csvData61 = [];27const csvData62 = [];28const csvData63 = [];29const csvData64 = [];30const csvData65 = [];31const csvData66 = [];32const csvData67 = [];33const csvData68 = [];34const csvData69 = [];35const csvData70 = [];36const csvData71 = [];

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const { exec } = require('child_process');5const { promisify } = require('util');6const execAsync = promisify(exec);7const { get } = require('https');8const { parse } = require('node-html-parser');9const { json2csvAsync } = require('json-2-csv');10const { parse } = require('node-html-parser');11const { promisify } = require('util');12const { get } = require('https');13const execAsync = promisify(exec);14const { json2csvAsync } = require('json-2-csv');15const { parse } = require('node-html-parser');16const { promisify } = require('util');17const { get } = require('https');18const execAsync = promisify(exec);19const { json2csvAsync } = require('json-2-csv');20const { parse } = require('node-html-parser');21const { promisify } = require('util');22const { get } = require('https');23const execAsync = promisify(exec);24const { json2csvAsync } = require('json-2-csv');25const { parse } = require('node-html-parser');26const { promisify } = require('util');27const { get } = require('https');28const execAsync = promisify(exec);29const { json2csvAsync } = require('json-2-csv');30const { parse } = require('node-html-parser');31const { promisify } = require('util');32const { get } = require('https');33const execAsync = promisify(exec);34const { json2csvAsync } = require('json-2-csv');35const { parse } = require('node-html-parser');36const { promisify } = require('util');37const { get } = require('https');38const execAsync = promisify(exec);39const { json2csvAsync } = require('json-2-csv');40const { parse } = require('node-html-parser');41const { promisify } = require('util');42const { get } = require('https');43const execAsync = promisify(exec);44const { json2csvAsync } = require('json-2-csv');45const { parse } = require('node-html-parser');46const { promisify } = require('util');47const { get } = require('https');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var page = wptools.page('Barack_Obama');4page.get(function(err, resp) {5 fs.writeFile('test.json', JSON.stringify(resp, null, 2), function(err) {6 if (err) {7 console.log('error');8 } else {9 console.log('success');10 }11 })12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptools = require('./wptools.js');3var page = wptools.page('Sachin Tendulkar');4page.getPull(function(err, resp, body) {5 if (err) {6 console.log(err);7 } else {8 console.log(body);9 fs.writeFileSync('pull.json', JSON.stringify(body));10 }11})

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2wp.posts().pull(function(err, posts){3 if(err){4 console.log(err);5 }else{6 console.log(posts);7 }8});9var wptoolkit = require('wptoolkit');10var post = {11 "date" : new Date(),12}13wp.posts().push(post, function(err, post){14 if(err){15 console.log(err);16 }else{17 console.log(post);18 }19});20var wptoolkit = require('wptoolkit');21wp.posts().delete(1, function(err, status){22 if(err){23 console.log(err);24 }else{25 console.log(status);26 }27});28var wptoolkit = require('wptoolkit');29var post = {30 "date" : new Date(),31}32wp.posts().update(1, post, function(err, post){33 if(err){34 console.log(err);35 }else{36 console.log(post);37 }38});39MIT License. See [LICENSE](

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